~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/net/3c503.c

Version: ~ [ 2.2.5 ] ~ [ 2.4.1 ] ~ [ 2.4.9 ] ~ [ 2.6.17.10 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* 3c503.c: A shared-memory NS8390 ethernet driver for linux. */
  2 /*
  3     Written 1992-94 by Donald Becker.
  4 
  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.
  9 
 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
 13 
 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.
 17 
 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
 22 
 23     The Crynwr 3c503 packet driver.
 24 
 25     Changelog:
 26 
 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.
 30 
 31 */
 32 
 33 static const char *version =
 34     "3c503.c:v1.10 9/23/93  Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
 35 
 36 #include <linux/module.h>
 37 
 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>
 46 
 47 #include <asm/io.h>
 48 #include <asm/system.h>
 49 #include <asm/byteorder.h>
 50 
 51 #include "8390.h"
 52 #include "3c503.h"
 53 #define WRD_COUNT 4
 54 
 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);
 58 
 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};
 62 
 63 #define EL2_IO_EXTENT   16
 64 
 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);
 75 
 76 
 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.
 80 
 81    If the ethercard isn't found there is an optional probe for
 82    ethercard jumpered to programmed-I/O mode.
 83    */
 84 int __init 
 85 el2_probe(struct net_device *dev)
 86 {
 87     int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
 88     int base_addr = dev->base_addr;
 89 
 90     SET_MODULE_OWNER(dev);
 91     
 92     if (base_addr > 0x1ff)      /* Check a single specified location. */
 93         return el2_probe1(dev, base_addr);
 94     else if (base_addr != 0)            /* Don't probe at all. */
 95         return -ENXIO;
 96 
 97     for (addr = addrs; *addr; addr++) {
 98         int i;
 99         unsigned int base_bits = isa_readb(*addr);
100         /* Find first set bit. */
101         for(i = 7; i >= 0; i--, base_bits >>= 1)
102             if (base_bits & 0x1)
103                 break;
104         if (base_bits != 1)
105             continue;
106         if (el2_probe1(dev, netcard_portlist[i]) == 0)
107             return 0;
108     }
109 #if ! defined(no_probe_nonshared_memory)
110     return el2_pio_probe(dev);
111 #else
112     return -ENODEV;
113 #endif
114 }
115 
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)
120 {
121     int i;
122     int base_addr = dev ? dev->base_addr : 0;
123 
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;
128 
129     for (i = 0; netcard_portlist[i]; i++)
130         if (el2_probe1(dev, netcard_portlist[i]) == 0)
131             return 0;
132 
133     return -ENODEV;
134 }
135 
136 /* Probe for the Etherlink II card at I/O port base IOADDR,
137    returning non-zero on success.  If found, set the station
138    address and memory parameters in DEVICE. */
139 int __init 
140 el2_probe1(struct net_device *dev, int ioaddr)
141 {
142     int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
143     static unsigned version_printed;
144     unsigned long vendor_id;
145 
146     if (!request_region(ioaddr, EL2_IO_EXTENT, dev->name))
147         return -EBUSY;
148 
149     /* Reset and/or avoid any lurking NE2000 */
150     if (inb(ioaddr + 0x408) == 0xff) {
151         mdelay(1);
152         retval = -ENODEV;
153         goto out;
154     }
155 
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         retval = -ENODEV;
164         goto out;
165     }
166     saved_406 = inb_p(ioaddr + 0x406);
167     outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
168     outb_p(ECNTRL_THIN, ioaddr + 0x406);
169     /* Map the station addr PROM into the lower I/O ports. We now check
170        for both the old and new 3Com prefix */
171     outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
172     vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
173     if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
174         /* Restore the register we frobbed. */
175         outb(saved_406, ioaddr + 0x406);
176         retval = -ENODEV;
177         goto out;
178     }
179 
180     if (ei_debug  &&  version_printed++ == 0)
181         printk(version);
182 
183     dev->base_addr = ioaddr;
184     /* Allocate dev->priv and fill in 8390 specific dev fields. */
185     if (ethdev_init(dev)) {
186         printk ("3c503: unable to allocate memory for dev->priv.\n");
187         retval = -ENOMEM;
188         goto out;
189     }
190 
191     printk("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
192 
193     /* Retrieve and print the ethernet address. */
194     for (i = 0; i < 6; i++)
195         printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
196 
197     /* Map the 8390 back into the window. */
198     outb(ECNTRL_THIN, ioaddr + 0x406);
199 
200     /* Check for EL2/16 as described in tech. man. */
201     outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
202     outb_p(0, ioaddr + EN0_DCFG);
203     outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
204     wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
205     outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
206 
207     /* Probe for, turn on and clear the board's shared memory. */
208     if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
209     outb(EGACFR_NORM, ioaddr + 0x405);  /* Enable RAM */
210 
211     /* This should be probed for (or set via an ioctl()) at run-time.
212        Right now we use a sleazy hack to pass in the interface number
213        at boot-time via the low bits of the mem_end field.  That value is
214        unused, and the low bits would be discarded even if it was used. */
215 #if defined(EI8390_THICK) || defined(EL2_AUI)
216     ei_status.interface_num = 1;
217 #else
218     ei_status.interface_num = dev->mem_end & 0xf;
219 #endif
220     printk(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
221 
222     if ((membase_reg & 0xf0) == 0) {
223         dev->mem_start = 0;
224         ei_status.name = "3c503-PIO";
225     } else {
226         dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
227             ((membase_reg & 0xA0) ? 0x4000 : 0);
228 
229 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
230 #ifdef EL2MEMTEST
231         /* This has never found an error, but someone might care.
232            Note that it only tests the 2nd 8kB on 16kB 3c503/16
233            cards between card addr. 0x2000 and 0x3fff. */
234         {                       /* Check the card's memory. */
235             unsigned long mem_base = dev->mem_start;
236             unsigned int test_val = 0xbbadf00d;
237             isa_writel(0xba5eba5e, mem_base);
238             for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
239                 isa_writel(test_val, mem_base + i);
240                 if (isa_readl(mem_base) != 0xba5eba5e
241                     || isa_readl(mem_base + i) != test_val) {
242                     printk("3c503: memory failure or memory address conflict.\n");
243                     dev->mem_start = 0;
244                     ei_status.name = "3c503-PIO";
245                     break;
246                 }
247                 test_val += 0x55555555;
248                 isa_writel(0, mem_base + i);
249             }
250         }
251 #endif  /* EL2MEMTEST */
252 
253         dev->mem_end = dev->rmem_end = dev->mem_start + EL2_MEMSIZE;
254 
255         if (wordlength) {       /* No Tx pages to skip over to get to Rx */
256                 dev->rmem_start = dev->mem_start;
257                 ei_status.name = "3c503/16";
258         } else {
259                 dev->rmem_start = TX_PAGES*256 + dev->mem_start;
260                 ei_status.name = "3c503";
261         }
262     }
263 
264     /*
265         Divide up the memory on the card. This is the same regardless of
266         whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
267         we use the entire 8k of bank1 for an Rx ring. We only use 3k
268         of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
269         (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
270         5kB for an Rx ring.  */
271 
272     if (wordlength) {
273         ei_status.tx_start_page = EL2_MB0_START_PG;
274         ei_status.rx_start_page = EL2_MB1_START_PG;
275     } else {
276         ei_status.tx_start_page = EL2_MB1_START_PG;
277         ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
278     }
279 
280     /* Finish setting the board's parameters. */
281     ei_status.stop_page = EL2_MB1_STOP_PG;
282     ei_status.word16 = wordlength;
283     ei_status.reset_8390 = &el2_reset_8390;
284     ei_status.get_8390_hdr = &el2_get_8390_hdr;
285     ei_status.block_input = &el2_block_input;
286     ei_status.block_output = &el2_block_output;
287 
288     if (dev->irq == 2)
289         dev->irq = 9;
290     else if (dev->irq > 5 && dev->irq != 9) {
291         printk("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
292                dev->irq);
293         dev->irq = 0;
294     }
295 
296     ei_status.saved_irq = dev->irq;
297 
298     dev->open = &el2_open;
299     dev->stop = &el2_close;
300 
301     if (dev->mem_start)
302         printk("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
303                 dev->name, ei_status.name, (wordlength+1)<<3,
304                 dev->mem_start, dev->mem_end-1);
305 
306     else
307     {
308         ei_status.tx_start_page = EL2_MB1_START_PG;
309         ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
310         printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
311                dev->name, ei_status.name, (wordlength+1)<<3);
312     }
313     return 0;
314 out:
315     release_region(ioaddr, EL2_IO_EXTENT);
316     return retval;
317 }
318 
319 static int
320 el2_open(struct net_device *dev)
321 {
322     int retval = -EAGAIN;
323 
324     if (dev->irq < 2) {
325         int irqlist[] = {5, 9, 3, 4, 0};
326         int *irqp = irqlist;
327 
328         outb(EGACFR_NORM, E33G_GACFR);  /* Enable RAM and interrupts. */
329         do {
330             if (request_irq (*irqp, NULL, 0, "bogus", dev) != -EBUSY) {
331                 /* Twinkle the interrupt, and check if it's seen. */
332                 unsigned long cookie = probe_irq_on();
333                 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
334                 outb_p(0x00, E33G_IDCFR);
335                 if (*irqp == probe_irq_off(cookie)      /* It's a good IRQ line! */
336                     && ((retval = request_irq(dev->irq = *irqp, 
337                     ei_interrupt, 0, dev->name, dev)) == 0))
338                     break;
339             }
340         } while (*++irqp);
341         if (*irqp == 0) {
342             outb(EGACFR_IRQOFF, E33G_GACFR);    /* disable interrupts. */
343             return retval;
344         }
345     } else {
346         if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) {
347             return retval;
348         }
349     }
350 
351     el2_init_card(dev);
352     ei_open(dev);
353     return 0;
354 }
355 
356 static int
357 el2_close(struct net_device *dev)
358 {
359     free_irq(dev->irq, dev);
360     dev->irq = ei_status.saved_irq;
361     outb(EGACFR_IRQOFF, E33G_GACFR);    /* disable interrupts. */
362 
363     ei_close(dev);
364     return 0;
365 }
366 
367 /* This is called whenever we have a unrecoverable failure:
368        transmit timeout
369        Bad ring buffer packet header
370  */
371 static void
372 el2_reset_8390(struct net_device *dev)
373 {
374     if (ei_debug > 1) {
375         printk("%s: Resetting the 3c503 board...", dev->name);
376         printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
377                E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
378     }
379     outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
380     ei_status.txing = 0;
381     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
382     el2_init_card(dev);
383     if (ei_debug > 1) printk("done\n");
384 }
385 
386 /* Initialize the 3c503 GA registers after a reset. */
387 static void
388 el2_init_card(struct net_device *dev)
389 {
390     /* Unmap the station PROM and select the DIX or BNC connector. */
391     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
392 
393     /* Set ASIC copy of rx's first and last+1 buffer pages */
394     /* These must be the same as in the 8390. */
395     outb(ei_status.rx_start_page, E33G_STARTPG);
396     outb(ei_status.stop_page,  E33G_STOPPG);
397 
398     /* Point the vector pointer registers somewhere ?harmless?. */
399     outb(0xff, E33G_VP2);       /* Point at the ROM restart location 0xffff0 */
400     outb(0xff, E33G_VP1);
401     outb(0x00, E33G_VP0);
402     /* Turn off all interrupts until we're opened. */
403     outb_p(0x00,  dev->base_addr + EN0_IMR);
404     /* Enable IRQs iff started. */
405     outb(EGACFR_NORM, E33G_GACFR);
406 
407     /* Set the interrupt line. */
408     outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
409     outb_p((WRD_COUNT << 1), E33G_DRQCNT);      /* Set burst size to 8 */
410     outb_p(0x20, E33G_DMAAH);   /* Put a valid addr in the GA DMA */
411     outb_p(0x00, E33G_DMAAL);
412     return;                     /* We always succeed */
413 }
414 
415 /*
416  * Either use the shared memory (if enabled on the board) or put the packet
417  * out through the ASIC FIFO.
418  */
419 static void
420 el2_block_output(struct net_device *dev, int count,
421                  const unsigned char *buf, int start_page)
422 {
423     unsigned short int *wrd;
424     int boguscount;             /* timeout counter */
425     unsigned short word;        /* temporary for better machine code */
426 
427     if (ei_status.word16)      /* Tx packets go into bank 0 on EL2/16 card */
428         outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
429     else
430         outb(EGACFR_NORM, E33G_GACFR);
431 
432     if (dev->mem_start) {       /* Shared memory transfer */
433         unsigned long dest_addr = dev->mem_start +
434             ((start_page - ei_status.tx_start_page) << 8);
435         isa_memcpy_toio(dest_addr, buf, count);
436         outb(EGACFR_NORM, E33G_GACFR);  /* Back to bank1 in case on bank0 */
437         return;
438     }
439 
440 /*
441  *  No shared memory, put the packet out the other way.
442  *  Set up then start the internal memory transfer to Tx Start Page
443  */
444 
445     word = (unsigned short)start_page;
446     outb(word&0xFF, E33G_DMAAH);
447     outb(word>>8, E33G_DMAAL);
448 
449     outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
450            | ECNTRL_START, E33G_CNTRL);
451 
452 /*
453  *  Here I am going to write data to the FIFO as quickly as possible.
454  *  Note that E33G_FIFOH is defined incorrectly. It is really
455  *  E33G_FIFOL, the lowest port address for both the byte and
456  *  word write. Variable 'count' is NOT checked. Caller must supply a
457  *  valid count. Note that I may write a harmless extra byte to the
458  *  8390 if the byte-count was not even.
459  */
460     wrd = (unsigned short int *) buf;
461     count  = (count + 1) >> 1;
462     for(;;)
463     {
464         boguscount = 0x1000;
465         while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
466         {
467             if(!boguscount--)
468             {
469                 printk("%s: FIFO blocked in el2_block_output.\n", dev->name);
470                 el2_reset_8390(dev);
471                 goto blocked;
472             }
473         }
474         if(count > WRD_COUNT)
475         {
476             outsw(E33G_FIFOH, wrd, WRD_COUNT);
477             wrd   += WRD_COUNT;
478             count -= WRD_COUNT;
479         }
480         else
481         {
482             outsw(E33G_FIFOH, wrd, count);
483             break;
484         }
485     }
486     blocked:;
487     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
488     return;
489 }
490 
491 /* Read the 4 byte, page aligned 8390 specific header. */
492 static void
493 el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
494 {
495     int boguscount;
496     unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
497     unsigned short word;
498 
499     if (dev->mem_start) {       /* Use the shared memory. */
500         isa_memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
501         return;
502     }
503 
504 /*
505  *  No shared memory, use programmed I/O.
506  */
507 
508     word = (unsigned short)ring_page;
509     outb(word&0xFF, E33G_DMAAH);
510     outb(word>>8, E33G_DMAAL);
511 
512     outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
513            | ECNTRL_START, E33G_CNTRL);
514     boguscount = 0x1000;
515     while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
516     {
517         if(!boguscount--)
518         {
519             printk("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
520             memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
521             el2_reset_8390(dev);
522             goto blocked;
523         }
524     }
525     insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
526     blocked:;
527     outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
528 }
529 
530 
531 static void
532 el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
533 {
534     int boguscount = 0;
535     unsigned short int *buf;
536     unsigned short word;
537 
538     int end_of_ring = dev->rmem_end;
539 
540     /* Maybe enable shared memory just be to be safe... nahh.*/
541     if (dev->mem_start) {       /* Use the shared memory. */
542         ring_offset -= (EL2_MB1_START_PG<<8);
543         if (dev->mem_start + ring_offset + count > end_of_ring) {
544             /* We must wrap the input move. */
545             int semi_count = end_of_ring - (dev->mem_start + ring_offset);
546             isa_memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
547             count -= semi_count;
548             isa_memcpy_fromio(skb->data + semi_count, dev->rmem_start, count);
549         } else {
550                 /* Packet is in one chunk -- we can copy + cksum. */
551                 isa_eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
552         }
553         return;
554     }
555 
556 /*
557  *  No shared memory, use programmed I/O.
558  */
559     word = (unsigned short) ring_offset;
560     outb(word>>8, E33G_DMAAH);
561     outb(word&0xFF, E33G_DMAAL);
562 
563     outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
564            | ECNTRL_START, E33G_CNTRL);
565 
566 /*
567  *  Here I also try to get data as fast as possible. I am betting that I
568  *  can read one extra byte without clobbering anything in the kernel because
569  *  this would only occur on an odd byte-count and allocation of skb->data
570  *  is word-aligned. Variable 'count' is NOT checked. Caller must check
571  *  for a valid count.
572  *  [This is currently quite safe.... but if one day the 3c503 explodes
573  *   you know where to come looking ;)]
574  */
575 
576     buf =  (unsigned short int *) skb->data;
577     count =  (count + 1) >> 1;
578     for(;;)
579     {
580         boguscount = 0x1000;
581         while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
582         {
583             if(!boguscount--)
584             {
585                 printk("%s: FIFO blocked in el2_block_input.\n", dev->name);
586                 el2_reset_8390(dev);
587                 goto blocked;
588             }
589         }
590         if(count > WRD_COUNT)
591         {
592             insw(E33G_FIFOH, buf, WRD_COUNT);
593             buf   += WRD_COUNT;
594             count -= WRD_COUNT;
595         }
596         else
597         {
598             insw(E33G_FIFOH, buf, count);
599             break;
600         }
601     }
602     blocked:;
603     outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
604     return;
605 }
606 #ifdef MODULE
607 #define MAX_EL2_CARDS   4       /* Max number of EL2 cards per module */
608 
609 static struct net_device dev_el2[MAX_EL2_CARDS];
610 static int io[MAX_EL2_CARDS];
611 static int irq[MAX_EL2_CARDS];
612 static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
613 MODULE_PARM(io, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
614 MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
615 MODULE_PARM(xcvr, "1-" __MODULE_STRING(MAX_EL2_CARDS) "i");
616 
617 /* This is set up so that only a single autoprobe takes place per call.
618 ISA device autoprobes on a running machine are not recommended. */
619 int
620 init_module(void)
621 {
622         int this_dev, found = 0;
623 
624         for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
625                 struct net_device *dev = &dev_el2[this_dev];
626                 dev->irq = irq[this_dev];
627                 dev->base_addr = io[this_dev];
628                 dev->mem_end = xcvr[this_dev];  /* low 4bits = xcvr sel. */
629                 dev->init = el2_probe;
630                 if (io[this_dev] == 0)  {
631                         if (this_dev != 0) break; /* only autoprobe 1st one */
632                         printk(KERN_NOTICE "3c503.c: Presently autoprobing (not recommended) for a single card.\n");
633                 }
634                 if (register_netdev(dev) != 0) {
635                         printk(KERN_WARNING "3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
636                         if (found != 0) {       /* Got at least one. */
637                                 return 0;
638                         }
639                         return -ENXIO;
640                 }
641                 found++;
642         }
643         return 0;
644 }
645 
646 void
647 cleanup_module(void)
648 {
649         int this_dev;
650 
651         for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
652                 struct net_device *dev = &dev_el2[this_dev];
653                 if (dev->priv != NULL) {
654                         void *priv = dev->priv;
655                         /* NB: el2_close() handles free_irq */
656                         release_region(dev->base_addr, EL2_IO_EXTENT);
657                         unregister_netdev(dev);
658                         kfree(priv);
659                 }
660         }
661 }
662 #endif /* MODULE */
663 
664 /*
665  * Local variables:
666  *  version-control: t
667  *  kept-new-versions: 5
668  *  c-indent-level: 4
669  * End:
670  */
671 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.