Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

depca.c

Go to the documentation of this file.
00001 /*  depca.c: A DIGITAL DEPCA  & EtherWORKS ethernet driver for linux.
00002 
00003     Written 1994, 1995 by David C. Davies.
00004 
00005 
00006                       Copyright 1994 David C. Davies
00007                                    and 
00008                          United States Government
00009          (as represented by the Director, National Security Agency).  
00010 
00011                Copyright 1995  Digital Equipment Corporation.
00012 
00013 
00014     This software may be used and distributed according to the terms of
00015     the GNU Public License, incorporated herein by reference.
00016 
00017     This driver is written for the Digital Equipment Corporation series
00018     of DEPCA and EtherWORKS ethernet cards:
00019 
00020         DEPCA       (the original)
00021         DE100
00022         DE101
00023         DE200 Turbo
00024         DE201 Turbo
00025         DE202 Turbo (TP BNC)
00026         DE210
00027         DE422       (EISA)
00028 
00029     The  driver has been tested on DE100, DE200 and DE202 cards  in  a
00030     relatively busy network. The DE422 has been tested a little.
00031 
00032     This  driver will NOT work   for the DE203,  DE204  and DE205 series  of
00033     cards,  since they have  a  new custom ASIC in   place of the AMD  LANCE
00034     chip.  See the 'ewrk3.c'   driver in the  Linux  source tree for running
00035     those cards.
00036 
00037     I have benchmarked the driver with a  DE100 at 595kB/s to (542kB/s from)
00038     a DECstation 5000/200.
00039 
00040     The author may be reached at davies@maniac.ultranet.com
00041 
00042     =========================================================================
00043 
00044     The  driver was originally based  on   the 'lance.c' driver from  Donald
00045     Becker   which  is included with  the  standard  driver distribution for
00046     linux.  V0.4  is  a complete  re-write  with only  the kernel  interface
00047     remaining from the original code.
00048 
00049     1) Lance.c code in /linux/drivers/net/
00050     2) "Ethernet/IEEE 802.3 Family. 1992 World Network Data Book/Handbook",
00051        AMD, 1992 [(800) 222-9323].
00052     3) "Am79C90 CMOS Local Area Network Controller for Ethernet (C-LANCE)",
00053        AMD, Pub. #17881, May 1993.
00054     4) "Am79C960 PCnet-ISA(tm), Single-Chip Ethernet Controller for ISA",
00055        AMD, Pub. #16907, May 1992
00056     5) "DEC EtherWORKS LC Ethernet Controller Owners Manual",
00057        Digital Equipment corporation, 1990, Pub. #EK-DE100-OM.003
00058     6) "DEC EtherWORKS Turbo Ethernet Controller Owners Manual",
00059        Digital Equipment corporation, 1990, Pub. #EK-DE200-OM.003
00060     7) "DEPCA Hardware Reference Manual", Pub. #EK-DEPCA-PR
00061        Digital Equipment Corporation, 1989
00062     8) "DEC EtherWORKS Turbo_(TP BNC) Ethernet Controller Owners Manual",
00063        Digital Equipment corporation, 1991, Pub. #EK-DE202-OM.001
00064     
00065 
00066     Peter Bauer's depca.c (V0.5) was referred to when debugging V0.1 of this
00067     driver.
00068 
00069     The original DEPCA  card requires that the  ethernet ROM address counter
00070     be enabled to count and has an 8 bit NICSR.  The ROM counter enabling is
00071     only  done when a  0x08 is read as the  first address octet (to minimise
00072     the chances  of writing over some  other hardware's  I/O register).  The
00073     NICSR accesses   have been changed  to  byte accesses  for all the cards
00074     supported by this driver, since there is only one  useful bit in the MSB
00075     (remote boot timeout) and it  is not used.  Also, there  is a maximum of
00076     only 48kB network  RAM for this  card.  My thanks  to Torbjorn Lindh for
00077     help debugging all this (and holding my feet to  the fire until I got it
00078     right).
00079 
00080     The DE200  series  boards have  on-board 64kB  RAM for  use  as a shared
00081     memory network  buffer. Only the DE100  cards make use  of a  2kB buffer
00082     mode which has not  been implemented in  this driver (only the 32kB  and
00083     64kB modes are supported [16kB/48kB for the original DEPCA]).
00084 
00085     At the most only 2 DEPCA cards can  be supported on  the ISA bus because
00086     there is only provision  for two I/O base addresses  on each card (0x300
00087     and 0x200). The I/O address is detected by searching for a byte sequence
00088     in the Ethernet station address PROM at the expected I/O address for the
00089     Ethernet  PROM.   The shared memory  base   address  is 'autoprobed'  by
00090     looking  for the self  test PROM  and detecting the  card name.   When a
00091     second  DEPCA is  detected,  information  is   placed in the   base_addr
00092     variable of the  next device structure (which  is created if necessary),
00093     thus  enabling ethif_probe  initialization  for the device.  More than 2
00094     EISA cards can  be  supported, but  care will  be  needed assigning  the
00095     shared memory to ensure that each slot has the  correct IRQ, I/O address
00096     and shared memory address assigned.
00097 
00098     ************************************************************************
00099 
00100     NOTE: If you are using two  ISA DEPCAs, it is  important that you assign
00101     the base memory addresses correctly.   The  driver autoprobes I/O  0x300
00102     then 0x200.  The  base memory address for  the first device must be less
00103     than that of the second so that the auto probe will correctly assign the
00104     I/O and memory addresses on the same card.  I can't think of a way to do
00105     this unambiguously at the moment, since there is nothing on the cards to
00106     tie I/O and memory information together.
00107 
00108     I am unable  to  test  2 cards   together for now,    so this  code   is
00109     unchecked. All reports, good or bad, are welcome.
00110 
00111     ************************************************************************
00112 
00113     The board IRQ   setting must be  at an  unused IRQ which  is auto-probed
00114     using Donald Becker's autoprobe routines. DEPCA and DE100 board IRQs are
00115     {2,3,4,5,7}, whereas the  DE200 is at {5,9,10,11,15}.  Note that IRQ2 is
00116     really IRQ9 in machines with 16 IRQ lines.
00117 
00118     No 16MB memory  limitation should exist with this  driver as DMA is  not
00119     used and the common memory area is in low memory on the network card (my
00120     current system has 20MB and I've not had problems yet).
00121 
00122     The ability to load this driver as a loadable module has been added. To
00123     utilise this ability, you have to do <8 things:
00124 
00125     0) have a copy of the loadable modules code installed on your system.
00126     1) copy depca.c from the  /linux/drivers/net directory to your favourite
00127     temporary directory.
00128     2) if you wish, edit the  source code near  line 1530 to reflect the I/O
00129     address and IRQ you're using (see also 5).
00130     3) compile  depca.c, but include -DMODULE in  the command line to ensure
00131     that the correct bits are compiled (see end of source code).
00132     4) if you are wanting to add a new  card, goto 5. Otherwise, recompile a
00133     kernel with the depca configuration turned off and reboot.
00134     5) insmod depca.o [irq=7] [io=0x200] [mem=0xd0000] [adapter_name=DE100]
00135        [Alan Cox: Changed the code to allow command line irq/io assignments]
00136        [Dave Davies: Changed the code to allow command line mem/name
00137                                                                 assignments]
00138     6) run the net startup bits for your eth?? interface manually 
00139     (usually /etc/rc.inet[12] at boot time). 
00140     7) enjoy!
00141 
00142     Note that autoprobing is not allowed in loadable modules - the system is
00143     already up and running and you're messing with interrupts.
00144 
00145     To unload a module, turn off the associated interface 
00146     'ifconfig eth?? down' then 'rmmod depca'.
00147 
00148     To assign a base memory address for the shared memory  when running as a
00149     loadable module, see 5 above.  To include the adapter  name (if you have
00150     no PROM  but know the card name)  also see 5  above. Note that this last
00151     option  will not work  with kernel  built-in  depca's. 
00152 
00153     The shared memory assignment for a loadable module  makes sense to avoid
00154     the 'memory autoprobe' picking the wrong shared memory  (for the case of
00155     2 depca's in a PC).
00156 
00157     ************************************************************************
00158     Support for MCA EtherWORKS cards added 11-3-98.
00159     Verified to work with up to 2 DE212 cards in a system (although not
00160       fully stress-tested).  
00161 
00162     Currently known bugs/limitations:
00163 
00164     Note:  with the MCA stuff as a module, it trusts the MCA configuration,
00165            not the command line for IRQ and memory address.  You can
00166            specify them if you want, but it will throw your values out.
00167            You still have to pass the IO address it was configured as
00168            though.
00169 
00170     ************************************************************************
00171     TO DO:
00172     ------
00173 
00174 
00175     Revision History
00176     ----------------
00177 
00178     Version   Date        Description
00179   
00180       0.1     25-jan-94   Initial writing.
00181       0.2     27-jan-94   Added LANCE TX hardware buffer chaining.
00182       0.3      1-feb-94   Added multiple DEPCA support.
00183       0.31     4-feb-94   Added DE202 recognition.
00184       0.32    19-feb-94   Tidy up. Improve multi-DEPCA support.
00185       0.33    25-feb-94   Fix DEPCA ethernet ROM counter enable.
00186                           Add jabber packet fix from murf@perftech.com
00187                           and becker@super.org
00188       0.34     7-mar-94   Fix DEPCA max network memory RAM & NICSR access.
00189       0.35     8-mar-94   Added DE201 recognition. Tidied up.
00190       0.351   30-apr-94   Added EISA support. Added DE422 recognition.
00191       0.36    16-may-94   DE422 fix released.
00192       0.37    22-jul-94   Added MODULE support
00193       0.38    15-aug-94   Added DBR ROM switch in depca_close(). 
00194                           Multi DEPCA bug fix.
00195       0.38axp 15-sep-94   Special version for Alpha AXP Linux V1.0.
00196       0.381   12-dec-94   Added DE101 recognition, fix multicast bug.
00197       0.382    9-feb-95   Fix recognition bug reported by <bkm@star.rl.ac.uk>.
00198       0.383   22-feb-95   Fix for conflict with VESA SCSI reported by
00199                           <stromain@alf.dec.com>
00200       0.384   17-mar-95   Fix a ring full bug reported by <bkm@star.rl.ac.uk>
00201       0.385    3-apr-95   Fix a recognition bug reported by 
00202                                                 <ryan.niemi@lastfrontier.com>
00203       0.386   21-apr-95   Fix the last fix...sorry, must be galloping senility
00204       0.40    25-May-95   Rewrite for portability & updated.
00205                           ALPHA support from <jestabro@amt.tay1.dec.com>
00206       0.41    26-Jun-95   Added verify_area() calls in depca_ioctl() from
00207                           suggestion by <heiko@colossus.escape.de>
00208       0.42    27-Dec-95   Add 'mem' shared memory assignment for loadable 
00209                           modules.
00210                           Add 'adapter_name' for loadable modules when no PROM.
00211                           Both above from a suggestion by 
00212                           <pchen@woodruffs121.residence.gatech.edu>.
00213                           Add new multicasting code.
00214       0.421   22-Apr-96   Fix alloc_device() bug <jari@markkus2.fimr.fi>
00215       0.422   29-Apr-96   Fix depca_hw_init() bug <jari@markkus2.fimr.fi>
00216       0.423    7-Jun-96   Fix module load bug <kmg@barco.be>
00217       0.43    16-Aug-96   Update alloc_device() to conform to de4x5.c
00218       0.44     1-Sep-97   Fix *_probe() to test check_region() first - bug
00219                            reported by <mmogilvi@elbert.uccs.edu>
00220       0.45     3-Nov-98   Added support for MCA EtherWORKS (DE210/DE212) cards
00221                            by <tymm@computer.org> 
00222       0.451    5-Nov-98   Fixed mca stuff cuz I'm a dummy. <tymm@computer.org>
00223       0.5     14-Nov-98   Re-spin for 2.1.x kernels.
00224       0.51    27-Jun-99   Correct received packet length for CRC from
00225                            report by <worm@dkik.dk>
00226 
00227     =========================================================================
00228 */
00229 
00230 static const char *version = "depca.c:v0.51 1999/6/27 davies@maniac.ultranet.com\n";
00231 
00232 #include <linux/config.h>
00233 #include <linux/module.h>
00234 
00235 #include <linux/kernel.h>
00236 #include <linux/sched.h>
00237 #include <linux/string.h>
00238 #include <linux/ptrace.h>
00239 #include <linux/errno.h>
00240 #include <linux/ioport.h>
00241 #include <linux/malloc.h>
00242 #include <linux/interrupt.h>
00243 #include <linux/delay.h>
00244 #include <linux/init.h>
00245 #include <asm/uaccess.h>
00246 #include <asm/bitops.h>
00247 #include <asm/io.h>
00248 #include <asm/dma.h>
00249 
00250 #include <linux/netdevice.h>
00251 #include <linux/etherdevice.h>
00252 #include <linux/skbuff.h>
00253 
00254 #include <linux/time.h>
00255 #include <linux/types.h>
00256 #include <linux/unistd.h>
00257 #include <linux/ctype.h>
00258 
00259 #ifdef CONFIG_MCA
00260 #include <linux/mca.h>
00261 #endif
00262 
00263 #include "depca.h"
00264 
00265 #ifdef DEPCA_DEBUG
00266 static int depca_debug = DEPCA_DEBUG;
00267 #else
00268 static int depca_debug = 1;
00269 #endif
00270 
00271 #define DEPCA_NDA 0xffe0        /* No Device Address */
00272 
00273 /*
00274 ** Ethernet PROM defines
00275 */
00276 #define PROBE_LENGTH    32
00277 #define ETH_PROM_SIG    0xAA5500FFUL
00278 
00279 /*
00280 ** Set the number of Tx and Rx buffers. Ensure that the memory requested
00281 ** here is <= to the amount of shared memory set up by the board switches.
00282 ** The number of descriptors MUST BE A POWER OF 2.
00283 **
00284 ** total_memory = NUM_RX_DESC*(8+RX_BUFF_SZ) + NUM_TX_DESC*(8+TX_BUFF_SZ)
00285 */
00286 #define NUM_RX_DESC     8       /* Number of RX descriptors */
00287 #define NUM_TX_DESC     8       /* Number of TX descriptors */
00288 #define RX_BUFF_SZ      1536    /* Buffer size for each Rx buffer */
00289 #define TX_BUFF_SZ      1536    /* Buffer size for each Tx buffer */
00290 
00291 #define CRC_POLYNOMIAL_BE 0x04c11db7UL  /* Ethernet CRC, big endian */
00292 #define CRC_POLYNOMIAL_LE 0xedb88320UL  /* Ethernet CRC, little endian */
00293 
00294 /*
00295 ** EISA bus defines
00296 */
00297 #define DEPCA_EISA_IO_PORTS 0x0c00      /* I/O port base address, slot 0 */
00298 #define MAX_EISA_SLOTS 16
00299 #define EISA_SLOT_INC 0x1000
00300 
00301 /*
00302 ** ISA Bus defines
00303 */
00304 #define DEPCA_RAM_BASE_ADDRESSES {0xc0000,0xd0000,0xe0000,0x00000}
00305 #define DEPCA_IO_PORTS {0x300, 0x200, 0}
00306 #define DEPCA_TOTAL_SIZE 0x10
00307 static short mem_chkd = 0;
00308 
00309 /*
00310 ** Adapter ID for the MCA EtherWORKS DE210/212 adapter
00311 */
00312 #define DE212_ID 0x6def
00313 
00314 /*
00315 ** Name <-> Adapter mapping
00316 */
00317 #define DEPCA_SIGNATURE {"DEPCA",\
00318                          "DE100","DE101",\
00319                          "DE200","DE201","DE202",\
00320                          "DE210","DE212",\
00321                          "DE422",\
00322                          ""}
00323 static enum {
00324         DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown
00325 } adapter;
00326 
00327 /*
00328 ** Miscellaneous info...
00329 */
00330 #define DEPCA_STRLEN 16
00331 #define MAX_NUM_DEPCAS 2
00332 
00333 /*
00334 ** Memory Alignment. Each descriptor is 4 longwords long. To force a
00335 ** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and
00336 ** DESC_ALIGN. ALIGN aligns the start address of the private memory area
00337 ** and hence the RX descriptor ring's first entry. 
00338 */
00339 #define ALIGN4      ((u_long)4 - 1)     /* 1 longword align */
00340 #define ALIGN8      ((u_long)8 - 1)     /* 2 longword (quadword) align */
00341 #define ALIGN         ALIGN8    /* Keep the LANCE happy... */
00342 
00343 /*
00344 ** The DEPCA Rx and Tx ring descriptors. 
00345 */
00346 struct depca_rx_desc {
00347         volatile s32 base;
00348         s16 buf_length;         /* This length is negative 2's complement! */
00349         s16 msg_length;         /* This length is "normal". */
00350 };
00351 
00352 struct depca_tx_desc {
00353         volatile s32 base;
00354         s16 length;             /* This length is negative 2's complement! */
00355         s16 misc;               /* Errors and TDR info */
00356 };
00357 
00358 #define LA_MASK 0x0000ffff      /* LANCE address mask for mapping network RAM
00359                                    to LANCE memory address space */
00360 
00361 /*
00362 ** The Lance initialization block, described in databook, in common memory.
00363 */
00364 struct depca_init {
00365         u16 mode;               /* Mode register */
00366         u8 phys_addr[ETH_ALEN]; /* Physical ethernet address */
00367         u8 mcast_table[8];      /* Multicast Hash Table. */
00368         u32 rx_ring;            /* Rx ring base pointer & ring length */
00369         u32 tx_ring;            /* Tx ring base pointer & ring length */
00370 };
00371 
00372 #define DEPCA_PKT_STAT_SZ 16
00373 #define DEPCA_PKT_BIN_SZ  128   /* Should be >=100 unless you
00374                                    increase DEPCA_PKT_STAT_SZ */
00375 struct depca_private {
00376         char devname[DEPCA_STRLEN];     /* Device Product String                  */
00377         char adapter_name[DEPCA_STRLEN];        /* /proc/ioports string                  */
00378         char adapter;           /* Adapter type                           */
00379         char mca_slot;          /* MCA slot, if MCA else -1               */
00380         struct depca_rx_desc *rx_ring;  /* Pointer to start of RX descriptor ring */
00381         struct depca_tx_desc *tx_ring;  /* Pointer to start of TX descriptor ring */
00382         struct depca_init init_block;   /* Shadow Initialization block            */
00383         char *rx_memcpy[NUM_RX_DESC];   /* CPU virt address of sh'd memory buffs  */
00384         char *tx_memcpy[NUM_TX_DESC];   /* CPU virt address of sh'd memory buffs  */
00385         u_long bus_offset;      /* (E)ISA bus address offset vs LANCE     */
00386         u_long sh_mem;          /* Physical start addr of shared mem area */
00387         u_long dma_buffs;       /* LANCE Rx and Tx buffers start address. */
00388         int rx_new, tx_new;     /* The next free ring entry               */
00389         int rx_old, tx_old;     /* The ring entries to be free()ed.       */
00390         struct net_device_stats stats;
00391         struct {                /* Private stats counters                 */
00392                 u32 bins[DEPCA_PKT_STAT_SZ];
00393                 u32 unicast;
00394                 u32 multicast;
00395                 u32 broadcast;
00396                 u32 excessive_collisions;
00397                 u32 tx_underruns;
00398                 u32 excessive_underruns;
00399         } pktStats;
00400         int txRingMask;         /* TX ring mask                           */
00401         int rxRingMask;         /* RX ring mask                           */
00402         s32 rx_rlen;            /* log2(rxRingMask+1) for the descriptors */
00403         s32 tx_rlen;            /* log2(txRingMask+1) for the descriptors */
00404 };
00405 
00406 /*
00407 ** The transmit ring full condition is described by the tx_old and tx_new
00408 ** pointers by:
00409 **    tx_old            = tx_new    Empty ring
00410 **    tx_old            = tx_new+1  Full ring
00411 **    tx_old+txRingMask = tx_new    Full ring  (wrapped condition)
00412 */
00413 #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
00414                          lp->tx_old+lp->txRingMask-lp->tx_new:\
00415                          lp->tx_old               -lp->tx_new-1)
00416 
00417 /*
00418 ** Public Functions
00419 */
00420 static int depca_open(struct device *dev);
00421 static int depca_start_xmit(struct sk_buff *skb, struct device *dev);
00422 static void depca_interrupt(int irq, void *dev_id, struct pt_regs *regs);
00423 static int depca_close(struct device *dev);
00424 static int depca_ioctl(struct device *dev, struct ifreq *rq, int cmd);
00425 static struct net_device_stats *depca_get_stats(struct device *dev);
00426 static void set_multicast_list(struct device *dev);
00427 
00428 /*
00429 ** Private functions
00430 */
00431 static int depca_hw_init(struct device *dev, u_long ioaddr, int mca_slot);
00432 static void depca_init_ring(struct device *dev);
00433 static int depca_rx(struct device *dev);
00434 static int depca_tx(struct device *dev);
00435 
00436 static void LoadCSRs(struct device *dev);
00437 static int InitRestartDepca(struct device *dev);
00438 static void DepcaSignature(char *name, u_long paddr);
00439 static int DevicePresent(u_long ioaddr);
00440 static int get_hw_addr(struct device *dev);
00441 static int EISA_signature(char *name, s32 eisa_id);
00442 static void SetMulticastFilter(struct device *dev);
00443 static void isa_probe(struct device *dev, u_long iobase);
00444 static void eisa_probe(struct device *dev, u_long iobase);
00445 #ifdef CONFIG_MCA
00446 static void mca_probe(struct device *dev, u_long iobase);
00447 #endif
00448 static struct device *alloc_device(struct device *dev, u_long iobase);
00449 static int depca_dev_index(char *s);
00450 static struct device *insert_device(struct device *dev, u_long iobase, int (*init) (struct device *));
00451 static int load_packet(struct device *dev, struct sk_buff *skb);
00452 static void depca_dbg_open(struct device *dev);
00453 
00454 #ifdef MODULE
00455 int init_module(void);
00456 void cleanup_module(void);
00457 static int autoprobed = 1, loading_module = 1;
00458 # else
00459 static u_char de1xx_irq[] __initdata = { 2, 3, 4, 5, 7, 9, 0 };
00460 static u_char de2xx_irq[] __initdata = { 5, 9, 10, 11, 15, 0 };
00461 static u_char de422_irq[] __initdata = { 5, 9, 10, 11, 0 };
00462 static u_char *depca_irq;
00463 static int autoprobed = 0, loading_module = 0;
00464 #endif                          /* MODULE */
00465 
00466 static char name[DEPCA_STRLEN];
00467 static int num_depcas = 0, num_eth = 0;
00468 static int mem = 0;             /* For loadable module assignment
00469                                    use insmod mem=0x????? .... */
00470 static char *adapter_name = '\0';       /* If no PROM when loadable module
00471                                            use insmod adapter_name=DE??? ...
00472                                          */
00473 /*
00474 ** Miscellaneous defines...
00475 */
00476 #define STOP_DEPCA \
00477     outw(CSR0, DEPCA_ADDR);\
00478     outw(STOP, DEPCA_DATA)
00479 
00480 
00481 
00482 __initfunc(int depca_probe(struct device *dev))
00483 {
00484         int tmp = num_depcas, status = -ENODEV;
00485         u_long iobase = dev->base_addr;
00486 
00487         if ((iobase == 0) && loading_module) {
00488                 printk("Autoprobing is not supported when loading a module based driver.\n");
00489                 status = -EIO;
00490         } else {
00491 #ifdef CONFIG_MCA
00492                 mca_probe(dev, iobase);
00493 #endif
00494                 isa_probe(dev, iobase);
00495                 eisa_probe(dev, iobase);
00496 
00497                 if ((tmp == num_depcas) && (iobase != 0) && loading_module) {
00498                         printk("%s: depca_probe() cannot find device at 0x%04lx.\n", dev->name, iobase);
00499                 }
00500 
00501                 /*
00502                    ** Walk the device list to check that at least one device
00503                    ** initialised OK
00504                  */
00505                 for (; (dev->priv == NULL) && (dev->next != NULL); dev = dev->next);
00506 
00507                 if (dev->priv)
00508                         status = 0;
00509                 if (iobase == 0)
00510                         autoprobed = 1;
00511         }
00512 
00513         return status;
00514 }
00515 
00516 __initfunc(static int depca_hw_init(struct device *dev, u_long ioaddr, int mca_slot))
00517 {
00518         struct depca_private *lp;
00519         int i, j, offset, netRAM, mem_len, status = 0;
00520         s16 nicsr;
00521         u_long mem_start = 0, mem_base[] = DEPCA_RAM_BASE_ADDRESSES;
00522 
00523         STOP_DEPCA;
00524 
00525         nicsr = inb(DEPCA_NICSR);
00526         nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM);
00527         outb(nicsr, DEPCA_NICSR);
00528 
00529         if (inw(DEPCA_DATA) == STOP) {
00530                 do {
00531                         strcpy(name, (adapter_name ? adapter_name : ""));
00532                         mem_start = (mem ? mem & 0xf0000 : mem_base[mem_chkd++]);
00533                         DepcaSignature(name, mem_start);
00534                 } while (!mem && mem_base[mem_chkd] && (adapter == unknown));
00535 
00536                 if ((adapter != unknown) && mem_start) {        /* found a DEPCA device */
00537                         dev->base_addr = ioaddr;
00538 
00539                         if (mca_slot != -1) {
00540                                 printk("%s: %s at 0x%04lx (MCA slot %d)", dev->name, name, ioaddr, mca_slot);
00541                         } else if ((ioaddr & 0x0fff) == DEPCA_EISA_IO_PORTS) {  /* EISA slot address */
00542                                 printk("%s: %s at 0x%04lx (EISA slot %d)", dev->name, name, ioaddr, (int) ((ioaddr >> 12) & 0x0f));
00543                         } else {        /* ISA port address */
00544                                 printk("%s: %s at 0x%04lx", dev->name, name, ioaddr);
00545                         }
00546 
00547                         printk(", h/w address ");
00548                         status = get_hw_addr(dev);
00549                         for (i = 0; i < ETH_ALEN - 1; i++) {    /* get the ethernet address */
00550                                 printk("%2.2x:", dev->dev_addr[i]);
00551                         }
00552                         printk("%2.2x", dev->dev_addr[i]);
00553 
00554                         if (status == 0) {
00555                                 /* Set up the maximum amount of network RAM(kB) */
00556                                 netRAM = ((adapter != DEPCA) ? 64 : 48);
00557                                 if ((nicsr & _128KB) && (adapter == de422))
00558                                         netRAM = 128;
00559                                 offset = 0x0000;
00560 
00561                                 /* Shared Memory Base Address */
00562                                 if (nicsr & BUF) {
00563                                         offset = 0x8000;        /* 32kbyte RAM offset */
00564                                         nicsr &= ~BS;   /* DEPCA RAM in top 32k */
00565                                         netRAM -= 32;
00566                                 }
00567                                 mem_start += offset;    /* (E)ISA start address */
00568                                 if ((mem_len = (NUM_RX_DESC * (sizeof(struct depca_rx_desc) + RX_BUFF_SZ) + NUM_TX_DESC * (sizeof(struct depca_tx_desc) + TX_BUFF_SZ) + sizeof(struct depca_init))) <= (netRAM << 10)) {
00569                                         printk(",\n      has %dkB RAM at 0x%.5lx", netRAM, mem_start);
00570 
00571                                         /* Enable the shadow RAM. */
00572                                         if (adapter != DEPCA) {
00573                                                 nicsr |= SHE;
00574                                                 outb(nicsr, DEPCA_NICSR);
00575                                         }
00576 
00577                                         /* Define the device private memory */
00578                                         dev->priv = (void *) kmalloc(sizeof(struct depca_private), GFP_KERNEL);
00579                                         if (dev->priv == NULL)
00580                                                 return -ENOMEM;
00581                                         lp = (struct depca_private *) dev->priv;
00582                                         memset((char *) dev->priv, 0, sizeof(struct depca_private));
00583                                         lp->adapter = adapter;
00584                                         lp->mca_slot = mca_slot;
00585                                         sprintf(lp->adapter_name, "%s (%s)", name, dev->name);
00586                                         request_region(ioaddr, DEPCA_TOTAL_SIZE, lp->adapter_name);
00587 
00588                                         /* Initialisation Block */
00589                                         lp->sh_mem = mem_start;
00590                                         mem_start += sizeof(struct depca_init);
00591 
00592                                         /* Tx & Rx descriptors (aligned to a quadword boundary) */
00593                                         mem_start = (mem_start + ALIGN) & ~ALIGN;
00594                                         lp->rx_ring = (struct depca_rx_desc *) mem_start;
00595 
00596                                         mem_start += (sizeof(struct depca_rx_desc) * NUM_RX_DESC);
00597                                         lp->tx_ring = (struct depca_tx_desc *) mem_start;
00598 
00599                                         mem_start += (sizeof(struct depca_tx_desc) * NUM_TX_DESC);
00600                                         lp->bus_offset = mem_start & 0x00ff0000;
00601                                         mem_start &= LA_MASK;   /* LANCE re-mapped start address */
00602 
00603                                         lp->dma_buffs = mem_start;
00604 
00605                                         /* Finish initialising the ring information. */
00606                                         lp->rxRingMask = NUM_RX_DESC - 1;
00607                                         lp->txRingMask = NUM_TX_DESC - 1;
00608 
00609                                         /* Calculate Tx/Rx RLEN size for the descriptors. */
00610                                         for (i = 0, j = lp->rxRingMask; j > 0; i++) {
00611                                                 j >>= 1;
00612                                         }
00613                                         lp->rx_rlen = (s32) (i << 29);
00614                                         for (i = 0, j = lp->txRingMask; j > 0; i++) {
00615                                                 j >>= 1;
00616                                         }
00617                                         lp->tx_rlen = (s32) (i << 29);
00618 
00619                                         /* Load the initialisation block */
00620                                         depca_init_ring(dev);
00621 
00622                                         /* Initialise the control and status registers */
00623                                         LoadCSRs(dev);
00624 
00625                                         /* Enable DEPCA board interrupts for autoprobing */
00626                                         nicsr = ((nicsr & ~IM) | IEN);
00627                                         outb(nicsr, DEPCA_NICSR);
00628 
00629                                         /* To auto-IRQ we enable the initialization-done and DMA err,
00630                                            interrupts. For now we will always get a DMA error. */
00631                                         if (dev->irq < 2) {
00632 #ifndef MODULE
00633                                                 unsigned char irqnum;
00634                                                 autoirq_setup(0);
00635 
00636                                                 /* Assign the correct irq list */
00637                                                 switch (lp->adapter) {
00638                                                 case DEPCA:
00639                                                 case de100:
00640                                                 case de101:
00641                                                         depca_irq = de1xx_irq;
00642                                                         break;
00643                                                 case de200:
00644                                                 case de201:
00645                                                 case de202:
00646                                                 case de210:
00647                                                 case de212:
00648                                                         depca_irq = de2xx_irq;
00649                                                         break;
00650                                                 case de422:
00651                                                         depca_irq = de422_irq;
00652                                                         break;
00653                                                 }
00654 
00655                                                 /* Trigger an initialization just for the interrupt. */
00656                                                 outw(INEA | INIT, DEPCA_DATA);
00657 
00658                                                 irqnum = autoirq_report(1);
00659                                                 if (!irqnum) {
00660                                                         printk(" and failed to detect IRQ line.\n");
00661                                                         status = -ENXIO;
00662                                                 } else {
00663                                                         for (dev->irq = 0, i = 0; (depca_irq[i]) && (!dev->irq); i++) {
00664                                                                 if (irqnum == depca_irq[i]) {
00665                                                                         dev->irq = irqnum;
00666                                                                         printk(" and uses IRQ%d.\n", dev->irq);
00667                                                                 }
00668                                                         }
00669 
00670                                                         if (!dev->irq) {
00671                                                                 printk(" but incorrect IRQ line detected.\n");
00672                                                                 status = -ENXIO;
00673                                                         }
00674                                                 }
00675 #endif                          /* MODULE */
00676                                         } else {
00677                                                 printk(" and assigned IRQ%d.\n", dev->irq);
00678                                         }
00679                                         if (status)
00680                                                 release_region(ioaddr, DEPCA_TOTAL_SIZE);
00681                                 } else {
00682                                         printk(",\n      requests %dkB RAM: only %dkB is available!\n", (mem_len >> 10), netRAM);
00683                                         status = -ENXIO;
00684                                 }
00685                         } else {
00686                                 printk("      which has an Ethernet PROM CRC error.\n");
00687                                 status = -ENXIO;
00688                         }
00689                 } else {
00690                         status = -ENXIO;
00691                 }
00692                 if (!status) {
00693                         if (depca_debug > 1) {
00694                                 printk(version);
00695                         }
00696 
00697                         /* The DEPCA-specific entries in the device structure. */
00698                         dev->open = &depca_open;
00699                         dev->hard_start_xmit = &depca_start_xmit;
00700                         dev->stop = &depca_close;
00701                         dev->get_stats = &depca_get_stats;
00702                         dev->set_multicast_list = &set_multicast_list;
00703                         dev->do_ioctl = &depca_ioctl;
00704 
00705                         dev->mem_start = 0;
00706 
00707                         /* Fill in the generic field of the device structure. */
00708                         ether_setup(dev);
00709                 } else {        /* Incorrectly initialised hardware */
00710                         if (dev->priv) {
00711                                 kfree_s(dev->priv, sizeof(struct depca_private));
00712                                 dev->priv = NULL;
00713                         }
00714                 }
00715         } else {
00716                 status = -ENXIO;
00717         }
00718 
00719         return status;
00720 }
00721 
00722 
00723 static int depca_open(struct device *dev)
00724 {
00725         struct depca_private *lp = (struct depca_private *) dev->priv;
00726         u_long ioaddr = dev->base_addr;
00727         s16 nicsr;
00728         int status = 0;
00729 
00730         STOP_DEPCA;
00731         nicsr = inb(DEPCA_NICSR);
00732 
00733         /* Make sure the shadow RAM is enabled */
00734         if (adapter != DEPCA) {
00735                 nicsr |= SHE;
00736                 outb(nicsr, DEPCA_NICSR);
00737         }
00738 
00739         /* Re-initialize the DEPCA... */
00740         depca_init_ring(dev);
00741         LoadCSRs(dev);
00742 
00743         depca_dbg_open(dev);
00744 
00745         if (request_irq(dev->irq, &depca_interrupt, 0, lp->adapter_name, dev)) {
00746                 printk("depca_open(): Requested IRQ%d is busy\n", dev->irq);
00747                 status = -EAGAIN;
00748         } else {
00749 
00750                 /* Enable DEPCA board interrupts and turn off LED */
00751                 nicsr = ((nicsr & ~IM & ~LED) | IEN);
00752                 outb(nicsr, DEPCA_NICSR);
00753                 outw(CSR0, DEPCA_ADDR);
00754 
00755                 dev->tbusy = 0;
00756                 dev->interrupt = 0;
00757                 dev->start = 1;
00758 
00759                 status = InitRestartDepca(dev);
00760 
00761                 if (depca_debug > 1) {
00762                         printk("CSR0: 0x%4.4x\n", inw(DEPCA_DATA));
00763                         printk("nicsr: 0x%02x\n", inb(DEPCA_NICSR));
00764                 }
00765         }
00766 
00767         MOD_INC_USE_COUNT;
00768 
00769         return status;
00770 }
00771 
00772 /* Initialize the lance Rx and Tx descriptor rings. */
00773 static void depca_init_ring(struct device *dev)
00774 {
00775         struct depca_private *lp = (struct depca_private *) dev->priv;
00776         u_int i;
00777         u_long p;
00778 
00779         /* Lock out other processes whilst setting up the hardware */
00780         test_and_set_bit(0, (void *) &dev->tbusy);
00781 
00782         lp->rx_new = lp->tx_new = 0;
00783         lp->rx_old = lp->tx_old = 0;
00784 
00785         /* Initialize the base addresses and length of each buffer in the ring */
00786         for (i = 0; i <= lp->rxRingMask; i++) {
00787                 writel((p = lp->dma_buffs + i * RX_BUFF_SZ) | R_OWN, &lp->rx_ring[i].base);
00788                 writew(-RX_BUFF_SZ, &lp->rx_ring[i].buf_length);
00789                 lp->rx_memcpy[i] = (char *) (p + lp->bus_offset);
00790         }
00791         for (i = 0; i <= lp->txRingMask; i++) {
00792                 writel((p = lp->dma_buffs + (i + lp->txRingMask + 1) * TX_BUFF_SZ) & 0x00ffffff, &lp->tx_ring[i].base);
00793                 lp->tx_memcpy[i] = (char *) (p + lp->bus_offset);
00794         }
00795 
00796         /* Set up the initialization block */
00797         lp->init_block.rx_ring = ((u32) ((u_long) lp->rx_ring) & LA_MASK) | lp->rx_rlen;
00798         lp->init_block.tx_ring = ((u32) ((u_long) lp->tx_ring) & LA_MASK) | lp->tx_rlen;
00799 
00800         SetMulticastFilter(dev);
00801 
00802         for (i = 0; i < ETH_ALEN; i++) {
00803                 lp->init_block.phys_addr[i] = dev->dev_addr[i];
00804         }
00805 
00806         lp->init_block.mode = 0x0000;   /* Enable the Tx and Rx */
00807 
00808         return;
00809 }
00810 
00811 /* 
00812 ** Writes a socket buffer to TX descriptor ring and starts transmission 
00813 */
00814 static int depca_start_xmit(struct sk_buff *skb, struct device *dev)
00815 {
00816         struct depca_private *lp = (struct depca_private *) dev->priv;
00817         u_long ioaddr = dev->base_addr;
00818         int status = 0;
00819 
00820         /* Transmitter timeout, serious problems. */
00821         if (dev->tbusy) {
00822                 int tickssofar = jiffies - dev->trans_start;
00823                 if (tickssofar < 1 * HZ) {
00824                         status = -1;
00825                 } else {
00826                         printk("%s: transmit timed out, status %04x, resetting.\n", dev->name, inw(DEPCA_DATA));
00827 
00828                         STOP_DEPCA;
00829                         depca_init_ring(dev);
00830                         LoadCSRs(dev);
00831                         dev->interrupt = UNMASK_INTERRUPTS;
00832                         dev->start = 1;
00833                         dev->tbusy = 0;
00834                         dev->trans_start = jiffies;
00835                         InitRestartDepca(dev);
00836                 }
00837                 return status;
00838         } else if (skb->len > 0) {
00839                 if(skb->len < ETH_ZLEN)
00840                 {
00841                         skb = skb_padto(skb, ETH_ZLEN);
00842                         if(skb == NULL)
00843                                 return 0;
00844                 }
00845 
00846                 /* Enforce 1 process per h/w access */
00847                 if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) {
00848                         printk("%s: Transmitter access conflict.\n", dev->name);
00849                         status = -1;
00850                 } else {
00851                         if (TX_BUFFS_AVAIL) {   /* Fill in a Tx ring entry */
00852                                 status = load_packet(dev, skb);
00853 
00854                                 if (!status) {
00855                                         /* Trigger an immediate send demand. */
00856                                         outw(CSR0, DEPCA_ADDR);
00857                                         outw(INEA | TDMD, DEPCA_DATA);
00858 
00859                                         dev->trans_start = jiffies;
00860                                         dev_kfree_skb(skb);
00861                                 }
00862                                 if (TX_BUFFS_AVAIL) {
00863                                         dev->tbusy = 0;
00864                                 }
00865                         } else {
00866                                 status = -1;
00867                         }
00868                 }
00869         }
00870 
00871         return status;
00872 }
00873 
00874 /*
00875 ** The DEPCA interrupt handler. 
00876 */
00877 static void depca_interrupt(int irq, void *dev_id, struct pt_regs *regs)
00878 {
00879         struct device *dev = dev_id;
00880         struct depca_private *lp;
00881         s16 csr0, nicsr;
00882         u_long ioaddr;
00883 
00884         if (dev == NULL) {
00885                 printk("depca_interrupt(): irq %d for unknown device.\n", irq);
00886         } else {
00887                 lp = (struct depca_private *) dev->priv;
00888                 ioaddr = dev->base_addr;
00889 
00890                 if (dev->interrupt)
00891                         printk("%s: Re-entering the interrupt handler.\n", dev->name);
00892 
00893                 dev->interrupt = MASK_INTERRUPTS;
00894 
00895                 /* mask the DEPCA board interrupts and turn on the LED */
00896                 nicsr = inb(DEPCA_NICSR);
00897                 nicsr |= (IM | LED);
00898                 outb(nicsr, DEPCA_NICSR);
00899 
00900                 outw(CSR0, DEPCA_ADDR);
00901                 csr0 = inw(DEPCA_DATA);
00902 
00903                 /* Acknowledge all of the current interrupt sources ASAP. */
00904                 outw(csr0 & INTE, DEPCA_DATA);
00905 
00906                 if (csr0 & RINT)        /* Rx interrupt (packet arrived) */
00907                         depca_rx(dev);
00908 
00909                 if (csr0 & TINT)        /* Tx interrupt (packet sent) */
00910                         depca_tx(dev);
00911 
00912                 if ((TX_BUFFS_AVAIL >= 0) && dev->tbusy) {      /* any resources available? */
00913                         dev->tbusy = 0; /* clear TX busy flag */
00914                         mark_bh(NET_BH);
00915                 }
00916 
00917                 /* Unmask the DEPCA board interrupts and turn off the LED */
00918                 nicsr = (nicsr & ~IM & ~LED);
00919                 outb(nicsr, DEPCA_NICSR);
00920 
00921                 dev->interrupt = UNMASK_INTERRUPTS;
00922         }
00923 
00924         return;
00925 }
00926 
00927 static int depca_rx(struct device *dev)
00928 {
00929         struct depca_private *lp = (struct depca_private *) dev->priv;
00930         int i, entry;
00931         s32 status;
00932 
00933         for (entry = lp->rx_new; !(readl(&lp->rx_ring[entry].base) & R_OWN); entry = lp->rx_new) {
00934                 status = readl(&lp->rx_ring[entry].base) >> 16;
00935                 if (status & R_STP) {   /* Remember start of frame */
00936                         lp->rx_old = entry;
00937                 }
00938                 if (status & R_ENP) {   /* Valid frame status */
00939                         if (status & R_ERR) {   /* There was an error. */
00940                                 lp->stats.rx_errors++;  /* Update the error stats. */
00941                                 if (status & R_FRAM)
00942                                         lp->stats.rx_frame_errors++;
00943                                 if (status & R_OFLO)
00944                                         lp->stats.rx_over_errors++;
00945                                 if (status & R_CRC)
00946                                         lp->stats.rx_crc_errors++;
00947                                 if (status & R_BUFF)
00948                                         lp->stats.rx_fifo_errors++;
00949                         } else {
00950                                 short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4;
00951                                 struct sk_buff *skb;
00952 
00953                                 skb = dev_alloc_skb(pkt_len + 2);
00954                                 if (skb != NULL) {
00955                                         unsigned char *buf;
00956                                         skb_reserve(skb, 2);    /* 16 byte align the IP header */
00957                                         buf = skb_put(skb, pkt_len);
00958                                         skb->dev = dev;
00959                                         if (entry < lp->rx_old) {       /* Wrapped buffer */
00960                                                 len = (lp->rxRingMask - lp->rx_old + 1) * RX_BUFF_SZ;
00961                                                 memcpy_fromio(buf, lp->rx_memcpy[lp->rx_old], len);
00962                                                 memcpy_fromio(buf + len, lp->rx_memcpy[0], pkt_len - len);
00963                                         } else {        /* Linear buffer */
00964                                                 memcpy_fromio(buf, lp->rx_memcpy[lp->rx_old], pkt_len);
00965                                         }
00966 
00967                                         /* 
00968                                            ** Notify the upper protocol layers that there is another 
00969                                            ** packet to handle
00970                                          */
00971                                         skb->protocol = eth_type_trans(skb, dev);
00972                                         netif_rx(skb);
00973 
00974                                         /*
00975                                            ** Update stats
00976                                          */
00977                                         lp->stats.rx_packets++;
00978                                         for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) {
00979                                                 if (pkt_len < (i * DEPCA_PKT_BIN_SZ)) {
00980                                                         lp->pktStats.bins[i]++;
00981                                                         i = DEPCA_PKT_STAT_SZ;
00982                                                 }
00983                                         }
00984                                         if (buf[0] & 0x01) {    /* Multicast/Broadcast */
00985                                                 if ((*(s16 *) & buf[0] == -1) && (*(s16 *) & buf[2] == -1) && (*(s16 *) & buf[4] == -1)) {
00986                                                         lp->pktStats.broadcast++;
00987                                                 } else {
00988                                                         lp->pktStats.multicast++;
00989                                                 }
00990                                         } else if ((*(s16 *) & buf[0] == *(s16 *) & dev->dev_addr[0]) && (*(s16 *) & buf[2] == *(s16 *) & dev->dev_addr[2]) && (*(s16 *) & buf[4] == *(s16 *) & dev->dev_addr[4])) {
00991                                                 lp->pktStats.unicast++;
00992                                         }
00993 
00994                                         lp->pktStats.bins[0]++; /* Duplicates stats.rx_packets */
00995                                         if (lp->pktStats.bins[0] == 0) {        /* Reset counters */
00996                                                 memset((char *) &lp->pktStats, 0, sizeof(lp->pktStats));
00997                                         }
00998                                 } else {
00999                                         printk("%s: Memory squeeze, deferring packet.\n", dev->name);
01000                                         lp->stats.rx_dropped++; /* Really, deferred. */
01001                                         break;
01002                                 }
01003                         }
01004                         /* Change buffer ownership for this last frame, back to the adapter */
01005                         for (; lp->rx_old != entry; lp->rx_old = (++lp->rx_old) & lp->rxRingMask) {
01006                                 writel(readl(&lp->rx_ring[lp->rx_old].base) | R_OWN, &lp->rx_ring[lp->rx_old].base);
01007                         }
01008                         writel(readl(&lp->rx_ring[entry].base) | R_OWN, &lp->rx_ring[entry].base);
01009                 }
01010 
01011                 /*
01012                    ** Update entry information
01013                  */
01014                 lp->rx_new = (++lp->rx_new) & lp->rxRingMask;
01015         }
01016 
01017         return 0;
01018 }
01019 
01020 /*
01021 ** Buffer sent - check for buffer errors.
01022 */
01023 static int depca_tx(struct device *dev)
01024 {
01025         struct depca_private *lp = (struct depca_private *) dev->priv;
01026         int entry;
01027         s32 status;
01028         u_long ioaddr = dev->base_addr;
01029 
01030         for (entry = lp->tx_old; entry != lp->tx_new; entry = lp->tx_old) {
01031                 status = readl(&lp->tx_ring[entry].base) >> 16;
01032 
01033                 if (status < 0) {       /* Packet not yet sent! */
01034                         break;
01035                 } else if (status & T_ERR) {    /* An error occurred. */
01036                         status = readl(&lp->tx_ring[entry].misc);
01037                         lp->stats.tx_errors++;
01038                         if (status & TMD3_RTRY)
01039                                 lp->stats.tx_aborted_errors++;
01040                         if (status & TMD3_LCAR)
01041                                 lp->stats.tx_carrier_errors++;
01042                         if (status & TMD3_LCOL)
01043                                 lp->stats.tx_window_errors++;
01044                         if (status & TMD3_UFLO)
01045                                 lp->stats.tx_fifo_errors++;
01046                         if (status & (TMD3_BUFF | TMD3_UFLO)) {
01047                                 /* Trigger an immediate send demand. */
01048                                 outw(CSR0, DEPCA_ADDR);
01049                                 outw(INEA | TDMD, DEPCA_DATA);
01050                         }
01051                 } else if (status & (T_MORE | T_ONE)) {
01052                         lp->stats.collisions++;
01053                 } else {
01054                         lp->stats.tx_packets++;
01055                 }
01056 
01057                 /* Update all the pointers */
01058                 lp->tx_old = (++lp->tx_old) & lp->txRingMask;
01059         }
01060 
01061         return 0;
01062 }
01063 
01064 static int depca_close(struct device *dev)
01065 {
01066         struct depca_private *lp = (struct depca_private *) dev->priv;
01067         s16 nicsr;
01068         u_long ioaddr = dev->base_addr;
01069 
01070         dev->start = 0;
01071         dev->tbusy = 1;
01072 
01073         outw(CSR0, DEPCA_ADDR);
01074 
01075         if (depca_debug > 1) {
01076                 printk("%s: Shutting down ethercard, status was %2.2x.\n", dev->name, inw(DEPCA_DATA));
01077         }
01078 
01079         /* 
01080            ** We stop the DEPCA here -- it occasionally polls
01081            ** memory if we don't. 
01082          */
01083         outw(STOP, DEPCA_DATA);
01084 
01085         /*
01086            ** Give back the ROM in case the user wants to go to DOS
01087          */
01088         if (lp->adapter != DEPCA) {
01089                 nicsr = inb(DEPCA_NICSR);
01090                 nicsr &= ~SHE;
01091                 outb(nicsr, DEPCA_NICSR);
01092         }
01093 
01094         /*
01095            ** Free the associated irq
01096          */
01097         free_irq(dev->irq, dev);
01098 
01099         MOD_DEC_USE_COUNT;
01100 
01101         return 0;
01102 }
01103 
01104 static void LoadCSRs(struct device *dev)
01105 {
01106