Ok, test10-final is out there now. This has no _known_ bugs that I
[davej-history.git] / drivers / net / 3c503.c
blob06745646cad32caa6ab415bc18c578f2d136133c
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 Public License,
8 incorporated herein by reference.
10 The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O
11 Center of Excellence in Space Data and Information Sciences
12 Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771
14 This driver should work with the 3c503 and 3c503/16. It should be used
15 in shared memory mode for best performance, although it may also work
16 in programmed-I/O mode.
18 Sources:
19 EtherLink II Technical Reference Manual,
20 EtherLink II/16 Technical Reference Manual Supplement,
21 3Com Corporation, 5400 Bayfront Plaza, Santa Clara CA 95052-8145
23 The Crynwr 3c503 packet driver.
25 Changelog:
27 Paul Gortmaker : add support for the 2nd 8kB of RAM on 16 bit cards.
28 Paul Gortmaker : multiple card support for module users.
29 rjohnson@analogic.com : Fix up PIO interface for efficient operation.
33 static const char *version =
34 "3c503.c:v1.10 9/23/93 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
36 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/sched.h>
40 #include <linux/errno.h>
41 #include <linux/string.h>
42 #include <linux/delay.h>
43 #include <linux/netdevice.h>
44 #include <linux/etherdevice.h>
45 #include <linux/init.h>
47 #include <asm/io.h>
48 #include <asm/system.h>
49 #include <asm/byteorder.h>
51 #include "8390.h"
52 #include "3c503.h"
53 #define WRD_COUNT 4
55 int el2_probe(struct net_device *dev);
56 int el2_pio_probe(struct net_device *dev);
57 int el2_probe1(struct net_device *dev, int ioaddr);
59 /* A zero-terminated list of I/O addresses to be probed in PIO mode. */
60 static unsigned int netcard_portlist[] __initdata =
61 { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
63 #define EL2_IO_EXTENT 16
65 static int el2_open(struct net_device *dev);
66 static int el2_close(struct net_device *dev);
67 static void el2_reset_8390(struct net_device *dev);
68 static void el2_init_card(struct net_device *dev);
69 static void el2_block_output(struct net_device *dev, int count,
70 const unsigned char *buf, int start_page);
71 static void el2_block_input(struct net_device *dev, int count, struct sk_buff *skb,
72 int ring_offset);
73 static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
74 int ring_page);
77 /* This routine probes for a memory-mapped 3c503 board by looking for
78 the "location register" at the end of the jumpered boot PROM space.
79 This works even if a PROM isn't there.
81 If the ethercard isn't found there is an optional probe for
82 ethercard jumpered to programmed-I/O mode.
84 int __init
85 el2_probe(struct net_device *dev)
87 int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
88 int base_addr = dev->base_addr;
90 if (base_addr > 0x1ff) /* Check a single specified location. */
91 return el2_probe1(dev, base_addr);
92 else if (base_addr != 0) /* Don't probe at all. */
93 return -ENXIO;
95 for (addr = addrs; *addr; addr++) {
96 int i;
97 unsigned int base_bits = isa_readb(*addr);
98 /* Find first set bit. */
99 for(i = 7; i >= 0; i--, base_bits >>= 1)
100 if (base_bits & 0x1)
101 break;
102 if (base_bits != 1)
103 continue;
104 if (check_region(netcard_portlist[i], EL2_IO_EXTENT))
105 continue;
106 if (el2_probe1(dev, netcard_portlist[i]) == 0)
107 return 0;
109 #if ! defined(no_probe_nonshared_memory)
110 return el2_pio_probe(dev);
111 #else
112 return -ENODEV;
113 #endif
116 /* Try all of the locations that aren't obviously empty. This touches
117 a lot of locations, and is much riskier than the code above. */
118 int __init
119 el2_pio_probe(struct net_device *dev)
121 int i;
122 int base_addr = dev ? dev->base_addr : 0;
124 if (base_addr > 0x1ff) /* Check a single specified location. */
125 return el2_probe1(dev, base_addr);
126 else if (base_addr != 0) /* Don't probe at all. */
127 return -ENXIO;
129 for (i = 0; netcard_portlist[i]; i++) {
130 int ioaddr = netcard_portlist[i];
131 if (check_region(ioaddr, EL2_IO_EXTENT))
132 continue;
133 if (el2_probe1(dev, ioaddr) == 0)
134 return 0;
137 return -ENODEV;
140 /* Probe for the Etherlink II card at I/O port base IOADDR,
141 returning non-zero on success. If found, set the station
142 address and memory parameters in DEVICE. */
143 int __init
144 el2_probe1(struct net_device *dev, int ioaddr)
146 int i, iobase_reg, membase_reg, saved_406, wordlength;
147 static unsigned version_printed = 0;
148 unsigned long vendor_id;
150 /* Reset and/or avoid any lurking NE2000 */
151 if (inb(ioaddr + 0x408) == 0xff) {
152 mdelay(1);
153 return -ENODEV;
156 /* We verify that it's a 3C503 board by checking the first three octets
157 of its ethernet address. */
158 iobase_reg = inb(ioaddr+0x403);
159 membase_reg = inb(ioaddr+0x404);
160 /* ASIC location registers should be 0 or have only a single bit set. */
161 if ( (iobase_reg & (iobase_reg - 1))
162 || (membase_reg & (membase_reg - 1))) {
163 return -ENODEV;
165 saved_406 = inb_p(ioaddr + 0x406);
166 outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
167 outb_p(ECNTRL_THIN, ioaddr + 0x406);
168 /* Map the station addr PROM into the lower I/O ports. We now check
169 for both the old and new 3Com prefix */
170 outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
171 vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
172 if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
173 /* Restore the register we frobbed. */
174 outb(saved_406, ioaddr + 0x406);
175 return -ENODEV;
178 if (ei_debug && version_printed++ == 0)
179 printk(version);
181 dev->base_addr = ioaddr;
182 /* Allocate dev->priv and fill in 8390 specific dev fields. */
183 if (ethdev_init(dev)) {
184 printk ("3c503: unable to allocate memory for dev->priv.\n");
185 return -ENOMEM;
188 printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
190 /* Retrieve and print the ethernet address. */
191 for (i = 0; i < 6; i++)
192 printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
194 /* Map the 8390 back into the window. */
195 outb(ECNTRL_THIN, ioaddr + 0x406);
197 /* Check for EL2/16 as described in tech. man. */
198 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
199 outb_p(0, ioaddr + EN0_DCFG);
200 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
201 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
202 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
204 /* Probe for, turn on and clear the board's shared memory. */
205 if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
206 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
208 /* This should be probed for (or set via an ioctl()) at run-time.
209 Right now we use a sleazy hack to pass in the interface number
210 at boot-time via the low bits of the mem_end field. That value is
211 unused, and the low bits would be discarded even if it was used. */
212 #if defined(EI8390_THICK) || defined(EL2_AUI)
213 ei_status.interface_num = 1;
214 #else
215 ei_status.interface_num = dev->mem_end & 0xf;
216 #endif
217 printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
219 if ((membase_reg & 0xf0) == 0) {
220 dev->mem_start = 0;
221 ei_status.name = "3c503-PIO";
222 } else {
223 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
224 ((membase_reg & 0xA0) ? 0x4000 : 0);
226 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
227 #ifdef EL2MEMTEST
228 /* This has never found an error, but someone might care.
229 Note that it only tests the 2nd 8kB on 16kB 3c503/16
230 cards between card addr. 0x2000 and 0x3fff. */
231 { /* Check the card's memory. */
232 unsigned long mem_base = dev->mem_start;
233 unsigned int test_val = 0xbbadf00d;
234 isa_writel(0xba5eba5e, mem_base);
235 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
236 isa_writel(test_val, mem_base + i);
237 if (isa_readl(mem_base) != 0xba5eba5e
238 || isa_readl(mem_base + i) != test_val) {
239 printk("3c503: memory failure or memory address conflict.\n");
240 dev->mem_start = 0;
241 ei_status.name = "3c503-PIO";
242 break;
244 test_val += 0x55555555;
245 isa_writel(0, mem_base + i);
248 #endif /* EL2MEMTEST */
250 dev->mem_end = dev->rmem_end = dev->mem_start + EL2_MEMSIZE;
252 if (wordlength) { /* No Tx pages to skip over to get to Rx */
253 dev->rmem_start = dev->mem_start;
254 ei_status.name = "3c503/16";
255 } else {
256 dev->rmem_start = TX_PAGES*256 + dev->mem_start;
257 ei_status.name = "3c503";
262 Divide up the memory on the card. This is the same regardless of
263 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
264 we use the entire 8k of bank1 for an Rx ring. We only use 3k
265 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
266 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
267 5kB for an Rx ring. */
269 if (wordlength) {
270 ei_status.tx_start_page = EL2_MB0_START_PG;
271 ei_status.rx_start_page = EL2_MB1_START_PG;
272 } else {
273 ei_status.tx_start_page = EL2_MB1_START_PG;
274 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
277 /* Finish setting the board's parameters. */
278 ei_status.stop_page = EL2_MB1_STOP_PG;
279 ei_status.word16 = wordlength;
280 ei_status.reset_8390 = &el2_reset_8390;
281 ei_status.get_8390_hdr = &el2_get_8390_hdr;
282 ei_status.block_input = &el2_block_input;
283 ei_status.block_output = &el2_block_output;
285 request_region(ioaddr, EL2_IO_EXTENT, ei_status.name);
287 if (dev->irq == 2)
288 dev->irq = 9;
289 else if (dev->irq > 5 && dev->irq != 9) {
290 printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
291 dev->irq);
292 dev->irq = 0;
295 ei_status.saved_irq = dev->irq;
297 dev->open = &el2_open;
298 dev->stop = &el2_close;
300 if (dev->mem_start)
301 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
302 dev->name, ei_status.name, (wordlength+1)<<3,
303 dev->mem_start, dev->mem_end-1);
305 else
307 ei_status.tx_start_page = EL2_MB1_START_PG;
308 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
309 printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
310 dev->name, ei_status.name, (wordlength+1)<<3);
312 return 0;
315 static int
316 el2_open(struct net_device *dev)
319 if (dev->irq < 2) {
320 int irqlist[] = {5, 9, 3, 4, 0};
321 int *irqp = irqlist;
323 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
324 do {
325 if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
326 /* Twinkle the interrupt, and check if it's seen. */
327 autoirq_setup(0);
328 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
329 outb_p(0x00, E33G_IDCFR);
330 if (*irqp == autoirq_report(0) /* It's a good IRQ line! */
331 && request_irq (dev->irq = *irqp, ei_interrupt, 0, ei_status.name, dev) == 0)
332 break;
334 } while (*++irqp);
335 if (*irqp == 0) {
336 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
337 return -EAGAIN;
339 } else {
340 if (request_irq(dev->irq, ei_interrupt, 0, ei_status.name, dev)) {
341 return -EAGAIN;
345 el2_init_card(dev);
346 ei_open(dev);
347 MOD_INC_USE_COUNT;
348 return 0;
351 static int
352 el2_close(struct net_device *dev)
354 free_irq(dev->irq, dev);
355 dev->irq = ei_status.saved_irq;
356 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
358 ei_close(dev);
359 MOD_DEC_USE_COUNT;
360 return 0;
363 /* This is called whenever we have a unrecoverable failure:
364 transmit timeout
365 Bad ring buffer packet header
367 static void
368 el2_reset_8390(struct net_device *dev)
370 if (ei_debug > 1) {
371 printk("%s: Resetting the 3c503 board...", dev->name);
372 printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
373 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
375 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
376 ei_status.txing = 0;
377 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
378 el2_init_card(dev);
379 if (ei_debug > 1) printk("done\n");
382 /* Initialize the 3c503 GA registers after a reset. */
383 static void
384 el2_init_card(struct net_device *dev)
386 /* Unmap the station PROM and select the DIX or BNC connector. */
387 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
389 /* Set ASIC copy of rx's first and last+1 buffer pages */
390 /* These must be the same as in the 8390. */
391 outb(ei_status.rx_start_page, E33G_STARTPG);
392 outb(ei_status.stop_page, E33G_STOPPG);
394 /* Point the vector pointer registers somewhere ?harmless?. */
395 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
396 outb(0xff, E33G_VP1);
397 outb(0x00, E33G_VP0);
398 /* Turn off all interrupts until we're opened. */
399 outb_p(0x00, dev->base_addr + EN0_IMR);
400 /* Enable IRQs iff started. */
401 outb(EGACFR_NORM, E33G_GACFR);
403 /* Set the interrupt line. */
404 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
405 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
406 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
407 outb_p(0x00, E33G_DMAAL);
408 return; /* We always succeed */
412 * Either use the shared memory (if enabled on the board) or put the packet
413 * out through the ASIC FIFO.
415 static void
416 el2_block_output(struct net_device *dev, int count,
417 const unsigned char *buf, int start_page)
419 unsigned short int *wrd;
420 int boguscount; /* timeout counter */
421 unsigned short word; /* temporary for better machine code */
423 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
424 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
425 else
426 outb(EGACFR_NORM, E33G_GACFR);
428 if (dev->mem_start) { /* Shared memory transfer */
429 unsigned long dest_addr = dev->mem_start +
430 ((start_page - ei_status.tx_start_page) << 8);
431 isa_memcpy_toio(dest_addr, buf, count);
432 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
433 return;
437 * No shared memory, put the packet out the other way.
438 * Set up then start the internal memory transfer to Tx Start Page
441 word = (unsigned short)start_page;
442 outb(word&0xFF, E33G_DMAAH);
443 outb(word>>8, E33G_DMAAL);
445 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
446 | ECNTRL_START, E33G_CNTRL);
449 * Here I am going to write data to the FIFO as quickly as possible.
450 * Note that E33G_FIFOH is defined incorrectly. It is really
451 * E33G_FIFOL, the lowest port address for both the byte and
452 * word write. Variable 'count' is NOT checked. Caller must supply a
453 * valid count. Note that I may write a harmless extra byte to the
454 * 8390 if the byte-count was not even.
456 wrd = (unsigned short int *) buf;
457 count = (count + 1) >> 1;
458 for(;;)
460 boguscount = 0x1000;
461 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
463 if(!boguscount--)
465 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
466 el2_reset_8390(dev);
467 goto blocked;
470 if(count > WRD_COUNT)
472 outsw(E33G_FIFOH, wrd, WRD_COUNT);
473 wrd += WRD_COUNT;
474 count -= WRD_COUNT;
476 else
478 outsw(E33G_FIFOH, wrd, count);
479 break;
482 blocked:;
483 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
484 return;
487 /* Read the 4 byte, page aligned 8390 specific header. */
488 static void
489 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
491 int boguscount;
492 unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
493 unsigned short word;
495 if (dev->mem_start) { /* Use the shared memory. */
496 isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
497 return;
501 * No shared memory, use programmed I/O.
504 word = (unsigned short)ring_page;
505 outb(word&0xFF, E33G_DMAAH);
506 outb(word>>8, E33G_DMAAL);
508 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
509 | ECNTRL_START, E33G_CNTRL);
510 boguscount = 0x1000;
511 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
513 if(!boguscount--)
515 printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
516 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
517 el2_reset_8390(dev);
518 goto blocked;
521 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
522 blocked:;
523 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
527 static void
528 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
530 int boguscount = 0;
531 unsigned short int *buf;
532 unsigned short word;
534 int end_of_ring = dev->rmem_end;
536 /* Maybe enable shared memory just be to be safe... nahh.*/
537 if (dev->mem_start) { /* Use the shared memory. */
538 ring_offset -= (EL2_MB1_START_PG<<8);
539 if (dev->mem_start + ring_offset + count > end_of_ring) {
540 /* We must wrap the input move. */
541 int semi_count = end_of_ring - (dev->mem_start + ring_offset);
542 isa_memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
543 count -= semi_count;
544 isa_memcpy_fromio(skb->data + semi_count, dev->rmem_start, count);
545 } else {
546 /* Packet is in one chunk -- we can copy + cksum. */
547 isa_eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
549 return;
553 * No shared memory, use programmed I/O.
555 word = (unsigned short) ring_offset;
556 outb(word>>8, E33G_DMAAH);
557 outb(word&0xFF, E33G_DMAAL);
559 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
560 | ECNTRL_START, E33G_CNTRL);
563 * Here I also try to get data as fast as possible. I am betting that I
564 * can read one extra byte without clobbering anything in the kernel because
565 * this would only occur on an odd byte-count and allocation of skb->data
566 * is word-aligned. Variable 'count' is NOT checked. Caller must check
567 * for a valid count.
568 * [This is currently quite safe.... but if one day the 3c503 explodes
569 * you know where to come looking ;)]
572 buf = (unsigned short int *) skb->data;
573 count = (count + 1) >> 1;
574 for(;;)
576 boguscount = 0x1000;
577 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
579 if(!boguscount--)
581 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
582 el2_reset_8390(dev);
583 goto blocked;
586 if(count > WRD_COUNT)
588 insw(E33G_FIFOH, buf, WRD_COUNT);
589 buf += WRD_COUNT;
590 count -= WRD_COUNT;
592 else
594 insw(E33G_FIFOH, buf, count);
595 break;
598 blocked:;
599 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
600 return;
602 #ifdef MODULE
603 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
605 static struct net_device dev_el2[MAX_EL2_CARDS] = {
608 0, 0, 0, 0,
609 0, 0,
610 0, 0, 0, NULL, NULL
614 static int io[MAX_EL2_CARDS] = { 0, };
615 static int irq[MAX_EL2_CARDS] = { 0, };
616 static int xcvr[MAX_EL2_CARDS] = { 0, }; /* choose int. or ext. xcvr */
617 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
618 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
619 MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
621 /* This is set up so that only a single autoprobe takes place per call.
622 ISA device autoprobes on a running machine are not recommended. */
624 init_module(void)
626 int this_dev, found = 0;
628 if (load_8390_module("3c503.c"))
629 return -ENOSYS;
631 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
632 struct net_device *dev = &dev_el2[this_dev];
633 dev->irq = irq[this_dev];
634 dev->base_addr = io[this_dev];
635 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
636 dev->init = el2_probe;
637 if (io[this_dev] == 0) {
638 if (this_dev != 0) break; /* only autoprobe 1st one */
639 printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
641 if (register_netdev(dev) != 0) {
642 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
643 if (found != 0) { /* Got at least one. */
644 return 0;
646 unload_8390_module();
647 return -ENXIO;
649 found++;
651 return 0;
654 void
655 cleanup_module(void)
657 int this_dev;
659 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
660 struct net_device *dev = &dev_el2[this_dev];
661 if (dev->priv != NULL) {
662 void *priv = dev->priv;
663 /* NB: el2_close() handles free_irq */
664 release_region(dev->base_addr, EL2_IO_EXTENT);
665 unregister_netdev(dev);
666 kfree(priv);
669 unload_8390_module();
671 #endif /* MODULE */
674 * Local variables:
675 * version-control: t
676 * kept-new-versions: 5
677 * c-indent-level: 4
678 * End: