More meth updates.
[linux-2.6/linux-mips.git] / drivers / net / 3c503.c
blob39fc773bfb4be4700a92a6d25cc13d831c9e0874
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 int el2_probe(struct net_device *dev);
64 static int el2_pio_probe(struct net_device *dev);
65 static int el2_probe1(struct net_device *dev, int ioaddr);
67 /* A zero-terminated list of I/O addresses to be probed in PIO mode. */
68 static unsigned int netcard_portlist[] __initdata =
69 { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
71 #define EL2_IO_EXTENT 16
73 static int el2_open(struct net_device *dev);
74 static int el2_close(struct net_device *dev);
75 static void el2_reset_8390(struct net_device *dev);
76 static void el2_init_card(struct net_device *dev);
77 static void el2_block_output(struct net_device *dev, int count,
78 const unsigned char *buf, int start_page);
79 static void el2_block_input(struct net_device *dev, int count, struct sk_buff *skb,
80 int ring_offset);
81 static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
82 int ring_page);
83 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
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 SET_MODULE_OWNER(dev);
101 if (base_addr > 0x1ff) /* Check a single specified location. */
102 return el2_probe1(dev, base_addr);
103 else if (base_addr != 0) /* Don't probe at all. */
104 return -ENXIO;
106 for (addr = addrs; *addr; addr++) {
107 int i;
108 unsigned int base_bits = isa_readb(*addr);
109 /* Find first set bit. */
110 for(i = 7; i >= 0; i--, base_bits >>= 1)
111 if (base_bits & 0x1)
112 break;
113 if (base_bits != 1)
114 continue;
115 if (el2_probe1(dev, netcard_portlist[i]) == 0)
116 return 0;
118 #if ! defined(no_probe_nonshared_memory)
119 return el2_pio_probe(dev);
120 #else
121 return -ENODEV;
122 #endif
125 /* Try all of the locations that aren't obviously empty. This touches
126 a lot of locations, and is much riskier than the code above. */
127 static int __init
128 el2_pio_probe(struct net_device *dev)
130 int i;
131 int base_addr = dev ? dev->base_addr : 0;
133 if (base_addr > 0x1ff) /* Check a single specified location. */
134 return el2_probe1(dev, base_addr);
135 else if (base_addr != 0) /* Don't probe at all. */
136 return -ENXIO;
138 for (i = 0; netcard_portlist[i]; i++)
139 if (el2_probe1(dev, netcard_portlist[i]) == 0)
140 return 0;
142 return -ENODEV;
145 /* Probe for the Etherlink II card at I/O port base IOADDR,
146 returning non-zero on success. If found, set the station
147 address and memory parameters in DEVICE. */
148 static int __init
149 el2_probe1(struct net_device *dev, int ioaddr)
151 int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
152 static unsigned version_printed;
153 unsigned long vendor_id;
155 /* FIXME: code reads ioaddr + 0x400, we request ioaddr + 16 */
156 if (!request_region(ioaddr, EL2_IO_EXTENT, dev->name))
157 return -EBUSY;
159 /* Reset and/or avoid any lurking NE2000 */
160 if (inb(ioaddr + 0x408) == 0xff) {
161 mdelay(1);
162 retval = -ENODEV;
163 goto out;
166 /* We verify that it's a 3C503 board by checking the first three octets
167 of its ethernet address. */
168 iobase_reg = inb(ioaddr+0x403);
169 membase_reg = inb(ioaddr+0x404);
170 /* ASIC location registers should be 0 or have only a single bit set. */
171 if ( (iobase_reg & (iobase_reg - 1))
172 || (membase_reg & (membase_reg - 1))) {
173 retval = -ENODEV;
174 goto out;
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 retval = -ENODEV;
187 goto out;
190 if (ei_debug && version_printed++ == 0)
191 printk(version);
193 dev->base_addr = ioaddr;
194 /* Allocate dev->priv and fill in 8390 specific dev fields. */
195 if (ethdev_init(dev)) {
196 printk ("3c503: unable to allocate memory for dev->priv.\n");
197 retval = -ENOMEM;
198 goto out;
201 printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
203 /* Retrieve and print the ethernet address. */
204 for (i = 0; i < 6; i++)
205 printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
207 /* Map the 8390 back into the window. */
208 outb(ECNTRL_THIN, ioaddr + 0x406);
210 /* Check for EL2/16 as described in tech. man. */
211 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
212 outb_p(0, ioaddr + EN0_DCFG);
213 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
214 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
215 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
217 /* Probe for, turn on and clear the board's shared memory. */
218 if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
219 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
221 /* This should be probed for (or set via an ioctl()) at run-time.
222 Right now we use a sleazy hack to pass in the interface number
223 at boot-time via the low bits of the mem_end field. That value is
224 unused, and the low bits would be discarded even if it was used. */
225 #if defined(EI8390_THICK) || defined(EL2_AUI)
226 ei_status.interface_num = 1;
227 #else
228 ei_status.interface_num = dev->mem_end & 0xf;
229 #endif
230 printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
232 if ((membase_reg & 0xf0) == 0) {
233 dev->mem_start = 0;
234 ei_status.name = "3c503-PIO";
235 } else {
236 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
237 ((membase_reg & 0xA0) ? 0x4000 : 0);
239 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
240 #ifdef EL2MEMTEST
241 /* This has never found an error, but someone might care.
242 Note that it only tests the 2nd 8kB on 16kB 3c503/16
243 cards between card addr. 0x2000 and 0x3fff. */
244 { /* Check the card's memory. */
245 unsigned long mem_base = dev->mem_start;
246 unsigned int test_val = 0xbbadf00d;
247 isa_writel(0xba5eba5e, mem_base);
248 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
249 isa_writel(test_val, mem_base + i);
250 if (isa_readl(mem_base) != 0xba5eba5e
251 || isa_readl(mem_base + i) != test_val) {
252 printk("3c503: memory failure or memory address conflict.\n");
253 dev->mem_start = 0;
254 ei_status.name = "3c503-PIO";
255 break;
257 test_val += 0x55555555;
258 isa_writel(0, mem_base + i);
261 #endif /* EL2MEMTEST */
263 if (dev->mem_start)
264 dev->mem_end = ei_status.rmem_end = dev->mem_start + EL2_MEMSIZE;
266 if (wordlength) { /* No Tx pages to skip over to get to Rx */
267 ei_status.rmem_start = dev->mem_start;
268 ei_status.name = "3c503/16";
269 } else {
270 ei_status.rmem_start = TX_PAGES*256 + dev->mem_start;
271 ei_status.name = "3c503";
276 Divide up the memory on the card. This is the same regardless of
277 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
278 we use the entire 8k of bank1 for an Rx ring. We only use 3k
279 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
280 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
281 5kB for an Rx ring. */
283 if (wordlength) {
284 ei_status.tx_start_page = EL2_MB0_START_PG;
285 ei_status.rx_start_page = EL2_MB1_START_PG;
286 } else {
287 ei_status.tx_start_page = EL2_MB1_START_PG;
288 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
291 /* Finish setting the board's parameters. */
292 ei_status.stop_page = EL2_MB1_STOP_PG;
293 ei_status.word16 = wordlength;
294 ei_status.reset_8390 = &el2_reset_8390;
295 ei_status.get_8390_hdr = &el2_get_8390_hdr;
296 ei_status.block_input = &el2_block_input;
297 ei_status.block_output = &el2_block_output;
299 if (dev->irq == 2)
300 dev->irq = 9;
301 else if (dev->irq > 5 && dev->irq != 9) {
302 printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
303 dev->irq);
304 dev->irq = 0;
307 ei_status.saved_irq = dev->irq;
309 dev->open = &el2_open;
310 dev->stop = &el2_close;
311 dev->do_ioctl = &netdev_ioctl;
313 if (dev->mem_start)
314 printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
315 dev->name, ei_status.name, (wordlength+1)<<3,
316 dev->mem_start, dev->mem_end-1);
318 else
320 ei_status.tx_start_page = EL2_MB1_START_PG;
321 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
322 printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
323 dev->name, ei_status.name, (wordlength+1)<<3);
325 return 0;
326 out:
327 release_region(ioaddr, EL2_IO_EXTENT);
328 return retval;
331 static int
332 el2_open(struct net_device *dev)
334 int retval = -EAGAIN;
336 if (dev->irq < 2) {
337 int irqlist[] = {5, 9, 3, 4, 0};
338 int *irqp = irqlist;
340 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
341 do {
342 if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
343 /* Twinkle the interrupt, and check if it's seen. */
344 unsigned long cookie = probe_irq_on();
345 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
346 outb_p(0x00, E33G_IDCFR);
347 if (*irqp == probe_irq_off(cookie) /* It's a good IRQ line! */
348 && ((retval = request_irq(dev->irq = *irqp,
349 ei_interrupt, 0, dev->name, dev)) == 0))
350 break;
352 } while (*++irqp);
353 if (*irqp == 0) {
354 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
355 return retval;
357 } else {
358 if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
359 return retval;
363 el2_init_card(dev);
364 ei_open(dev);
365 return 0;
368 static int
369 el2_close(struct net_device *dev)
371 free_irq(dev->irq, dev);
372 dev->irq = ei_status.saved_irq;
373 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
375 ei_close(dev);
376 return 0;
379 /* This is called whenever we have a unrecoverable failure:
380 transmit timeout
381 Bad ring buffer packet header
383 static void
384 el2_reset_8390(struct net_device *dev)
386 if (ei_debug > 1) {
387 printk("%s: Resetting the 3c503 board...", dev->name);
388 printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
389 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
391 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
392 ei_status.txing = 0;
393 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
394 el2_init_card(dev);
395 if (ei_debug > 1) printk("done\n");
398 /* Initialize the 3c503 GA registers after a reset. */
399 static void
400 el2_init_card(struct net_device *dev)
402 /* Unmap the station PROM and select the DIX or BNC connector. */
403 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
405 /* Set ASIC copy of rx's first and last+1 buffer pages */
406 /* These must be the same as in the 8390. */
407 outb(ei_status.rx_start_page, E33G_STARTPG);
408 outb(ei_status.stop_page, E33G_STOPPG);
410 /* Point the vector pointer registers somewhere ?harmless?. */
411 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
412 outb(0xff, E33G_VP1);
413 outb(0x00, E33G_VP0);
414 /* Turn off all interrupts until we're opened. */
415 outb_p(0x00, dev->base_addr + EN0_IMR);
416 /* Enable IRQs iff started. */
417 outb(EGACFR_NORM, E33G_GACFR);
419 /* Set the interrupt line. */
420 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
421 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
422 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
423 outb_p(0x00, E33G_DMAAL);
424 return; /* We always succeed */
428 * Either use the shared memory (if enabled on the board) or put the packet
429 * out through the ASIC FIFO.
431 static void
432 el2_block_output(struct net_device *dev, int count,
433 const unsigned char *buf, int start_page)
435 unsigned short int *wrd;
436 int boguscount; /* timeout counter */
437 unsigned short word; /* temporary for better machine code */
439 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
440 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
441 else
442 outb(EGACFR_NORM, E33G_GACFR);
444 if (dev->mem_start) { /* Shared memory transfer */
445 unsigned long dest_addr = dev->mem_start +
446 ((start_page - ei_status.tx_start_page) << 8);
447 isa_memcpy_toio(dest_addr, buf, count);
448 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
449 return;
453 * No shared memory, put the packet out the other way.
454 * Set up then start the internal memory transfer to Tx Start Page
457 word = (unsigned short)start_page;
458 outb(word&0xFF, E33G_DMAAH);
459 outb(word>>8, E33G_DMAAL);
461 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
462 | ECNTRL_START, E33G_CNTRL);
465 * Here I am going to write data to the FIFO as quickly as possible.
466 * Note that E33G_FIFOH is defined incorrectly. It is really
467 * E33G_FIFOL, the lowest port address for both the byte and
468 * word write. Variable 'count' is NOT checked. Caller must supply a
469 * valid count. Note that I may write a harmless extra byte to the
470 * 8390 if the byte-count was not even.
472 wrd = (unsigned short int *) buf;
473 count = (count + 1) >> 1;
474 for(;;)
476 boguscount = 0x1000;
477 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
479 if(!boguscount--)
481 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
482 el2_reset_8390(dev);
483 goto blocked;
486 if(count > WRD_COUNT)
488 outsw(E33G_FIFOH, wrd, WRD_COUNT);
489 wrd += WRD_COUNT;
490 count -= WRD_COUNT;
492 else
494 outsw(E33G_FIFOH, wrd, count);
495 break;
498 blocked:;
499 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
500 return;
503 /* Read the 4 byte, page aligned 8390 specific header. */
504 static void
505 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
507 int boguscount;
508 unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
509 unsigned short word;
511 if (dev->mem_start) { /* Use the shared memory. */
512 isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
513 hdr->count = le16_to_cpu(hdr->count);
514 return;
518 * No shared memory, use programmed I/O.
521 word = (unsigned short)ring_page;
522 outb(word&0xFF, E33G_DMAAH);
523 outb(word>>8, E33G_DMAAL);
525 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
526 | ECNTRL_START, E33G_CNTRL);
527 boguscount = 0x1000;
528 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
530 if(!boguscount--)
532 printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
533 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
534 el2_reset_8390(dev);
535 goto blocked;
538 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
539 blocked:;
540 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
544 static void
545 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
547 int boguscount = 0;
548 unsigned short int *buf;
549 unsigned short word;
551 int end_of_ring = ei_status.rmem_end;
553 /* Maybe enable shared memory just be to be safe... nahh.*/
554 if (dev->mem_start) { /* Use the shared memory. */
555 ring_offset -= (EL2_MB1_START_PG<<8);
556 if (dev->mem_start + ring_offset + count > end_of_ring) {
557 /* We must wrap the input move. */
558 int semi_count = end_of_ring - (dev->mem_start + ring_offset);
559 isa_memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
560 count -= semi_count;
561 isa_memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, count);
562 } else {
563 /* Packet is in one chunk -- we can copy + cksum. */
564 isa_eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
566 return;
570 * No shared memory, use programmed I/O.
572 word = (unsigned short) ring_offset;
573 outb(word>>8, E33G_DMAAH);
574 outb(word&0xFF, E33G_DMAAL);
576 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
577 | ECNTRL_START, E33G_CNTRL);
580 * Here I also try to get data as fast as possible. I am betting that I
581 * can read one extra byte without clobbering anything in the kernel because
582 * this would only occur on an odd byte-count and allocation of skb->data
583 * is word-aligned. Variable 'count' is NOT checked. Caller must check
584 * for a valid count.
585 * [This is currently quite safe.... but if one day the 3c503 explodes
586 * you know where to come looking ;)]
589 buf = (unsigned short int *) skb->data;
590 count = (count + 1) >> 1;
591 for(;;)
593 boguscount = 0x1000;
594 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
596 if(!boguscount--)
598 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
599 el2_reset_8390(dev);
600 goto blocked;
603 if(count > WRD_COUNT)
605 insw(E33G_FIFOH, buf, WRD_COUNT);
606 buf += WRD_COUNT;
607 count -= WRD_COUNT;
609 else
611 insw(E33G_FIFOH, buf, count);
612 break;
615 blocked:;
616 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
617 return;
621 * netdev_ethtool_ioctl: Handle network interface SIOCETHTOOL ioctls
622 * @dev: network interface on which out-of-band action is to be performed
623 * @useraddr: userspace address to which data is to be read and returned
625 * Process the various commands of the SIOCETHTOOL interface.
628 static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
630 u32 ethcmd;
632 /* dev_ioctl() in ../../net/core/dev.c has already checked
633 capable(CAP_NET_ADMIN), so don't bother with that here. */
635 if (get_user(ethcmd, (u32 *)useraddr))
636 return -EFAULT;
638 switch (ethcmd) {
640 case ETHTOOL_GDRVINFO: {
641 struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
642 strcpy (info.driver, DRV_NAME);
643 strcpy (info.version, DRV_VERSION);
644 sprintf(info.bus_info, "ISA 0x%lx", dev->base_addr);
645 if (copy_to_user (useraddr, &info, sizeof (info)))
646 return -EFAULT;
647 return 0;
650 default:
651 break;
654 return -EOPNOTSUPP;
658 * netdev_ioctl: Handle network interface ioctls
659 * @dev: network interface on which out-of-band action is to be performed
660 * @rq: user request data
661 * @cmd: command issued by user
663 * Process the various out-of-band ioctls passed to this driver.
666 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
668 int rc = 0;
670 switch (cmd) {
671 case SIOCETHTOOL:
672 rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
673 break;
675 default:
676 rc = -EOPNOTSUPP;
677 break;
680 return rc;
684 #ifdef MODULE
685 #define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
687 static struct net_device dev_el2[MAX_EL2_CARDS];
688 static int io[MAX_EL2_CARDS];
689 static int irq[MAX_EL2_CARDS];
690 static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
691 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
692 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
693 MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
694 MODULE_PARM_DESC(io, "I/O base address(es)");
695 MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
696 MODULE_PARM_DESC(xcvr, "transceiver(s) (0=internal, 1=external)");
697 MODULE_DESCRIPTION("3Com ISA EtherLink II, II/16 (3c503, 3c503/16) driver");
698 MODULE_LICENSE("GPL");
700 /* This is set up so that only a single autoprobe takes place per call.
701 ISA device autoprobes on a running machine are not recommended. */
703 init_module(void)
705 int this_dev, found = 0;
707 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
708 struct net_device *dev = &dev_el2[this_dev];
709 dev->irq = irq[this_dev];
710 dev->base_addr = io[this_dev];
711 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
712 dev->init = el2_probe;
713 if (io[this_dev] == 0) {
714 if (this_dev != 0) break; /* only autoprobe 1st one */
715 printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
717 if (register_netdev(dev) != 0) {
718 printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
719 if (found != 0) { /* Got at least one. */
720 return 0;
722 return -ENXIO;
724 found++;
726 return 0;
729 void
730 cleanup_module(void)
732 int this_dev;
734 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
735 struct net_device *dev = &dev_el2[this_dev];
736 if (dev->priv != NULL) {
737 void *priv = dev->priv;
738 /* NB: el2_close() handles free_irq */
739 release_region(dev->base_addr, EL2_IO_EXTENT);
740 unregister_netdev(dev);
741 kfree(priv);
745 #endif /* MODULE */
749 * Local variables:
750 * version-control: t
751 * kept-new-versions: 5
752 * c-indent-level: 4
753 * End: