Back to home page

OSCL-LXR

 
 

    


0001 /* 3c574.c: A PCMCIA ethernet driver for the 3com 3c574 "RoadRunner".
0002 
0003     Written 1993-1998 by
0004     Donald Becker, becker@scyld.com, (driver core) and
0005     David Hinds, dahinds@users.sourceforge.net (from his PC card code).
0006     Locking fixes (C) Copyright 2003 Red Hat Inc
0007 
0008     This software may be used and distributed according to the terms of
0009     the GNU General Public License, incorporated herein by reference.
0010 
0011     This driver derives from Donald Becker's 3c509 core, which has the
0012     following copyright:
0013     Copyright 1993 United States Government as represented by the
0014     Director, National Security Agency.
0015     
0016 
0017 */
0018 
0019 /*
0020                 Theory of Operation
0021 
0022 I. Board Compatibility
0023 
0024 This device driver is designed for the 3Com 3c574 PC card Fast Ethernet
0025 Adapter.
0026 
0027 II. Board-specific settings
0028 
0029 None -- PC cards are autoconfigured.
0030 
0031 III. Driver operation
0032 
0033 The 3c574 uses a Boomerang-style interface, without the bus-master capability.
0034 See the Boomerang driver and documentation for most details.
0035 
0036 IV. Notes and chip documentation.
0037 
0038 Two added registers are used to enhance PIO performance, RunnerRdCtrl and
0039 RunnerWrCtrl.  These are 11 bit down-counters that are preloaded with the
0040 count of word (16 bits) reads or writes the driver is about to do to the Rx
0041 or Tx FIFO.  The chip is then able to hide the internal-PCI-bus to PC-card
0042 translation latency by buffering the I/O operations with an 8 word FIFO.
0043 Note: No other chip accesses are permitted when this buffer is used.
0044 
0045 A second enhancement is that both attribute and common memory space
0046 0x0800-0x0fff can translated to the PIO FIFO.  Thus memory operations (faster
0047 with *some* PCcard bridges) may be used instead of I/O operations.
0048 This is enabled by setting the 0x10 bit in the PCMCIA LAN COR.
0049 
0050 Some slow PC card bridges work better if they never see a WAIT signal.
0051 This is configured by setting the 0x20 bit in the PCMCIA LAN COR.
0052 Only do this after testing that it is reliable and improves performance.
0053 
0054 The upper five bits of RunnerRdCtrl are used to window into PCcard
0055 configuration space registers.  Window 0 is the regular Boomerang/Odie
0056 register set, 1-5 are various PC card control registers, and 16-31 are
0057 the (reversed!) CIS table.
0058 
0059 A final note: writing the InternalConfig register in window 3 with an
0060 invalid ramWidth is Very Bad.
0061 
0062 V. References
0063 
0064 http://www.scyld.com/expert/NWay.html
0065 http://www.national.com/opf/DP/DP83840A.html
0066 
0067 Thanks to Terry Murphy of 3Com for providing development information for
0068 earlier 3Com products.
0069 
0070 */
0071 
0072 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0073 
0074 #include <linux/module.h>
0075 #include <linux/kernel.h>
0076 #include <linux/slab.h>
0077 #include <linux/string.h>
0078 #include <linux/timer.h>
0079 #include <linux/interrupt.h>
0080 #include <linux/in.h>
0081 #include <linux/delay.h>
0082 #include <linux/netdevice.h>
0083 #include <linux/etherdevice.h>
0084 #include <linux/skbuff.h>
0085 #include <linux/if_arp.h>
0086 #include <linux/ioport.h>
0087 #include <linux/bitops.h>
0088 #include <linux/mii.h>
0089 
0090 #include <pcmcia/cistpl.h>
0091 #include <pcmcia/cisreg.h>
0092 #include <pcmcia/ciscode.h>
0093 #include <pcmcia/ds.h>
0094 
0095 #include <linux/uaccess.h>
0096 #include <asm/io.h>
0097 
0098 /*====================================================================*/
0099 
0100 /* Module parameters */
0101 
0102 MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
0103 MODULE_DESCRIPTION("3Com 3c574 series PCMCIA ethernet driver");
0104 MODULE_LICENSE("GPL");
0105 
0106 #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)
0107 
0108 /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
0109 INT_MODULE_PARM(max_interrupt_work, 32);
0110 
0111 /* Force full duplex modes? */
0112 INT_MODULE_PARM(full_duplex, 0);
0113 
0114 /* Autodetect link polarity reversal? */
0115 INT_MODULE_PARM(auto_polarity, 1);
0116 
0117 
0118 /*====================================================================*/
0119 
0120 /* Time in jiffies before concluding the transmitter is hung. */
0121 #define TX_TIMEOUT  ((800*HZ)/1000)
0122 
0123 /* To minimize the size of the driver source and make the driver more
0124    readable not all constants are symbolically defined.
0125    You'll need the manual if you want to understand driver details anyway. */
0126 /* Offsets from base I/O address. */
0127 #define EL3_DATA    0x00
0128 #define EL3_CMD     0x0e
0129 #define EL3_STATUS  0x0e
0130 
0131 #define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
0132 
0133 /* The top five bits written to EL3_CMD are a command, the lower
0134    11 bits are the parameter, if applicable. */
0135 enum el3_cmds {
0136     TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11,
0137     RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11,
0138     TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11,
0139     FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11,
0140     SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11,
0141     SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11,
0142     StatsDisable = 22<<11, StopCoax = 23<<11,
0143 };
0144 
0145 enum elxl_status {
0146     IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004,
0147     TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
0148     IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000 };
0149 
0150 /* The SetRxFilter command accepts the following classes: */
0151 enum RxFilter {
0152     RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8
0153 };
0154 
0155 enum Window0 {
0156     Wn0EepromCmd = 10, Wn0EepromData = 12, /* EEPROM command/address, data. */
0157     IntrStatus=0x0E,        /* Valid in all windows. */
0158 };
0159 /* These assumes the larger EEPROM. */
0160 enum Win0_EEPROM_cmds {
0161     EEPROM_Read = 0x200, EEPROM_WRITE = 0x100, EEPROM_ERASE = 0x300,
0162     EEPROM_EWENB = 0x30,        /* Enable erasing/writing for 10 msec. */
0163     EEPROM_EWDIS = 0x00,        /* Disable EWENB before 10 msec timeout. */
0164 };
0165 
0166 /* Register window 1 offsets, the window used in normal operation.
0167    On the "Odie" this window is always mapped at offsets 0x10-0x1f.
0168    Except for TxFree, which is overlapped by RunnerWrCtrl. */
0169 enum Window1 {
0170     TX_FIFO = 0x10,  RX_FIFO = 0x10,  RxErrors = 0x14,
0171     RxStatus = 0x18,  Timer=0x1A, TxStatus = 0x1B,
0172     TxFree = 0x0C, /* Remaining free bytes in Tx buffer. */
0173     RunnerRdCtrl = 0x16, RunnerWrCtrl = 0x1c,
0174 };
0175 
0176 enum Window3 {          /* Window 3: MAC/config bits. */
0177     Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
0178 };
0179 enum wn3_config {
0180     Ram_size = 7,
0181     Ram_width = 8,
0182     Ram_speed = 0x30,
0183     Rom_size = 0xc0,
0184     Ram_split_shift = 16,
0185     Ram_split = 3 << Ram_split_shift,
0186     Xcvr_shift = 20,
0187     Xcvr = 7 << Xcvr_shift,
0188     Autoselect = 0x1000000,
0189 };
0190 
0191 enum Window4 {      /* Window 4: Xcvr/media bits. */
0192     Wn4_FIFODiag = 4, Wn4_NetDiag = 6, Wn4_PhysicalMgmt=8, Wn4_Media = 10,
0193 };
0194 
0195 #define MEDIA_TP    0x00C0  /* Enable link beat and jabber for 10baseT. */
0196 
0197 struct el3_private {
0198     struct pcmcia_device    *p_dev;
0199     u16 advertising, partner;       /* NWay media advertisement */
0200     unsigned char phys;         /* MII device address */
0201     unsigned int autoselect:1, default_media:3; /* Read from the EEPROM/Wn3_Config. */
0202     /* for transceiver monitoring */
0203     struct timer_list media;
0204     unsigned short media_status;
0205     unsigned short fast_poll;
0206     unsigned long last_irq;
0207     spinlock_t window_lock;         /* Guards the Window selection */
0208 };
0209 
0210 /* Set iff a MII transceiver on any interface requires mdio preamble.
0211    This only set with the original DP83840 on older 3c905 boards, so the extra
0212    code size of a per-interface flag is not worthwhile. */
0213 static char mii_preamble_required = 0;
0214 
0215 /* Index of functions. */
0216 
0217 static int tc574_config(struct pcmcia_device *link);
0218 static void tc574_release(struct pcmcia_device *link);
0219 
0220 static void mdio_sync(unsigned int ioaddr, int bits);
0221 static int mdio_read(unsigned int ioaddr, int phy_id, int location);
0222 static void mdio_write(unsigned int ioaddr, int phy_id, int location,
0223                int value);
0224 static unsigned short read_eeprom(unsigned int ioaddr, int index);
0225 static void tc574_wait_for_completion(struct net_device *dev, int cmd);
0226 
0227 static void tc574_reset(struct net_device *dev);
0228 static void media_check(struct timer_list *t);
0229 static int el3_open(struct net_device *dev);
0230 static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
0231                     struct net_device *dev);
0232 static irqreturn_t el3_interrupt(int irq, void *dev_id);
0233 static void update_stats(struct net_device *dev);
0234 static struct net_device_stats *el3_get_stats(struct net_device *dev);
0235 static int el3_rx(struct net_device *dev, int worklimit);
0236 static int el3_close(struct net_device *dev);
0237 static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue);
0238 static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
0239 static void set_rx_mode(struct net_device *dev);
0240 static void set_multicast_list(struct net_device *dev);
0241 
0242 static void tc574_detach(struct pcmcia_device *p_dev);
0243 
0244 /*
0245     tc574_attach() creates an "instance" of the driver, allocating
0246     local data structures for one device.  The device is registered
0247     with Card Services.
0248 */
0249 static const struct net_device_ops el3_netdev_ops = {
0250     .ndo_open       = el3_open,
0251     .ndo_stop       = el3_close,
0252     .ndo_start_xmit     = el3_start_xmit,
0253     .ndo_tx_timeout     = el3_tx_timeout,
0254     .ndo_get_stats      = el3_get_stats,
0255     .ndo_eth_ioctl      = el3_ioctl,
0256     .ndo_set_rx_mode    = set_multicast_list,
0257     .ndo_set_mac_address    = eth_mac_addr,
0258     .ndo_validate_addr  = eth_validate_addr,
0259 };
0260 
0261 static int tc574_probe(struct pcmcia_device *link)
0262 {
0263     struct el3_private *lp;
0264     struct net_device *dev;
0265 
0266     dev_dbg(&link->dev, "3c574_attach()\n");
0267 
0268     /* Create the PC card device object. */
0269     dev = alloc_etherdev(sizeof(struct el3_private));
0270     if (!dev)
0271         return -ENOMEM;
0272     lp = netdev_priv(dev);
0273     link->priv = dev;
0274     lp->p_dev = link;
0275 
0276     spin_lock_init(&lp->window_lock);
0277     link->resource[0]->end = 32;
0278     link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
0279     link->config_flags |= CONF_ENABLE_IRQ;
0280     link->config_index = 1;
0281 
0282     dev->netdev_ops = &el3_netdev_ops;
0283     dev->watchdog_timeo = TX_TIMEOUT;
0284 
0285     return tc574_config(link);
0286 }
0287 
0288 static void tc574_detach(struct pcmcia_device *link)
0289 {
0290     struct net_device *dev = link->priv;
0291 
0292     dev_dbg(&link->dev, "3c574_detach()\n");
0293 
0294     unregister_netdev(dev);
0295 
0296     tc574_release(link);
0297 
0298     free_netdev(dev);
0299 } /* tc574_detach */
0300 
0301 static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
0302 
0303 static int tc574_config(struct pcmcia_device *link)
0304 {
0305     struct net_device *dev = link->priv;
0306     struct el3_private *lp = netdev_priv(dev);
0307     int ret, i, j;
0308     __be16 addr[ETH_ALEN / 2];
0309     unsigned int ioaddr;
0310     char *cardname;
0311     __u32 config;
0312     u8 *buf;
0313     size_t len;
0314 
0315     dev_dbg(&link->dev, "3c574_config()\n");
0316 
0317     link->io_lines = 16;
0318 
0319     for (i = j = 0; j < 0x400; j += 0x20) {
0320         link->resource[0]->start = j ^ 0x300;
0321         i = pcmcia_request_io(link);
0322         if (i == 0)
0323             break;
0324     }
0325     if (i != 0)
0326         goto failed;
0327 
0328     ret = pcmcia_request_irq(link, el3_interrupt);
0329     if (ret)
0330         goto failed;
0331 
0332     ret = pcmcia_enable_device(link);
0333     if (ret)
0334         goto failed;
0335 
0336     dev->irq = link->irq;
0337     dev->base_addr = link->resource[0]->start;
0338 
0339     ioaddr = dev->base_addr;
0340 
0341     /* The 3c574 normally uses an EEPROM for configuration info, including
0342        the hardware address.  The future products may include a modem chip
0343        and put the address in the CIS. */
0344 
0345     len = pcmcia_get_tuple(link, 0x88, &buf);
0346     if (buf && len >= 6) {
0347         for (i = 0; i < 3; i++)
0348             addr[i] = htons(le16_to_cpu(buf[i * 2]));
0349         kfree(buf);
0350     } else {
0351         kfree(buf); /* 0 < len < 6 */
0352         EL3WINDOW(0);
0353         for (i = 0; i < 3; i++)
0354             addr[i] = htons(read_eeprom(ioaddr, i + 10));
0355         if (addr[0] == htons(0x6060)) {
0356             pr_notice("IO port conflict at 0x%03lx-0x%03lx\n",
0357                   dev->base_addr, dev->base_addr+15);
0358             goto failed;
0359         }
0360     }
0361     eth_hw_addr_set(dev, (u8 *)addr);
0362     if (link->prod_id[1])
0363         cardname = link->prod_id[1];
0364     else
0365         cardname = "3Com 3c574";
0366 
0367     {
0368         u_char mcr;
0369         outw(2<<11, ioaddr + RunnerRdCtrl);
0370         mcr = inb(ioaddr + 2);
0371         outw(0<<11, ioaddr + RunnerRdCtrl);
0372         pr_info("  ASIC rev %d,", mcr>>3);
0373         EL3WINDOW(3);
0374         config = inl(ioaddr + Wn3_Config);
0375         lp->default_media = (config & Xcvr) >> Xcvr_shift;
0376         lp->autoselect = config & Autoselect ? 1 : 0;
0377     }
0378 
0379     timer_setup(&lp->media, media_check, 0);
0380 
0381     {
0382         int phy;
0383         
0384         /* Roadrunner only: Turn on the MII transceiver */
0385         outw(0x8040, ioaddr + Wn3_Options);
0386         mdelay(1);
0387         outw(0xc040, ioaddr + Wn3_Options);
0388         tc574_wait_for_completion(dev, TxReset);
0389         tc574_wait_for_completion(dev, RxReset);
0390         mdelay(1);
0391         outw(0x8040, ioaddr + Wn3_Options);
0392         
0393         EL3WINDOW(4);
0394         for (phy = 1; phy <= 32; phy++) {
0395             int mii_status;
0396             mdio_sync(ioaddr, 32);
0397             mii_status = mdio_read(ioaddr, phy & 0x1f, 1);
0398             if (mii_status != 0xffff) {
0399                 lp->phys = phy & 0x1f;
0400                 dev_dbg(&link->dev, "  MII transceiver at "
0401                     "index %d, status %x.\n",
0402                       phy, mii_status);
0403                 if ((mii_status & 0x0040) == 0)
0404                     mii_preamble_required = 1;
0405                 break;
0406             }
0407         }
0408         if (phy > 32) {
0409             pr_notice("  No MII transceivers found!\n");
0410             goto failed;
0411         }
0412         i = mdio_read(ioaddr, lp->phys, 16) | 0x40;
0413         mdio_write(ioaddr, lp->phys, 16, i);
0414         lp->advertising = mdio_read(ioaddr, lp->phys, 4);
0415         if (full_duplex) {
0416             /* Only advertise the FD media types. */
0417             lp->advertising &= ~0x02a0;
0418             mdio_write(ioaddr, lp->phys, 4, lp->advertising);
0419         }
0420     }
0421 
0422     SET_NETDEV_DEV(dev, &link->dev);
0423 
0424     if (register_netdev(dev) != 0) {
0425         pr_notice("register_netdev() failed\n");
0426         goto failed;
0427     }
0428 
0429     netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n",
0430             cardname, dev->base_addr, dev->irq, dev->dev_addr);
0431     netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n",
0432             8 << (config & Ram_size),
0433             ram_split[(config & Ram_split) >> Ram_split_shift],
0434             config & Autoselect ? "autoselect " : "");
0435 
0436     return 0;
0437 
0438 failed:
0439     tc574_release(link);
0440     return -ENODEV;
0441 
0442 } /* tc574_config */
0443 
0444 static void tc574_release(struct pcmcia_device *link)
0445 {
0446     pcmcia_disable_device(link);
0447 }
0448 
0449 static int tc574_suspend(struct pcmcia_device *link)
0450 {
0451     struct net_device *dev = link->priv;
0452 
0453     if (link->open)
0454         netif_device_detach(dev);
0455 
0456     return 0;
0457 }
0458 
0459 static int tc574_resume(struct pcmcia_device *link)
0460 {
0461     struct net_device *dev = link->priv;
0462 
0463     if (link->open) {
0464         tc574_reset(dev);
0465         netif_device_attach(dev);
0466     }
0467 
0468     return 0;
0469 }
0470 
0471 static void dump_status(struct net_device *dev)
0472 {
0473     unsigned int ioaddr = dev->base_addr;
0474     EL3WINDOW(1);
0475     netdev_info(dev, "  irq status %04x, rx status %04x, tx status %02x, tx free %04x\n",
0476             inw(ioaddr+EL3_STATUS),
0477             inw(ioaddr+RxStatus), inb(ioaddr+TxStatus),
0478             inw(ioaddr+TxFree));
0479     EL3WINDOW(4);
0480     netdev_info(dev, "  diagnostics: fifo %04x net %04x ethernet %04x media %04x\n",
0481             inw(ioaddr+0x04), inw(ioaddr+0x06),
0482             inw(ioaddr+0x08), inw(ioaddr+0x0a));
0483     EL3WINDOW(1);
0484 }
0485 
0486 /*
0487   Use this for commands that may take time to finish
0488 */
0489 static void tc574_wait_for_completion(struct net_device *dev, int cmd)
0490 {
0491     int i = 1500;
0492     outw(cmd, dev->base_addr + EL3_CMD);
0493     while (--i > 0)
0494         if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break;
0495     if (i == 0)
0496         netdev_notice(dev, "command 0x%04x did not complete!\n", cmd);
0497 }
0498 
0499 /* Read a word from the EEPROM using the regular EEPROM access register.
0500    Assume that we are in register window zero.
0501  */
0502 static unsigned short read_eeprom(unsigned int ioaddr, int index)
0503 {
0504     int timer;
0505     outw(EEPROM_Read + index, ioaddr + Wn0EepromCmd);
0506     /* Pause for at least 162 usec for the read to take place. */
0507     for (timer = 1620; timer >= 0; timer--) {
0508         if ((inw(ioaddr + Wn0EepromCmd) & 0x8000) == 0)
0509             break;
0510     }
0511     return inw(ioaddr + Wn0EepromData);
0512 }
0513 
0514 /* MII transceiver control section.
0515    Read and write the MII registers using software-generated serial
0516    MDIO protocol.  See the MII specifications or DP83840A data sheet
0517    for details.
0518    The maxium data clock rate is 2.5 Mhz.  The timing is easily met by the
0519    slow PC card interface. */
0520 
0521 #define MDIO_SHIFT_CLK  0x01
0522 #define MDIO_DIR_WRITE  0x04
0523 #define MDIO_DATA_WRITE0 (0x00 | MDIO_DIR_WRITE)
0524 #define MDIO_DATA_WRITE1 (0x02 | MDIO_DIR_WRITE)
0525 #define MDIO_DATA_READ  0x02
0526 #define MDIO_ENB_IN     0x00
0527 
0528 /* Generate the preamble required for initial synchronization and
0529    a few older transceivers. */
0530 static void mdio_sync(unsigned int ioaddr, int bits)
0531 {
0532     unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
0533 
0534     /* Establish sync by sending at least 32 logic ones. */
0535     while (-- bits >= 0) {
0536         outw(MDIO_DATA_WRITE1, mdio_addr);
0537         outw(MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
0538     }
0539 }
0540 
0541 static int mdio_read(unsigned int ioaddr, int phy_id, int location)
0542 {
0543     int i;
0544     int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
0545     unsigned int retval = 0;
0546     unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
0547 
0548     if (mii_preamble_required)
0549         mdio_sync(ioaddr, 32);
0550 
0551     /* Shift the read command bits out. */
0552     for (i = 14; i >= 0; i--) {
0553         int dataval = (read_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
0554         outw(dataval, mdio_addr);
0555         outw(dataval | MDIO_SHIFT_CLK, mdio_addr);
0556     }
0557     /* Read the two transition, 16 data, and wire-idle bits. */
0558     for (i = 19; i > 0; i--) {
0559         outw(MDIO_ENB_IN, mdio_addr);
0560         retval = (retval << 1) | ((inw(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
0561         outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
0562     }
0563     return (retval>>1) & 0xffff;
0564 }
0565 
0566 static void mdio_write(unsigned int ioaddr, int phy_id, int location, int value)
0567 {
0568     int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) | value;
0569     unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
0570     int i;
0571 
0572     if (mii_preamble_required)
0573         mdio_sync(ioaddr, 32);
0574 
0575     /* Shift the command bits out. */
0576     for (i = 31; i >= 0; i--) {
0577         int dataval = (write_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
0578         outw(dataval, mdio_addr);
0579         outw(dataval | MDIO_SHIFT_CLK, mdio_addr);
0580     }
0581     /* Leave the interface idle. */
0582     for (i = 1; i >= 0; i--) {
0583         outw(MDIO_ENB_IN, mdio_addr);
0584         outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
0585     }
0586 }
0587 
0588 /* Reset and restore all of the 3c574 registers. */
0589 static void tc574_reset(struct net_device *dev)
0590 {
0591     struct el3_private *lp = netdev_priv(dev);
0592     int i;
0593     unsigned int ioaddr = dev->base_addr;
0594     unsigned long flags;
0595 
0596     tc574_wait_for_completion(dev, TotalReset|0x10);
0597 
0598     spin_lock_irqsave(&lp->window_lock, flags);
0599     /* Clear any transactions in progress. */
0600     outw(0, ioaddr + RunnerWrCtrl);
0601     outw(0, ioaddr + RunnerRdCtrl);
0602 
0603     /* Set the station address and mask. */
0604     EL3WINDOW(2);
0605     for (i = 0; i < 6; i++)
0606         outb(dev->dev_addr[i], ioaddr + i);
0607     for (; i < 12; i+=2)
0608         outw(0, ioaddr + i);
0609 
0610     /* Reset config options */
0611     EL3WINDOW(3);
0612     outb((dev->mtu > 1500 ? 0x40 : 0), ioaddr + Wn3_MAC_Ctrl);
0613     outl((lp->autoselect ? 0x01000000 : 0) | 0x0062001b,
0614          ioaddr + Wn3_Config);
0615     /* Roadrunner only: Turn on the MII transceiver. */
0616     outw(0x8040, ioaddr + Wn3_Options);
0617     mdelay(1);
0618     outw(0xc040, ioaddr + Wn3_Options);
0619     EL3WINDOW(1);
0620     spin_unlock_irqrestore(&lp->window_lock, flags);
0621     
0622     tc574_wait_for_completion(dev, TxReset);
0623     tc574_wait_for_completion(dev, RxReset);
0624     mdelay(1);
0625     spin_lock_irqsave(&lp->window_lock, flags);
0626     EL3WINDOW(3);
0627     outw(0x8040, ioaddr + Wn3_Options);
0628 
0629     /* Switch to the stats window, and clear all stats by reading. */
0630     outw(StatsDisable, ioaddr + EL3_CMD);
0631     EL3WINDOW(6);
0632     for (i = 0; i < 10; i++)
0633         inb(ioaddr + i);
0634     inw(ioaddr + 10);
0635     inw(ioaddr + 12);
0636     EL3WINDOW(4);
0637     inb(ioaddr + 12);
0638     inb(ioaddr + 13);
0639 
0640     /* .. enable any extra statistics bits.. */
0641     outw(0x0040, ioaddr + Wn4_NetDiag);
0642     
0643     EL3WINDOW(1);
0644     spin_unlock_irqrestore(&lp->window_lock, flags);
0645     
0646     /* .. re-sync MII and re-fill what NWay is advertising. */
0647     mdio_sync(ioaddr, 32);
0648     mdio_write(ioaddr, lp->phys, 4, lp->advertising);
0649     if (!auto_polarity) {
0650         /* works for TDK 78Q2120 series MII's */
0651         i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
0652         mdio_write(ioaddr, lp->phys, 16, i);
0653     }
0654 
0655     spin_lock_irqsave(&lp->window_lock, flags);
0656     /* Switch to register set 1 for normal use, just for TxFree. */
0657     set_rx_mode(dev);
0658     spin_unlock_irqrestore(&lp->window_lock, flags);
0659     outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */
0660     outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */
0661     outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */
0662     /* Allow status bits to be seen. */
0663     outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD);
0664     /* Ack all pending events, and set active indicator mask. */
0665     outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
0666          ioaddr + EL3_CMD);
0667     outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
0668          | AdapterFailure | RxEarly, ioaddr + EL3_CMD);
0669 }
0670 
0671 static int el3_open(struct net_device *dev)
0672 {
0673     struct el3_private *lp = netdev_priv(dev);
0674     struct pcmcia_device *link = lp->p_dev;
0675 
0676     if (!pcmcia_dev_present(link))
0677         return -ENODEV;
0678     
0679     link->open++;
0680     netif_start_queue(dev);
0681     
0682     tc574_reset(dev);
0683     lp->media.expires = jiffies + HZ;
0684     add_timer(&lp->media);
0685     
0686     dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
0687           dev->name, inw(dev->base_addr + EL3_STATUS));
0688     
0689     return 0;
0690 }
0691 
0692 static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue)
0693 {
0694     unsigned int ioaddr = dev->base_addr;
0695     
0696     netdev_notice(dev, "Transmit timed out!\n");
0697     dump_status(dev);
0698     dev->stats.tx_errors++;
0699     netif_trans_update(dev); /* prevent tx timeout */
0700     /* Issue TX_RESET and TX_START commands. */
0701     tc574_wait_for_completion(dev, TxReset);
0702     outw(TxEnable, ioaddr + EL3_CMD);
0703     netif_wake_queue(dev);
0704 }
0705 
0706 static void pop_tx_status(struct net_device *dev)
0707 {
0708     unsigned int ioaddr = dev->base_addr;
0709     int i;
0710     
0711     /* Clear the Tx status stack. */
0712     for (i = 32; i > 0; i--) {
0713         u_char tx_status = inb(ioaddr + TxStatus);
0714         if (!(tx_status & 0x84))
0715             break;
0716         /* reset transmitter on jabber error or underrun */
0717         if (tx_status & 0x30)
0718             tc574_wait_for_completion(dev, TxReset);
0719         if (tx_status & 0x38) {
0720             pr_debug("%s: transmit error: status 0x%02x\n",
0721                   dev->name, tx_status);
0722             outw(TxEnable, ioaddr + EL3_CMD);
0723             dev->stats.tx_aborted_errors++;
0724         }
0725         outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */
0726     }
0727 }
0728 
0729 static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
0730                     struct net_device *dev)
0731 {
0732     unsigned int ioaddr = dev->base_addr;
0733     struct el3_private *lp = netdev_priv(dev);
0734     unsigned long flags;
0735 
0736     pr_debug("%s: el3_start_xmit(length = %ld) called, "
0737           "status %4.4x.\n", dev->name, (long)skb->len,
0738           inw(ioaddr + EL3_STATUS));
0739 
0740     spin_lock_irqsave(&lp->window_lock, flags);
0741 
0742     dev->stats.tx_bytes += skb->len;
0743 
0744     /* Put out the doubleword header... */
0745     outw(skb->len, ioaddr + TX_FIFO);
0746     outw(0, ioaddr + TX_FIFO);
0747     /* ... and the packet rounded to a doubleword. */
0748     outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
0749 
0750     /* TxFree appears only in Window 1, not offset 0x1c. */
0751     if (inw(ioaddr + TxFree) <= 1536) {
0752         netif_stop_queue(dev);
0753         /* Interrupt us when the FIFO has room for max-sized packet. 
0754            The threshold is in units of dwords. */
0755         outw(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD);
0756     }
0757 
0758     pop_tx_status(dev);
0759     spin_unlock_irqrestore(&lp->window_lock, flags);
0760     dev_kfree_skb(skb);
0761     return NETDEV_TX_OK;
0762 }
0763 
0764 /* The EL3 interrupt handler. */
0765 static irqreturn_t el3_interrupt(int irq, void *dev_id)
0766 {
0767     struct net_device *dev = (struct net_device *) dev_id;
0768     struct el3_private *lp = netdev_priv(dev);
0769     unsigned int ioaddr;
0770     unsigned status;
0771     int work_budget = max_interrupt_work;
0772     int handled = 0;
0773 
0774     if (!netif_device_present(dev))
0775         return IRQ_NONE;
0776     ioaddr = dev->base_addr;
0777 
0778     pr_debug("%s: interrupt, status %4.4x.\n",
0779           dev->name, inw(ioaddr + EL3_STATUS));
0780 
0781     spin_lock(&lp->window_lock);
0782     
0783     while ((status = inw(ioaddr + EL3_STATUS)) &
0784            (IntLatch | RxComplete | RxEarly | StatsFull)) {
0785         if (!netif_device_present(dev) ||
0786             ((status & 0xe000) != 0x2000)) {
0787             pr_debug("%s: Interrupt from dead card\n", dev->name);
0788             break;
0789         }
0790 
0791         handled = 1;
0792 
0793         if (status & RxComplete)
0794             work_budget = el3_rx(dev, work_budget);
0795 
0796         if (status & TxAvailable) {
0797             pr_debug("  TX room bit was handled.\n");
0798             /* There's room in the FIFO for a full-sized packet. */
0799             outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
0800             netif_wake_queue(dev);
0801         }
0802 
0803         if (status & TxComplete)
0804             pop_tx_status(dev);
0805 
0806         if (status & (AdapterFailure | RxEarly | StatsFull)) {
0807             /* Handle all uncommon interrupts. */
0808             if (status & StatsFull)
0809                 update_stats(dev);
0810             if (status & RxEarly) {
0811                 work_budget = el3_rx(dev, work_budget);
0812                 outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
0813             }
0814             if (status & AdapterFailure) {
0815                 u16 fifo_diag;
0816                 EL3WINDOW(4);
0817                 fifo_diag = inw(ioaddr + Wn4_FIFODiag);
0818                 EL3WINDOW(1);
0819                 netdev_notice(dev, "adapter failure, FIFO diagnostic register %04x\n",
0820                           fifo_diag);
0821                 if (fifo_diag & 0x0400) {
0822                     /* Tx overrun */
0823                     tc574_wait_for_completion(dev, TxReset);
0824                     outw(TxEnable, ioaddr + EL3_CMD);
0825                 }
0826                 if (fifo_diag & 0x2000) {
0827                     /* Rx underrun */
0828                     tc574_wait_for_completion(dev, RxReset);
0829                     set_rx_mode(dev);
0830                     outw(RxEnable, ioaddr + EL3_CMD);
0831                 }
0832                 outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD);
0833             }
0834         }
0835 
0836         if (--work_budget < 0) {
0837             pr_debug("%s: Too much work in interrupt, "
0838                   "status %4.4x.\n", dev->name, status);
0839             /* Clear all interrupts */
0840             outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
0841             break;
0842         }
0843         /* Acknowledge the IRQ. */
0844         outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
0845     }
0846 
0847     pr_debug("%s: exiting interrupt, status %4.4x.\n",
0848           dev->name, inw(ioaddr + EL3_STATUS));
0849           
0850     spin_unlock(&lp->window_lock);
0851     return IRQ_RETVAL(handled);
0852 }
0853 
0854 /*
0855     This timer serves two purposes: to check for missed interrupts
0856     (and as a last resort, poll the NIC for events), and to monitor
0857     the MII, reporting changes in cable status.
0858 */
0859 static void media_check(struct timer_list *t)
0860 {
0861     struct el3_private *lp = from_timer(lp, t, media);
0862     struct net_device *dev = lp->p_dev->priv;
0863     unsigned int ioaddr = dev->base_addr;
0864     unsigned long flags;
0865     unsigned short /* cable, */ media, partner;
0866 
0867     if (!netif_device_present(dev))
0868         goto reschedule;
0869     
0870     /* Check for pending interrupt with expired latency timer: with
0871        this, we can limp along even if the interrupt is blocked */
0872     if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
0873         if (!lp->fast_poll)
0874             netdev_info(dev, "interrupt(s) dropped!\n");
0875 
0876         local_irq_save(flags);
0877         el3_interrupt(dev->irq, dev);
0878         local_irq_restore(flags);
0879 
0880         lp->fast_poll = HZ;
0881     }
0882     if (lp->fast_poll) {
0883         lp->fast_poll--;
0884         lp->media.expires = jiffies + 2*HZ/100;
0885         add_timer(&lp->media);
0886         return;
0887     }
0888 
0889     spin_lock_irqsave(&lp->window_lock, flags);
0890     EL3WINDOW(4);
0891     media = mdio_read(ioaddr, lp->phys, 1);
0892     partner = mdio_read(ioaddr, lp->phys, 5);
0893     EL3WINDOW(1);
0894     
0895     if (media != lp->media_status) {
0896         if ((media ^ lp->media_status) & 0x0004)
0897             netdev_info(dev, "%s link beat\n",
0898                     (lp->media_status & 0x0004) ? "lost" : "found");
0899         if ((media ^ lp->media_status) & 0x0020) {
0900             lp->partner = 0;
0901             if (lp->media_status & 0x0020) {
0902                 netdev_info(dev, "autonegotiation restarted\n");
0903             } else if (partner) {
0904                 partner &= lp->advertising;
0905                 lp->partner = partner;
0906                 netdev_info(dev, "autonegotiation complete: "
0907                         "%dbaseT-%cD selected\n",
0908                         (partner & 0x0180) ? 100 : 10,
0909                         (partner & 0x0140) ? 'F' : 'H');
0910             } else {
0911                 netdev_info(dev, "link partner did not autonegotiate\n");
0912             }
0913 
0914             EL3WINDOW(3);
0915             outb((partner & 0x0140 ? 0x20 : 0) |
0916                  (dev->mtu > 1500 ? 0x40 : 0), ioaddr + Wn3_MAC_Ctrl);
0917             EL3WINDOW(1);
0918 
0919         }
0920         if (media & 0x0010)
0921             netdev_info(dev, "remote fault detected\n");
0922         if (media & 0x0002)
0923             netdev_info(dev, "jabber detected\n");
0924         lp->media_status = media;
0925     }
0926     spin_unlock_irqrestore(&lp->window_lock, flags);
0927 
0928 reschedule:
0929     lp->media.expires = jiffies + HZ;
0930     add_timer(&lp->media);
0931 }
0932 
0933 static struct net_device_stats *el3_get_stats(struct net_device *dev)
0934 {
0935     struct el3_private *lp = netdev_priv(dev);
0936 
0937     if (netif_device_present(dev)) {
0938         unsigned long flags;
0939         spin_lock_irqsave(&lp->window_lock, flags);
0940         update_stats(dev);
0941         spin_unlock_irqrestore(&lp->window_lock, flags);
0942     }
0943     return &dev->stats;
0944 }
0945 
0946 /*  Update statistics.
0947     Surprisingly this need not be run single-threaded, but it effectively is.
0948     The counters clear when read, so the adds must merely be atomic.
0949  */
0950 static void update_stats(struct net_device *dev)
0951 {
0952     unsigned int ioaddr = dev->base_addr;
0953     u8 up;
0954 
0955     pr_debug("%s: updating the statistics.\n", dev->name);
0956 
0957     if (inw(ioaddr+EL3_STATUS) == 0xffff) /* No card. */
0958         return;
0959         
0960     /* Unlike the 3c509 we need not turn off stats updates while reading. */
0961     /* Switch to the stats window, and read everything. */
0962     EL3WINDOW(6);
0963     dev->stats.tx_carrier_errors        += inb(ioaddr + 0);
0964     dev->stats.tx_heartbeat_errors      += inb(ioaddr + 1);
0965     /* Multiple collisions. */      inb(ioaddr + 2);
0966     dev->stats.collisions           += inb(ioaddr + 3);
0967     dev->stats.tx_window_errors     += inb(ioaddr + 4);
0968     dev->stats.rx_fifo_errors       += inb(ioaddr + 5);
0969     dev->stats.tx_packets           += inb(ioaddr + 6);
0970     up                   = inb(ioaddr + 9);
0971     dev->stats.tx_packets           += (up&0x30) << 4;
0972     /* Rx packets   */             inb(ioaddr + 7);
0973     /* Tx deferrals */             inb(ioaddr + 8);
0974     /* rx */                   inw(ioaddr + 10);
0975     /* tx */                   inw(ioaddr + 12);
0976 
0977     EL3WINDOW(4);
0978     /* BadSSD */                   inb(ioaddr + 12);
0979     up                   = inb(ioaddr + 13);
0980 
0981     EL3WINDOW(1);
0982 }
0983 
0984 static int el3_rx(struct net_device *dev, int worklimit)
0985 {
0986     unsigned int ioaddr = dev->base_addr;
0987     short rx_status;
0988     
0989     pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
0990           dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RxStatus));
0991     while (!((rx_status = inw(ioaddr + RxStatus)) & 0x8000) &&
0992             worklimit > 0) {
0993         worklimit--;
0994         if (rx_status & 0x4000) { /* Error, update stats. */
0995             short error = rx_status & 0x3800;
0996             dev->stats.rx_errors++;
0997             switch (error) {
0998             case 0x0000:    dev->stats.rx_over_errors++; break;
0999             case 0x0800:    dev->stats.rx_length_errors++; break;
1000             case 0x1000:    dev->stats.rx_frame_errors++; break;
1001             case 0x1800:    dev->stats.rx_length_errors++; break;
1002             case 0x2000:    dev->stats.rx_frame_errors++; break;
1003             case 0x2800:    dev->stats.rx_crc_errors++; break;
1004             }
1005         } else {
1006             short pkt_len = rx_status & 0x7ff;
1007             struct sk_buff *skb;
1008 
1009             skb = netdev_alloc_skb(dev, pkt_len + 5);
1010 
1011             pr_debug("  Receiving packet size %d status %4.4x.\n",
1012                   pkt_len, rx_status);
1013             if (skb != NULL) {
1014                 skb_reserve(skb, 2);
1015                 insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len),
1016                         ((pkt_len+3)>>2));
1017                 skb->protocol = eth_type_trans(skb, dev);
1018                 netif_rx(skb);
1019                 dev->stats.rx_packets++;
1020                 dev->stats.rx_bytes += pkt_len;
1021             } else {
1022                 pr_debug("%s: couldn't allocate a sk_buff of"
1023                       " size %d.\n", dev->name, pkt_len);
1024                 dev->stats.rx_dropped++;
1025             }
1026         }
1027         tc574_wait_for_completion(dev, RxDiscard);
1028     }
1029 
1030     return worklimit;
1031 }
1032 
1033 /* Provide ioctl() calls to examine the MII xcvr state. */
1034 static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1035 {
1036     struct el3_private *lp = netdev_priv(dev);
1037     unsigned int ioaddr = dev->base_addr;
1038     struct mii_ioctl_data *data = if_mii(rq);
1039     int phy = lp->phys & 0x1f;
1040 
1041     pr_debug("%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n",
1042           dev->name, rq->ifr_ifrn.ifrn_name, cmd,
1043           data->phy_id, data->reg_num, data->val_in, data->val_out);
1044 
1045     switch(cmd) {
1046     case SIOCGMIIPHY:       /* Get the address of the PHY in use. */
1047         data->phy_id = phy;
1048         fallthrough;
1049     case SIOCGMIIREG:       /* Read the specified MII register. */
1050         {
1051             int saved_window;
1052             unsigned long flags;
1053 
1054             spin_lock_irqsave(&lp->window_lock, flags);
1055             saved_window = inw(ioaddr + EL3_CMD) >> 13;
1056             EL3WINDOW(4);
1057             data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f,
1058                           data->reg_num & 0x1f);
1059             EL3WINDOW(saved_window);
1060             spin_unlock_irqrestore(&lp->window_lock, flags);
1061             return 0;
1062         }
1063     case SIOCSMIIREG:       /* Write the specified MII register */
1064         {
1065             int saved_window;
1066                        unsigned long flags;
1067 
1068             spin_lock_irqsave(&lp->window_lock, flags);
1069             saved_window = inw(ioaddr + EL3_CMD) >> 13;
1070             EL3WINDOW(4);
1071             mdio_write(ioaddr, data->phy_id & 0x1f,
1072                    data->reg_num & 0x1f, data->val_in);
1073             EL3WINDOW(saved_window);
1074             spin_unlock_irqrestore(&lp->window_lock, flags);
1075             return 0;
1076         }
1077     default:
1078         return -EOPNOTSUPP;
1079     }
1080 }
1081 
1082 /* The Odie chip has a 64 bin multicast filter, but the bit layout is not
1083    documented.  Until it is we revert to receiving all multicast frames when
1084    any multicast reception is desired.
1085    Note: My other drivers emit a log message whenever promiscuous mode is
1086    entered to help detect password sniffers.  This is less desirable on
1087    typical PC card machines, so we omit the message.
1088    */
1089 
1090 static void set_rx_mode(struct net_device *dev)
1091 {
1092     unsigned int ioaddr = dev->base_addr;
1093 
1094     if (dev->flags & IFF_PROMISC)
1095         outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
1096              ioaddr + EL3_CMD);
1097     else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI))
1098         outw(SetRxFilter|RxStation|RxMulticast|RxBroadcast, ioaddr + EL3_CMD);
1099     else
1100         outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD);
1101 }
1102 
1103 static void set_multicast_list(struct net_device *dev)
1104 {
1105     struct el3_private *lp = netdev_priv(dev);
1106     unsigned long flags;
1107 
1108     spin_lock_irqsave(&lp->window_lock, flags);
1109     set_rx_mode(dev);
1110     spin_unlock_irqrestore(&lp->window_lock, flags);
1111 }
1112 
1113 static int el3_close(struct net_device *dev)
1114 {
1115     unsigned int ioaddr = dev->base_addr;
1116     struct el3_private *lp = netdev_priv(dev);
1117     struct pcmcia_device *link = lp->p_dev;
1118 
1119     dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
1120     
1121     if (pcmcia_dev_present(link)) {
1122         unsigned long flags;
1123 
1124         /* Turn off statistics ASAP.  We update lp->stats below. */
1125         outw(StatsDisable, ioaddr + EL3_CMD);
1126         
1127         /* Disable the receiver and transmitter. */
1128         outw(RxDisable, ioaddr + EL3_CMD);
1129         outw(TxDisable, ioaddr + EL3_CMD);
1130         
1131         /* Note: Switching to window 0 may disable the IRQ. */
1132         EL3WINDOW(0);
1133         spin_lock_irqsave(&lp->window_lock, flags);
1134         update_stats(dev);
1135         spin_unlock_irqrestore(&lp->window_lock, flags);
1136 
1137         /* force interrupts off */
1138         outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD);
1139     }
1140 
1141     link->open--;
1142     netif_stop_queue(dev);
1143     del_timer_sync(&lp->media);
1144 
1145     return 0;
1146 }
1147 
1148 static const struct pcmcia_device_id tc574_ids[] = {
1149     PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0574),
1150     PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
1151     PCMCIA_DEVICE_NULL,
1152 };
1153 MODULE_DEVICE_TABLE(pcmcia, tc574_ids);
1154 
1155 static struct pcmcia_driver tc574_driver = {
1156     .owner      = THIS_MODULE,
1157     .name       = "3c574_cs",
1158     .probe      = tc574_probe,
1159     .remove     = tc574_detach,
1160     .id_table       = tc574_ids,
1161     .suspend    = tc574_suspend,
1162     .resume     = tc574_resume,
1163 };
1164 module_pcmcia_driver(tc574_driver);