1 /* 3c503.c: A shared-memory NS8390 ethernet driver for linux. */
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
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.
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.
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>
56 #include <asm/system.h>
57 #include <asm/byteorder.h>
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
,
80 static void el2_get_8390_hdr(struct net_device
*dev
, struct e8390_pkt_hdr
*hdr
,
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
;
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. */
103 for (addr
= addrs
; *addr
; addr
++) {
104 void __iomem
*p
= ioremap(*addr
, 1);
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
);
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. */
129 el2_pio_probe(struct net_device
*dev
)
132 int base_addr
= dev
->base_addr
;
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. */
140 for (i
= 0; netcard_portlist
[i
]; i
++) {
141 if (el2_probe1(dev
, netcard_portlist
[i
]) == 0)
150 struct net_device
* __init
el2_probe(int unit
)
152 struct net_device
*dev
= alloc_eip_netdev();
156 return ERR_PTR(-ENOMEM
);
158 sprintf(dev
->name
, "eth%d", unit
);
159 netdev_boot_setup_check(dev
);
161 err
= do_el2_probe(dev
);
171 static const struct net_device_ops el2_netdev_ops
= {
172 .ndo_open
= el2_open
,
173 .ndo_stop
= el2_close
,
175 .ndo_start_xmit
= eip_start_xmit
,
176 .ndo_tx_timeout
= eip_tx_timeout
,
177 .ndo_get_stats
= eip_get_stats
,
178 .ndo_set_multicast_list
= eip_set_multicast_list
,
179 .ndo_validate_addr
= eth_validate_addr
,
180 .ndo_set_mac_address
= eth_mac_addr
,
181 .ndo_change_mtu
= eth_change_mtu
,
182 #ifdef CONFIG_NET_POLL_CONTROLLER
183 .ndo_poll_controller
= eip_poll
,
187 /* Probe for the Etherlink II card at I/O port base IOADDR,
188 returning non-zero on success. If found, set the station
189 address and memory parameters in DEVICE. */
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
;
195 unsigned long vendor_id
;
197 if (!request_region(ioaddr
, EL2_IO_EXTENT
, DRV_NAME
))
200 if (!request_region(ioaddr
+ 0x400, 8, DRV_NAME
)) {
205 /* Reset and/or avoid any lurking NE2000 */
206 if (inb(ioaddr
+ 0x408) == 0xff) {
212 /* We verify that it's a 3C503 board by checking the first three octets
213 of its ethernet address. */
214 iobase_reg
= inb(ioaddr
+0x403);
215 membase_reg
= inb(ioaddr
+0x404);
216 /* ASIC location registers should be 0 or have only a single bit set. */
217 if ( (iobase_reg
& (iobase_reg
- 1))
218 || (membase_reg
& (membase_reg
- 1))) {
222 saved_406
= inb_p(ioaddr
+ 0x406);
223 outb_p(ECNTRL_RESET
|ECNTRL_THIN
, ioaddr
+ 0x406); /* Reset it... */
224 outb_p(ECNTRL_THIN
, ioaddr
+ 0x406);
225 /* Map the station addr PROM into the lower I/O ports. We now check
226 for both the old and new 3Com prefix */
227 outb(ECNTRL_SAPROM
|ECNTRL_THIN
, ioaddr
+ 0x406);
228 vendor_id
= inb(ioaddr
)*0x10000 + inb(ioaddr
+ 1)*0x100 + inb(ioaddr
+ 2);
229 if ((vendor_id
!= OLD_3COM_ID
) && (vendor_id
!= NEW_3COM_ID
)) {
230 /* Restore the register we frobbed. */
231 outb(saved_406
, ioaddr
+ 0x406);
236 if (ei_debug
&& version_printed
++ == 0)
237 pr_debug("%s", version
);
239 dev
->base_addr
= ioaddr
;
241 pr_info("%s: 3c503 at i/o base %#3x, node ", dev
->name
, ioaddr
);
243 /* Retrieve and print the ethernet address. */
244 for (i
= 0; i
< 6; i
++)
245 dev
->dev_addr
[i
] = inb(ioaddr
+ i
);
246 pr_cont("%pM", dev
->dev_addr
);
248 /* Map the 8390 back into the window. */
249 outb(ECNTRL_THIN
, ioaddr
+ 0x406);
251 /* Check for EL2/16 as described in tech. man. */
252 outb_p(E8390_PAGE0
, ioaddr
+ E8390_CMD
);
253 outb_p(0, ioaddr
+ EN0_DCFG
);
254 outb_p(E8390_PAGE2
, ioaddr
+ E8390_CMD
);
255 wordlength
= inb_p(ioaddr
+ EN0_DCFG
) & ENDCFG_WTS
;
256 outb_p(E8390_PAGE0
, ioaddr
+ E8390_CMD
);
258 /* Probe for, turn on and clear the board's shared memory. */
260 pr_cont(" memory jumpers %2.2x ", membase_reg
);
261 outb(EGACFR_NORM
, ioaddr
+ 0x405); /* Enable RAM */
263 /* This should be probed for (or set via an ioctl()) at run-time.
264 Right now we use a sleazy hack to pass in the interface number
265 at boot-time via the low bits of the mem_end field. That value is
266 unused, and the low bits would be discarded even if it was used. */
267 #if defined(EI8390_THICK) || defined(EL2_AUI)
268 ei_status
.interface_num
= 1;
270 ei_status
.interface_num
= dev
->mem_end
& 0xf;
272 pr_cont(", using %sternal xcvr.\n", ei_status
.interface_num
== 0 ? "in" : "ex");
274 if ((membase_reg
& 0xf0) == 0) {
276 ei_status
.name
= "3c503-PIO";
277 ei_status
.mem
= NULL
;
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
282 ei_status
.mem
= ioremap(dev
->mem_start
, EL2_MEMSIZE
);
285 /* This has never found an error, but someone might care.
286 Note that it only tests the 2nd 8kB on 16kB 3c503/16
287 cards between card addr. 0x2000 and 0x3fff. */
288 { /* Check the card's memory. */
289 void __iomem
*mem_base
= ei_status
.mem
;
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");
298 ei_status
.name
= "3c503-PIO";
300 ei_status
.mem
= NULL
;
303 test_val
+= 0x55555555;
304 writel(0, mem_base
+ i
);
307 #endif /* EL2MEMTEST */
310 dev
->mem_end
= dev
->mem_start
+ EL2_MEMSIZE
;
312 if (wordlength
) { /* No Tx pages to skip over to get to Rx */
314 ei_status
.name
= "3c503/16";
316 ei_status
.priv
= TX_PAGES
* 256;
317 ei_status
.name
= "3c503";
322 Divide up the memory on the card. This is the same regardless of
323 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
324 we use the entire 8k of bank1 for an Rx ring. We only use 3k
325 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
326 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
327 5kB for an Rx ring. */
330 ei_status
.tx_start_page
= EL2_MB0_START_PG
;
331 ei_status
.rx_start_page
= EL2_MB1_START_PG
;
333 ei_status
.tx_start_page
= EL2_MB1_START_PG
;
334 ei_status
.rx_start_page
= EL2_MB1_START_PG
+ TX_PAGES
;
337 /* Finish setting the board's parameters. */
338 ei_status
.stop_page
= EL2_MB1_STOP_PG
;
339 ei_status
.word16
= wordlength
;
340 ei_status
.reset_8390
= &el2_reset_8390
;
341 ei_status
.get_8390_hdr
= &el2_get_8390_hdr
;
342 ei_status
.block_input
= &el2_block_input
;
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",
353 ei_status
.saved_irq
= dev
->irq
;
355 dev
->netdev_ops
= &el2_netdev_ops
;
356 dev
->ethtool_ops
= &netdev_ethtool_ops
;
358 retval
= register_netdev(dev
);
363 pr_info("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
364 dev
->name
, ei_status
.name
, (wordlength
+1)<<3,
365 dev
->mem_start
, dev
->mem_end
-1);
369 ei_status
.tx_start_page
= EL2_MB1_START_PG
;
370 ei_status
.rx_start_page
= EL2_MB1_START_PG
+ TX_PAGES
;
371 pr_info("%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
372 dev
->name
, ei_status
.name
, (wordlength
+1)<<3);
374 release_region(ioaddr
+ 0x400, 8);
377 release_region(ioaddr
+ 0x400, 8);
379 release_region(ioaddr
, EL2_IO_EXTENT
);
384 el2_open(struct net_device
*dev
)
389 int irqlist
[] = {5, 9, 3, 4, 0};
392 outb(EGACFR_NORM
, E33G_GACFR
); /* Enable RAM and interrupts. */
394 retval
= request_irq(*irqp
, NULL
, 0, "bogus", dev
);
396 /* Twinkle the interrupt, and check if it's seen. */
397 unsigned long cookie
= probe_irq_on();
398 outb_p(0x04 << ((*irqp
== 9) ? 2 : *irqp
), E33G_IDCFR
);
399 outb_p(0x00, E33G_IDCFR
);
400 if (*irqp
== probe_irq_off(cookie
) /* It's a good IRQ line! */
401 && ((retval
= request_irq(dev
->irq
= *irqp
,
402 eip_interrupt
, 0, dev
->name
, dev
)) == 0))
405 if (retval
!= -EBUSY
)
410 outb(EGACFR_IRQOFF
, E33G_GACFR
); /* disable interrupts. */
414 if ((retval
= request_irq(dev
->irq
, eip_interrupt
, 0, dev
->name
, dev
))) {
425 el2_close(struct net_device
*dev
)
427 free_irq(dev
->irq
, dev
);
428 dev
->irq
= ei_status
.saved_irq
;
429 outb(EGACFR_IRQOFF
, E33G_GACFR
); /* disable interrupts. */
435 /* This is called whenever we have a unrecoverable failure:
437 Bad ring buffer packet header
440 el2_reset_8390(struct net_device
*dev
)
443 pr_debug("%s: Resetting the 3c503 board...", dev
->name
);
444 pr_cont(" %#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR
, inb(E33G_IDCFR
),
445 E33G_CNTRL
, inb(E33G_CNTRL
), E33G_GACFR
, inb(E33G_GACFR
));
447 outb_p(ECNTRL_RESET
|ECNTRL_THIN
, E33G_CNTRL
);
449 outb_p(ei_status
.interface_num
==0 ? ECNTRL_THIN
: ECNTRL_AUI
, E33G_CNTRL
);
455 /* Initialize the 3c503 GA registers after a reset. */
457 el2_init_card(struct net_device
*dev
)
459 /* Unmap the station PROM and select the DIX or BNC connector. */
460 outb_p(ei_status
.interface_num
==0 ? ECNTRL_THIN
: ECNTRL_AUI
, E33G_CNTRL
);
462 /* Set ASIC copy of rx's first and last+1 buffer pages */
463 /* These must be the same as in the 8390. */
464 outb(ei_status
.rx_start_page
, E33G_STARTPG
);
465 outb(ei_status
.stop_page
, E33G_STOPPG
);
467 /* Point the vector pointer registers somewhere ?harmless?. */
468 outb(0xff, E33G_VP2
); /* Point at the ROM restart location 0xffff0 */
469 outb(0xff, E33G_VP1
);
470 outb(0x00, E33G_VP0
);
471 /* Turn off all interrupts until we're opened. */
472 outb_p(0x00, dev
->base_addr
+ EN0_IMR
);
473 /* Enable IRQs iff started. */
474 outb(EGACFR_NORM
, E33G_GACFR
);
476 /* Set the interrupt line. */
477 outb_p((0x04 << (dev
->irq
== 9 ? 2 : dev
->irq
)), E33G_IDCFR
);
478 outb_p((WRD_COUNT
<< 1), E33G_DRQCNT
); /* Set burst size to 8 */
479 outb_p(0x20, E33G_DMAAH
); /* Put a valid addr in the GA DMA */
480 outb_p(0x00, E33G_DMAAL
);
481 return; /* We always succeed */
485 * Either use the shared memory (if enabled on the board) or put the packet
486 * out through the ASIC FIFO.
489 el2_block_output(struct net_device
*dev
, int count
,
490 const unsigned char *buf
, int start_page
)
492 unsigned short int *wrd
;
493 int boguscount
; /* timeout counter */
494 unsigned short word
; /* temporary for better machine code */
495 void __iomem
*base
= ei_status
.mem
;
497 if (ei_status
.word16
) /* Tx packets go into bank 0 on EL2/16 card */
498 outb(EGACFR_RSEL
|EGACFR_TCM
, E33G_GACFR
);
500 outb(EGACFR_NORM
, E33G_GACFR
);
502 if (base
) { /* Shared memory transfer */
503 memcpy_toio(base
+ ((start_page
- ei_status
.tx_start_page
) << 8),
505 outb(EGACFR_NORM
, E33G_GACFR
); /* Back to bank1 in case on bank0 */
510 * No shared memory, put the packet out the other way.
511 * Set up then start the internal memory transfer to Tx Start Page
514 word
= (unsigned short)start_page
;
515 outb(word
&0xFF, E33G_DMAAH
);
516 outb(word
>>8, E33G_DMAAL
);
518 outb_p((ei_status
.interface_num
? ECNTRL_AUI
: ECNTRL_THIN
) | ECNTRL_OUTPUT
519 | ECNTRL_START
, E33G_CNTRL
);
522 * Here I am going to write data to the FIFO as quickly as possible.
523 * Note that E33G_FIFOH is defined incorrectly. It is really
524 * E33G_FIFOL, the lowest port address for both the byte and
525 * word write. Variable 'count' is NOT checked. Caller must supply a
526 * valid count. Note that I may write a harmless extra byte to the
527 * 8390 if the byte-count was not even.
529 wrd
= (unsigned short int *) buf
;
530 count
= (count
+ 1) >> 1;
534 while ((inb(E33G_STATUS
) & ESTAT_DPRDY
) == 0)
538 pr_notice("%s: FIFO blocked in el2_block_output.\n", dev
->name
);
543 if(count
> WRD_COUNT
)
545 outsw(E33G_FIFOH
, wrd
, WRD_COUNT
);
551 outsw(E33G_FIFOH
, wrd
, count
);
556 outb_p(ei_status
.interface_num
==0 ? ECNTRL_THIN
: ECNTRL_AUI
, E33G_CNTRL
);
560 /* Read the 4 byte, page aligned 8390 specific header. */
562 el2_get_8390_hdr(struct net_device
*dev
, struct e8390_pkt_hdr
*hdr
, int ring_page
)
565 void __iomem
*base
= ei_status
.mem
;
568 if (base
) { /* Use the shared memory. */
569 void __iomem
*hdr_start
= base
+ ((ring_page
- EL2_MB1_START_PG
)<<8);
570 memcpy_fromio(hdr
, hdr_start
, sizeof(struct e8390_pkt_hdr
));
571 hdr
->count
= le16_to_cpu(hdr
->count
);
576 * No shared memory, use programmed I/O.
579 word
= (unsigned short)ring_page
;
580 outb(word
&0xFF, E33G_DMAAH
);
581 outb(word
>>8, E33G_DMAAL
);
583 outb_p((ei_status
.interface_num
== 0 ? ECNTRL_THIN
: ECNTRL_AUI
) | ECNTRL_INPUT
584 | ECNTRL_START
, E33G_CNTRL
);
586 while ((inb(E33G_STATUS
) & ESTAT_DPRDY
) == 0)
590 pr_notice("%s: FIFO blocked in el2_get_8390_hdr.\n", dev
->name
);
591 memset(hdr
, 0x00, sizeof(struct e8390_pkt_hdr
));
596 insw(E33G_FIFOH
, hdr
, (sizeof(struct e8390_pkt_hdr
))>> 1);
598 outb_p(ei_status
.interface_num
== 0 ? ECNTRL_THIN
: ECNTRL_AUI
, E33G_CNTRL
);
603 el2_block_input(struct net_device
*dev
, int count
, struct sk_buff
*skb
, int ring_offset
)
606 void __iomem
*base
= ei_status
.mem
;
607 unsigned short int *buf
;
610 /* Maybe enable shared memory just be to be safe... nahh.*/
611 if (base
) { /* Use the shared memory. */
612 ring_offset
-= (EL2_MB1_START_PG
<<8);
613 if (ring_offset
+ count
> EL2_MEMSIZE
) {
614 /* We must wrap the input move. */
615 int semi_count
= EL2_MEMSIZE
- ring_offset
;
616 memcpy_fromio(skb
->data
, base
+ ring_offset
, semi_count
);
618 memcpy_fromio(skb
->data
+ semi_count
, base
+ ei_status
.priv
, count
);
620 memcpy_fromio(skb
->data
, base
+ ring_offset
, count
);
626 * No shared memory, use programmed I/O.
628 word
= (unsigned short) ring_offset
;
629 outb(word
>>8, E33G_DMAAH
);
630 outb(word
&0xFF, E33G_DMAAL
);
632 outb_p((ei_status
.interface_num
== 0 ? ECNTRL_THIN
: ECNTRL_AUI
) | ECNTRL_INPUT
633 | ECNTRL_START
, E33G_CNTRL
);
636 * Here I also try to get data as fast as possible. I am betting that I
637 * can read one extra byte without clobbering anything in the kernel because
638 * this would only occur on an odd byte-count and allocation of skb->data
639 * is word-aligned. Variable 'count' is NOT checked. Caller must check
641 * [This is currently quite safe.... but if one day the 3c503 explodes
642 * you know where to come looking ;)]
645 buf
= (unsigned short int *) skb
->data
;
646 count
= (count
+ 1) >> 1;
650 while ((inb(E33G_STATUS
) & ESTAT_DPRDY
) == 0)
654 pr_notice("%s: FIFO blocked in el2_block_input.\n", dev
->name
);
659 if(count
> WRD_COUNT
)
661 insw(E33G_FIFOH
, buf
, WRD_COUNT
);
667 insw(E33G_FIFOH
, buf
, count
);
672 outb_p(ei_status
.interface_num
== 0 ? ECNTRL_THIN
: ECNTRL_AUI
, E33G_CNTRL
);
677 static void netdev_get_drvinfo(struct net_device
*dev
,
678 struct ethtool_drvinfo
*info
)
680 strcpy(info
->driver
, DRV_NAME
);
681 strcpy(info
->version
, DRV_VERSION
);
682 sprintf(info
->bus_info
, "ISA 0x%lx", dev
->base_addr
);
685 static const struct ethtool_ops netdev_ethtool_ops
= {
686 .get_drvinfo
= netdev_get_drvinfo
,
690 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
692 static struct net_device
*dev_el2
[MAX_EL2_CARDS
];
693 static int io
[MAX_EL2_CARDS
];
694 static int irq
[MAX_EL2_CARDS
];
695 static int xcvr
[MAX_EL2_CARDS
]; /* choose int. or ext. xcvr */
696 module_param_array(io
, int, NULL
, 0);
697 module_param_array(irq
, int, NULL
, 0);
698 module_param_array(xcvr
, int, NULL
, 0);
699 MODULE_PARM_DESC(io
, "I/O base address(es)");
700 MODULE_PARM_DESC(irq
, "IRQ number(s) (assigned)");
701 MODULE_PARM_DESC(xcvr
, "transceiver(s) (0=internal, 1=external)");
702 MODULE_DESCRIPTION("3Com ISA EtherLink II, II/16 (3c503, 3c503/16) driver");
703 MODULE_LICENSE("GPL");
705 /* This is set up so that only a single autoprobe takes place per call.
706 ISA device autoprobes on a running machine are not recommended. */
710 struct net_device
*dev
;
711 int this_dev
, found
= 0;
713 for (this_dev
= 0; this_dev
< MAX_EL2_CARDS
; this_dev
++) {
714 if (io
[this_dev
] == 0) {
715 if (this_dev
!= 0) break; /* only autoprobe 1st one */
716 pr_notice("3c503.c: Presently autoprobing (not recommended) for a single card.\n");
718 dev
= alloc_eip_netdev();
721 dev
->irq
= irq
[this_dev
];
722 dev
->base_addr
= io
[this_dev
];
723 dev
->mem_end
= xcvr
[this_dev
]; /* low 4bits = xcvr sel. */
724 if (do_el2_probe(dev
) == 0) {
725 dev_el2
[found
++] = dev
;
729 pr_warning("3c503.c: No 3c503 card found (i/o = 0x%x).\n", io
[this_dev
]);
737 static void cleanup_card(struct net_device
*dev
)
739 /* NB: el2_close() handles free_irq */
740 release_region(dev
->base_addr
, EL2_IO_EXTENT
);
742 iounmap(ei_status
.mem
);
750 for (this_dev
= 0; this_dev
< MAX_EL2_CARDS
; this_dev
++) {
751 struct net_device
*dev
= dev_el2
[this_dev
];
753 unregister_netdev(dev
);