36 #define DRV_NAME "3c503"
37 #define DRV_VERSION "1.10a"
38 #define DRV_RELDATE "11/17/2001"
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/errno.h>
47 #include <linux/string.h>
49 #include <linux/netdevice.h>
53 #include <linux/ethtool.h>
55 #include <asm/uaccess.h>
57 #include <asm/byteorder.h>
67 static unsigned int netcard_portlist[]
__initdata =
68 { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
70 #define EL2_IO_EXTENT 16
77 const unsigned char *
buf,
int start_page);
94 int *
addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
98 if (base_addr > 0x1ff)
99 return el2_probe1(dev, base_addr);
100 else if (base_addr != 0)
103 for (addr = addrs; *
addr; addr++) {
110 base_bits =
readb(p);
112 i =
ffs(base_bits) - 1;
113 if (i == -1 || base_bits != (1 << i))
115 if (el2_probe1(dev, netcard_portlist[i]) == 0)
119 #if ! defined(no_probe_nonshared_memory)
120 return el2_pio_probe(dev);
135 if (base_addr > 0x1ff)
136 return el2_probe1(dev, base_addr);
137 else if (base_addr != 0)
140 for (i = 0; netcard_portlist[
i]; i++) {
141 if (el2_probe1(dev, netcard_portlist[i]) == 0)
161 err = do_el2_probe(dev);
172 .ndo_open = el2_open,
173 .ndo_stop = el2_close,
182 #ifdef CONFIG_NET_POLL_CONTROLLER
183 .ndo_poll_controller = eip_poll,
191 el2_probe1(
struct net_device *dev,
int ioaddr)
193 int i, iobase_reg, membase_reg, saved_406, wordlength,
retval;
194 static unsigned version_printed;
206 if (
inb(ioaddr + 0x408) == 0xff) {
214 iobase_reg =
inb(ioaddr+0x403);
215 membase_reg =
inb(ioaddr+0x404);
217 if ((iobase_reg & (iobase_reg - 1)) ||
218 (membase_reg & (membase_reg - 1))) {
222 saved_406 =
inb_p(ioaddr + 0x406);
228 vendor_id =
inb(ioaddr)*0x10000 +
inb(ioaddr + 1)*0x100 +
inb(ioaddr + 2);
231 outb(saved_406, ioaddr + 0x406);
236 if (
ei_debug && version_printed++ == 0)
241 pr_info(
"%s: 3c503 at i/o base %#3x, node ", dev->
name, ioaddr);
244 for (i = 0; i < 6; i++)
260 pr_cont(
" memory jumpers %2.2x ", membase_reg);
267 #if defined(EI8390_THICK) || defined(EL2_AUI)
272 pr_cont(
", using %sternal xcvr.\n",
ei_status.interface_num == 0 ?
"in" :
"ex");
274 if ((membase_reg & 0xf0) == 0) {
279 dev->
mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
280 ((membase_reg & 0xA0) ? 0x4000 : 0);
281 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
290 unsigned int test_val = 0xbbadf00d;
291 writel(0xba5eba5e, mem_base);
292 for (i =
sizeof(test_val); i <
EL2_MEMSIZE; i+=
sizeof(test_val)) {
293 writel(test_val, mem_base + i);
294 if (
readl(mem_base) != 0xba5eba5e ||
295 readl(mem_base + i) != test_val) {
296 pr_warning(
"3c503: memory failure or memory address conflict.\n");
303 test_val += 0x55555555;
341 ei_status.get_8390_hdr = el2_get_8390_hdr;
343 ei_status.block_output = el2_block_output;
347 else if (dev->
irq > 5 && dev->
irq != 9) {
348 pr_warning(
"3c503: configured interrupt %d invalid, will use autoIRQ.\n",
363 pr_info(
"%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
371 pr_info(
"%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
383 static irqreturn_t el2_probe_interrupt(
int irq,
void *seen)
385 *(
bool *)seen =
true;
395 static const int irqlist[] = {5, 9, 3, 4, 0};
396 const int *irqp = irqlist;
402 retval =
request_irq(*irqp, el2_probe_interrupt, 0,
404 if (retval == -
EBUSY)
421 if (retval == -
EBUSY)
463 pr_debug(
"%s: Resetting the 3c503 board...", dev->
name);
510 const unsigned char *
buf,
int start_page)
512 unsigned short int *wrd;
534 word = (
unsigned short)start_page;
549 wrd = (
unsigned short int *) buf;
550 count = (count + 1) >> 1;
558 pr_notice(
"%s: FIFO blocked in el2_block_output.\n", dev->
name);
598 word = (
unsigned short)ring_page;
609 pr_notice(
"%s: FIFO blocked in el2_get_8390_hdr.\n", dev->
name);
626 unsigned short int *
buf;
632 if (ring_offset + count > EL2_MEMSIZE) {
647 word = (
unsigned short) ring_offset;
664 buf = (
unsigned short int *) skb->
data;
665 count = (count + 1) >> 1;
673 pr_notice(
"%s: FIFO blocked in el2_block_input.\n", dev->
name);
695 static void netdev_get_drvinfo(
struct net_device *dev,
703 static const struct ethtool_ops netdev_ethtool_ops = {
704 .get_drvinfo = netdev_get_drvinfo,
708 #define MAX_EL2_CARDS 4
710 static struct net_device *dev_el2[MAX_EL2_CARDS];
711 static int io[MAX_EL2_CARDS];
712 static int irq[MAX_EL2_CARDS];
713 static int xcvr[MAX_EL2_CARDS];
729 int this_dev, found = 0;
731 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
732 if (io[this_dev] == 0) {
733 if (this_dev != 0)
break;
734 pr_notice(
"3c503.c: Presently autoprobing (not recommended) for a single card.\n");
736 dev = alloc_eip_netdev();
739 dev->
irq = irq[this_dev];
742 if (do_el2_probe(dev) == 0) {
743 dev_el2[found++] =
dev;
747 pr_warning(
"3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
755 static void cleanup_card(
struct net_device *dev)
768 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {