1 /* 3c574.c: A PCMCIA ethernet driver for the 3com 3c574 "RoadRunner".
4 Donald Becker, becker@scyld.com, (driver core) and
5 David Hinds, dahinds@users.sourceforge.net (from his PC card code).
6 Locking fixes (C) Copyright 2003 Red Hat Inc
8 This software may be used and distributed according to the terms of
9 the GNU General Public License, incorporated herein by reference.
11 This driver derives from Donald Becker's 3c509 core, which has the
13 Copyright 1993 United States Government as represented by the
14 Director, National Security Agency.
22 I. Board Compatibility
24 This device driver is designed for the 3Com 3c574 PC card Fast Ethernet
27 II. Board-specific settings
29 None -- PC cards are autoconfigured.
33 The 3c574 uses a Boomerang-style interface, without the bus-master capability.
34 See the Boomerang driver and documentation for most details.
36 IV. Notes and chip documentation.
38 Two added registers are used to enhance PIO performance, RunnerRdCtrl and
39 RunnerWrCtrl. These are 11 bit down-counters that are preloaded with the
40 count of word (16 bits) reads or writes the driver is about to do to the Rx
41 or Tx FIFO. The chip is then able to hide the internal-PCI-bus to PC-card
42 translation latency by buffering the I/O operations with an 8 word FIFO.
43 Note: No other chip accesses are permitted when this buffer is used.
45 A second enhancement is that both attribute and common memory space
46 0x0800-0x0fff can translated to the PIO FIFO. Thus memory operations (faster
47 with *some* PCcard bridges) may be used instead of I/O operations.
48 This is enabled by setting the 0x10 bit in the PCMCIA LAN COR.
50 Some slow PC card bridges work better if they never see a WAIT signal.
51 This is configured by setting the 0x20 bit in the PCMCIA LAN COR.
52 Only do this after testing that it is reliable and improves performance.
54 The upper five bits of RunnerRdCtrl are used to window into PCcard
55 configuration space registers. Window 0 is the regular Boomerang/Odie
56 register set, 1-5 are various PC card control registers, and 16-31 are
57 the (reversed!) CIS table.
59 A final note: writing the InternalConfig register in window 3 with an
60 invalid ramWidth is Very Bad.
64 http://www.scyld.com/expert/NWay.html
65 http://www.national.com/pf/DP/DP83840.html
67 Thanks to Terry Murphy of 3Com for providing development information for
68 earlier 3Com products.
72 #include <linux/module.h>
73 #include <linux/kernel.h>
74 #include <linux/init.h>
75 #include <linux/slab.h>
76 #include <linux/string.h>
77 #include <linux/timer.h>
78 #include <linux/interrupt.h>
80 #include <linux/delay.h>
81 #include <linux/netdevice.h>
82 #include <linux/etherdevice.h>
83 #include <linux/skbuff.h>
84 #include <linux/if_arp.h>
85 #include <linux/ioport.h>
86 #include <linux/ethtool.h>
88 #include <pcmcia/version.h>
89 #include <pcmcia/cs_types.h>
90 #include <pcmcia/cs.h>
91 #include <pcmcia/cistpl.h>
92 #include <pcmcia/cisreg.h>
93 #include <pcmcia/ciscode.h>
94 #include <pcmcia/ds.h>
95 #include <pcmcia/mem_op.h>
97 #include <asm/uaccess.h>
99 #include <asm/system.h>
100 #include <asm/bitops.h>
102 /*====================================================================*/
104 /* Module parameters */
106 MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
107 MODULE_DESCRIPTION("3Com 3c574 series PCMCIA ethernet driver");
108 MODULE_LICENSE("GPL");
110 #define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
112 /* Now-standard PC card module parameters. */
113 INT_MODULE_PARM(irq_mask
, 0xdeb8);
114 static int irq_list
[4] = { -1 };
115 MODULE_PARM(irq_list
, "1-4i");
117 /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
118 INT_MODULE_PARM(max_interrupt_work
, 32);
120 /* Force full duplex modes? */
121 INT_MODULE_PARM(full_duplex
, 0);
123 /* Autodetect link polarity reversal? */
124 INT_MODULE_PARM(auto_polarity
, 1);
127 INT_MODULE_PARM(pc_debug
, PCMCIA_DEBUG
);
128 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
129 static char *version
=
130 "3c574_cs.c 1.65ac1 2003/04/07 Donald Becker/David Hinds, becker@scyld.com.\n";
132 #define DEBUG(n, args...)
135 /*====================================================================*/
137 /* Time in jiffies before concluding the transmitter is hung. */
138 #define TX_TIMEOUT ((800*HZ)/1000)
140 /* To minimize the size of the driver source and make the driver more
141 readable not all constants are symbolically defined.
142 You'll need the manual if you want to understand driver details anyway. */
143 /* Offsets from base I/O address. */
144 #define EL3_DATA 0x00
146 #define EL3_STATUS 0x0e
148 #define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
150 /* The top five bits written to EL3_CMD are a command, the lower
151 11 bits are the parameter, if applicable. */
153 TotalReset
= 0<<11, SelectWindow
= 1<<11, StartCoax
= 2<<11,
154 RxDisable
= 3<<11, RxEnable
= 4<<11, RxReset
= 5<<11, RxDiscard
= 8<<11,
155 TxEnable
= 9<<11, TxDisable
= 10<<11, TxReset
= 11<<11,
156 FakeIntr
= 12<<11, AckIntr
= 13<<11, SetIntrEnb
= 14<<11,
157 SetStatusEnb
= 15<<11, SetRxFilter
= 16<<11, SetRxThreshold
= 17<<11,
158 SetTxThreshold
= 18<<11, SetTxStart
= 19<<11, StatsEnable
= 21<<11,
159 StatsDisable
= 22<<11, StopCoax
= 23<<11,
163 IntLatch
= 0x0001, AdapterFailure
= 0x0002, TxComplete
= 0x0004,
164 TxAvailable
= 0x0008, RxComplete
= 0x0010, RxEarly
= 0x0020,
165 IntReq
= 0x0040, StatsFull
= 0x0080, CmdBusy
= 0x1000 };
167 /* The SetRxFilter command accepts the following classes: */
169 RxStation
= 1, RxMulticast
= 2, RxBroadcast
= 4, RxProm
= 8
173 Wn0EepromCmd
= 10, Wn0EepromData
= 12, /* EEPROM command/address, data. */
174 IntrStatus
=0x0E, /* Valid in all windows. */
176 /* These assumes the larger EEPROM. */
177 enum Win0_EEPROM_cmds
{
178 EEPROM_Read
= 0x200, EEPROM_WRITE
= 0x100, EEPROM_ERASE
= 0x300,
179 EEPROM_EWENB
= 0x30, /* Enable erasing/writing for 10 msec. */
180 EEPROM_EWDIS
= 0x00, /* Disable EWENB before 10 msec timeout. */
183 /* Register window 1 offsets, the window used in normal operation.
184 On the "Odie" this window is always mapped at offsets 0x10-0x1f.
185 Except for TxFree, which is overlapped by RunnerWrCtrl. */
187 TX_FIFO
= 0x10, RX_FIFO
= 0x10, RxErrors
= 0x14,
188 RxStatus
= 0x18, Timer
=0x1A, TxStatus
= 0x1B,
189 TxFree
= 0x0C, /* Remaining free bytes in Tx buffer. */
190 RunnerRdCtrl
= 0x16, RunnerWrCtrl
= 0x1c,
193 enum Window3
{ /* Window 3: MAC/config bits. */
194 Wn3_Config
=0, Wn3_MAC_Ctrl
=6, Wn3_Options
=8,
198 struct w3_config_fields
{
199 unsigned int ram_size
:3, ram_width
:1, ram_speed
:2, rom_size
:2;
201 unsigned int ram_split
:2, pad18
:2, xcvr
:3, pad21
:1, autoselect
:1;
206 enum Window4
{ /* Window 4: Xcvr/media bits. */
207 Wn4_FIFODiag
= 4, Wn4_NetDiag
= 6, Wn4_PhysicalMgmt
=8, Wn4_Media
= 10,
210 #define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
215 struct net_device_stats stats
;
216 u16 advertising
, partner
; /* NWay media advertisement */
217 unsigned char phys
; /* MII device address */
218 unsigned int autoselect
:1, default_media
:3; /* Read from the EEPROM/Wn3_Config. */
219 /* for transceiver monitoring */
220 struct timer_list media
;
221 unsigned short media_status
;
222 unsigned short fast_poll
;
223 unsigned long last_irq
;
224 spinlock_t window_lock
; /* Guards the Window selection */
227 /* Set iff a MII transceiver on any interface requires mdio preamble.
228 This only set with the original DP83840 on older 3c905 boards, so the extra
229 code size of a per-interface flag is not worthwhile. */
230 static char mii_preamble_required
= 0;
232 /* Index of functions. */
234 static void tc574_config(dev_link_t
*link
);
235 static void tc574_release(unsigned long arg
);
236 static int tc574_event(event_t event
, int priority
,
237 event_callback_args_t
*args
);
239 static void mdio_sync(ioaddr_t ioaddr
, int bits
);
240 static int mdio_read(ioaddr_t ioaddr
, int phy_id
, int location
);
241 static void mdio_write(ioaddr_t ioaddr
, int phy_id
, int location
, int value
);
242 static unsigned short read_eeprom(ioaddr_t ioaddr
, int index
);
243 static void tc574_wait_for_completion(struct net_device
*dev
, int cmd
);
245 static void tc574_reset(struct net_device
*dev
);
246 static void media_check(unsigned long arg
);
247 static int el3_open(struct net_device
*dev
);
248 static int el3_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
249 static irqreturn_t
el3_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
250 static void update_stats(struct net_device
*dev
);
251 static struct net_device_stats
*el3_get_stats(struct net_device
*dev
);
252 static int el3_rx(struct net_device
*dev
, int worklimit
);
253 static int el3_close(struct net_device
*dev
);
254 static void el3_tx_timeout(struct net_device
*dev
);
255 static int el3_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
);
256 static void set_rx_mode(struct net_device
*dev
);
258 static dev_info_t dev_info
= "3c574_cs";
260 static dev_link_t
*tc574_attach(void);
261 static void tc574_detach(dev_link_t
*);
263 static dev_link_t
*dev_list
;
265 static void flush_stale_links(void)
267 dev_link_t
*link
, *next
;
268 for (link
= dev_list
; link
; link
= next
) {
270 if (link
->state
& DEV_STALE_LINK
)
276 tc574_attach() creates an "instance" of the driver, allocating
277 local data structures for one device. The device is registered
281 static dev_link_t
*tc574_attach(void)
283 struct el3_private
*lp
;
284 client_reg_t client_reg
;
286 struct net_device
*dev
;
289 DEBUG(0, "3c574_attach()\n");
292 /* Create the PC card device object. */
293 dev
= alloc_etherdev(sizeof(struct el3_private
));
300 init_timer(&link
->release
);
301 link
->release
.function
= &tc574_release
;
302 link
->release
.data
= (unsigned long)link
;
303 link
->io
.NumPorts1
= 32;
304 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_16
;
305 link
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
306 link
->irq
.IRQInfo1
= IRQ_INFO2_VALID
|IRQ_LEVEL_ID
;
307 if (irq_list
[0] == -1)
308 link
->irq
.IRQInfo2
= irq_mask
;
310 for (i
= 0; i
< 4; i
++)
311 link
->irq
.IRQInfo2
|= 1 << irq_list
[i
];
312 link
->irq
.Handler
= &el3_interrupt
;
313 link
->irq
.Instance
= dev
;
314 link
->conf
.Attributes
= CONF_ENABLE_IRQ
;
316 link
->conf
.IntType
= INT_MEMORY_AND_IO
;
317 link
->conf
.ConfigIndex
= 1;
318 link
->conf
.Present
= PRESENT_OPTION
;
320 /* The EL3-specific entries in the device structure. */
321 dev
->hard_start_xmit
= &el3_start_xmit
;
322 dev
->get_stats
= &el3_get_stats
;
323 dev
->do_ioctl
= &el3_ioctl
;
324 dev
->set_multicast_list
= &set_rx_mode
;
325 dev
->open
= &el3_open
;
326 dev
->stop
= &el3_close
;
327 #ifdef HAVE_TX_TIMEOUT
328 dev
->tx_timeout
= el3_tx_timeout
;
329 dev
->watchdog_timeo
= TX_TIMEOUT
;
332 /* Register with Card Services */
333 link
->next
= dev_list
;
335 client_reg
.dev_info
= &dev_info
;
336 client_reg
.Attributes
= INFO_IO_CLIENT
| INFO_CARD_SHARE
;
337 client_reg
.EventMask
=
338 CS_EVENT_CARD_INSERTION
| CS_EVENT_CARD_REMOVAL
|
339 CS_EVENT_RESET_PHYSICAL
| CS_EVENT_CARD_RESET
|
340 CS_EVENT_PM_SUSPEND
| CS_EVENT_PM_RESUME
;
341 client_reg
.event_handler
= &tc574_event
;
342 client_reg
.Version
= 0x0210;
343 client_reg
.event_callback_args
.client_data
= link
;
344 ret
= CardServices(RegisterClient
, &link
->handle
, &client_reg
);
346 cs_error(link
->handle
, RegisterClient
, ret
);
356 This deletes a driver "instance". The device is de-registered
357 with Card Services. If it has been released, all local data
358 structures are freed. Otherwise, the structures will be freed
359 when the device is released.
363 static void tc574_detach(dev_link_t
*link
)
365 struct net_device
*dev
= link
->priv
;
368 DEBUG(0, "3c574_detach(0x%p)\n", link
);
370 /* Locate device structure */
371 for (linkp
= &dev_list
; *linkp
; linkp
= &(*linkp
)->next
)
372 if (*linkp
== link
) break;
376 del_timer_sync(&link
->release
);
377 if (link
->state
& DEV_CONFIG
) {
378 tc574_release((unsigned long)link
);
379 if (link
->state
& DEV_STALE_CONFIG
) {
380 link
->state
|= DEV_STALE_LINK
;
386 CardServices(DeregisterClient
, link
->handle
);
388 /* Unlink device structure, free bits */
391 unregister_netdev(dev
);
397 tc574_config() is scheduled to run after a CARD_INSERTION event
398 is received, to configure the PCMCIA socket, and to make the
399 ethernet device available to the system.
402 #define CS_CHECK(fn, args...) \
403 while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
405 static void tc574_config(dev_link_t
*link
)
407 client_handle_t handle
= link
->handle
;
408 struct net_device
*dev
= link
->priv
;
409 struct el3_private
*lp
= dev
->priv
;
412 unsigned short buf
[32];
413 int last_fn
, last_ret
, i
, j
;
418 phys_addr
= (u16
*)dev
->dev_addr
;
420 DEBUG(0, "3c574_config(0x%p)\n", link
);
422 tuple
.Attributes
= 0;
423 tuple
.DesiredTuple
= CISTPL_CONFIG
;
424 CS_CHECK(GetFirstTuple
, handle
, &tuple
);
425 tuple
.TupleData
= (cisdata_t
*)buf
;
426 tuple
.TupleDataMax
= 64;
427 tuple
.TupleOffset
= 0;
428 CS_CHECK(GetTupleData
, handle
, &tuple
);
429 CS_CHECK(ParseTuple
, handle
, &tuple
, &parse
);
430 link
->conf
.ConfigBase
= parse
.config
.base
;
431 link
->conf
.Present
= parse
.config
.rmask
[0];
434 link
->state
|= DEV_CONFIG
;
436 link
->io
.IOAddrLines
= 16;
437 for (i
= j
= 0; j
< 0x400; j
+= 0x20) {
438 link
->io
.BasePort1
= j
^ 0x300;
439 i
= CardServices(RequestIO
, link
->handle
, &link
->io
);
440 if (i
== CS_SUCCESS
) break;
442 if (i
!= CS_SUCCESS
) {
443 cs_error(link
->handle
, RequestIO
, i
);
446 CS_CHECK(RequestIRQ
, link
->handle
, &link
->irq
);
447 CS_CHECK(RequestConfiguration
, link
->handle
, &link
->conf
);
449 dev
->irq
= link
->irq
.AssignedIRQ
;
450 dev
->base_addr
= link
->io
.BasePort1
;
452 if (register_netdev(dev
) != 0) {
453 printk(KERN_NOTICE
"3c574_cs: register_netdev() failed\n");
457 ioaddr
= dev
->base_addr
;
458 strcpy(lp
->node
.dev_name
, dev
->name
);
459 link
->dev
= &lp
->node
;
460 link
->state
&= ~DEV_CONFIG_PENDING
;
462 /* The 3c574 normally uses an EEPROM for configuration info, including
463 the hardware address. The future products may include a modem chip
464 and put the address in the CIS. */
465 tuple
.DesiredTuple
= 0x88;
466 if (CardServices(GetFirstTuple
, handle
, &tuple
) == CS_SUCCESS
) {
467 CardServices(GetTupleData
, handle
, &tuple
);
468 for (i
= 0; i
< 3; i
++)
469 phys_addr
[i
] = htons(buf
[i
]);
472 for (i
= 0; i
< 3; i
++)
473 phys_addr
[i
] = htons(read_eeprom(ioaddr
, i
+ 10));
474 if (phys_addr
[0] == 0x6060) {
475 printk(KERN_NOTICE
"3c574_cs: IO port conflict at 0x%03lx"
476 "-0x%03lx\n", dev
->base_addr
, dev
->base_addr
+15);
480 tuple
.DesiredTuple
= CISTPL_VERS_1
;
481 if (CardServices(GetFirstTuple
, handle
, &tuple
) == CS_SUCCESS
&&
482 CardServices(GetTupleData
, handle
, &tuple
) == CS_SUCCESS
&&
483 CardServices(ParseTuple
, handle
, &tuple
, &parse
) == CS_SUCCESS
) {
484 cardname
= parse
.version_1
.str
+ parse
.version_1
.ofs
[1];
486 cardname
= "3Com 3c574";
488 printk(KERN_INFO
"%s: %s at io %#3lx, irq %d, hw_addr ",
489 dev
->name
, cardname
, dev
->base_addr
, dev
->irq
);
491 for (i
= 0; i
< 6; i
++)
492 printk("%02X%s", dev
->dev_addr
[i
], ((i
<5) ? ":" : ".\n"));
495 u_char mcr
, *ram_split
[] = {"5:3", "3:1", "1:1", "3:5"};
496 union wn3_config config
;
497 outw(2<<11, ioaddr
+ RunnerRdCtrl
);
498 mcr
= inb(ioaddr
+ 2);
499 outw(0<<11, ioaddr
+ RunnerRdCtrl
);
500 printk(KERN_INFO
" ASIC rev %d,", mcr
>>3);
502 config
.i
= inl(ioaddr
+ Wn3_Config
);
503 printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n",
504 8 << config
.u
.ram_size
, ram_split
[config
.u
.ram_split
],
505 config
.u
.autoselect
? "autoselect " : "");
506 lp
->default_media
= config
.u
.xcvr
;
507 lp
->autoselect
= config
.u
.autoselect
;
510 init_timer(&lp
->media
);
515 /* Roadrunner only: Turn on the MII transceiver */
516 outw(0x8040, ioaddr
+ Wn3_Options
);
518 outw(0xc040, ioaddr
+ Wn3_Options
);
519 tc574_wait_for_completion(dev
, TxReset
);
520 tc574_wait_for_completion(dev
, RxReset
);
522 outw(0x8040, ioaddr
+ Wn3_Options
);
525 for (phy
= 1; phy
<= 32; phy
++) {
527 mdio_sync(ioaddr
, 32);
528 mii_status
= mdio_read(ioaddr
, phy
& 0x1f, 1);
529 if (mii_status
!= 0xffff) {
530 lp
->phys
= phy
& 0x1f;
531 DEBUG(0, " MII transceiver at index %d, status %x.\n",
533 if ((mii_status
& 0x0040) == 0)
534 mii_preamble_required
= 1;
539 printk(KERN_NOTICE
" No MII transceivers found!\n");
542 i
= mdio_read(ioaddr
, lp
->phys
, 16) | 0x40;
543 mdio_write(ioaddr
, lp
->phys
, 16, i
);
544 lp
->advertising
= mdio_read(ioaddr
, lp
->phys
, 4);
546 /* Only advertise the FD media types. */
547 lp
->advertising
&= ~0x02a0;
548 mdio_write(ioaddr
, lp
->phys
, 4, lp
->advertising
);
555 cs_error(link
->handle
, last_fn
, last_ret
);
557 tc574_release((unsigned long)link
);
563 After a card is removed, tc574_release() will unregister the net
564 device, and release the PCMCIA configuration. If the device is
565 still open, this will be postponed until it is closed.
568 static void tc574_release(unsigned long arg
)
570 dev_link_t
*link
= (dev_link_t
*)arg
;
572 DEBUG(0, "3c574_release(0x%p)\n", link
);
575 DEBUG(1, "3c574_cs: release postponed, '%s' still open\n",
576 link
->dev
->dev_name
);
577 link
->state
|= DEV_STALE_CONFIG
;
581 CardServices(ReleaseConfiguration
, link
->handle
);
582 CardServices(ReleaseIO
, link
->handle
, &link
->io
);
583 CardServices(ReleaseIRQ
, link
->handle
, &link
->irq
);
585 link
->state
&= ~DEV_CONFIG
;
587 } /* tc574_release */
590 The card status event handler. Mostly, this schedules other
591 stuff to run after an event is received. A CARD_REMOVAL event
592 also sets some flags to discourage the net drivers from trying
593 to talk to the card any more.
596 static int tc574_event(event_t event
, int priority
,
597 event_callback_args_t
*args
)
599 dev_link_t
*link
= args
->client_data
;
600 struct net_device
*dev
= link
->priv
;
602 DEBUG(1, "3c574_event(0x%06x)\n", event
);
605 case CS_EVENT_CARD_REMOVAL
:
606 link
->state
&= ~DEV_PRESENT
;
607 if (link
->state
& DEV_CONFIG
) {
608 netif_device_detach(dev
);
609 mod_timer(&link
->release
, jiffies
+ HZ
/20);
612 case CS_EVENT_CARD_INSERTION
:
613 link
->state
|= DEV_PRESENT
| DEV_CONFIG_PENDING
;
616 case CS_EVENT_PM_SUSPEND
:
617 link
->state
|= DEV_SUSPEND
;
618 /* Fall through... */
619 case CS_EVENT_RESET_PHYSICAL
:
620 if (link
->state
& DEV_CONFIG
) {
622 netif_device_detach(dev
);
623 CardServices(ReleaseConfiguration
, link
->handle
);
626 case CS_EVENT_PM_RESUME
:
627 link
->state
&= ~DEV_SUSPEND
;
628 /* Fall through... */
629 case CS_EVENT_CARD_RESET
:
630 if (link
->state
& DEV_CONFIG
) {
631 CardServices(RequestConfiguration
, link
->handle
, &link
->conf
);
634 netif_device_attach(dev
);
642 static void dump_status(struct net_device
*dev
)
644 ioaddr_t ioaddr
= dev
->base_addr
;
646 printk(KERN_INFO
" irq status %04x, rx status %04x, tx status "
647 "%02x, tx free %04x\n", inw(ioaddr
+EL3_STATUS
),
648 inw(ioaddr
+RxStatus
), inb(ioaddr
+TxStatus
),
651 printk(KERN_INFO
" diagnostics: fifo %04x net %04x ethernet %04x"
652 " media %04x\n", inw(ioaddr
+0x04), inw(ioaddr
+0x06),
653 inw(ioaddr
+0x08), inw(ioaddr
+0x0a));
658 Use this for commands that may take time to finish
660 static void tc574_wait_for_completion(struct net_device
*dev
, int cmd
)
663 outw(cmd
, dev
->base_addr
+ EL3_CMD
);
665 if (!(inw(dev
->base_addr
+ EL3_STATUS
) & 0x1000)) break;
667 printk(KERN_NOTICE
"%s: command 0x%04x did not complete!\n", dev
->name
, cmd
);
670 /* Read a word from the EEPROM using the regular EEPROM access register.
671 Assume that we are in register window zero.
673 static unsigned short read_eeprom(ioaddr_t ioaddr
, int index
)
676 outw(EEPROM_Read
+ index
, ioaddr
+ Wn0EepromCmd
);
677 /* Pause for at least 162 usec for the read to take place. */
678 for (timer
= 1620; timer
>= 0; timer
--) {
679 if ((inw(ioaddr
+ Wn0EepromCmd
) & 0x8000) == 0)
682 return inw(ioaddr
+ Wn0EepromData
);
685 /* MII transceiver control section.
686 Read and write the MII registers using software-generated serial
687 MDIO protocol. See the MII specifications or DP83840A data sheet
689 The maxium data clock rate is 2.5 Mhz. The timing is easily met by the
690 slow PC card interface. */
692 #define MDIO_SHIFT_CLK 0x01
693 #define MDIO_DIR_WRITE 0x04
694 #define MDIO_DATA_WRITE0 (0x00 | MDIO_DIR_WRITE)
695 #define MDIO_DATA_WRITE1 (0x02 | MDIO_DIR_WRITE)
696 #define MDIO_DATA_READ 0x02
697 #define MDIO_ENB_IN 0x00
699 /* Generate the preamble required for initial synchronization and
700 a few older transceivers. */
701 static void mdio_sync(ioaddr_t ioaddr
, int bits
)
703 int mdio_addr
= ioaddr
+ Wn4_PhysicalMgmt
;
705 /* Establish sync by sending at least 32 logic ones. */
706 while (-- bits
>= 0) {
707 outw(MDIO_DATA_WRITE1
, mdio_addr
);
708 outw(MDIO_DATA_WRITE1
| MDIO_SHIFT_CLK
, mdio_addr
);
712 static int mdio_read(ioaddr_t ioaddr
, int phy_id
, int location
)
715 int read_cmd
= (0xf6 << 10) | (phy_id
<< 5) | location
;
716 unsigned int retval
= 0;
717 int mdio_addr
= ioaddr
+ Wn4_PhysicalMgmt
;
719 if (mii_preamble_required
)
720 mdio_sync(ioaddr
, 32);
722 /* Shift the read command bits out. */
723 for (i
= 14; i
>= 0; i
--) {
724 int dataval
= (read_cmd
&(1<<i
)) ? MDIO_DATA_WRITE1
: MDIO_DATA_WRITE0
;
725 outw(dataval
, mdio_addr
);
726 outw(dataval
| MDIO_SHIFT_CLK
, mdio_addr
);
728 /* Read the two transition, 16 data, and wire-idle bits. */
729 for (i
= 19; i
> 0; i
--) {
730 outw(MDIO_ENB_IN
, mdio_addr
);
731 retval
= (retval
<< 1) | ((inw(mdio_addr
) & MDIO_DATA_READ
) ? 1 : 0);
732 outw(MDIO_ENB_IN
| MDIO_SHIFT_CLK
, mdio_addr
);
734 return (retval
>>1) & 0xffff;
737 static void mdio_write(ioaddr_t ioaddr
, int phy_id
, int location
, int value
)
739 int write_cmd
= 0x50020000 | (phy_id
<< 23) | (location
<< 18) | value
;
740 int mdio_addr
= ioaddr
+ Wn4_PhysicalMgmt
;
743 if (mii_preamble_required
)
744 mdio_sync(ioaddr
, 32);
746 /* Shift the command bits out. */
747 for (i
= 31; i
>= 0; i
--) {
748 int dataval
= (write_cmd
&(1<<i
)) ? MDIO_DATA_WRITE1
: MDIO_DATA_WRITE0
;
749 outw(dataval
, mdio_addr
);
750 outw(dataval
| MDIO_SHIFT_CLK
, mdio_addr
);
752 /* Leave the interface idle. */
753 for (i
= 1; i
>= 0; i
--) {
754 outw(MDIO_ENB_IN
, mdio_addr
);
755 outw(MDIO_ENB_IN
| MDIO_SHIFT_CLK
, mdio_addr
);
761 /* Reset and restore all of the 3c574 registers. */
762 static void tc574_reset(struct net_device
*dev
)
764 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
765 int i
, ioaddr
= dev
->base_addr
;
768 tc574_wait_for_completion(dev
, TotalReset
|0x10);
770 spin_lock_irqsave(&lp
->window_lock
, flags
);
771 /* Clear any transactions in progress. */
772 outw(0, ioaddr
+ RunnerWrCtrl
);
773 outw(0, ioaddr
+ RunnerRdCtrl
);
775 /* Set the station address and mask. */
777 for (i
= 0; i
< 6; i
++)
778 outb(dev
->dev_addr
[i
], ioaddr
+ i
);
782 /* Reset config options */
784 outb((dev
->mtu
> 1500 ? 0x40 : 0), ioaddr
+ Wn3_MAC_Ctrl
);
785 outl((lp
->autoselect
? 0x01000000 : 0) | 0x0062001b,
786 ioaddr
+ Wn3_Config
);
787 /* Roadrunner only: Turn on the MII transceiver. */
788 outw(0x8040, ioaddr
+ Wn3_Options
);
790 outw(0xc040, ioaddr
+ Wn3_Options
);
792 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
794 tc574_wait_for_completion(dev
, TxReset
);
795 tc574_wait_for_completion(dev
, RxReset
);
797 spin_lock_irqsave(&lp
->window_lock
, flags
);
799 outw(0x8040, ioaddr
+ Wn3_Options
);
801 /* Switch to the stats window, and clear all stats by reading. */
802 outw(StatsDisable
, ioaddr
+ EL3_CMD
);
804 for (i
= 0; i
< 10; i
++)
812 /* .. enable any extra statistics bits.. */
813 outw(0x0040, ioaddr
+ Wn4_NetDiag
);
816 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
818 /* .. re-sync MII and re-fill what NWay is advertising. */
819 mdio_sync(ioaddr
, 32);
820 mdio_write(ioaddr
, lp
->phys
, 4, lp
->advertising
);
821 if (!auto_polarity
) {
822 /* works for TDK 78Q2120 series MII's */
823 int i
= mdio_read(ioaddr
, lp
->phys
, 16) | 0x20;
824 mdio_write(ioaddr
, lp
->phys
, 16, i
);
827 spin_lock_irqsave(&lp
->window_lock
, flags
);
828 /* Switch to register set 1 for normal use, just for TxFree. */
830 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
831 outw(StatsEnable
, ioaddr
+ EL3_CMD
); /* Turn on statistics. */
832 outw(RxEnable
, ioaddr
+ EL3_CMD
); /* Enable the receiver. */
833 outw(TxEnable
, ioaddr
+ EL3_CMD
); /* Enable transmitter. */
834 /* Allow status bits to be seen. */
835 outw(SetStatusEnb
| 0xff, ioaddr
+ EL3_CMD
);
836 /* Ack all pending events, and set active indicator mask. */
837 outw(AckIntr
| IntLatch
| TxAvailable
| RxEarly
| IntReq
,
839 outw(SetIntrEnb
| IntLatch
| TxAvailable
| RxComplete
| StatsFull
840 | AdapterFailure
| RxEarly
, ioaddr
+ EL3_CMD
);
843 static int el3_open(struct net_device
*dev
)
845 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
846 dev_link_t
*link
= &lp
->link
;
852 netif_start_queue(dev
);
855 lp
->media
.function
= &media_check
;
856 lp
->media
.data
= (unsigned long) dev
;
857 lp
->media
.expires
= jiffies
+ HZ
;
858 add_timer(&lp
->media
);
860 DEBUG(2, "%s: opened, status %4.4x.\n",
861 dev
->name
, inw(dev
->base_addr
+ EL3_STATUS
));
866 static void el3_tx_timeout(struct net_device
*dev
)
868 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
869 ioaddr_t ioaddr
= dev
->base_addr
;
871 printk(KERN_NOTICE
"%s: Transmit timed out!\n", dev
->name
);
873 lp
->stats
.tx_errors
++;
874 dev
->trans_start
= jiffies
;
875 /* Issue TX_RESET and TX_START commands. */
876 tc574_wait_for_completion(dev
, TxReset
);
877 outw(TxEnable
, ioaddr
+ EL3_CMD
);
878 netif_wake_queue(dev
);
881 static void pop_tx_status(struct net_device
*dev
)
883 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
884 ioaddr_t ioaddr
= dev
->base_addr
;
887 /* Clear the Tx status stack. */
888 for (i
= 32; i
> 0; i
--) {
889 u_char tx_status
= inb(ioaddr
+ TxStatus
);
890 if (!(tx_status
& 0x84))
892 /* reset transmitter on jabber error or underrun */
893 if (tx_status
& 0x30)
894 tc574_wait_for_completion(dev
, TxReset
);
895 if (tx_status
& 0x38) {
896 DEBUG(1, "%s: transmit error: status 0x%02x\n",
897 dev
->name
, tx_status
);
898 outw(TxEnable
, ioaddr
+ EL3_CMD
);
899 lp
->stats
.tx_aborted_errors
++;
901 outb(0x00, ioaddr
+ TxStatus
); /* Pop the status stack. */
905 static int el3_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
907 ioaddr_t ioaddr
= dev
->base_addr
;
908 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
911 DEBUG(3, "%s: el3_start_xmit(length = %ld) called, "
912 "status %4.4x.\n", dev
->name
, (long)skb
->len
,
913 inw(ioaddr
+ EL3_STATUS
));
915 spin_lock_irqsave(&lp
->window_lock
, flags
);
916 outw(skb
->len
, ioaddr
+ TX_FIFO
);
917 outw(0, ioaddr
+ TX_FIFO
);
918 outsl(ioaddr
+ TX_FIFO
, skb
->data
, (skb
->len
+3)>>2);
920 dev
->trans_start
= jiffies
;
922 /* TxFree appears only in Window 1, not offset 0x1c. */
923 if (inw(ioaddr
+ TxFree
) <= 1536) {
924 netif_stop_queue(dev
);
925 /* Interrupt us when the FIFO has room for max-sized packet.
926 The threshold is in units of dwords. */
927 outw(SetTxThreshold
+ (1536>>2), ioaddr
+ EL3_CMD
);
931 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
936 /* The EL3 interrupt handler. */
937 static irqreturn_t
el3_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
939 struct net_device
*dev
= (struct net_device
*) dev_id
;
940 struct el3_private
*lp
= dev
->priv
;
941 ioaddr_t ioaddr
, status
;
942 int work_budget
= max_interrupt_work
;
945 if (!netif_device_present(dev
))
947 ioaddr
= dev
->base_addr
;
949 DEBUG(3, "%s: interrupt, status %4.4x.\n",
950 dev
->name
, inw(ioaddr
+ EL3_STATUS
));
952 spin_lock(&lp
->window_lock
);
954 while ((status
= inw(ioaddr
+ EL3_STATUS
)) &
955 (IntLatch
| RxComplete
| RxEarly
| StatsFull
)) {
956 if (!netif_device_present(dev
) ||
957 ((status
& 0xe000) != 0x2000)) {
958 DEBUG(1, "%s: Interrupt from dead card\n", dev
->name
);
964 if (status
& RxComplete
)
965 work_budget
= el3_rx(dev
, work_budget
);
967 if (status
& TxAvailable
) {
968 DEBUG(3, " TX room bit was handled.\n");
969 /* There's room in the FIFO for a full-sized packet. */
970 outw(AckIntr
| TxAvailable
, ioaddr
+ EL3_CMD
);
971 netif_wake_queue(dev
);
974 if (status
& TxComplete
)
977 if (status
& (AdapterFailure
| RxEarly
| StatsFull
)) {
978 /* Handle all uncommon interrupts. */
979 if (status
& StatsFull
)
981 if (status
& RxEarly
) {
982 work_budget
= el3_rx(dev
, work_budget
);
983 outw(AckIntr
| RxEarly
, ioaddr
+ EL3_CMD
);
985 if (status
& AdapterFailure
) {
988 fifo_diag
= inw(ioaddr
+ Wn4_FIFODiag
);
990 printk(KERN_NOTICE
"%s: adapter failure, FIFO diagnostic"
991 " register %04x.\n", dev
->name
, fifo_diag
);
992 if (fifo_diag
& 0x0400) {
994 tc574_wait_for_completion(dev
, TxReset
);
995 outw(TxEnable
, ioaddr
+ EL3_CMD
);
997 if (fifo_diag
& 0x2000) {
999 tc574_wait_for_completion(dev
, RxReset
);
1001 outw(RxEnable
, ioaddr
+ EL3_CMD
);
1003 outw(AckIntr
| AdapterFailure
, ioaddr
+ EL3_CMD
);
1007 if (--work_budget
< 0) {
1008 DEBUG(0, "%s: Too much work in interrupt, "
1009 "status %4.4x.\n", dev
->name
, status
);
1010 /* Clear all interrupts */
1011 outw(AckIntr
| 0xFF, ioaddr
+ EL3_CMD
);
1014 /* Acknowledge the IRQ. */
1015 outw(AckIntr
| IntReq
| IntLatch
, ioaddr
+ EL3_CMD
);
1018 DEBUG(3, "%s: exiting interrupt, status %4.4x.\n",
1019 dev
->name
, inw(ioaddr
+ EL3_STATUS
));
1021 spin_unlock(&lp
->window_lock
);
1022 return IRQ_RETVAL(handled
);
1026 This timer serves two purposes: to check for missed interrupts
1027 (and as a last resort, poll the NIC for events), and to monitor
1028 the MII, reporting changes in cable status.
1030 static void media_check(unsigned long arg
)
1032 struct net_device
*dev
= (struct net_device
*) arg
;
1033 struct el3_private
*lp
= dev
->priv
;
1034 ioaddr_t ioaddr
= dev
->base_addr
;
1035 unsigned long flags
;
1036 unsigned short /* cable, */ media
, partner
;
1038 if (!netif_device_present(dev
))
1041 /* Check for pending interrupt with expired latency timer: with
1042 this, we can limp along even if the interrupt is blocked */
1043 if ((inw(ioaddr
+ EL3_STATUS
) & IntLatch
) && (inb(ioaddr
+ Timer
) == 0xff)) {
1045 printk(KERN_INFO
"%s: interrupt(s) dropped!\n", dev
->name
);
1046 el3_interrupt(dev
->irq
, lp
, NULL
);
1049 if (lp
->fast_poll
) {
1051 lp
->media
.expires
= jiffies
+ 2;
1052 add_timer(&lp
->media
);
1056 spin_lock_irqsave(&lp
->window_lock
, flags
);
1058 media
= mdio_read(ioaddr
, lp
->phys
, 1);
1059 partner
= mdio_read(ioaddr
, lp
->phys
, 5);
1062 if (media
!= lp
->media_status
) {
1063 if ((media
^ lp
->media_status
) & 0x0004)
1064 printk(KERN_INFO
"%s: %s link beat\n", dev
->name
,
1065 (lp
->media_status
& 0x0004) ? "lost" : "found");
1066 if ((media
^ lp
->media_status
) & 0x0020) {
1068 if (lp
->media_status
& 0x0020) {
1069 printk(KERN_INFO
"%s: autonegotiation restarted\n",
1071 } else if (partner
) {
1072 partner
&= lp
->advertising
;
1073 lp
->partner
= partner
;
1074 printk(KERN_INFO
"%s: autonegotiation complete: "
1075 "%sbaseT-%cD selected\n", dev
->name
,
1076 ((partner
& 0x0180) ? "100" : "10"),
1077 ((partner
& 0x0140) ? 'F' : 'H'));
1079 printk(KERN_INFO
"%s: link partner did not autonegotiate\n",
1084 outb((partner
& 0x0140 ? 0x20 : 0) |
1085 (dev
->mtu
> 1500 ? 0x40 : 0), ioaddr
+ Wn3_MAC_Ctrl
);
1090 printk(KERN_INFO
"%s: remote fault detected\n",
1093 printk(KERN_INFO
"%s: jabber detected\n", dev
->name
);
1094 lp
->media_status
= media
;
1096 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
1099 lp
->media
.expires
= jiffies
+ HZ
;
1100 add_timer(&lp
->media
);
1103 static struct net_device_stats
*el3_get_stats(struct net_device
*dev
)
1105 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
1107 if (netif_device_present(dev
))
1112 /* Update statistics.
1113 Suprisingly this need not be run single-threaded, but it effectively is.
1114 The counters clear when read, so the adds must merely be atomic.
1116 static void update_stats(struct net_device
*dev
)
1118 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
1119 ioaddr_t ioaddr
= dev
->base_addr
;
1120 unsigned long flags
;
1123 DEBUG(2, "%s: updating the statistics.\n", dev
->name
);
1125 if (inw(ioaddr
+EL3_STATUS
) == 0xffff) /* No card. */
1128 spin_lock_irqsave(&lp
->window_lock
, flags
);
1130 /* Unlike the 3c509 we need not turn off stats updates while reading. */
1131 /* Switch to the stats window, and read everything. */
1133 lp
->stats
.tx_carrier_errors
+= inb(ioaddr
+ 0);
1134 lp
->stats
.tx_heartbeat_errors
+= inb(ioaddr
+ 1);
1135 /* Multiple collisions. */ inb(ioaddr
+ 2);
1136 lp
->stats
.collisions
+= inb(ioaddr
+ 3);
1137 lp
->stats
.tx_window_errors
+= inb(ioaddr
+ 4);
1138 lp
->stats
.rx_fifo_errors
+= inb(ioaddr
+ 5);
1139 lp
->stats
.tx_packets
+= inb(ioaddr
+ 6);
1140 up
= inb(ioaddr
+ 9);
1141 lp
->stats
.tx_packets
+= (up
&0x30) << 4;
1142 /* Rx packets */ inb(ioaddr
+ 7);
1143 /* Tx deferrals */ inb(ioaddr
+ 8);
1144 rx
= inw(ioaddr
+ 10);
1145 tx
= inw(ioaddr
+ 12);
1148 /* BadSSD */ inb(ioaddr
+ 12);
1149 up
= inb(ioaddr
+ 13);
1151 lp
->stats
.tx_bytes
+= tx
+ ((up
& 0xf0) << 12);
1154 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
1157 static int el3_rx(struct net_device
*dev
, int worklimit
)
1159 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
1160 ioaddr_t ioaddr
= dev
->base_addr
;
1163 DEBUG(3, "%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
1164 dev
->name
, inw(ioaddr
+EL3_STATUS
), inw(ioaddr
+RxStatus
));
1165 while (!((rx_status
= inw(ioaddr
+ RxStatus
)) & 0x8000) &&
1166 (--worklimit
>= 0)) {
1167 if (rx_status
& 0x4000) { /* Error, update stats. */
1168 short error
= rx_status
& 0x3800;
1169 lp
->stats
.rx_errors
++;
1171 case 0x0000: lp
->stats
.rx_over_errors
++; break;
1172 case 0x0800: lp
->stats
.rx_length_errors
++; break;
1173 case 0x1000: lp
->stats
.rx_frame_errors
++; break;
1174 case 0x1800: lp
->stats
.rx_length_errors
++; break;
1175 case 0x2000: lp
->stats
.rx_frame_errors
++; break;
1176 case 0x2800: lp
->stats
.rx_crc_errors
++; break;
1179 short pkt_len
= rx_status
& 0x7ff;
1180 struct sk_buff
*skb
;
1182 skb
= dev_alloc_skb(pkt_len
+5);
1184 DEBUG(3, " Receiving packet size %d status %4.4x.\n",
1185 pkt_len
, rx_status
);
1188 skb_reserve(skb
, 2);
1189 insl(ioaddr
+RX_FIFO
, skb_put(skb
, pkt_len
),
1191 skb
->protocol
= eth_type_trans(skb
, dev
);
1193 dev
->last_rx
= jiffies
;
1194 lp
->stats
.rx_packets
++;
1195 lp
->stats
.rx_bytes
+= pkt_len
;
1197 DEBUG(1, "%s: couldn't allocate a sk_buff of"
1198 " size %d.\n", dev
->name
, pkt_len
);
1199 lp
->stats
.rx_dropped
++;
1202 tc574_wait_for_completion(dev
, RxDiscard
);
1208 static int netdev_ethtool_ioctl(struct net_device
*dev
, void *useraddr
)
1212 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1216 case ETHTOOL_GDRVINFO
: {
1217 struct ethtool_drvinfo info
= {ETHTOOL_GDRVINFO
};
1218 strncpy(info
.driver
, "3c574_cs", sizeof(info
.driver
)-1);
1219 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
1228 /* Provide ioctl() calls to examine the MII xcvr state. */
1229 static int el3_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
1231 struct el3_private
*lp
= (struct el3_private
*)dev
->priv
;
1232 ioaddr_t ioaddr
= dev
->base_addr
;
1233 u16
*data
= (u16
*)&rq
->ifr_data
;
1234 int phy
= lp
->phys
& 0x1f;
1236 DEBUG(2, "%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n",
1237 dev
->name
, rq
->ifr_ifrn
.ifrn_name
, cmd
,
1238 data
[0], data
[1], data
[2], data
[3]);
1242 return netdev_ethtool_ioctl(dev
, (void *)rq
->ifr_data
);
1243 case SIOCDEVPRIVATE
: /* Get the address of the PHY in use. */
1245 case SIOCDEVPRIVATE
+1: /* Read the specified MII register. */
1248 unsigned long flags
;
1250 spin_lock_irqsave(&lp
->window_lock
, flags
);
1251 saved_window
= inw(ioaddr
+ EL3_CMD
) >> 13;
1253 data
[3] = mdio_read(ioaddr
, data
[0] & 0x1f, data
[1] & 0x1f);
1254 EL3WINDOW(saved_window
);
1255 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
1258 case SIOCDEVPRIVATE
+2: /* Write the specified MII register */
1261 unsigned long flags
;
1263 if (!capable(CAP_NET_ADMIN
))
1265 spin_lock_irqsave(&lp
->window_lock
, flags
);
1266 saved_window
= inw(ioaddr
+ EL3_CMD
) >> 13;
1268 mdio_write(ioaddr
, data
[0] & 0x1f, data
[1] & 0x1f, data
[2]);
1269 EL3WINDOW(saved_window
);
1270 spin_unlock_irqrestore(&lp
->window_lock
, flags
);
1278 /* The Odie chip has a 64 bin multicast filter, but the bit layout is not
1279 documented. Until it is we revert to receiving all multicast frames when
1280 any multicast reception is desired.
1281 Note: My other drivers emit a log message whenever promiscuous mode is
1282 entered to help detect password sniffers. This is less desirable on
1283 typical PC card machines, so we omit the message.
1286 static void set_rx_mode(struct net_device
*dev
)
1288 ioaddr_t ioaddr
= dev
->base_addr
;
1290 if (dev
->flags
& IFF_PROMISC
)
1291 outw(SetRxFilter
| RxStation
| RxMulticast
| RxBroadcast
| RxProm
,
1293 else if (dev
->mc_count
|| (dev
->flags
& IFF_ALLMULTI
))
1294 outw(SetRxFilter
|RxStation
|RxMulticast
|RxBroadcast
, ioaddr
+ EL3_CMD
);
1296 outw(SetRxFilter
| RxStation
| RxBroadcast
, ioaddr
+ EL3_CMD
);
1299 static int el3_close(struct net_device
*dev
)
1301 ioaddr_t ioaddr
= dev
->base_addr
;
1302 struct el3_private
*lp
= dev
->priv
;
1303 dev_link_t
*link
= &lp
->link
;
1305 DEBUG(2, "%s: shutting down ethercard.\n", dev
->name
);
1308 /* Turn off statistics ASAP. We update lp->stats below. */
1309 outw(StatsDisable
, ioaddr
+ EL3_CMD
);
1311 /* Disable the receiver and transmitter. */
1312 outw(RxDisable
, ioaddr
+ EL3_CMD
);
1313 outw(TxDisable
, ioaddr
+ EL3_CMD
);
1315 /* Note: Switching to window 0 may disable the IRQ. */
1322 netif_stop_queue(dev
);
1323 del_timer_sync(&lp
->media
);
1324 if (link
->state
& DEV_STALE_CONFIG
)
1325 mod_timer(&link
->release
, jiffies
+ HZ
/20);
1329 static struct pcmcia_driver tc574_driver
= {
1330 .owner
= THIS_MODULE
,
1334 .attach
= tc574_attach
,
1335 .detach
= tc574_detach
,
1338 static int __init
init_tc574(void)
1340 return pcmcia_register_driver(&tc574_driver
);
1343 static void __exit
exit_tc574(void)
1345 pcmcia_unregister_driver(&tc574_driver
);
1346 while (dev_list
!= NULL
)
1347 tc574_detach(dev_list
);
1350 module_init(init_tc574
);
1351 module_exit(exit_tc574
);