MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / 3c503.c
blobc4524decb9e97e4b627a761be865aa75f8da6783
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 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 SET_MODULE_OWNER(dev);
100 if (base_addr > 0x1ff) /* Check a single specified location. */
101 return el2_probe1(dev, base_addr);
102 else if (base_addr != 0) /* Don't probe at all. */
103 return -ENXIO;
105 for (addr = addrs; *addr; addr++) {
106 unsigned base_bits = isa_readb(*addr);
107 int i = ffs(base_bits) - 1;
108 if (i == -1 || base_bits != (1 << i))
109 continue;
110 if (el2_probe1(dev, netcard_portlist[i]) == 0)
111 return 0;
112 dev->irq = irq;
114 #if ! defined(no_probe_nonshared_memory)
115 return el2_pio_probe(dev);
116 #else
117 return -ENODEV;
118 #endif
121 /* Try all of the locations that aren't obviously empty. This touches
122 a lot of locations, and is much riskier than the code above. */
123 static int __init
124 el2_pio_probe(struct net_device *dev)
126 int i;
127 int base_addr = dev->base_addr;
128 int irq = dev->irq;
130 if (base_addr > 0x1ff) /* Check a single specified location. */
131 return el2_probe1(dev, base_addr);
132 else if (base_addr != 0) /* Don't probe at all. */
133 return -ENXIO;
135 for (i = 0; netcard_portlist[i]; i++) {
136 if (el2_probe1(dev, netcard_portlist[i]) == 0)
137 return 0;
138 dev->irq = irq;
141 return -ENODEV;
144 static void cleanup_card(struct net_device *dev)
146 /* NB: el2_close() handles free_irq */
147 release_region(dev->base_addr, EL2_IO_EXTENT);
150 #ifndef MODULE
151 struct net_device * __init el2_probe(int unit)
153 struct net_device *dev = alloc_ei_netdev();
154 int err;
156 if (!dev)
157 return ERR_PTR(-ENOMEM);
159 sprintf(dev->name, "eth%d", unit);
160 netdev_boot_setup_check(dev);
162 err = do_el2_probe(dev);
163 if (err)
164 goto out;
165 err = register_netdev(dev);
166 if (err)
167 goto out1;
168 return dev;
169 out1:
170 cleanup_card(dev);
171 out:
172 free_netdev(dev);
173 return ERR_PTR(err);
175 #endif
177 /* Probe for the Etherlink II card at I/O port base IOADDR,
178 returning non-zero on success. If found, set the station
179 address and memory parameters in DEVICE. */
180 static int __init
181 el2_probe1(struct net_device *dev, int ioaddr)
183 int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
184 static unsigned version_printed;
185 unsigned long vendor_id;
187 if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
188 return -EBUSY;
190 if (!request_region(ioaddr + 0x400, 8, DRV_NAME)) {
191 retval = -EBUSY;
192 goto out;
195 /* Reset and/or avoid any lurking NE2000 */
196 if (inb(ioaddr + 0x408) == 0xff) {
197 mdelay(1);
198 retval = -ENODEV;
199 goto out1;
202 /* We verify that it's a 3C503 board by checking the first three octets
203 of its ethernet address. */
204 iobase_reg = inb(ioaddr+0x403);
205 membase_reg = inb(ioaddr+0x404);
206 /* ASIC location registers should be 0 or have only a single bit set. */
207 if ( (iobase_reg & (iobase_reg - 1))
208 || (membase_reg & (membase_reg - 1))) {
209 retval = -ENODEV;
210 goto out1;
212 saved_406 = inb_p(ioaddr + 0x406);
213 outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
214 outb_p(ECNTRL_THIN, ioaddr + 0x406);
215 /* Map the station addr PROM into the lower I/O ports. We now check
216 for both the old and new 3Com prefix */
217 outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
218 vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
219 if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
220 /* Restore the register we frobbed. */
221 outb(saved_406, ioaddr + 0x406);
222 retval = -ENODEV;
223 goto out1;
226 if (ei_debug && version_printed++ == 0)
227 printk(version);
229 dev->base_addr = ioaddr;
231 printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
233 /* Retrieve and print the ethernet address. */
234 for (i = 0; i < 6; i++)
235 printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
237 /* Map the 8390 back into the window. */
238 outb(ECNTRL_THIN, ioaddr + 0x406);
240 /* Check for EL2/16 as described in tech. man. */
241 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
242 outb_p(0, ioaddr + EN0_DCFG);
243 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
244 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
245 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
247 /* Probe for, turn on and clear the board's shared memory. */
248 if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
249 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
251 /* This should be probed for (or set via an ioctl()) at run-time.
252 Right now we use a sleazy hack to pass in the interface number
253 at boot-time via the low bits of the mem_end field. That value is
254 unused, and the low bits would be discarded even if it was used. */
255 #if defined(EI8390_THICK) || defined(EL2_AUI)
256 ei_status.interface_num = 1;
257 #else
258 ei_status.interface_num = dev->mem_end & 0xf;
259 #endif
260 printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
262 if ((membase_reg & 0xf0) == 0) {
263 dev->mem_start = 0;
264 ei_status.name = "3c503-PIO";
265 } else {
266 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
267 ((membase_reg & 0xA0) ? 0x4000 : 0);
269 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
270 #ifdef EL2MEMTEST
271 /* This has never found an error, but someone might care.
272 Note that it only tests the 2nd 8kB on 16kB 3c503/16
273 cards between card addr. 0x2000 and 0x3fff. */
274 { /* Check the card's memory. */
275 unsigned long mem_base = dev->mem_start;
276 unsigned int test_val = 0xbbadf00d;
277 isa_writel(0xba5eba5e, mem_base);
278 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
279 isa_writel(test_val, mem_base + i);
280 if (isa_readl(mem_base) != 0xba5eba5e
281 || isa_readl(mem_base + i) != test_val) {
282 printk("3c503: memory failure or memory address conflict.\n");
283 dev->mem_start = 0;
284 ei_status.name = "3c503-PIO";
285 break;
287 test_val += 0x55555555;
288 isa_writel(0, mem_base + i);
291 #endif /* EL2MEMTEST */
293 if (dev->mem_start)
294 dev->mem_end = ei_status.rmem_end = dev->mem_start + EL2_MEMSIZE;
296 if (wordlength) { /* No Tx pages to skip over to get to Rx */
297 ei_status.rmem_start = dev->mem_start;
298 ei_status.name = "3c503/16";
299 } else {
300 ei_status.rmem_start = TX_PAGES*256 + dev->mem_start;
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 if (dev->mem_start)
347 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
348 dev->name, ei_status.name, (wordlength+1)<<3,
349 dev->mem_start, dev->mem_end-1);
351 else
353 ei_status.tx_start_page = EL2_MB1_START_PG;
354 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
355 printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
356 dev->name, ei_status.name, (wordlength+1)<<3);
358 release_region(ioaddr + 0x400, 8);
359 return 0;
360 out1:
361 release_region(ioaddr + 0x400, 8);
362 out:
363 release_region(ioaddr, EL2_IO_EXTENT);
364 return retval;
367 static int
368 el2_open(struct net_device *dev)
370 int retval = -EAGAIN;
372 if (dev->irq < 2) {
373 int irqlist[] = {5, 9, 3, 4, 0};
374 int *irqp = irqlist;
376 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
377 do {
378 if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
379 /* Twinkle the interrupt, and check if it's seen. */
380 unsigned long cookie = probe_irq_on();
381 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
382 outb_p(0x00, E33G_IDCFR);
383 if (*irqp == probe_irq_off(cookie) /* It's a good IRQ line! */
384 && ((retval = request_irq(dev->irq = *irqp,
385 ei_interrupt, 0, dev->name, dev)) == 0))
386 break;
388 } while (*++irqp);
389 if (*irqp == 0) {
390 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
391 return retval;
393 } else {
394 if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
395 return retval;
399 el2_init_card(dev);
400 ei_open(dev);
401 return 0;
404 static int
405 el2_close(struct net_device *dev)
407 free_irq(dev->irq, dev);
408 dev->irq = ei_status.saved_irq;
409 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
411 ei_close(dev);
412 return 0;
415 /* This is called whenever we have a unrecoverable failure:
416 transmit timeout
417 Bad ring buffer packet header
419 static void
420 el2_reset_8390(struct net_device *dev)
422 if (ei_debug > 1) {
423 printk("%s: Resetting the 3c503 board...", dev->name);
424 printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
425 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
427 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
428 ei_status.txing = 0;
429 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
430 el2_init_card(dev);
431 if (ei_debug > 1) printk("done\n");
434 /* Initialize the 3c503 GA registers after a reset. */
435 static void
436 el2_init_card(struct net_device *dev)
438 /* Unmap the station PROM and select the DIX or BNC connector. */
439 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
441 /* Set ASIC copy of rx's first and last+1 buffer pages */
442 /* These must be the same as in the 8390. */
443 outb(ei_status.rx_start_page, E33G_STARTPG);
444 outb(ei_status.stop_page, E33G_STOPPG);
446 /* Point the vector pointer registers somewhere ?harmless?. */
447 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
448 outb(0xff, E33G_VP1);
449 outb(0x00, E33G_VP0);
450 /* Turn off all interrupts until we're opened. */
451 outb_p(0x00, dev->base_addr + EN0_IMR);
452 /* Enable IRQs iff started. */
453 outb(EGACFR_NORM, E33G_GACFR);
455 /* Set the interrupt line. */
456 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
457 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
458 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
459 outb_p(0x00, E33G_DMAAL);
460 return; /* We always succeed */
464 * Either use the shared memory (if enabled on the board) or put the packet
465 * out through the ASIC FIFO.
467 static void
468 el2_block_output(struct net_device *dev, int count,
469 const unsigned char *buf, int start_page)
471 unsigned short int *wrd;
472 int boguscount; /* timeout counter */
473 unsigned short word; /* temporary for better machine code */
475 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
476 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
477 else
478 outb(EGACFR_NORM, E33G_GACFR);
480 if (dev->mem_start) { /* Shared memory transfer */
481 unsigned long dest_addr = dev->mem_start +
482 ((start_page - ei_status.tx_start_page) << 8);
483 isa_memcpy_toio(dest_addr, buf, count);
484 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
485 return;
489 * No shared memory, put the packet out the other way.
490 * Set up then start the internal memory transfer to Tx Start Page
493 word = (unsigned short)start_page;
494 outb(word&0xFF, E33G_DMAAH);
495 outb(word>>8, E33G_DMAAL);
497 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
498 | ECNTRL_START, E33G_CNTRL);
501 * Here I am going to write data to the FIFO as quickly as possible.
502 * Note that E33G_FIFOH is defined incorrectly. It is really
503 * E33G_FIFOL, the lowest port address for both the byte and
504 * word write. Variable 'count' is NOT checked. Caller must supply a
505 * valid count. Note that I may write a harmless extra byte to the
506 * 8390 if the byte-count was not even.
508 wrd = (unsigned short int *) buf;
509 count = (count + 1) >> 1;
510 for(;;)
512 boguscount = 0x1000;
513 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
515 if(!boguscount--)
517 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
518 el2_reset_8390(dev);
519 goto blocked;
522 if(count > WRD_COUNT)
524 outsw(E33G_FIFOH, wrd, WRD_COUNT);
525 wrd += WRD_COUNT;
526 count -= WRD_COUNT;
528 else
530 outsw(E33G_FIFOH, wrd, count);
531 break;
534 blocked:;
535 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
536 return;
539 /* Read the 4 byte, page aligned 8390 specific header. */
540 static void
541 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
543 int boguscount;
544 unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
545 unsigned short word;
547 if (dev->mem_start) { /* Use the shared memory. */
548 isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
549 hdr->count = le16_to_cpu(hdr->count);
550 return;
554 * No shared memory, use programmed I/O.
557 word = (unsigned short)ring_page;
558 outb(word&0xFF, E33G_DMAAH);
559 outb(word>>8, E33G_DMAAL);
561 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
562 | ECNTRL_START, E33G_CNTRL);
563 boguscount = 0x1000;
564 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
566 if(!boguscount--)
568 printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
569 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
570 el2_reset_8390(dev);
571 goto blocked;
574 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
575 blocked:;
576 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
580 static void
581 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
583 int boguscount = 0;
584 unsigned short int *buf;
585 unsigned short word;
587 int end_of_ring = ei_status.rmem_end;
589 /* Maybe enable shared memory just be to be safe... nahh.*/
590 if (dev->mem_start) { /* Use the shared memory. */
591 ring_offset -= (EL2_MB1_START_PG<<8);
592 if (dev->mem_start + ring_offset + count > end_of_ring) {
593 /* We must wrap the input move. */
594 int semi_count = end_of_ring - (dev->mem_start + ring_offset);
595 isa_memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
596 count -= semi_count;
597 isa_memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count);
598 } else {
599 /* Packet is in one chunk -- we can copy + cksum. */
600 isa_eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
602 return;
606 * No shared memory, use programmed I/O.
608 word = (unsigned short) ring_offset;
609 outb(word>>8, E33G_DMAAH);
610 outb(word&0xFF, E33G_DMAAL);
612 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
613 | ECNTRL_START, E33G_CNTRL);
616 * Here I also try to get data as fast as possible. I am betting that I
617 * can read one extra byte without clobbering anything in the kernel because
618 * this would only occur on an odd byte-count and allocation of skb->data
619 * is word-aligned. Variable 'count' is NOT checked. Caller must check
620 * for a valid count.
621 * [This is currently quite safe.... but if one day the 3c503 explodes
622 * you know where to come looking ;)]
625 buf = (unsigned short int *) skb->data;
626 count = (count + 1) >> 1;
627 for(;;)
629 boguscount = 0x1000;
630 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
632 if(!boguscount--)
634 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
635 el2_reset_8390(dev);
636 goto blocked;
639 if(count > WRD_COUNT)
641 insw(E33G_FIFOH, buf, WRD_COUNT);
642 buf += WRD_COUNT;
643 count -= WRD_COUNT;
645 else
647 insw(E33G_FIFOH, buf, count);
648 break;
651 blocked:;
652 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
653 return;
657 static void netdev_get_drvinfo(struct net_device *dev,
658 struct ethtool_drvinfo *info)
660 strcpy(info->driver, DRV_NAME);
661 strcpy(info->version, DRV_VERSION);
662 sprintf(info->bus_info, "ISA 0x%lx", dev->base_addr);
665 static struct ethtool_ops netdev_ethtool_ops = {
666 .get_drvinfo = netdev_get_drvinfo,
669 #ifdef MODULE
670 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
672 static struct net_device *dev_el2[MAX_EL2_CARDS];
673 static int io[MAX_EL2_CARDS];
674 static int irq[MAX_EL2_CARDS];
675 static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
676 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
677 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
678 MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
679 MODULE_PARM_DESC(io, "I/O base address(es)");
680 MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
681 MODULE_PARM_DESC(xcvr, "transceiver(s) (0=internal, 1=external)");
682 MODULE_DESCRIPTION("3Com ISA EtherLink II, II/16 (3c503, 3c503/16) driver");
683 MODULE_LICENSE("GPL");
685 /* This is set up so that only a single autoprobe takes place per call.
686 ISA device autoprobes on a running machine are not recommended. */
688 init_module(void)
690 struct net_device *dev;
691 int this_dev, found = 0;
693 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
694 if (io[this_dev] == 0) {
695 if (this_dev != 0) break; /* only autoprobe 1st one */
696 printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
698 dev = alloc_ei_netdev();
699 if (!dev)
700 break;
701 dev->irq = irq[this_dev];
702 dev->base_addr = io[this_dev];
703 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
704 if (do_el2_probe(dev) == 0) {
705 if (register_netdev(dev) == 0) {
706 dev_el2[found++] = dev;
707 continue;
709 cleanup_card(dev);
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 void
721 cleanup_module(void)
723 int this_dev;
725 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
726 struct net_device *dev = dev_el2[this_dev];
727 if (dev) {
728 unregister_netdev(dev);
729 cleanup_card(dev);
730 free_netdev(dev);
734 #endif /* MODULE */