2005-04-17 06:20:36 +08:00
|
|
|
/* 3c574.c: A PCMCIA ethernet driver for the 3com 3c574 "RoadRunner".
|
|
|
|
|
|
|
|
Written 1993-1998 by
|
|
|
|
Donald Becker, becker@scyld.com, (driver core) and
|
|
|
|
David Hinds, dahinds@users.sourceforge.net (from his PC card code).
|
|
|
|
Locking fixes (C) Copyright 2003 Red Hat Inc
|
|
|
|
|
|
|
|
This software may be used and distributed according to the terms of
|
|
|
|
the GNU General Public License, incorporated herein by reference.
|
|
|
|
|
|
|
|
This driver derives from Donald Becker's 3c509 core, which has the
|
|
|
|
following copyright:
|
|
|
|
Copyright 1993 United States Government as represented by the
|
|
|
|
Director, National Security Agency.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Theory of Operation
|
|
|
|
|
|
|
|
I. Board Compatibility
|
|
|
|
|
|
|
|
This device driver is designed for the 3Com 3c574 PC card Fast Ethernet
|
|
|
|
Adapter.
|
|
|
|
|
|
|
|
II. Board-specific settings
|
|
|
|
|
|
|
|
None -- PC cards are autoconfigured.
|
|
|
|
|
|
|
|
III. Driver operation
|
|
|
|
|
|
|
|
The 3c574 uses a Boomerang-style interface, without the bus-master capability.
|
|
|
|
See the Boomerang driver and documentation for most details.
|
|
|
|
|
|
|
|
IV. Notes and chip documentation.
|
|
|
|
|
|
|
|
Two added registers are used to enhance PIO performance, RunnerRdCtrl and
|
|
|
|
RunnerWrCtrl. These are 11 bit down-counters that are preloaded with the
|
|
|
|
count of word (16 bits) reads or writes the driver is about to do to the Rx
|
|
|
|
or Tx FIFO. The chip is then able to hide the internal-PCI-bus to PC-card
|
|
|
|
translation latency by buffering the I/O operations with an 8 word FIFO.
|
|
|
|
Note: No other chip accesses are permitted when this buffer is used.
|
|
|
|
|
|
|
|
A second enhancement is that both attribute and common memory space
|
|
|
|
0x0800-0x0fff can translated to the PIO FIFO. Thus memory operations (faster
|
|
|
|
with *some* PCcard bridges) may be used instead of I/O operations.
|
|
|
|
This is enabled by setting the 0x10 bit in the PCMCIA LAN COR.
|
|
|
|
|
|
|
|
Some slow PC card bridges work better if they never see a WAIT signal.
|
|
|
|
This is configured by setting the 0x20 bit in the PCMCIA LAN COR.
|
|
|
|
Only do this after testing that it is reliable and improves performance.
|
|
|
|
|
|
|
|
The upper five bits of RunnerRdCtrl are used to window into PCcard
|
|
|
|
configuration space registers. Window 0 is the regular Boomerang/Odie
|
|
|
|
register set, 1-5 are various PC card control registers, and 16-31 are
|
|
|
|
the (reversed!) CIS table.
|
|
|
|
|
|
|
|
A final note: writing the InternalConfig register in window 3 with an
|
|
|
|
invalid ramWidth is Very Bad.
|
|
|
|
|
|
|
|
V. References
|
|
|
|
|
|
|
|
http://www.scyld.com/expert/NWay.html
|
2010-10-18 17:03:14 +08:00
|
|
|
http://www.national.com/opf/DP/DP83840A.html
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
Thanks to Terry Murphy of 3Com for providing development information for
|
|
|
|
earlier 3Com products.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2010-08-12 20:22:51 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/bitops.h>
|
2009-09-03 18:41:17 +08:00
|
|
|
#include <linux/mii.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <pcmcia/cistpl.h>
|
|
|
|
#include <pcmcia/cisreg.h>
|
|
|
|
#include <pcmcia/ciscode.h>
|
|
|
|
#include <pcmcia/ds.h>
|
|
|
|
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
/* Module parameters */
|
|
|
|
|
|
|
|
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
|
|
|
|
MODULE_DESCRIPTION("3Com 3c574 series PCMCIA ethernet driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)
|
|
|
|
|
|
|
|
/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
|
|
|
|
INT_MODULE_PARM(max_interrupt_work, 32);
|
|
|
|
|
|
|
|
/* Force full duplex modes? */
|
|
|
|
INT_MODULE_PARM(full_duplex, 0);
|
|
|
|
|
|
|
|
/* Autodetect link polarity reversal? */
|
|
|
|
INT_MODULE_PARM(auto_polarity, 1);
|
|
|
|
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
/* Time in jiffies before concluding the transmitter is hung. */
|
|
|
|
#define TX_TIMEOUT ((800*HZ)/1000)
|
|
|
|
|
|
|
|
/* To minimize the size of the driver source and make the driver more
|
|
|
|
readable not all constants are symbolically defined.
|
|
|
|
You'll need the manual if you want to understand driver details anyway. */
|
|
|
|
/* Offsets from base I/O address. */
|
|
|
|
#define EL3_DATA 0x00
|
|
|
|
#define EL3_CMD 0x0e
|
|
|
|
#define EL3_STATUS 0x0e
|
|
|
|
|
|
|
|
#define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
|
|
|
|
|
|
|
|
/* The top five bits written to EL3_CMD are a command, the lower
|
|
|
|
11 bits are the parameter, if applicable. */
|
|
|
|
enum el3_cmds {
|
|
|
|
TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11,
|
|
|
|
RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11, RxDiscard = 8<<11,
|
|
|
|
TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11,
|
|
|
|
FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11,
|
|
|
|
SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11,
|
|
|
|
SetTxThreshold = 18<<11, SetTxStart = 19<<11, StatsEnable = 21<<11,
|
|
|
|
StatsDisable = 22<<11, StopCoax = 23<<11,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum elxl_status {
|
|
|
|
IntLatch = 0x0001, AdapterFailure = 0x0002, TxComplete = 0x0004,
|
|
|
|
TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
|
|
|
|
IntReq = 0x0040, StatsFull = 0x0080, CmdBusy = 0x1000 };
|
|
|
|
|
|
|
|
/* The SetRxFilter command accepts the following classes: */
|
|
|
|
enum RxFilter {
|
|
|
|
RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Window0 {
|
|
|
|
Wn0EepromCmd = 10, Wn0EepromData = 12, /* EEPROM command/address, data. */
|
|
|
|
IntrStatus=0x0E, /* Valid in all windows. */
|
|
|
|
};
|
|
|
|
/* These assumes the larger EEPROM. */
|
|
|
|
enum Win0_EEPROM_cmds {
|
|
|
|
EEPROM_Read = 0x200, EEPROM_WRITE = 0x100, EEPROM_ERASE = 0x300,
|
|
|
|
EEPROM_EWENB = 0x30, /* Enable erasing/writing for 10 msec. */
|
|
|
|
EEPROM_EWDIS = 0x00, /* Disable EWENB before 10 msec timeout. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Register window 1 offsets, the window used in normal operation.
|
|
|
|
On the "Odie" this window is always mapped at offsets 0x10-0x1f.
|
|
|
|
Except for TxFree, which is overlapped by RunnerWrCtrl. */
|
|
|
|
enum Window1 {
|
|
|
|
TX_FIFO = 0x10, RX_FIFO = 0x10, RxErrors = 0x14,
|
|
|
|
RxStatus = 0x18, Timer=0x1A, TxStatus = 0x1B,
|
|
|
|
TxFree = 0x0C, /* Remaining free bytes in Tx buffer. */
|
|
|
|
RunnerRdCtrl = 0x16, RunnerWrCtrl = 0x1c,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Window3 { /* Window 3: MAC/config bits. */
|
|
|
|
Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
|
|
|
|
};
|
2008-01-13 22:17:35 +08:00
|
|
|
enum wn3_config {
|
|
|
|
Ram_size = 7,
|
|
|
|
Ram_width = 8,
|
|
|
|
Ram_speed = 0x30,
|
|
|
|
Rom_size = 0xc0,
|
|
|
|
Ram_split_shift = 16,
|
|
|
|
Ram_split = 3 << Ram_split_shift,
|
|
|
|
Xcvr_shift = 20,
|
|
|
|
Xcvr = 7 << Xcvr_shift,
|
|
|
|
Autoselect = 0x1000000,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Window4 { /* Window 4: Xcvr/media bits. */
|
|
|
|
Wn4_FIFODiag = 4, Wn4_NetDiag = 6, Wn4_PhysicalMgmt=8, Wn4_Media = 10,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
|
|
|
|
|
|
|
|
struct el3_private {
|
2006-03-05 17:45:09 +08:00
|
|
|
struct pcmcia_device *p_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
u16 advertising, partner; /* NWay media advertisement */
|
|
|
|
unsigned char phys; /* MII device address */
|
|
|
|
unsigned int autoselect:1, default_media:3; /* Read from the EEPROM/Wn3_Config. */
|
|
|
|
/* for transceiver monitoring */
|
|
|
|
struct timer_list media;
|
|
|
|
unsigned short media_status;
|
|
|
|
unsigned short fast_poll;
|
|
|
|
unsigned long last_irq;
|
|
|
|
spinlock_t window_lock; /* Guards the Window selection */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Set iff a MII transceiver on any interface requires mdio preamble.
|
|
|
|
This only set with the original DP83840 on older 3c905 boards, so the extra
|
|
|
|
code size of a per-interface flag is not worthwhile. */
|
|
|
|
static char mii_preamble_required = 0;
|
|
|
|
|
|
|
|
/* Index of functions. */
|
|
|
|
|
2006-03-31 23:26:06 +08:00
|
|
|
static int tc574_config(struct pcmcia_device *link);
|
2006-03-31 23:21:06 +08:00
|
|
|
static void tc574_release(struct pcmcia_device *link);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-05 14:27:35 +08:00
|
|
|
static void mdio_sync(unsigned int ioaddr, int bits);
|
|
|
|
static int mdio_read(unsigned int ioaddr, int phy_id, int location);
|
|
|
|
static void mdio_write(unsigned int ioaddr, int phy_id, int location,
|
|
|
|
int value);
|
|
|
|
static unsigned short read_eeprom(unsigned int ioaddr, int index);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void tc574_wait_for_completion(struct net_device *dev, int cmd);
|
|
|
|
|
|
|
|
static void tc574_reset(struct net_device *dev);
|
|
|
|
static void media_check(unsigned long arg);
|
|
|
|
static int el3_open(struct net_device *dev);
|
2009-09-01 03:50:49 +08:00
|
|
|
static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t el3_interrupt(int irq, void *dev_id);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void update_stats(struct net_device *dev);
|
|
|
|
static struct net_device_stats *el3_get_stats(struct net_device *dev);
|
|
|
|
static int el3_rx(struct net_device *dev, int worklimit);
|
|
|
|
static int el3_close(struct net_device *dev);
|
|
|
|
static void el3_tx_timeout(struct net_device *dev);
|
|
|
|
static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
|
|
|
|
static void set_rx_mode(struct net_device *dev);
|
2009-10-13 15:32:55 +08:00
|
|
|
static void set_multicast_list(struct net_device *dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-11-15 04:23:14 +08:00
|
|
|
static void tc574_detach(struct pcmcia_device *p_dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
tc574_attach() creates an "instance" of the driver, allocating
|
|
|
|
local data structures for one device. The device is registered
|
|
|
|
with Card Services.
|
|
|
|
*/
|
2009-03-21 03:36:02 +08:00
|
|
|
static const struct net_device_ops el3_netdev_ops = {
|
|
|
|
.ndo_open = el3_open,
|
|
|
|
.ndo_stop = el3_close,
|
|
|
|
.ndo_start_xmit = el3_start_xmit,
|
|
|
|
.ndo_tx_timeout = el3_tx_timeout,
|
|
|
|
.ndo_get_stats = el3_get_stats,
|
|
|
|
.ndo_do_ioctl = el3_ioctl,
|
2009-10-13 15:32:55 +08:00
|
|
|
.ndo_set_multicast_list = set_multicast_list,
|
2009-03-21 03:36:02 +08:00
|
|
|
.ndo_change_mtu = eth_change_mtu,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-31 23:26:06 +08:00
|
|
|
static int tc574_probe(struct pcmcia_device *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct el3_private *lp;
|
|
|
|
struct net_device *dev;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, "3c574_attach()\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Create the PC card device object. */
|
|
|
|
dev = alloc_etherdev(sizeof(struct el3_private));
|
|
|
|
if (!dev)
|
2005-11-15 04:25:51 +08:00
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
lp = netdev_priv(dev);
|
|
|
|
link->priv = dev;
|
2006-03-31 23:21:06 +08:00
|
|
|
lp->p_dev = link;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
spin_lock_init(&lp->window_lock);
|
2010-07-24 23:23:51 +08:00
|
|
|
link->resource[0]->end = 32;
|
|
|
|
link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
|
2010-07-30 01:27:09 +08:00
|
|
|
link->config_flags |= CONF_ENABLE_IRQ;
|
2010-07-30 00:35:47 +08:00
|
|
|
link->config_index = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-03-21 03:36:02 +08:00
|
|
|
dev->netdev_ops = &el3_netdev_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->watchdog_timeo = TX_TIMEOUT;
|
|
|
|
|
2006-03-31 23:26:06 +08:00
|
|
|
return tc574_config(link);
|
2010-08-15 14:38:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-31 23:21:06 +08:00
|
|
|
static void tc574_detach(struct pcmcia_device *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, "3c574_detach()\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-21 02:39:26 +08:00
|
|
|
unregister_netdev(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-02 07:09:29 +08:00
|
|
|
tc574_release(link);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
free_netdev(dev);
|
|
|
|
} /* tc574_detach */
|
|
|
|
|
2006-03-04 10:33:57 +08:00
|
|
|
static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-31 23:26:06 +08:00
|
|
|
static int tc574_config(struct pcmcia_device *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2009-10-24 21:51:05 +08:00
|
|
|
int ret, i, j;
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr;
|
2007-12-23 02:56:13 +08:00
|
|
|
__be16 *phys_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
char *cardname;
|
2008-01-13 22:17:35 +08:00
|
|
|
__u32 config;
|
2009-10-19 05:54:24 +08:00
|
|
|
u8 *buf;
|
|
|
|
size_t len;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-12-23 02:56:13 +08:00
|
|
|
phys_addr = (__be16 *)dev->dev_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, "3c574_config()\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-07-24 23:23:51 +08:00
|
|
|
link->io_lines = 16;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = j = 0; j < 0x400; j += 0x20) {
|
2010-07-24 23:23:51 +08:00
|
|
|
link->resource[0]->start = j ^ 0x300;
|
|
|
|
i = pcmcia_request_io(link);
|
2008-08-03 16:07:45 +08:00
|
|
|
if (i == 0)
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-10-24 21:51:05 +08:00
|
|
|
if (i != 0)
|
|
|
|
goto failed;
|
|
|
|
|
2010-03-07 19:21:16 +08:00
|
|
|
ret = pcmcia_request_irq(link, el3_interrupt);
|
2009-10-24 21:51:05 +08:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
|
|
|
|
2010-07-30 01:27:09 +08:00
|
|
|
ret = pcmcia_enable_device(link);
|
2009-10-24 21:51:05 +08:00
|
|
|
if (ret)
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed;
|
|
|
|
|
2010-03-07 19:21:16 +08:00
|
|
|
dev->irq = link->irq;
|
2010-07-24 21:58:54 +08:00
|
|
|
dev->base_addr = link->resource[0]->start;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ioaddr = dev->base_addr;
|
|
|
|
|
|
|
|
/* The 3c574 normally uses an EEPROM for configuration info, including
|
|
|
|
the hardware address. The future products may include a modem chip
|
|
|
|
and put the address in the CIS. */
|
2009-10-19 05:54:24 +08:00
|
|
|
|
|
|
|
len = pcmcia_get_tuple(link, 0x88, &buf);
|
|
|
|
if (buf && len >= 6) {
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < 3; i++)
|
2009-10-19 05:54:24 +08:00
|
|
|
phys_addr[i] = htons(le16_to_cpu(buf[i * 2]));
|
|
|
|
kfree(buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2009-10-19 05:54:24 +08:00
|
|
|
kfree(buf); /* 0 < len < 6 */
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(0);
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
phys_addr[i] = htons(read_eeprom(ioaddr, i + 10));
|
2007-12-23 02:56:13 +08:00
|
|
|
if (phys_addr[0] == htons(0x6060)) {
|
2010-08-12 20:22:51 +08:00
|
|
|
pr_notice("IO port conflict at 0x%03lx-0x%03lx\n",
|
|
|
|
dev->base_addr, dev->base_addr+15);
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
}
|
2006-06-05 00:06:13 +08:00
|
|
|
if (link->prod_id[1])
|
|
|
|
cardname = link->prod_id[1];
|
|
|
|
else
|
2005-04-17 06:20:36 +08:00
|
|
|
cardname = "3Com 3c574";
|
|
|
|
|
|
|
|
{
|
|
|
|
u_char mcr;
|
|
|
|
outw(2<<11, ioaddr + RunnerRdCtrl);
|
|
|
|
mcr = inb(ioaddr + 2);
|
|
|
|
outw(0<<11, ioaddr + RunnerRdCtrl);
|
2010-08-12 20:22:51 +08:00
|
|
|
pr_info(" ASIC rev %d,", mcr>>3);
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(3);
|
2008-01-13 22:17:35 +08:00
|
|
|
config = inl(ioaddr + Wn3_Config);
|
|
|
|
lp->default_media = (config & Xcvr) >> Xcvr_shift;
|
|
|
|
lp->autoselect = config & Autoselect ? 1 : 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
init_timer(&lp->media);
|
|
|
|
|
|
|
|
{
|
|
|
|
int phy;
|
|
|
|
|
|
|
|
/* Roadrunner only: Turn on the MII transceiver */
|
|
|
|
outw(0x8040, ioaddr + Wn3_Options);
|
|
|
|
mdelay(1);
|
|
|
|
outw(0xc040, ioaddr + Wn3_Options);
|
|
|
|
tc574_wait_for_completion(dev, TxReset);
|
|
|
|
tc574_wait_for_completion(dev, RxReset);
|
|
|
|
mdelay(1);
|
|
|
|
outw(0x8040, ioaddr + Wn3_Options);
|
|
|
|
|
|
|
|
EL3WINDOW(4);
|
|
|
|
for (phy = 1; phy <= 32; phy++) {
|
|
|
|
int mii_status;
|
|
|
|
mdio_sync(ioaddr, 32);
|
|
|
|
mii_status = mdio_read(ioaddr, phy & 0x1f, 1);
|
|
|
|
if (mii_status != 0xffff) {
|
|
|
|
lp->phys = phy & 0x1f;
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, " MII transceiver at "
|
|
|
|
"index %d, status %x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
phy, mii_status);
|
|
|
|
if ((mii_status & 0x0040) == 0)
|
|
|
|
mii_preamble_required = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (phy > 32) {
|
2010-08-12 20:22:51 +08:00
|
|
|
pr_notice(" No MII transceivers found!\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
i = mdio_read(ioaddr, lp->phys, 16) | 0x40;
|
|
|
|
mdio_write(ioaddr, lp->phys, 16, i);
|
|
|
|
lp->advertising = mdio_read(ioaddr, lp->phys, 4);
|
|
|
|
if (full_duplex) {
|
|
|
|
/* Only advertise the FD media types. */
|
|
|
|
lp->advertising &= ~0x02a0;
|
|
|
|
mdio_write(ioaddr, lp->phys, 4, lp->advertising);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 17:27:34 +08:00
|
|
|
SET_NETDEV_DEV(dev, &link->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (register_netdev(dev) != 0) {
|
2010-08-12 20:22:51 +08:00
|
|
|
pr_notice("register_netdev() failed\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n",
|
|
|
|
cardname, dev->base_addr, dev->irq, dev->dev_addr);
|
|
|
|
netdev_info(dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n",
|
|
|
|
8 << config & Ram_size,
|
|
|
|
ram_split[(config & Ram_split) >> Ram_split_shift],
|
|
|
|
config & Autoselect ? "autoselect " : "");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-31 23:26:06 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
failed:
|
|
|
|
tc574_release(link);
|
2006-03-31 23:26:06 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
} /* tc574_config */
|
|
|
|
|
2006-03-31 23:21:06 +08:00
|
|
|
static void tc574_release(struct pcmcia_device *link)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-03-31 23:21:06 +08:00
|
|
|
pcmcia_disable_device(link);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-03-31 23:21:06 +08:00
|
|
|
static int tc574_suspend(struct pcmcia_device *link)
|
2005-11-15 04:21:18 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-02 07:09:29 +08:00
|
|
|
if (link->open)
|
2006-03-02 07:02:33 +08:00
|
|
|
netif_device_detach(dev);
|
2005-11-15 04:21:18 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-31 23:21:06 +08:00
|
|
|
static int tc574_resume(struct pcmcia_device *link)
|
2005-11-15 04:21:18 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-02 07:09:29 +08:00
|
|
|
if (link->open) {
|
2006-03-02 07:02:33 +08:00
|
|
|
tc574_reset(dev);
|
|
|
|
netif_device_attach(dev);
|
2005-11-15 04:21:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static void dump_status(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(1);
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x, tx free %04x\n",
|
|
|
|
inw(ioaddr+EL3_STATUS),
|
|
|
|
inw(ioaddr+RxStatus), inb(ioaddr+TxStatus),
|
|
|
|
inw(ioaddr+TxFree));
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(4);
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n",
|
|
|
|
inw(ioaddr+0x04), inw(ioaddr+0x06),
|
|
|
|
inw(ioaddr+0x08), inw(ioaddr+0x0a));
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Use this for commands that may take time to finish
|
|
|
|
*/
|
|
|
|
static void tc574_wait_for_completion(struct net_device *dev, int cmd)
|
|
|
|
{
|
|
|
|
int i = 1500;
|
|
|
|
outw(cmd, dev->base_addr + EL3_CMD);
|
|
|
|
while (--i > 0)
|
|
|
|
if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break;
|
|
|
|
if (i == 0)
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_notice(dev, "command 0x%04x did not complete!\n", cmd);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a word from the EEPROM using the regular EEPROM access register.
|
|
|
|
Assume that we are in register window zero.
|
|
|
|
*/
|
2008-02-05 14:27:35 +08:00
|
|
|
static unsigned short read_eeprom(unsigned int ioaddr, int index)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int timer;
|
|
|
|
outw(EEPROM_Read + index, ioaddr + Wn0EepromCmd);
|
|
|
|
/* Pause for at least 162 usec for the read to take place. */
|
|
|
|
for (timer = 1620; timer >= 0; timer--) {
|
|
|
|
if ((inw(ioaddr + Wn0EepromCmd) & 0x8000) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return inw(ioaddr + Wn0EepromData);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MII transceiver control section.
|
|
|
|
Read and write the MII registers using software-generated serial
|
|
|
|
MDIO protocol. See the MII specifications or DP83840A data sheet
|
|
|
|
for details.
|
|
|
|
The maxium data clock rate is 2.5 Mhz. The timing is easily met by the
|
|
|
|
slow PC card interface. */
|
|
|
|
|
|
|
|
#define MDIO_SHIFT_CLK 0x01
|
|
|
|
#define MDIO_DIR_WRITE 0x04
|
|
|
|
#define MDIO_DATA_WRITE0 (0x00 | MDIO_DIR_WRITE)
|
|
|
|
#define MDIO_DATA_WRITE1 (0x02 | MDIO_DIR_WRITE)
|
|
|
|
#define MDIO_DATA_READ 0x02
|
|
|
|
#define MDIO_ENB_IN 0x00
|
|
|
|
|
|
|
|
/* Generate the preamble required for initial synchronization and
|
|
|
|
a few older transceivers. */
|
2008-02-05 14:27:35 +08:00
|
|
|
static void mdio_sync(unsigned int ioaddr, int bits)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Establish sync by sending at least 32 logic ones. */
|
|
|
|
while (-- bits >= 0) {
|
|
|
|
outw(MDIO_DATA_WRITE1, mdio_addr);
|
|
|
|
outw(MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-05 14:27:35 +08:00
|
|
|
static int mdio_read(unsigned int ioaddr, int phy_id, int location)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
|
|
|
|
unsigned int retval = 0;
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (mii_preamble_required)
|
|
|
|
mdio_sync(ioaddr, 32);
|
|
|
|
|
|
|
|
/* Shift the read command bits out. */
|
|
|
|
for (i = 14; i >= 0; i--) {
|
|
|
|
int dataval = (read_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
|
|
|
|
outw(dataval, mdio_addr);
|
|
|
|
outw(dataval | MDIO_SHIFT_CLK, mdio_addr);
|
|
|
|
}
|
|
|
|
/* Read the two transition, 16 data, and wire-idle bits. */
|
|
|
|
for (i = 19; i > 0; i--) {
|
|
|
|
outw(MDIO_ENB_IN, mdio_addr);
|
|
|
|
retval = (retval << 1) | ((inw(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
|
|
|
|
outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
|
|
|
|
}
|
|
|
|
return (retval>>1) & 0xffff;
|
|
|
|
}
|
|
|
|
|
2008-02-05 14:27:35 +08:00
|
|
|
static void mdio_write(unsigned int ioaddr, int phy_id, int location, int value)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) | value;
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (mii_preamble_required)
|
|
|
|
mdio_sync(ioaddr, 32);
|
|
|
|
|
|
|
|
/* Shift the command bits out. */
|
|
|
|
for (i = 31; i >= 0; i--) {
|
|
|
|
int dataval = (write_cmd&(1<<i)) ? MDIO_DATA_WRITE1 : MDIO_DATA_WRITE0;
|
|
|
|
outw(dataval, mdio_addr);
|
|
|
|
outw(dataval | MDIO_SHIFT_CLK, mdio_addr);
|
|
|
|
}
|
|
|
|
/* Leave the interface idle. */
|
|
|
|
for (i = 1; i >= 0; i--) {
|
|
|
|
outw(MDIO_ENB_IN, mdio_addr);
|
|
|
|
outw(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset and restore all of the 3c574 registers. */
|
|
|
|
static void tc574_reset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
|
|
int i;
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
tc574_wait_for_completion(dev, TotalReset|0x10);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
/* Clear any transactions in progress. */
|
|
|
|
outw(0, ioaddr + RunnerWrCtrl);
|
|
|
|
outw(0, ioaddr + RunnerRdCtrl);
|
|
|
|
|
|
|
|
/* Set the station address and mask. */
|
|
|
|
EL3WINDOW(2);
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
outb(dev->dev_addr[i], ioaddr + i);
|
|
|
|
for (; i < 12; i+=2)
|
|
|
|
outw(0, ioaddr + i);
|
|
|
|
|
|
|
|
/* Reset config options */
|
|
|
|
EL3WINDOW(3);
|
|
|
|
outb((dev->mtu > 1500 ? 0x40 : 0), ioaddr + Wn3_MAC_Ctrl);
|
|
|
|
outl((lp->autoselect ? 0x01000000 : 0) | 0x0062001b,
|
|
|
|
ioaddr + Wn3_Config);
|
|
|
|
/* Roadrunner only: Turn on the MII transceiver. */
|
|
|
|
outw(0x8040, ioaddr + Wn3_Options);
|
|
|
|
mdelay(1);
|
|
|
|
outw(0xc040, ioaddr + Wn3_Options);
|
|
|
|
EL3WINDOW(1);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
|
|
|
|
tc574_wait_for_completion(dev, TxReset);
|
|
|
|
tc574_wait_for_completion(dev, RxReset);
|
|
|
|
mdelay(1);
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
EL3WINDOW(3);
|
|
|
|
outw(0x8040, ioaddr + Wn3_Options);
|
|
|
|
|
|
|
|
/* Switch to the stats window, and clear all stats by reading. */
|
|
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
|
|
EL3WINDOW(6);
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
inb(ioaddr + i);
|
|
|
|
inw(ioaddr + 10);
|
|
|
|
inw(ioaddr + 12);
|
|
|
|
EL3WINDOW(4);
|
|
|
|
inb(ioaddr + 12);
|
|
|
|
inb(ioaddr + 13);
|
|
|
|
|
|
|
|
/* .. enable any extra statistics bits.. */
|
|
|
|
outw(0x0040, ioaddr + Wn4_NetDiag);
|
|
|
|
|
|
|
|
EL3WINDOW(1);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
|
|
|
|
/* .. re-sync MII and re-fill what NWay is advertising. */
|
|
|
|
mdio_sync(ioaddr, 32);
|
|
|
|
mdio_write(ioaddr, lp->phys, 4, lp->advertising);
|
|
|
|
if (!auto_polarity) {
|
|
|
|
/* works for TDK 78Q2120 series MII's */
|
2008-02-05 14:27:39 +08:00
|
|
|
i = mdio_read(ioaddr, lp->phys, 16) | 0x20;
|
2005-04-17 06:20:36 +08:00
|
|
|
mdio_write(ioaddr, lp->phys, 16, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
/* Switch to register set 1 for normal use, just for TxFree. */
|
|
|
|
set_rx_mode(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */
|
|
|
|
outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */
|
|
|
|
outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */
|
|
|
|
/* Allow status bits to be seen. */
|
|
|
|
outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD);
|
|
|
|
/* Ack all pending events, and set active indicator mask. */
|
|
|
|
outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
|
|
|
|
ioaddr + EL3_CMD);
|
|
|
|
outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
|
|
|
|
| AdapterFailure | RxEarly, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int el3_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2006-03-31 23:21:06 +08:00
|
|
|
struct pcmcia_device *link = lp->p_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-05 18:04:33 +08:00
|
|
|
if (!pcmcia_dev_present(link))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
link->open++;
|
|
|
|
netif_start_queue(dev);
|
|
|
|
|
|
|
|
tc574_reset(dev);
|
2010-08-24 02:20:03 +08:00
|
|
|
lp->media.function = media_check;
|
2005-04-17 06:20:36 +08:00
|
|
|
lp->media.data = (unsigned long) dev;
|
|
|
|
lp->media.expires = jiffies + HZ;
|
|
|
|
add_timer(&lp->media);
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, inw(dev->base_addr + EL3_STATUS));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void el3_tx_timeout(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_notice(dev, "Transmit timed out!\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
dump_status(dev);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.tx_errors++;
|
2010-05-10 20:01:31 +08:00
|
|
|
dev->trans_start = jiffies; /* prevent tx timeout */
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Issue TX_RESET and TX_START commands. */
|
|
|
|
tc574_wait_for_completion(dev, TxReset);
|
|
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pop_tx_status(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Clear the Tx status stack. */
|
|
|
|
for (i = 32; i > 0; i--) {
|
|
|
|
u_char tx_status = inb(ioaddr + TxStatus);
|
|
|
|
if (!(tx_status & 0x84))
|
|
|
|
break;
|
|
|
|
/* reset transmitter on jabber error or underrun */
|
|
|
|
if (tx_status & 0x30)
|
|
|
|
tc574_wait_for_completion(dev, TxReset);
|
|
|
|
if (tx_status & 0x38) {
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: transmit error: status 0x%02x\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, tx_status);
|
|
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.tx_aborted_errors++;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-01 03:50:49 +08:00
|
|
|
static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: el3_start_xmit(length = %ld) called, "
|
2005-04-17 06:20:36 +08:00
|
|
|
"status %4.4x.\n", dev->name, (long)skb->len,
|
|
|
|
inw(ioaddr + EL3_STATUS));
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
2010-04-16 11:01:01 +08:00
|
|
|
|
|
|
|
dev->stats.tx_bytes += skb->len;
|
|
|
|
|
|
|
|
/* Put out the doubleword header... */
|
2005-04-17 06:20:36 +08:00
|
|
|
outw(skb->len, ioaddr + TX_FIFO);
|
|
|
|
outw(0, ioaddr + TX_FIFO);
|
2010-04-16 11:01:01 +08:00
|
|
|
/* ... and the packet rounded to a doubleword. */
|
2005-04-17 06:20:36 +08:00
|
|
|
outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
|
|
|
|
|
|
|
|
/* TxFree appears only in Window 1, not offset 0x1c. */
|
|
|
|
if (inw(ioaddr + TxFree) <= 1536) {
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
/* Interrupt us when the FIFO has room for max-sized packet.
|
|
|
|
The threshold is in units of dwords. */
|
|
|
|
outw(SetTxThreshold + (1536>>2), ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
pop_tx_status(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
dev_kfree_skb(skb);
|
2009-06-23 14:03:08 +08:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The EL3 interrupt handler. */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t el3_interrupt(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct net_device *dev = (struct net_device *) dev_id;
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned status;
|
|
|
|
int work_budget = max_interrupt_work;
|
|
|
|
int handled = 0;
|
|
|
|
|
|
|
|
if (!netif_device_present(dev))
|
|
|
|
return IRQ_NONE;
|
|
|
|
ioaddr = dev->base_addr;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: interrupt, status %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, inw(ioaddr + EL3_STATUS));
|
|
|
|
|
|
|
|
spin_lock(&lp->window_lock);
|
|
|
|
|
|
|
|
while ((status = inw(ioaddr + EL3_STATUS)) &
|
|
|
|
(IntLatch | RxComplete | RxEarly | StatsFull)) {
|
|
|
|
if (!netif_device_present(dev) ||
|
|
|
|
((status & 0xe000) != 0x2000)) {
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: Interrupt from dead card\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
handled = 1;
|
|
|
|
|
|
|
|
if (status & RxComplete)
|
|
|
|
work_budget = el3_rx(dev, work_budget);
|
|
|
|
|
|
|
|
if (status & TxAvailable) {
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug(" TX room bit was handled.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
/* There's room in the FIFO for a full-sized packet. */
|
|
|
|
outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status & TxComplete)
|
|
|
|
pop_tx_status(dev);
|
|
|
|
|
|
|
|
if (status & (AdapterFailure | RxEarly | StatsFull)) {
|
|
|
|
/* Handle all uncommon interrupts. */
|
|
|
|
if (status & StatsFull)
|
|
|
|
update_stats(dev);
|
|
|
|
if (status & RxEarly) {
|
|
|
|
work_budget = el3_rx(dev, work_budget);
|
|
|
|
outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
if (status & AdapterFailure) {
|
|
|
|
u16 fifo_diag;
|
|
|
|
EL3WINDOW(4);
|
|
|
|
fifo_diag = inw(ioaddr + Wn4_FIFODiag);
|
|
|
|
EL3WINDOW(1);
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_notice(dev, "adapter failure, FIFO diagnostic register %04x\n",
|
|
|
|
fifo_diag);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (fifo_diag & 0x0400) {
|
|
|
|
/* Tx overrun */
|
|
|
|
tc574_wait_for_completion(dev, TxReset);
|
|
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
if (fifo_diag & 0x2000) {
|
|
|
|
/* Rx underrun */
|
|
|
|
tc574_wait_for_completion(dev, RxReset);
|
|
|
|
set_rx_mode(dev);
|
|
|
|
outw(RxEnable, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--work_budget < 0) {
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: Too much work in interrupt, "
|
2005-04-17 06:20:36 +08:00
|
|
|
"status %4.4x.\n", dev->name, status);
|
|
|
|
/* Clear all interrupts */
|
|
|
|
outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* Acknowledge the IRQ. */
|
|
|
|
outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: exiting interrupt, status %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, inw(ioaddr + EL3_STATUS));
|
|
|
|
|
|
|
|
spin_unlock(&lp->window_lock);
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This timer serves two purposes: to check for missed interrupts
|
|
|
|
(and as a last resort, poll the NIC for events), and to monitor
|
|
|
|
the MII, reporting changes in cable status.
|
|
|
|
*/
|
|
|
|
static void media_check(unsigned long arg)
|
|
|
|
{
|
|
|
|
struct net_device *dev = (struct net_device *) arg;
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned short /* cable, */ media, partner;
|
|
|
|
|
|
|
|
if (!netif_device_present(dev))
|
|
|
|
goto reschedule;
|
|
|
|
|
|
|
|
/* Check for pending interrupt with expired latency timer: with
|
|
|
|
this, we can limp along even if the interrupt is blocked */
|
|
|
|
if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
|
|
|
|
if (!lp->fast_poll)
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "interrupt(s) dropped!\n");
|
2009-12-12 22:44:11 +08:00
|
|
|
|
|
|
|
local_irq_save(flags);
|
2007-02-10 10:57:35 +08:00
|
|
|
el3_interrupt(dev->irq, dev);
|
2009-12-12 22:44:11 +08:00
|
|
|
local_irq_restore(flags);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
lp->fast_poll = HZ;
|
|
|
|
}
|
|
|
|
if (lp->fast_poll) {
|
|
|
|
lp->fast_poll--;
|
|
|
|
lp->media.expires = jiffies + 2*HZ/100;
|
|
|
|
add_timer(&lp->media);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
EL3WINDOW(4);
|
|
|
|
media = mdio_read(ioaddr, lp->phys, 1);
|
|
|
|
partner = mdio_read(ioaddr, lp->phys, 5);
|
|
|
|
EL3WINDOW(1);
|
|
|
|
|
|
|
|
if (media != lp->media_status) {
|
|
|
|
if ((media ^ lp->media_status) & 0x0004)
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "%s link beat\n",
|
|
|
|
(lp->media_status & 0x0004) ? "lost" : "found");
|
2005-04-17 06:20:36 +08:00
|
|
|
if ((media ^ lp->media_status) & 0x0020) {
|
|
|
|
lp->partner = 0;
|
|
|
|
if (lp->media_status & 0x0020) {
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "autonegotiation restarted\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (partner) {
|
|
|
|
partner &= lp->advertising;
|
|
|
|
lp->partner = partner;
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "autonegotiation complete: "
|
|
|
|
"%dbaseT-%cD selected\n",
|
|
|
|
(partner & 0x0180) ? 100 : 10,
|
|
|
|
(partner & 0x0140) ? 'F' : 'H');
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "link partner did not autonegotiate\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EL3WINDOW(3);
|
|
|
|
outb((partner & 0x0140 ? 0x20 : 0) |
|
|
|
|
(dev->mtu > 1500 ? 0x40 : 0), ioaddr + Wn3_MAC_Ctrl);
|
|
|
|
EL3WINDOW(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (media & 0x0010)
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "remote fault detected\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (media & 0x0002)
|
2010-08-12 20:22:51 +08:00
|
|
|
netdev_info(dev, "jabber detected\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
lp->media_status = media;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
|
|
|
|
reschedule:
|
|
|
|
lp->media.expires = jiffies + HZ;
|
|
|
|
add_timer(&lp->media);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct net_device_stats *el3_get_stats(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (netif_device_present(dev)) {
|
|
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
update_stats(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
}
|
2008-04-30 06:08:26 +08:00
|
|
|
return &dev->stats;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update statistics.
|
|
|
|
Suprisingly this need not be run single-threaded, but it effectively is.
|
|
|
|
The counters clear when read, so the adds must merely be atomic.
|
|
|
|
*/
|
|
|
|
static void update_stats(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 rx, tx, up;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: updating the statistics.\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (inw(ioaddr+EL3_STATUS) == 0xffff) /* No card. */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Unlike the 3c509 we need not turn off stats updates while reading. */
|
|
|
|
/* Switch to the stats window, and read everything. */
|
|
|
|
EL3WINDOW(6);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.tx_carrier_errors += inb(ioaddr + 0);
|
|
|
|
dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Multiple collisions. */ inb(ioaddr + 2);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.collisions += inb(ioaddr + 3);
|
|
|
|
dev->stats.tx_window_errors += inb(ioaddr + 4);
|
|
|
|
dev->stats.rx_fifo_errors += inb(ioaddr + 5);
|
|
|
|
dev->stats.tx_packets += inb(ioaddr + 6);
|
2005-04-17 06:20:36 +08:00
|
|
|
up = inb(ioaddr + 9);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.tx_packets += (up&0x30) << 4;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Rx packets */ inb(ioaddr + 7);
|
|
|
|
/* Tx deferrals */ inb(ioaddr + 8);
|
|
|
|
rx = inw(ioaddr + 10);
|
|
|
|
tx = inw(ioaddr + 12);
|
|
|
|
|
|
|
|
EL3WINDOW(4);
|
|
|
|
/* BadSSD */ inb(ioaddr + 12);
|
|
|
|
up = inb(ioaddr + 13);
|
|
|
|
|
|
|
|
EL3WINDOW(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int el3_rx(struct net_device *dev, int worklimit)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
short rx_status;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: in rx_packet(), status %4.4x, rx_status %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, inw(ioaddr+EL3_STATUS), inw(ioaddr+RxStatus));
|
|
|
|
while (!((rx_status = inw(ioaddr + RxStatus)) & 0x8000) &&
|
2009-03-04 16:05:56 +08:00
|
|
|
worklimit > 0) {
|
|
|
|
worklimit--;
|
2005-04-17 06:20:36 +08:00
|
|
|
if (rx_status & 0x4000) { /* Error, update stats. */
|
|
|
|
short error = rx_status & 0x3800;
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.rx_errors++;
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (error) {
|
2008-04-30 06:08:26 +08:00
|
|
|
case 0x0000: dev->stats.rx_over_errors++; break;
|
|
|
|
case 0x0800: dev->stats.rx_length_errors++; break;
|
|
|
|
case 0x1000: dev->stats.rx_frame_errors++; break;
|
|
|
|
case 0x1800: dev->stats.rx_length_errors++; break;
|
|
|
|
case 0x2000: dev->stats.rx_frame_errors++; break;
|
|
|
|
case 0x2800: dev->stats.rx_crc_errors++; break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
short pkt_len = rx_status & 0x7ff;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(pkt_len+5);
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug(" Receiving packet size %d status %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
pkt_len, rx_status);
|
|
|
|
if (skb != NULL) {
|
|
|
|
skb_reserve(skb, 2);
|
|
|
|
insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len),
|
|
|
|
((pkt_len+3)>>2));
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
netif_rx(skb);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += pkt_len;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: couldn't allocate a sk_buff of"
|
2005-04-17 06:20:36 +08:00
|
|
|
" size %d.\n", dev->name, pkt_len);
|
2008-04-30 06:08:26 +08:00
|
|
|
dev->stats.rx_dropped++;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tc574_wait_for_completion(dev, RxDiscard);
|
|
|
|
}
|
|
|
|
|
|
|
|
return worklimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Provide ioctl() calls to examine the MII xcvr state. */
|
|
|
|
static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2009-09-03 18:41:17 +08:00
|
|
|
struct mii_ioctl_data *data = if_mii(rq);
|
2005-04-17 06:20:36 +08:00
|
|
|
int phy = lp->phys & 0x1f;
|
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
pr_debug("%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, rq->ifr_ifrn.ifrn_name, cmd,
|
2009-09-03 18:41:17 +08:00
|
|
|
data->phy_id, data->reg_num, data->val_in, data->val_out);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
case SIOCGMIIPHY: /* Get the address of the PHY in use. */
|
2009-09-03 18:41:17 +08:00
|
|
|
data->phy_id = phy;
|
2005-04-17 06:20:36 +08:00
|
|
|
case SIOCGMIIREG: /* Read the specified MII register. */
|
|
|
|
{
|
|
|
|
int saved_window;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
saved_window = inw(ioaddr + EL3_CMD) >> 13;
|
|
|
|
EL3WINDOW(4);
|
2009-09-03 18:41:17 +08:00
|
|
|
data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f,
|
|
|
|
data->reg_num & 0x1f);
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(saved_window);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case SIOCSMIIREG: /* Write the specified MII register */
|
|
|
|
{
|
|
|
|
int saved_window;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
saved_window = inw(ioaddr + EL3_CMD) >> 13;
|
|
|
|
EL3WINDOW(4);
|
2009-09-03 18:41:17 +08:00
|
|
|
mdio_write(ioaddr, data->phy_id & 0x1f,
|
|
|
|
data->reg_num & 0x1f, data->val_in);
|
2005-04-17 06:20:36 +08:00
|
|
|
EL3WINDOW(saved_window);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The Odie chip has a 64 bin multicast filter, but the bit layout is not
|
|
|
|
documented. Until it is we revert to receiving all multicast frames when
|
|
|
|
any multicast reception is desired.
|
|
|
|
Note: My other drivers emit a log message whenever promiscuous mode is
|
|
|
|
entered to help detect password sniffers. This is less desirable on
|
|
|
|
typical PC card machines, so we omit the message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void set_rx_mode(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (dev->flags & IFF_PROMISC)
|
|
|
|
outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
|
|
|
|
ioaddr + EL3_CMD);
|
2010-02-08 12:30:35 +08:00
|
|
|
else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI))
|
2005-04-17 06:20:36 +08:00
|
|
|
outw(SetRxFilter|RxStation|RxMulticast|RxBroadcast, ioaddr + EL3_CMD);
|
|
|
|
else
|
|
|
|
outw(SetRxFilter | RxStation | RxBroadcast, ioaddr + EL3_CMD);
|
|
|
|
}
|
|
|
|
|
2009-10-13 15:32:55 +08:00
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
set_rx_mode(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int el3_close(struct net_device *dev)
|
|
|
|
{
|
2008-02-05 14:27:35 +08:00
|
|
|
unsigned int ioaddr = dev->base_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct el3_private *lp = netdev_priv(dev);
|
2006-03-31 23:21:06 +08:00
|
|
|
struct pcmcia_device *link = lp->p_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-10-24 21:51:05 +08:00
|
|
|
dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-03-05 18:04:33 +08:00
|
|
|
if (pcmcia_dev_present(link)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* Turn off statistics ASAP. We update lp->stats below. */
|
|
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
|
|
|
|
|
|
/* Disable the receiver and transmitter. */
|
|
|
|
outw(RxDisable, ioaddr + EL3_CMD);
|
|
|
|
outw(TxDisable, ioaddr + EL3_CMD);
|
|
|
|
|
|
|
|
/* Note: Switching to window 0 may disable the IRQ. */
|
|
|
|
EL3WINDOW(0);
|
|
|
|
spin_lock_irqsave(&lp->window_lock, flags);
|
|
|
|
update_stats(dev);
|
|
|
|
spin_unlock_irqrestore(&lp->window_lock, flags);
|
2005-04-11 02:27:45 +08:00
|
|
|
|
|
|
|
/* force interrupts off */
|
|
|
|
outw(SetIntrEnb | 0x0000, ioaddr + EL3_CMD);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
link->open--;
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
del_timer_sync(&lp->media);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-28 07:28:18 +08:00
|
|
|
static struct pcmcia_device_id tc574_ids[] = {
|
|
|
|
PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0574),
|
2009-05-02 10:21:26 +08:00
|
|
|
PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "cis/3CCFEM556.cis"),
|
2005-06-28 07:28:18 +08:00
|
|
|
PCMCIA_DEVICE_NULL,
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pcmcia, tc574_ids);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct pcmcia_driver tc574_driver = {
|
|
|
|
.owner = THIS_MODULE,
|
2010-08-08 17:36:26 +08:00
|
|
|
.name = "3c574_cs",
|
2006-03-31 23:26:06 +08:00
|
|
|
.probe = tc574_probe,
|
2005-11-15 04:23:14 +08:00
|
|
|
.remove = tc574_detach,
|
2005-06-28 07:28:18 +08:00
|
|
|
.id_table = tc574_ids,
|
2005-11-15 04:21:18 +08:00
|
|
|
.suspend = tc574_suspend,
|
|
|
|
.resume = tc574_resume,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_tc574(void)
|
|
|
|
{
|
|
|
|
return pcmcia_register_driver(&tc574_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_tc574(void)
|
|
|
|
{
|
|
|
|
pcmcia_unregister_driver(&tc574_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_tc574);
|
|
|
|
module_exit(exit_tc574);
|