39 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
41 #include <linux/module.h>
42 #include <linux/kernel.h>
44 #include <linux/net.h>
46 #include <linux/netdevice.h>
47 #include <linux/if_arp.h>
49 #include <linux/hdlc.h>
78 static inline int z8530_read_port(
unsigned long p)
102 static inline void z8530_write_port(
unsigned long p,
u8 d)
129 z8530_write_port(c->
ctrlio, reg);
130 return z8530_read_port(c->
ctrlio);
144 r=z8530_read_port(c->
dataio);
163 z8530_write_port(c->
ctrlio, reg);
164 z8530_write_port(c->
ctrlio, val);
178 z8530_write_port(c->
ctrlio, val);
192 z8530_write_port(c->
dataio, val);
308 write_zsreg(c,
R5, c->
regs[5]);
342 if(!(read_zsreg(c,
R0)&1))
345 stat=read_zsreg(c,
R1);
413 if(!(read_zsreg(c,
R0)&4))
454 status = read_zsreg(chan,
R0);
459 if (status &
TxEOM) {
476 z8530_flush_fifo(chan);
512 read_zsreg(chan,
R7);
513 read_zsreg(chan,
R6);
515 status=read_zsreg(chan,
R1);
543 pr_warn(
"Hey who turned the DMA off?\n");
548 pr_err(
"DMA tx - bogus event!\n");
566 status=read_zsreg(chan,
R0);
580 clear_dma_ff(chan->
txdma);
597 z8530_flush_fifo(chan);
637 stat=read_zsreg(c,
R1);
674 u8 status=read_zsreg(chan,
R0);
711 static volatile int locker=0;
722 spin_lock(&dev->
lock);
737 irqs=dev->
chanA.irqs;
749 irqs=dev->
chanB.irqs;
761 spin_unlock(&dev->
lock);
763 pr_err(
"%s: interrupt jammed - abort(0x%X)!\n",
812 spin_unlock_irqrestore(c->
lock, flags);
838 chk=read_zsreg(c,
R0);
842 spin_unlock_irqrestore(c->
lock, flags);
860 unsigned long cflags, dflags;
940 clear_dma_ff(c->
rxdma);
947 clear_dma_ff(c->
txdma);
961 c->
irqs = &z8530_dma_sync;
965 spin_unlock_irqrestore(c->
lock, cflags);
996 clear_dma_ff(c->
rxdma);
1001 clear_dma_ff(c->
txdma);
1031 chk=read_zsreg(c,
R0);
1035 spin_unlock_irqrestore(c->
lock, flags);
1054 unsigned long cflags, dflags;
1056 printk(
"Opening sync interface for TX-DMA\n");
1120 clear_dma_ff(c->
txdma);
1134 c->
irqs = &z8530_txdma_sync;
1137 spin_unlock_irqrestore(c->
lock, cflags);
1155 unsigned long dflags,
cflags;
1172 clear_dma_ff(c->
txdma);
1195 chk=read_zsreg(c,
R0);
1199 spin_unlock_irqrestore(c->
lock, cflags);
1212 static const char *z8530_type_name[]={
1231 pr_info(
"%s: %s found at %s 0x%lX, IRQ %d\n",
1233 z8530_type_name[dev->
type],
1255 write_zsreg(&dev->
chanA,
R9, 0xC0);
1258 write_zsreg(&dev->
chanA,
R12, 0xAA);
1259 if(read_zsreg(&dev->
chanA,
R12)!=0xAA)
1261 write_zsreg(&dev->
chanA,
R12, 0x55);
1262 if(read_zsreg(&dev->
chanA,
R12)!=0x55)
1271 write_zsreg(&dev->
chanA,
R15, 0x01);
1278 if(read_zsreg(&dev->
chanA,
R15)==0x01)
1282 write_zsreg(&dev->
chanA,
R8, 0);
1326 unsigned long flags;
1335 ret = do_z8530_init(dev);
1336 spin_unlock_irqrestore(&dev->
lock, flags);
1357 unsigned long flags;
1363 write_zsreg(&dev->
chanA,
R9, 0xC0);
1366 spin_unlock_irqrestore(&dev->
lock, flags);
1385 unsigned long flags;
1393 write_zsreg(c,
R15, c->
regs[15]|1);
1394 write_zsreg(c, reg&0x0F, *rtable);
1396 write_zsreg(c,
R15, c->
regs[15]&~1);
1410 spin_unlock_irqrestore(c->
lock, flags);
1433 unsigned long flags;
1488 clear_dma_ff(c->
txdma);
1500 write_zsreg(c,
R10, c->
regs[10]);
1591 unsigned long flags;
1600 clear_dma_ff(c->
rxdma);
1627 netdev_warn(c->
netdevice,
"DMA flip overrun!\n");
1639 skb = dev_alloc_skb(ct);
1642 netdev_warn(c->
netdevice,
"Memory squeeze\n");
1645 skb_copy_to_linear_data(skb, rxb, ct);
1680 c->
skb2 = dev_alloc_skb(c->
mtu);
1682 netdev_warn(c->
netdevice,
"memory squeeze\n");
1696 netdev_err(c->
netdevice,
"Lost a frame\n");
1708 static inline int spans_boundary(
struct sk_buff *skb)
1710 unsigned long a=(
unsigned long)skb->
data;
1733 unsigned long flags;
1768 spin_unlock_irqrestore(c->
lock, flags);
1779 KERN_INFO "Generic Z85C30/Z85230 interface driver v0.02\n";
1781 static int __init z85230_init_driver(
void)
1788 static void __exit z85230_cleanup_driver(
void)