root/drivers/net/3c503.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. el2_probe
  2. el2_pio_probe
  3. el2_probe1
  4. el2_open
  5. el2_close
  6. el2_reset_8390
  7. el2_init_card
  8. el2_block_output
  9. el2_get_8390_hdr
  10. el2_block_input
  11. init_module
  12. cleanup_module

   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 
  29 */
  30 
  31 static const char *version =
  32     "3c503.c:v1.10 9/23/93  Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
  33 
  34 #include <linux/module.h>
  35 
  36 #include <linux/kernel.h>
  37 #include <linux/sched.h>
  38 #include <linux/errno.h>
  39 #include <linux/string.h>
  40 #include <linux/delay.h>
  41 #include <linux/netdevice.h>
  42 #include <linux/etherdevice.h>
  43 
  44 #include <asm/io.h>
  45 #include <asm/system.h>
  46 
  47 #include "8390.h"
  48 #include "3c503.h"
  49 
  50 
  51 int el2_probe(struct device *dev);
  52 int el2_pio_probe(struct device *dev);
  53 int el2_probe1(struct device *dev, int ioaddr);
  54 
  55 /* A zero-terminated list of I/O addresses to be probed in PIO mode. */
  56 static unsigned int netcard_portlist[] =
  57         { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
  58 
  59 #define EL2_IO_EXTENT   16
  60 
  61 #ifdef HAVE_DEVLIST
  62 /* The 3c503 uses two entries, one for the safe memory-mapped probe and
  63    the other for the typical I/O probe. */
  64 struct netdev_entry el2_drv =
  65 {"3c503", el2_probe, EL1_IO_EXTENT, 0};
  66 struct netdev_entry el2pio_drv =
  67 {"3c503pio", el2_pioprobe1, EL1_IO_EXTENT, netcard_portlist};
  68 #endif
  69 
  70 static int el2_open(struct device *dev);
  71 static int el2_close(struct device *dev);
  72 static void el2_reset_8390(struct device *dev);
  73 static void el2_init_card(struct device *dev);
  74 static void el2_block_output(struct device *dev, int count,
  75                              const unsigned char *buf, const start_page);
  76 static void el2_block_input(struct device *dev, int count, struct sk_buff *skb,
  77                            int ring_offset);
  78 static void el2_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr,
  79                          int ring_page);
  80 
  81 
  82 /* This routine probes for a memory-mapped 3c503 board by looking for
  83    the "location register" at the end of the jumpered boot PROM space.
  84    This works even if a PROM isn't there.
  85 
  86    If the ethercard isn't found there is an optional probe for
  87    ethercard jumpered to programmed-I/O mode.
  88    */
  89 int
  90 el2_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  91 {
  92     int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
  93     int base_addr = dev->base_addr;
  94 
  95     if (base_addr > 0x1ff)      /* Check a single specified location. */
  96         return el2_probe1(dev, base_addr);
  97     else if (base_addr != 0)            /* Don't probe at all. */
  98         return ENXIO;
  99 
 100     for (addr = addrs; *addr; addr++) {
 101         int i;
 102         unsigned int base_bits = readb(*addr);
 103         /* Find first set bit. */
 104         for(i = 7; i >= 0; i--, base_bits >>= 1)
 105             if (base_bits & 0x1)
 106                 break;
 107         if (base_bits != 1)
 108             continue;
 109         if (check_region(netcard_portlist[i], EL2_IO_EXTENT))
 110             continue;
 111         if (el2_probe1(dev, netcard_portlist[i]) == 0)
 112             return 0;
 113     }
 114 #if ! defined(no_probe_nonshared_memory) && ! defined (HAVE_DEVLIST)
 115     return el2_pio_probe(dev);
 116 #else
 117     return ENODEV;
 118 #endif
 119 }
 120 
 121 #ifndef HAVE_DEVLIST
 122 /*  Try all of the locations that aren't obviously empty.  This touches
 123     a lot of locations, and is much riskier than the code above. */
 124 int
 125 el2_pio_probe(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 126 {
 127     int i;
 128     int base_addr = dev ? dev->base_addr : 0;
 129 
 130     if (base_addr > 0x1ff)      /* Check a single specified location. */
 131         return el2_probe1(dev, base_addr);
 132     else if (base_addr != 0)    /* Don't probe at all. */
 133         return ENXIO;
 134 
 135     for (i = 0; netcard_portlist[i]; i++) {
 136         int ioaddr = netcard_portlist[i];
 137         if (check_region(ioaddr, EL2_IO_EXTENT))
 138             continue;
 139         if (el2_probe1(dev, ioaddr) == 0)
 140             return 0;
 141     }
 142 
 143     return ENODEV;
 144 }
 145 #endif
 146 
 147 /* Probe for the Etherlink II card at I/O port base IOADDR,
 148    returning non-zero on success.  If found, set the station
 149    address and memory parameters in DEVICE. */
 150 int
 151 el2_probe1(struct device *dev, int ioaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 152 {
 153     int i, iobase_reg, membase_reg, saved_406, wordlength;
 154     static unsigned version_printed = 0;
 155     unsigned long vendor_id;
 156 
 157     /* Reset and/or avoid any lurking NE2000 */
 158     if (inb(ioaddr + 0x408) == 0xff) {
 159         udelay(1000);
 160         return ENODEV;
 161     }
 162 
 163     /* We verify that it's a 3C503 board by checking the first three octets
 164        of its ethernet address. */
 165     iobase_reg = inb(ioaddr+0x403);
 166     membase_reg = inb(ioaddr+0x404);
 167     /* ASIC location registers should be 0 or have only a single bit set. */
 168     if (   (iobase_reg  & (iobase_reg - 1))
 169         || (membase_reg & (membase_reg - 1))) {
 170         return ENODEV;
 171     }
 172     saved_406 = inb_p(ioaddr + 0x406);
 173     outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
 174     outb_p(ECNTRL_THIN, ioaddr + 0x406);
 175     /* Map the station addr PROM into the lower I/O ports. We now check
 176        for both the old and new 3Com prefix */
 177     outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
 178     vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
 179     if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
 180         /* Restore the register we frobbed. */
 181         outb(saved_406, ioaddr + 0x406);
 182         return ENODEV;
 183     }
 184 
 185     if (dev == NULL)
 186         dev = init_etherdev(0, sizeof(struct ei_device));
 187 
 188     if (ei_debug  &&  version_printed++ == 0)
 189         printk(version);
 190 
 191     dev->base_addr = ioaddr;
 192     ethdev_init(dev);
 193 
 194     printk("%s: 3c503 at i/o base %#3x, node address", dev->name, ioaddr);
 195 
 196     /* Retrieve and print the ethernet address. */
 197     for (i = 0; i < 6; i++)
 198         printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
 199 
 200     /* Map the 8390 back into the window. */
 201     outb(ECNTRL_THIN, ioaddr + 0x406);
 202 
 203     /* Check for EL2/16 as described in tech. man. */
 204     outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
 205     outb_p(0, ioaddr + EN0_DCFG);
 206     outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
 207     wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
 208     outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
 209 
 210     /* Probe for, turn on and clear the board's shared memory. */
 211     if (ei_debug > 2) printk(" memory jumpers %2.2x ", membase_reg);
 212     outb(EGACFR_NORM, ioaddr + 0x405);  /* Enable RAM */
 213 
 214     /* This should be probed for (or set via an ioctl()) at run-time.
 215        Right now we use a sleazy hack to pass in the interface number
 216        at boot-time via the low bits of the mem_end field.  That value is
 217        unused, and the low bits would be discarded even if it was used. */
 218 #if defined(EI8390_THICK) || defined(EL2_AUI)
 219     ei_status.interface_num = 1;
 220 #else
 221     ei_status.interface_num = dev->mem_end & 0xf;
 222 #endif
 223 
 224     if ((membase_reg & 0xf0) == 0) {
 225         dev->mem_start = 0;
 226         ei_status.name = "3c503-PIO";
 227     } else {
 228         dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
 229             ((membase_reg & 0xA0) ? 0x4000 : 0);
 230 
 231 #define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
 232 #ifdef EL2MEMTEST
 233         /* This has never found an error, but someone might care.
 234            Note that it only tests the 2nd 8kB on 16kB 3c503/16
 235            cards between card addr. 0x2000 and 0x3fff. */
 236         {                       /* Check the card's memory. */
 237             unsigned long mem_base = dev->mem_start;
 238             unsigned int test_val = 0xbbadf00d;
 239             writel(0xba5eba5e, mem_base);
 240             for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
 241                 writel(test_val, mem_base + i);
 242                 if (readl(mem_base) != 0xba5eba5e
 243                     || readl(mem_base + i) != test_val) {
 244                     printk(" memory failure or memory address conflict.\n");
 245                     dev->mem_start = 0;
 246                     ei_status.name = "3c503-PIO";
 247                     break;
 248                 }
 249                 test_val += 0x55555555;
 250                 writel(0, mem_base + i);
 251             }
 252         }
 253 #endif  /* EL2MEMTEST */
 254 
 255         dev->mem_end = dev->rmem_end = dev->mem_start + EL2_MEMSIZE;
 256 
 257         if (wordlength) {       /* No Tx pages to skip over to get to Rx */
 258                 dev->rmem_start = dev->mem_start;
 259                 ei_status.name = "3c503/16";
 260         } else {
 261                 dev->rmem_start = TX_PAGES*256 + dev->mem_start;
 262                 ei_status.name = "3c503";
 263         }
 264     }
 265 
 266     /*
 267         Divide up the memory on the card. This is the same regardless of
 268         whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
 269         we use the entire 8k of bank1 for an Rx ring. We only use 3k 
 270         of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
 271         (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining 
 272         5kB for an Rx ring.  */
 273 
 274     if (wordlength) {
 275         ei_status.tx_start_page = EL2_MB0_START_PG;
 276         ei_status.rx_start_page = EL2_MB1_START_PG;
 277     } else {
 278         ei_status.tx_start_page = EL2_MB1_START_PG;
 279         ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
 280     }
 281 
 282     /* Finish setting the board's parameters. */
 283     ei_status.stop_page = EL2_MB1_STOP_PG;
 284     ei_status.word16 = wordlength;
 285     ei_status.reset_8390 = &el2_reset_8390;
 286     ei_status.get_8390_hdr = &el2_get_8390_hdr;
 287     ei_status.block_input = &el2_block_input;
 288     ei_status.block_output = &el2_block_output;
 289 
 290     request_region(ioaddr, EL2_IO_EXTENT, ei_status.name);
 291 
 292     if (dev->irq == 2)
 293         dev->irq = 9;
 294     else if (dev->irq > 5 && dev->irq != 9) {
 295         printk("\n3c503: configured interrupt %d invalid, will use autoIRQ.\n",
 296                dev->irq);
 297         dev->irq = 0;
 298     }
 299 
 300     ei_status.saved_irq = dev->irq;
 301 
 302     dev->start = 0;
 303     dev->open = &el2_open;
 304     dev->stop = &el2_close;
 305 
 306     if (dev->mem_start)
 307         printk("\n%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
 308                 dev->name, ei_status.name, (wordlength+1)<<3,
 309                 dev->mem_start, dev->mem_end-1);
 310 
 311     else
 312         printk("\n%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
 313                dev->name, ei_status.name, (wordlength+1)<<3);
 314 
 315     return 0;
 316 }
 317 
 318 static int
 319 el2_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 320 {
 321 
 322     if (dev->irq < 2) {
 323         int irqlist[] = {5, 9, 3, 4, 0};
 324         int *irqp = irqlist;
 325 
 326         outb(EGACFR_NORM, E33G_GACFR);  /* Enable RAM and interrupts. */
 327         do {
 328             if (request_irq (*irqp, NULL, 0, "bogus") != -EBUSY) {
 329                 /* Twinkle the interrupt, and check if it's seen. */
 330                 autoirq_setup(0);
 331                 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
 332                 outb_p(0x00, E33G_IDCFR);
 333                 if (*irqp == autoirq_report(0)   /* It's a good IRQ line! */
 334                     && request_irq (dev->irq = *irqp, &ei_interrupt, 0, ei_status.name) == 0)
 335                     break;
 336             }
 337         } while (*++irqp);
 338         if (*irqp == 0) {
 339             outb(EGACFR_IRQOFF, E33G_GACFR);    /* disable interrupts. */
 340             return -EAGAIN;
 341         }
 342     } else {
 343         if (request_irq(dev->irq, &ei_interrupt, 0, ei_status.name)) {
 344             return -EAGAIN;
 345         }
 346     }
 347     el2_init_card(dev);
 348     return ei_open(dev);
 349 }
 350 
 351 static int
 352 el2_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 353 {
 354     free_irq(dev->irq);
 355     dev->irq = ei_status.saved_irq;
 356     irq2dev_map[dev->irq] = NULL;
 357     outb(EGACFR_IRQOFF, E33G_GACFR);    /* disable interrupts. */
 358 
 359     NS8390_init(dev, 0);
 360     dev->start = 0;
 361 
 362     return 0;
 363 }
 364 
 365 /* This is called whenever we have a unrecoverable failure:
 366        transmit timeout
 367        Bad ring buffer packet header
 368  */
 369 static void
 370 el2_reset_8390(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 371 {
 372     if (ei_debug > 1) {
 373         printk("%s: Resetting the 3c503 board...", dev->name);
 374         printk("%#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
 375                E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
 376     }
 377     outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
 378     ei_status.txing = 0;
 379     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
 380     el2_init_card(dev);
 381     if (ei_debug > 1) printk("done\n");
 382 }
 383 
 384 /* Initialize the 3c503 GA registers after a reset. */
 385 static void
 386 el2_init_card(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 387 {
 388     /* Unmap the station PROM and select the DIX or BNC connector. */
 389     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
 390 
 391     /* Set ASIC copy of rx's first and last+1 buffer pages */
 392     /* These must be the same as in the 8390. */
 393     outb(ei_status.rx_start_page, E33G_STARTPG);
 394     outb(ei_status.stop_page,  E33G_STOPPG);
 395 
 396     /* Point the vector pointer registers somewhere ?harmless?. */
 397     outb(0xff, E33G_VP2);       /* Point at the ROM restart location 0xffff0 */
 398     outb(0xff, E33G_VP1);
 399     outb(0x00, E33G_VP0);
 400     /* Turn off all interrupts until we're opened. */
 401     outb_p(0x00,  dev->base_addr + EN0_IMR);
 402     /* Enable IRQs iff started. */
 403     outb(EGACFR_NORM, E33G_GACFR);
 404 
 405     /* Set the interrupt line. */
 406     outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
 407     outb_p(8, E33G_DRQCNT);             /* Set burst size to 8 */
 408     outb_p(0x20, E33G_DMAAH);   /* Put a valid addr in the GA DMA */
 409     outb_p(0x00, E33G_DMAAL);
 410     return;                     /* We always succeed */
 411 }
 412 
 413 /* Either use the shared memory (if enabled on the board) or put the packet
 414    out through the ASIC FIFO.  The latter is probably much slower. */
 415 static void
 416 el2_block_output(struct device *dev, int count,
     /* [previous][next][first][last][top][bottom][index][help] */
 417                  const unsigned char *buf, const start_page)
 418 {
 419     int i;                              /* Buffer index */
 420     int boguscount = 0;         /* timeout counter */
 421 
 422     if (ei_status.word16)      /* Tx packets go into bank 0 on EL2/16 card */
 423         outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
 424     else 
 425         outb(EGACFR_NORM, E33G_GACFR);
 426 
 427     if (dev->mem_start) {       /* Shared memory transfer */
 428         unsigned long dest_addr = dev->mem_start +
 429             ((start_page - ei_status.tx_start_page) << 8);
 430         memcpy_toio(dest_addr, buf, count);
 431         outb(EGACFR_NORM, E33G_GACFR);  /* Back to bank1 in case on bank0 */
 432         return;
 433     }
 434     /* No shared memory, put the packet out the slow way. */
 435     /* Set up then start the internal memory transfer to Tx Start Page */
 436     outb(0x00, E33G_DMAAL);
 437     outb_p(start_page, E33G_DMAAH);
 438     outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
 439            | ECNTRL_START, E33G_CNTRL);
 440 
 441     /* This is the byte copy loop: it should probably be tuned for
 442        speed once everything is working.  I think it is possible
 443        to output 8 bytes between each check of the status bit. */
 444     for(i = 0; i < count; i++) {
 445         if (i % 8 == 0)
 446             while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
 447                 if (++boguscount > (i<<3) + 32) {
 448                     printk("%s: FIFO blocked in el2_block_output (at %d of %d, bc=%d).\n",
 449                            dev->name, i, count, boguscount);
 450                     outb(EGACFR_NORM, E33G_GACFR);      /* To MB1 for EL2/16 */
 451                     return;
 452                 }
 453         outb(buf[i], E33G_FIFOH);
 454     }
 455     outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
 456     outb(EGACFR_NORM, E33G_GACFR);      /* Back to bank1 in case on bank0 */
 457     return;
 458 }
 459 
 460 /* Read the 4 byte, page aligned 8390 specific header. */
 461 static void
 462 el2_get_8390_hdr(struct device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
     /* [previous][next][first][last][top][bottom][index][help] */
 463 {
 464     unsigned int i;
 465     unsigned long hdr_start = dev->mem_start + ((ring_page - EL2_MB1_START_PG)<<8);
 466 
 467     if (dev->mem_start) {       /* Use the shared memory. */
 468         memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
 469         return;
 470     }
 471 
 472     /* No shared memory, use programmed I/O. Ugh. */
 473     outb(0, E33G_DMAAL);
 474     outb_p(ring_page & 0xff, E33G_DMAAH);
 475     outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
 476            | ECNTRL_START, E33G_CNTRL);
 477 
 478     /* Header is less than 8 bytes, so we can ignore the FIFO. */
 479     for(i = 0; i < sizeof(struct e8390_pkt_hdr); i++)
 480         ((char *)(hdr))[i] = inb_p(E33G_FIFOH);
 481 
 482     outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
 483 }
 484 
 485 /* Returns the new ring pointer. */
 486 static void
 487 el2_block_input(struct device *dev, int count, struct sk_buff *skb, int ring_offset)
     /* [previous][next][first][last][top][bottom][index][help] */
 488 {
 489     int boguscount = 0;
 490     int end_of_ring = dev->rmem_end;
 491     unsigned int i;
 492 
 493     /* Maybe enable shared memory just be to be safe... nahh.*/
 494     if (dev->mem_start) {       /* Use the shared memory. */
 495         ring_offset -= (EL2_MB1_START_PG<<8);
 496         if (dev->mem_start + ring_offset + count > end_of_ring) {
 497             /* We must wrap the input move. */
 498             int semi_count = end_of_ring - (dev->mem_start + ring_offset);
 499             memcpy_fromio(skb->data, dev->mem_start + ring_offset, semi_count);
 500             count -= semi_count;
 501             memcpy_fromio(skb->data + semi_count, dev->rmem_start, count);
 502         } else {
 503                 /* Packet is in one chunk -- we can copy + cksum. */
 504                 eth_io_copy_and_sum(skb, dev->mem_start + ring_offset, count, 0);
 505         }
 506         return;
 507     }
 508     /* No shared memory, use programmed I/O. */
 509     outb(ring_offset & 0xff, E33G_DMAAL);
 510     outb_p((ring_offset >> 8) & 0xff, E33G_DMAAH);
 511     outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
 512            | ECNTRL_START, E33G_CNTRL);
 513 
 514     /* This is the byte copy loop: it should probably be tuned for
 515        speed once everything is working. */
 516     for(i = 0; i < count; i++) {
 517         if (i % 8 == 0)
 518             while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
 519                 if (++boguscount > (i<<3) + 32) {
 520                     printk("%s: FIFO blocked in el2_block_input() (at %d of %d, bc=%d).\n",
 521                            dev->name, i, count, boguscount);
 522                     boguscount = 0;
 523                     break;
 524                 }
 525         (skb->data)[i] = inb_p(E33G_FIFOH);
 526     }
 527     outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
 528 }
 529 #ifdef MODULE
 530 static struct device el2_drv =
 531 {"3c503", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, el2_probe };
 532        
 533 static struct device el2pio_drv =
 534 {"3c503pio", 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, el2_pio_probe };
 535 
 536 static int io = 0x300;
 537 static int irq = 0;
 538 
 539 static int no_pio = 1;
 540 int init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 541 {
 542         int rc1, rc2;
 543         el2_drv.base_addr = io;
 544         el2_drv.irq       = irq;
 545         el2pio_drv.base_addr = io;
 546         el2pio_drv.irq       = irq;
 547 
 548         if (io == 0)
 549             printk("3c503: You should not use auto-probing with insmod!\n");
 550 
 551         rc2 = 0;
 552         no_pio = 1;
 553         rc1 = register_netdev(&el2_drv);
 554         if (rc1 != 0) {
 555             rc2 = register_netdev(&el2pio_drv);
 556             no_pio = 0;
 557         }
 558 
 559         if (rc1 != 0 && rc2 != 0)
 560                 return -EIO;
 561         return 0;
 562 }
 563 
 564 void
 565 cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 566 {
 567         int ioaddr;
 568 
 569         if (no_pio) {
 570                 ioaddr = el2_drv.base_addr;
 571                 unregister_netdev(&el2_drv);
 572         } else {
 573                 ioaddr = el2pio_drv.base_addr;
 574                 unregister_netdev(&el2pio_drv);
 575         }
 576 
 577         /* If we don't do this, we can't re-insmod it later. */
 578         release_region(ioaddr, EL2_IO_EXTENT);
 579 }
 580 #endif /* MODULE */
 581 
 582 /*
 583  * Local variables:
 584  *  version-control: t
 585  *  kept-new-versions: 5
 586  *  c-indent-level: 4
 587  * End:
 588  */

/* [previous][next][first][last][top][bottom][index][help] */