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

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