Import 2.3.18pre1
[davej-history.git] / drivers / net / 3c503.c
blob56769686bcdbaa5645864aced8c9d8f2b334b8a9
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 #ifdef HAVE_DEVLIST
66 /* The 3c503 uses two entries, one for the safe memory-mapped probe and
67 the other for the typical I/O probe. */
68 struct netdev_entry el2_drv =
69 {"3c503", el2_probe, EL1_IO_EXTENT, 0};
70 struct netdev_entry el2pio_drv =
71 {"3c503pio", el2_pioprobe1, EL1_IO_EXTENT, netcard_portlist};
72 #endif
74 static int el2_open(struct net_device *dev);
75 static int el2_close(struct net_device *dev);
76 static void el2_reset_8390(struct net_device *dev);
77 static void el2_init_card(struct net_device *dev);
78 static void el2_block_output(struct net_device *dev, int count,
79 const unsigned char *buf, int start_page);
80 static void el2_block_input(struct net_device *dev, int count, struct sk_buff *skb,
81 int ring_offset);
82 static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
83 int ring_page);
86 /* This routine probes for a memory-mapped 3c503 board by looking for
87 the "location register" at the end of the jumpered boot PROM space.
88 This works even if a PROM isn't there.
90 If the ethercard isn't found there is an optional probe for
91 ethercard jumpered to programmed-I/O mode.
93 int __init
94 el2_probe(struct net_device *dev)
96 int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
97 int base_addr = dev->base_addr;
99 if (base_addr > 0x1ff) /* Check a single specified location. */
100 return el2_probe1(dev, base_addr);
101 else if (base_addr != 0) /* Don't probe at all. */
102 return ENXIO;
104 for (addr = addrs; *addr; addr++) {
105 int i;
106 unsigned int base_bits = readb(*addr);
107 /* Find first set bit. */
108 for(i = 7; i >= 0; i--, base_bits >>= 1)
109 if (base_bits & 0x1)
110 break;
111 if (base_bits != 1)
112 continue;
113 if (check_region(netcard_portlist[i], EL2_IO_EXTENT))
114 continue;
115 if (el2_probe1(dev, netcard_portlist[i]) == 0)
116 return 0;
118 #if ! defined(no_probe_nonshared_memory) && ! defined (HAVE_DEVLIST)
119 return el2_pio_probe(dev);
120 #else
121 return ENODEV;
122 #endif
125 #ifndef HAVE_DEVLIST
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 int __init
129 el2_pio_probe(struct net_device *dev)
131 int i;
132 int base_addr = dev ? dev->base_addr : 0;
134 if (base_addr > 0x1ff) /* Check a single specified location. */
135 return el2_probe1(dev, base_addr);
136 else if (base_addr != 0) /* Don't probe at all. */
137 return ENXIO;
139 for (i = 0; netcard_portlist[i]; i++) {
140 int ioaddr = netcard_portlist[i];
141 if (check_region(ioaddr, EL2_IO_EXTENT))
142 continue;
143 if (el2_probe1(dev, ioaddr) == 0)
144 return 0;
147 return ENODEV;
149 #endif
151 /* Probe for the Etherlink II card at I/O port base IOADDR,
152 returning non-zero on success. If found, set the station
153 address and memory parameters in DEVICE. */
154 int __init
155 el2_probe1(struct net_device *dev, int ioaddr)
157 int i, iobase_reg, membase_reg, saved_406, wordlength;
158 static unsigned version_printed = 0;
159 unsigned long vendor_id;
161 /* Reset and/or avoid any lurking NE2000 */
162 if (inb(ioaddr + 0x408) == 0xff) {
163 mdelay(1);
164 return ENODEV;
167 /* We verify that it's a 3C503 board by checking the first three octets
168 of its ethernet address. */
169 iobase_reg = inb(ioaddr+0x403);
170 membase_reg = inb(ioaddr+0x404);
171 /* ASIC location registers should be 0 or have only a single bit set. */
172 if ( (iobase_reg & (iobase_reg - 1))
173 || (membase_reg & (membase_reg - 1))) {
174 return ENODEV;
176 saved_406 = inb_p(ioaddr + 0x406);
177 outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
178 outb_p(ECNTRL_THIN, ioaddr + 0x406);
179 /* Map the station addr PROM into the lower I/O ports. We now check
180 for both the old and new 3Com prefix */
181 outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
182 vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
183 if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
184 /* Restore the register we frobbed. */
185 outb(saved_406, ioaddr + 0x406);
186 return ENODEV;
189 if (load_8390_module("3c503.c"))
190 return -ENOSYS;
192 /* We should have a "dev" from Space.c or the static module table. */
193 if (dev == NULL) {
194 printk("3c503.c: Passed a NULL device.\n");
195 dev = init_etherdev(0, 0);
198 if (ei_debug && version_printed++ == 0)
199 printk(version);
201 dev->base_addr = ioaddr;
202 /* Allocate dev->priv and fill in 8390 specific dev fields. */
203 if (ethdev_init(dev)) {
204 printk ("3c503: unable to allocate memory for dev->priv.\n");
205 return -ENOMEM;
208 printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
210 /* Retrieve and print the ethernet address. */
211 for (i = 0; i < 6; i++)
212 printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
214 /* Map the 8390 back into the window. */
215 outb(ECNTRL_THIN, ioaddr + 0x406);
217 /* Check for EL2/16 as described in tech. man. */
218 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
219 outb_p(0, ioaddr + EN0_DCFG);
220 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
221 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
222 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
224 /* Probe for, turn on and clear the board's shared memory. */
225 if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
226 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
228 /* This should be probed for (or set via an ioctl()) at run-time.
229 Right now we use a sleazy hack to pass in the interface number
230 at boot-time via the low bits of the mem_end field. That value is
231 unused, and the low bits would be discarded even if it was used. */
232 #if defined(EI8390_THICK) || defined(EL2_AUI)
233 ei_status.interface_num = 1;
234 #else
235 ei_status.interface_num = dev->mem_end & 0xf;
236 #endif
237 printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
239 if ((membase_reg & 0xf0) == 0) {
240 dev->mem_start = 0;
241 ei_status.name = "3c503-PIO";
242 } else {
243 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
244 ((membase_reg & 0xA0) ? 0x4000 : 0);
246 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
247 #ifdef EL2MEMTEST
248 /* This has never found an error, but someone might care.
249 Note that it only tests the 2nd 8kB on 16kB 3c503/16
250 cards between card addr. 0x2000 and 0x3fff. */
251 { /* Check the card's memory. */
252 unsigned long mem_base = dev->mem_start;
253 unsigned int test_val = 0xbbadf00d;
254 writel(0xba5eba5e, mem_base);
255 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
256 writel(test_val, mem_base + i);
257 if (readl(mem_base) != 0xba5eba5e
258 || readl(mem_base + i) != test_val) {
259 printk("3c503: memory failure or memory address conflict.\n");
260 dev->mem_start = 0;
261 ei_status.name = "3c503-PIO";
262 break;
264 test_val += 0x55555555;
265 writel(0, mem_base + i);
268 #endif /* EL2MEMTEST */
270 dev->mem_end = dev->rmem_end = dev->mem_start + EL2_MEMSIZE;
272 if (wordlength) { /* No Tx pages to skip over to get to Rx */
273 dev->rmem_start = dev->mem_start;
274 ei_status.name = "3c503/16";
275 } else {
276 dev->rmem_start = TX_PAGES*256 + dev->mem_start;
277 ei_status.name = "3c503";
282 Divide up the memory on the card. This is the same regardless of
283 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
284 we use the entire 8k of bank1 for an Rx ring. We only use 3k
285 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
286 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
287 5kB for an Rx ring. */
289 if (wordlength) {
290 ei_status.tx_start_page = EL2_MB0_START_PG;
291 ei_status.rx_start_page = EL2_MB1_START_PG;
292 } else {
293 ei_status.tx_start_page = EL2_MB1_START_PG;
294 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
297 /* Finish setting the board's parameters. */
298 ei_status.stop_page = EL2_MB1_STOP_PG;
299 ei_status.word16 = wordlength;
300 ei_status.reset_8390 = &el2_reset_8390;
301 ei_status.get_8390_hdr = &el2_get_8390_hdr;
302 ei_status.block_input = &el2_block_input;
303 ei_status.block_output = &el2_block_output;
305 request_region(ioaddr, EL2_IO_EXTENT, ei_status.name);
307 if (dev->irq == 2)
308 dev->irq = 9;
309 else if (dev->irq > 5 && dev->irq != 9) {
310 printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
311 dev->irq);
312 dev->irq = 0;
315 ei_status.saved_irq = dev->irq;
317 dev->start = 0;
318 dev->open = &el2_open;
319 dev->stop = &el2_close;
321 if (dev->mem_start)
322 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
323 dev->name, ei_status.name, (wordlength+1)<<3,
324 dev->mem_start, dev->mem_end-1);
326 else
328 ei_status.tx_start_page = EL2_MB1_START_PG;
329 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
330 printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
331 dev->name, ei_status.name, (wordlength+1)<<3);
333 return 0;
336 static int
337 el2_open(struct net_device *dev)
340 if (dev->irq < 2) {
341 int irqlist[] = {5, 9, 3, 4, 0};
342 int *irqp = irqlist;
344 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
345 do {
346 if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
347 /* Twinkle the interrupt, and check if it's seen. */
348 autoirq_setup(0);
349 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
350 outb_p(0x00, E33G_IDCFR);
351 if (*irqp == autoirq_report(0) /* It's a good IRQ line! */
352 && request_irq (dev->irq = *irqp, ei_interrupt, 0, ei_status.name, dev) == 0)
353 break;
355 } while (*++irqp);
356 if (*irqp == 0) {
357 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
358 return -EAGAIN;
360 } else {
361 if (request_irq(dev->irq, ei_interrupt, 0, ei_status.name, dev)) {
362 return -EAGAIN;
366 el2_init_card(dev);
367 ei_open(dev);
368 MOD_INC_USE_COUNT;
369 return 0;
372 static int
373 el2_close(struct net_device *dev)
375 free_irq(dev->irq, dev);
376 dev->irq = ei_status.saved_irq;
377 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
379 ei_close(dev);
380 MOD_DEC_USE_COUNT;
381 return 0;
384 /* This is called whenever we have a unrecoverable failure:
385 transmit timeout
386 Bad ring buffer packet header
388 static void
389 el2_reset_8390(struct net_device *dev)
391 if (ei_debug > 1) {
392 printk("%s: Resetting the 3c503 board...", dev->name);
393 printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
394 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
396 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
397 ei_status.txing = 0;
398 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
399 el2_init_card(dev);
400 if (ei_debug > 1) printk("done\n");
403 /* Initialize the 3c503 GA registers after a reset. */
404 static void
405 el2_init_card(struct net_device *dev)
407 /* Unmap the station PROM and select the DIX or BNC connector. */
408 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
410 /* Set ASIC copy of rx's first and last+1 buffer pages */
411 /* These must be the same as in the 8390. */
412 outb(ei_status.rx_start_page, E33G_STARTPG);
413 outb(ei_status.stop_page, E33G_STOPPG);
415 /* Point the vector pointer registers somewhere ?harmless?. */
416 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
417 outb(0xff, E33G_VP1);
418 outb(0x00, E33G_VP0);
419 /* Turn off all interrupts until we're opened. */
420 outb_p(0x00, dev->base_addr + EN0_IMR);
421 /* Enable IRQs iff started. */
422 outb(EGACFR_NORM, E33G_GACFR);
424 /* Set the interrupt line. */
425 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
426 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
427 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
428 outb_p(0x00, E33G_DMAAL);
429 return; /* We always succeed */
433 * Either use the shared memory (if enabled on the board) or put the packet
434 * out through the ASIC FIFO.
436 static void
437 el2_block_output(struct net_device *dev, int count,
438 const unsigned char *buf, int start_page)
440 unsigned short int *wrd;
441 int boguscount; /* timeout counter */
442 unsigned short word; /* temporary for better machine code */
444 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
445 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
446 else
447 outb(EGACFR_NORM, E33G_GACFR);
449 if (dev->mem_start) { /* Shared memory transfer */
450 unsigned long dest_addr = dev->mem_start +
451 ((start_page - ei_status.tx_start_page) << 8);
452 memcpy_toio(dest_addr, buf, count);
453 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
454 return;
458 * No shared memory, put the packet out the other way.
459 * Set up then start the internal memory transfer to Tx Start Page
462 word = (unsigned short)start_page;
463 outb(word&0xFF, E33G_DMAAH);
464 outb(word>>8, E33G_DMAAL);
466 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
467 | ECNTRL_START, E33G_CNTRL);
470 * Here I am going to write data to the FIFO as quickly as possible.
471 * Note that E33G_FIFOH is defined incorrectly. It is really
472 * E33G_FIFOL, the lowest port address for both the byte and
473 * word write. Variable 'count' is NOT checked. Caller must supply a
474 * valid count. Note that I may write a harmless extra byte to the
475 * 8390 if the byte-count was not even.
477 wrd = (unsigned short int *) buf;
478 count = (count + 1) >> 1;
479 for(;;)
481 boguscount = 0x1000;
482 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
484 if(!boguscount--)
486 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
487 el2_reset_8390(dev);
488 goto blocked;
491 if(count > WRD_COUNT)
493 outsw(E33G_FIFOH, wrd, WRD_COUNT);
494 wrd += WRD_COUNT;
495 count -= WRD_COUNT;
497 else
499 outsw(E33G_FIFOH, wrd, count);
500 break;
503 blocked:;
504 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
505 return;
508 /* Read the 4 byte, page aligned 8390 specific header. */
509 static void
510 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
512 int boguscount;
513 unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
514 unsigned short word;
516 if (dev->mem_start) { /* Use the shared memory. */
517 memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
518 return;
522 * No shared memory, use programmed I/O.
525 word = (unsigned short)ring_page;
526 outb(word&0xFF, E33G_DMAAH);
527 outb(word>>8, E33G_DMAAL);
529 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
530 | ECNTRL_START, E33G_CNTRL);
531 boguscount = 0x1000;
532 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
534 if(!boguscount--)
536 printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
537 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
538 el2_reset_8390(dev);
539 goto blocked;
542 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
543 blocked:;
544 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
548 static void
549 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
551 int boguscount = 0;
552 unsigned short int *buf;
553 unsigned short word;
555 int end_of_ring = dev->rmem_end;
557 /* Maybe enable shared memory just be to be safe... nahh.*/
558 if (dev->mem_start) { /* Use the shared memory. */
559 ring_offset -= (EL2_MB1_START_PG<<8);
560 if (dev->mem_start + ring_offset + count > end_of_ring) {
561 /* We must wrap the input move. */
562 int semi_count = end_of_ring - (dev->mem_start + ring_offset);
563 memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
564 count -= semi_count;
565 memcpy_fromio(skb->data + semi_count, dev->rmem_start, count);
566 } else {
567 /* Packet is in one chunk -- we can copy + cksum. */
568 eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
570 return;
574 * No shared memory, use programmed I/O.
576 word = (unsigned short) ring_offset;
577 outb(word>>8, E33G_DMAAH);
578 outb(word&0xFF, E33G_DMAAL);
580 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
581 | ECNTRL_START, E33G_CNTRL);
584 * Here I also try to get data as fast as possible. I am betting that I
585 * can read one extra byte without clobbering anything in the kernel because
586 * this would only occur on an odd byte-count and allocation of skb->data
587 * is word-aligned. Variable 'count' is NOT checked. Caller must check
588 * for a valid count.
589 * [This is currently quite safe.... but if one day the 3c503 explodes
590 * you know where to come looking ;)]
593 buf = (unsigned short int *) skb->data;
594 count = (count + 1) >> 1;
595 for(;;)
597 boguscount = 0x1000;
598 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
600 if(!boguscount--)
602 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
603 el2_reset_8390(dev);
604 goto blocked;
607 if(count > WRD_COUNT)
609 insw(E33G_FIFOH, buf, WRD_COUNT);
610 buf += WRD_COUNT;
611 count -= WRD_COUNT;
613 else
615 insw(E33G_FIFOH, buf, count);
616 break;
619 blocked:;
620 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
621 return;
623 #ifdef MODULE
624 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
625 #define NAMELEN 8 /* #of chars for storing dev->name */
627 static char namelist[NAMELEN * MAX_EL2_CARDS] = { 0, };
628 static struct net_device dev_el2[MAX_EL2_CARDS] = {
630 NULL, /* assign a chunk of namelist[] below */
631 0, 0, 0, 0,
632 0, 0,
633 0, 0, 0, NULL, NULL
637 static int io[MAX_EL2_CARDS] = { 0, };
638 static int irq[MAX_EL2_CARDS] = { 0, };
639 static int xcvr[MAX_EL2_CARDS] = { 0, }; /* choose int. or ext. xcvr */
640 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
641 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
642 MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
644 /* This is set up so that only a single autoprobe takes place per call.
645 ISA device autoprobes on a running machine are not recommended. */
647 init_module(void)
649 int this_dev, found = 0;
651 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
652 struct net_device *dev = &dev_el2[this_dev];
653 dev->name = namelist+(NAMELEN*this_dev);
654 dev->irq = irq[this_dev];
655 dev->base_addr = io[this_dev];
656 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
657 dev->init = el2_probe;
658 if (io[this_dev] == 0) {
659 if (this_dev != 0) break; /* only autoprobe 1st one */
660 printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
662 if (register_netdev(dev) != 0) {
663 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
664 if (found != 0) { /* Got at least one. */
665 lock_8390_module();
666 return 0;
668 return -ENXIO;
670 found++;
672 lock_8390_module();
673 return 0;
676 void
677 cleanup_module(void)
679 int this_dev;
681 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
682 struct net_device *dev = &dev_el2[this_dev];
683 if (dev->priv != NULL) {
684 void *priv = dev->priv;
685 /* NB: el2_close() handles free_irq */
686 release_region(dev->base_addr, EL2_IO_EXTENT);
687 unregister_netdev(dev);
688 kfree(priv);
691 unlock_8390_module();
693 #endif /* MODULE */
696 * Local variables:
697 * version-control: t
698 * kept-new-versions: 5
699 * c-indent-level: 4
700 * End: