Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / net / 3c503.c
blob9c23336750e240410e33cdd7b6fbf177100802eb
1 /* 3c503.c: A shared-memory NS8390 ethernet driver for linux. */
2 /*
3 Written 1992-94 by Donald Becker.
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency. This software may be used and
7 distributed according to the terms of the GNU General Public License,
8 incorporated herein by reference.
10 The author may be reached as becker@scyld.com, or C/O
11 Scyld Computing Corporation
12 410 Severn Ave., Suite 210
13 Annapolis MD 21403
16 This driver should work with the 3c503 and 3c503/16. It should be used
17 in shared memory mode for best performance, although it may also work
18 in programmed-I/O mode.
20 Sources:
21 EtherLink II Technical Reference Manual,
22 EtherLink II/16 Technical Reference Manual Supplement,
23 3Com Corporation, 5400 Bayfront Plaza, Santa Clara CA 95052-8145
25 The Crynwr 3c503 packet driver.
27 Changelog:
29 Paul Gortmaker : add support for the 2nd 8kB of RAM on 16 bit cards.
30 Paul Gortmaker : multiple card support for module users.
31 rjohnson@analogic.com : Fix up PIO interface for efficient operation.
32 Jeff Garzik : ethtool support
36 #define DRV_NAME "3c503"
37 #define DRV_VERSION "1.10a"
38 #define DRV_RELDATE "11/17/2001"
41 static const char version[] =
42 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n";
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/errno.h>
47 #include <linux/string.h>
48 #include <linux/delay.h>
49 #include <linux/netdevice.h>
50 #include <linux/etherdevice.h>
51 #include <linux/init.h>
52 #include <linux/ethtool.h>
54 #include <asm/uaccess.h>
55 #include <asm/io.h>
56 #include <asm/system.h>
57 #include <asm/byteorder.h>
59 #include "8390.h"
60 #include "3c503.h"
61 #define WRD_COUNT 4
63 static int el2_pio_probe(struct net_device *dev);
64 static int el2_probe1(struct net_device *dev, int ioaddr);
66 /* A zero-terminated list of I/O addresses to be probed in PIO mode. */
67 static unsigned int netcard_portlist[] __initdata =
68 { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
70 #define EL2_IO_EXTENT 16
72 static int el2_open(struct net_device *dev);
73 static int el2_close(struct net_device *dev);
74 static void el2_reset_8390(struct net_device *dev);
75 static void el2_init_card(struct net_device *dev);
76 static void el2_block_output(struct net_device *dev, int count,
77 const unsigned char *buf, int start_page);
78 static void el2_block_input(struct net_device *dev, int count, struct sk_buff *skb,
79 int ring_offset);
80 static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
81 int ring_page);
82 static const struct ethtool_ops netdev_ethtool_ops;
85 /* This routine probes for a memory-mapped 3c503 board by looking for
86 the "location register" at the end of the jumpered boot PROM space.
87 This works even if a PROM isn't there.
89 If the ethercard isn't found there is an optional probe for
90 ethercard jumpered to programmed-I/O mode.
92 static int __init do_el2_probe(struct net_device *dev)
94 int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
95 int base_addr = dev->base_addr;
96 int irq = dev->irq;
98 if (base_addr > 0x1ff) /* Check a single specified location. */
99 return el2_probe1(dev, base_addr);
100 else if (base_addr != 0) /* Don't probe at all. */
101 return -ENXIO;
103 for (addr = addrs; *addr; addr++) {
104 void __iomem *p = ioremap(*addr, 1);
105 unsigned base_bits;
106 int i;
108 if (!p)
109 continue;
110 base_bits = readb(p);
111 iounmap(p);
112 i = ffs(base_bits) - 1;
113 if (i == -1 || base_bits != (1 << i))
114 continue;
115 if (el2_probe1(dev, netcard_portlist[i]) == 0)
116 return 0;
117 dev->irq = irq;
119 #if ! defined(no_probe_nonshared_memory)
120 return el2_pio_probe(dev);
121 #else
122 return -ENODEV;
123 #endif
126 /* Try all of the locations that aren't obviously empty. This touches
127 a lot of locations, and is much riskier than the code above. */
128 static int __init
129 el2_pio_probe(struct net_device *dev)
131 int i;
132 int base_addr = dev->base_addr;
133 int irq = dev->irq;
135 if (base_addr > 0x1ff) /* Check a single specified location. */
136 return el2_probe1(dev, base_addr);
137 else if (base_addr != 0) /* Don't probe at all. */
138 return -ENXIO;
140 for (i = 0; netcard_portlist[i]; i++) {
141 if (el2_probe1(dev, netcard_portlist[i]) == 0)
142 return 0;
143 dev->irq = irq;
146 return -ENODEV;
149 #ifndef MODULE
150 struct net_device * __init el2_probe(int unit)
152 struct net_device *dev = alloc_ei_netdev();
153 int err;
155 if (!dev)
156 return ERR_PTR(-ENOMEM);
158 sprintf(dev->name, "eth%d", unit);
159 netdev_boot_setup_check(dev);
161 err = do_el2_probe(dev);
162 if (err)
163 goto out;
164 return dev;
165 out:
166 free_netdev(dev);
167 return ERR_PTR(err);
169 #endif
171 /* Probe for the Etherlink II card at I/O port base IOADDR,
172 returning non-zero on success. If found, set the station
173 address and memory parameters in DEVICE. */
174 static int __init
175 el2_probe1(struct net_device *dev, int ioaddr)
177 int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
178 static unsigned version_printed;
179 unsigned long vendor_id;
180 DECLARE_MAC_BUF(mac);
182 if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
183 return -EBUSY;
185 if (!request_region(ioaddr + 0x400, 8, DRV_NAME)) {
186 retval = -EBUSY;
187 goto out;
190 /* Reset and/or avoid any lurking NE2000 */
191 if (inb(ioaddr + 0x408) == 0xff) {
192 mdelay(1);
193 retval = -ENODEV;
194 goto out1;
197 /* We verify that it's a 3C503 board by checking the first three octets
198 of its ethernet address. */
199 iobase_reg = inb(ioaddr+0x403);
200 membase_reg = inb(ioaddr+0x404);
201 /* ASIC location registers should be 0 or have only a single bit set. */
202 if ( (iobase_reg & (iobase_reg - 1))
203 || (membase_reg & (membase_reg - 1))) {
204 retval = -ENODEV;
205 goto out1;
207 saved_406 = inb_p(ioaddr + 0x406);
208 outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
209 outb_p(ECNTRL_THIN, ioaddr + 0x406);
210 /* Map the station addr PROM into the lower I/O ports. We now check
211 for both the old and new 3Com prefix */
212 outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
213 vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
214 if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
215 /* Restore the register we frobbed. */
216 outb(saved_406, ioaddr + 0x406);
217 retval = -ENODEV;
218 goto out1;
221 if (ei_debug && version_printed++ == 0)
222 printk(version);
224 dev->base_addr = ioaddr;
226 printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
228 /* Retrieve and print the ethernet address. */
229 for (i = 0; i < 6; i++)
230 dev->dev_addr[i] = inb(ioaddr + i);
231 printk("%s", print_mac(mac, dev->dev_addr));
233 /* Map the 8390 back into the window. */
234 outb(ECNTRL_THIN, ioaddr + 0x406);
236 /* Check for EL2/16 as described in tech. man. */
237 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
238 outb_p(0, ioaddr + EN0_DCFG);
239 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
240 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
241 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
243 /* Probe for, turn on and clear the board's shared memory. */
244 if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
245 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
247 /* This should be probed for (or set via an ioctl()) at run-time.
248 Right now we use a sleazy hack to pass in the interface number
249 at boot-time via the low bits of the mem_end field. That value is
250 unused, and the low bits would be discarded even if it was used. */
251 #if defined(EI8390_THICK) || defined(EL2_AUI)
252 ei_status.interface_num = 1;
253 #else
254 ei_status.interface_num = dev->mem_end & 0xf;
255 #endif
256 printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
258 if ((membase_reg & 0xf0) == 0) {
259 dev->mem_start = 0;
260 ei_status.name = "3c503-PIO";
261 ei_status.mem = NULL;
262 } else {
263 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
264 ((membase_reg & 0xA0) ? 0x4000 : 0);
265 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
266 ei_status.mem = ioremap(dev->mem_start, EL2_MEMSIZE);
268 #ifdef EL2MEMTEST
269 /* This has never found an error, but someone might care.
270 Note that it only tests the 2nd 8kB on 16kB 3c503/16
271 cards between card addr. 0x2000 and 0x3fff. */
272 { /* Check the card's memory. */
273 void __iomem *mem_base = ei_status.mem;
274 unsigned int test_val = 0xbbadf00d;
275 writel(0xba5eba5e, mem_base);
276 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
277 writel(test_val, mem_base + i);
278 if (readl(mem_base) != 0xba5eba5e
279 || readl(mem_base + i) != test_val) {
280 printk("3c503: memory failure or memory address conflict.\n");
281 dev->mem_start = 0;
282 ei_status.name = "3c503-PIO";
283 iounmap(mem_base);
284 ei_status.mem = NULL;
285 break;
287 test_val += 0x55555555;
288 writel(0, mem_base + i);
291 #endif /* EL2MEMTEST */
293 if (dev->mem_start)
294 dev->mem_end = dev->mem_start + EL2_MEMSIZE;
296 if (wordlength) { /* No Tx pages to skip over to get to Rx */
297 ei_status.priv = 0;
298 ei_status.name = "3c503/16";
299 } else {
300 ei_status.priv = TX_PAGES * 256;
301 ei_status.name = "3c503";
306 Divide up the memory on the card. This is the same regardless of
307 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
308 we use the entire 8k of bank1 for an Rx ring. We only use 3k
309 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
310 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
311 5kB for an Rx ring. */
313 if (wordlength) {
314 ei_status.tx_start_page = EL2_MB0_START_PG;
315 ei_status.rx_start_page = EL2_MB1_START_PG;
316 } else {
317 ei_status.tx_start_page = EL2_MB1_START_PG;
318 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
321 /* Finish setting the board's parameters. */
322 ei_status.stop_page = EL2_MB1_STOP_PG;
323 ei_status.word16 = wordlength;
324 ei_status.reset_8390 = &el2_reset_8390;
325 ei_status.get_8390_hdr = &el2_get_8390_hdr;
326 ei_status.block_input = &el2_block_input;
327 ei_status.block_output = &el2_block_output;
329 if (dev->irq == 2)
330 dev->irq = 9;
331 else if (dev->irq > 5 && dev->irq != 9) {
332 printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
333 dev->irq);
334 dev->irq = 0;
337 ei_status.saved_irq = dev->irq;
339 dev->open = &el2_open;
340 dev->stop = &el2_close;
341 dev->ethtool_ops = &netdev_ethtool_ops;
342 #ifdef CONFIG_NET_POLL_CONTROLLER
343 dev->poll_controller = ei_poll;
344 #endif
346 retval = register_netdev(dev);
347 if (retval)
348 goto out1;
350 if (dev->mem_start)
351 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
352 dev->name, ei_status.name, (wordlength+1)<<3,
353 dev->mem_start, dev->mem_end-1);
355 else
357 ei_status.tx_start_page = EL2_MB1_START_PG;
358 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
359 printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
360 dev->name, ei_status.name, (wordlength+1)<<3);
362 release_region(ioaddr + 0x400, 8);
363 return 0;
364 out1:
365 release_region(ioaddr + 0x400, 8);
366 out:
367 release_region(ioaddr, EL2_IO_EXTENT);
368 return retval;
371 static int
372 el2_open(struct net_device *dev)
374 int retval = -EAGAIN;
376 if (dev->irq < 2) {
377 int irqlist[] = {5, 9, 3, 4, 0};
378 int *irqp = irqlist;
380 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
381 do {
382 if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
383 /* Twinkle the interrupt, and check if it's seen. */
384 unsigned long cookie = probe_irq_on();
385 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
386 outb_p(0x00, E33G_IDCFR);
387 if (*irqp == probe_irq_off(cookie) /* It's a good IRQ line! */
388 && ((retval = request_irq(dev->irq = *irqp,
389 ei_interrupt, 0, dev->name, dev)) == 0))
390 break;
392 } while (*++irqp);
393 if (*irqp == 0) {
394 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
395 return retval;
397 } else {
398 if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
399 return retval;
403 el2_init_card(dev);
404 ei_open(dev);
405 return 0;
408 static int
409 el2_close(struct net_device *dev)
411 free_irq(dev->irq, dev);
412 dev->irq = ei_status.saved_irq;
413 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
415 ei_close(dev);
416 return 0;
419 /* This is called whenever we have a unrecoverable failure:
420 transmit timeout
421 Bad ring buffer packet header
423 static void
424 el2_reset_8390(struct net_device *dev)
426 if (ei_debug > 1) {
427 printk("%s: Resetting the 3c503 board...", dev->name);
428 printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
429 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
431 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
432 ei_status.txing = 0;
433 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
434 el2_init_card(dev);
435 if (ei_debug > 1) printk("done\n");
438 /* Initialize the 3c503 GA registers after a reset. */
439 static void
440 el2_init_card(struct net_device *dev)
442 /* Unmap the station PROM and select the DIX or BNC connector. */
443 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
445 /* Set ASIC copy of rx's first and last+1 buffer pages */
446 /* These must be the same as in the 8390. */
447 outb(ei_status.rx_start_page, E33G_STARTPG);
448 outb(ei_status.stop_page, E33G_STOPPG);
450 /* Point the vector pointer registers somewhere ?harmless?. */
451 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
452 outb(0xff, E33G_VP1);
453 outb(0x00, E33G_VP0);
454 /* Turn off all interrupts until we're opened. */
455 outb_p(0x00, dev->base_addr + EN0_IMR);
456 /* Enable IRQs iff started. */
457 outb(EGACFR_NORM, E33G_GACFR);
459 /* Set the interrupt line. */
460 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
461 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
462 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
463 outb_p(0x00, E33G_DMAAL);
464 return; /* We always succeed */
468 * Either use the shared memory (if enabled on the board) or put the packet
469 * out through the ASIC FIFO.
471 static void
472 el2_block_output(struct net_device *dev, int count,
473 const unsigned char *buf, int start_page)
475 unsigned short int *wrd;
476 int boguscount; /* timeout counter */
477 unsigned short word; /* temporary for better machine code */
478 void __iomem *base = ei_status.mem;
480 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
481 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
482 else
483 outb(EGACFR_NORM, E33G_GACFR);
485 if (base) { /* Shared memory transfer */
486 memcpy_toio(base + ((start_page - ei_status.tx_start_page) << 8),
487 buf, count);
488 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
489 return;
493 * No shared memory, put the packet out the other way.
494 * Set up then start the internal memory transfer to Tx Start Page
497 word = (unsigned short)start_page;
498 outb(word&0xFF, E33G_DMAAH);
499 outb(word>>8, E33G_DMAAL);
501 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
502 | ECNTRL_START, E33G_CNTRL);
505 * Here I am going to write data to the FIFO as quickly as possible.
506 * Note that E33G_FIFOH is defined incorrectly. It is really
507 * E33G_FIFOL, the lowest port address for both the byte and
508 * word write. Variable 'count' is NOT checked. Caller must supply a
509 * valid count. Note that I may write a harmless extra byte to the
510 * 8390 if the byte-count was not even.
512 wrd = (unsigned short int *) buf;
513 count = (count + 1) >> 1;
514 for(;;)
516 boguscount = 0x1000;
517 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
519 if(!boguscount--)
521 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
522 el2_reset_8390(dev);
523 goto blocked;
526 if(count > WRD_COUNT)
528 outsw(E33G_FIFOH, wrd, WRD_COUNT);
529 wrd += WRD_COUNT;
530 count -= WRD_COUNT;
532 else
534 outsw(E33G_FIFOH, wrd, count);
535 break;
538 blocked:;
539 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
540 return;
543 /* Read the 4 byte, page aligned 8390 specific header. */
544 static void
545 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
547 int boguscount;
548 void __iomem *base = ei_status.mem;
549 unsigned short word;
551 if (base) { /* Use the shared memory. */
552 void __iomem *hdr_start = base + ((ring_page - EL2_MB1_START_PG)<<8);
553 memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
554 hdr->count = le16_to_cpu(hdr->count);
555 return;
559 * No shared memory, use programmed I/O.
562 word = (unsigned short)ring_page;
563 outb(word&0xFF, E33G_DMAAH);
564 outb(word>>8, E33G_DMAAL);
566 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
567 | ECNTRL_START, E33G_CNTRL);
568 boguscount = 0x1000;
569 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
571 if(!boguscount--)
573 printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
574 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
575 el2_reset_8390(dev);
576 goto blocked;
579 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
580 blocked:;
581 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
585 static void
586 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
588 int boguscount = 0;
589 void __iomem *base = ei_status.mem;
590 unsigned short int *buf;
591 unsigned short word;
593 /* Maybe enable shared memory just be to be safe... nahh.*/
594 if (base) { /* Use the shared memory. */
595 ring_offset -= (EL2_MB1_START_PG<<8);
596 if (ring_offset + count > EL2_MEMSIZE) {
597 /* We must wrap the input move. */
598 int semi_count = EL2_MEMSIZE - ring_offset;
599 memcpy_fromio(skb->data, base + ring_offset, semi_count);
600 count -= semi_count;
601 memcpy_fromio(skb->data + semi_count, base + ei_status.priv, count);
602 } else {
603 memcpy_fromio(skb->data, base + ring_offset, count);
605 return;
609 * No shared memory, use programmed I/O.
611 word = (unsigned short) ring_offset;
612 outb(word>>8, E33G_DMAAH);
613 outb(word&0xFF, E33G_DMAAL);
615 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
616 | ECNTRL_START, E33G_CNTRL);
619 * Here I also try to get data as fast as possible. I am betting that I
620 * can read one extra byte without clobbering anything in the kernel because
621 * this would only occur on an odd byte-count and allocation of skb->data
622 * is word-aligned. Variable 'count' is NOT checked. Caller must check
623 * for a valid count.
624 * [This is currently quite safe.... but if one day the 3c503 explodes
625 * you know where to come looking ;)]
628 buf = (unsigned short int *) skb->data;
629 count = (count + 1) >> 1;
630 for(;;)
632 boguscount = 0x1000;
633 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
635 if(!boguscount--)
637 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
638 el2_reset_8390(dev);
639 goto blocked;
642 if(count > WRD_COUNT)
644 insw(E33G_FIFOH, buf, WRD_COUNT);
645 buf += WRD_COUNT;
646 count -= WRD_COUNT;
648 else
650 insw(E33G_FIFOH, buf, count);
651 break;
654 blocked:;
655 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
656 return;
660 static void netdev_get_drvinfo(struct net_device *dev,
661 struct ethtool_drvinfo *info)
663 strcpy(info->driver, DRV_NAME);
664 strcpy(info->version, DRV_VERSION);
665 sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
668 static const struct ethtool_ops netdev_ethtool_ops = {
669 .get_drvinfo = netdev_get_drvinfo,
672 #ifdef MODULE
673 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
675 static struct net_device *dev_el2[MAX_EL2_CARDS];
676 static int io[MAX_EL2_CARDS];
677 static int irq[MAX_EL2_CARDS];
678 static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
679 module_param_array(io, int, NULL, 0);
680 module_param_array(irq, int, NULL, 0);
681 module_param_array(xcvr, int, NULL, 0);
682 MODULE_PARM_DESC(io, "I/O base address(es)");
683 MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
684 MODULE_PARM_DESC(xcvr, "transceiver(s) (0=internal, 1=external)");
685 MODULE_DESCRIPTION("3Com ISA EtherLink II, II/16 (3c503, 3c503/16) driver");
686 MODULE_LICENSE("GPL");
688 /* This is set up so that only a single autoprobe takes place per call.
689 ISA device autoprobes on a running machine are not recommended. */
690 int __init
691 init_module(void)
693 struct net_device *dev;
694 int this_dev, found = 0;
696 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
697 if (io[this_dev] == 0) {
698 if (this_dev != 0) break; /* only autoprobe 1st one */
699 printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
701 dev = alloc_ei_netdev();
702 if (!dev)
703 break;
704 dev->irq = irq[this_dev];
705 dev->base_addr = io[this_dev];
706 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
707 if (do_el2_probe(dev) == 0) {
708 dev_el2[found++] = dev;
709 continue;
711 free_netdev(dev);
712 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
713 break;
715 if (found)
716 return 0;
717 return -ENXIO;
720 static void cleanup_card(struct net_device *dev)
722 /* NB: el2_close() handles free_irq */
723 release_region(dev->base_addr, EL2_IO_EXTENT);
724 if (ei_status.mem)
725 iounmap(ei_status.mem);
728 void __exit
729 cleanup_module(void)
731 int this_dev;
733 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
734 struct net_device *dev = dev_el2[this_dev];
735 if (dev) {
736 unregister_netdev(dev);
737 cleanup_card(dev);
738 free_netdev(dev);
742 #endif /* MODULE */