aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-09 21:01:40 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-22 10:39:51 -0500
commitf84932d8313af16a37cf25412b7d9054d01d3bea (patch)
tree2863ab40744adba6a3a74607b33a0fe928c1517e /drivers
parent0e245dbaac9fa1c2fd0f4e2af7b9f6d874083a8b (diff)
drivers/net: delete ISA intel eexpress and eepro i825xx drivers
These old drivers should not be confused with the very common PCI cards that are supported by e100.c -- these older 10Mbit ISA only drivers were not as commonly used as some of the other ISA drivers, simply due to hardware availability and pricing. Given the rarity of the hardware, and the subsequent less extensive use of the drivers, it makes sense to obsolete them at this point in time, along with other rare/experimental ISA drivers. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/Space.c8
-rw-r--r--drivers/net/ethernet/i825xx/Kconfig27
-rw-r--r--drivers/net/ethernet/i825xx/Makefile2
-rw-r--r--drivers/net/ethernet/i825xx/eepro.c1822
-rw-r--r--drivers/net/ethernet/i825xx/eexpress.c1661
-rw-r--r--drivers/net/ethernet/i825xx/eexpress.h179
6 files changed, 0 insertions, 3699 deletions
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index ac66a6af7138..726b17b79610 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -44,8 +44,6 @@ extern struct net_device *el2_probe(int unit);
44extern struct net_device *ne_probe(int unit); 44extern struct net_device *ne_probe(int unit);
45extern struct net_device *hp_probe(int unit); 45extern struct net_device *hp_probe(int unit);
46extern struct net_device *hp_plus_probe(int unit); 46extern struct net_device *hp_plus_probe(int unit);
47extern struct net_device *express_probe(int unit);
48extern struct net_device *eepro_probe(int unit);
49extern struct net_device *at1700_probe(int unit); 47extern struct net_device *at1700_probe(int unit);
50extern struct net_device *fmv18x_probe(int unit); 48extern struct net_device *fmv18x_probe(int unit);
51extern struct net_device *eth16i_probe(int unit); 49extern struct net_device *eth16i_probe(int unit);
@@ -150,12 +148,6 @@ static struct devprobe2 isa_probes[] __initdata = {
150#ifdef CONFIG_ETH16I 148#ifdef CONFIG_ETH16I
151 {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */ 149 {eth16i_probe, 0}, /* ICL EtherTeam 16i/32 */
152#endif 150#endif
153#ifdef CONFIG_EEXPRESS /* Intel EtherExpress */
154 {express_probe, 0},
155#endif
156#ifdef CONFIG_EEXPRESS_PRO /* Intel EtherExpress Pro/10 */
157 {eepro_probe, 0},
158#endif
159#ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */ 151#ifdef CONFIG_EWRK3 /* DEC EtherWORKS 3 */
160 {ewrk3_probe, 0}, 152 {ewrk3_probe, 0},
161#endif 153#endif
diff --git a/drivers/net/ethernet/i825xx/Kconfig b/drivers/net/ethernet/i825xx/Kconfig
index b800a94fc875..16b14a93c205 100644
--- a/drivers/net/ethernet/i825xx/Kconfig
+++ b/drivers/net/ethernet/i825xx/Kconfig
@@ -36,33 +36,6 @@ config BVME6000_NET
36 in your kernel. 36 in your kernel.
37 To compile this driver as a module, choose M here. 37 To compile this driver as a module, choose M here.
38 38
39config EEXPRESS
40 tristate "EtherExpress 16 support"
41 depends on ISA
42 ---help---
43 If you have an EtherExpress16 network (Ethernet) card, say Y and
44 read the Ethernet-HOWTO, available from
45 <http://www.tldp.org/docs.html#howto>. Note that the Intel
46 EtherExpress16 card used to be regarded as a very poor choice
47 because the driver was very unreliable. We now have a new driver
48 that should do better.
49
50 To compile this driver as a module, choose M here. The module
51 will be called eexpress.
52
53config EEXPRESS_PRO
54 tristate "EtherExpressPro support/EtherExpress 10 (i82595) support"
55 depends on ISA
56 ---help---
57 If you have a network (Ethernet) card of this type, say Y. This
58 driver supports Intel i82595{FX,TX} based boards. Note however
59 that the EtherExpress PRO/100 Ethernet card has its own separate
60 driver. Please read the Ethernet-HOWTO, available from
61 <http://www.tldp.org/docs.html#howto>.
62
63 To compile this driver as a module, choose M here. The module
64 will be called eepro.
65
66config LASI_82596 39config LASI_82596
67 tristate "Lasi ethernet" 40 tristate "Lasi ethernet"
68 depends on GSC 41 depends on GSC
diff --git a/drivers/net/ethernet/i825xx/Makefile b/drivers/net/ethernet/i825xx/Makefile
index bc81e14ed5bd..4267ae72c5d2 100644
--- a/drivers/net/ethernet/i825xx/Makefile
+++ b/drivers/net/ethernet/i825xx/Makefile
@@ -3,8 +3,6 @@
3# 3#
4 4
5obj-$(CONFIG_ARM_ETHER1) += ether1.o 5obj-$(CONFIG_ARM_ETHER1) += ether1.o
6obj-$(CONFIG_EEXPRESS) += eexpress.o
7obj-$(CONFIG_EEXPRESS_PRO) += eepro.o
8obj-$(CONFIG_NI52) += ni52.o 6obj-$(CONFIG_NI52) += ni52.o
9obj-$(CONFIG_SUN3_82586) += sun3_82586.o 7obj-$(CONFIG_SUN3_82586) += sun3_82586.o
10obj-$(CONFIG_ZNET) += znet.o 8obj-$(CONFIG_ZNET) += znet.o
diff --git a/drivers/net/ethernet/i825xx/eepro.c b/drivers/net/ethernet/i825xx/eepro.c
deleted file mode 100644
index 7f49fd54c521..000000000000
--- a/drivers/net/ethernet/i825xx/eepro.c
+++ /dev/null
@@ -1,1822 +0,0 @@
1/* eepro.c: Intel EtherExpress Pro/10 device driver for Linux. */
2/*
3 Written 1994, 1995,1996 by Bao C. Ha.
4
5 Copyright (C) 1994, 1995,1996 by Bao C. Ha.
6
7 This software may be used and distributed
8 according to the terms of the GNU General Public License,
9 incorporated herein by reference.
10
11 The author may be reached at bao.ha@srs.gov
12 or 418 Hastings Place, Martinez, GA 30907.
13
14 Things remaining to do:
15 Better record keeping of errors.
16 Eliminate transmit interrupt to reduce overhead.
17 Implement "concurrent processing". I won't be doing it!
18
19 Bugs:
20
21 If you have a problem of not detecting the 82595 during a
22 reboot (warm reset), disable the FLASH memory should fix it.
23 This is a compatibility hardware problem.
24
25 Versions:
26 0.13b basic ethtool support (aris, 09/13/2004)
27 0.13a in memory shortage, drop packets also in board
28 (Michael Westermann <mw@microdata-pos.de>, 07/30/2002)
29 0.13 irq sharing, rewrote probe function, fixed a nasty bug in
30 hardware_send_packet and a major cleanup (aris, 11/08/2001)
31 0.12d fixing a problem with single card detected as eight eth devices
32 fixing a problem with sudden drop in card performance
33 (chris (asdn@go2.pl), 10/29/2001)
34 0.12c fixing some problems with old cards (aris, 01/08/2001)
35 0.12b misc fixes (aris, 06/26/2000)
36 0.12a port of version 0.12a of 2.2.x kernels to 2.3.x
37 (aris (aris@conectiva.com.br), 05/19/2000)
38 0.11e some tweaks about multiple cards support (PdP, jul/aug 1999)
39 0.11d added __initdata, __init stuff; call spin_lock_init
40 in eepro_probe1. Replaced "eepro" by dev->name. Augmented
41 the code protected by spin_lock in interrupt routine
42 (PdP, 12/12/1998)
43 0.11c minor cleanup (PdP, RMC, 09/12/1998)
44 0.11b Pascal Dupuis (dupuis@lei.ucl.ac.be): works as a module
45 under 2.1.xx. Debug messages are flagged as KERN_DEBUG to
46 avoid console flooding. Added locking at critical parts. Now
47 the dawn thing is SMP safe.
48 0.11a Attempt to get 2.1.xx support up (RMC)
49 0.11 Brian Candler added support for multiple cards. Tested as
50 a module, no idea if it works when compiled into kernel.
51
52 0.10e Rick Bressler notified me that ifconfig up;ifconfig down fails
53 because the irq is lost somewhere. Fixed that by moving
54 request_irq and free_irq to eepro_open and eepro_close respectively.
55 0.10d Ugh! Now Wakeup works. Was seriously broken in my first attempt.
56 I'll need to find a way to specify an ioport other than
57 the default one in the PnP case. PnP definitively sucks.
58 And, yes, this is not the only reason.
59 0.10c PnP Wakeup Test for 595FX. uncomment #define PnPWakeup;
60 to use.
61 0.10b Should work now with (some) Pro/10+. At least for
62 me (and my two cards) it does. _No_ guarantee for
63 function with non-Pro/10+ cards! (don't have any)
64 (RMC, 9/11/96)
65
66 0.10 Added support for the Etherexpress Pro/10+. The
67 IRQ map was changed significantly from the old
68 pro/10. The new interrupt map was provided by
69 Rainer M. Canavan (Canavan@Zeus.cs.bonn.edu).
70 (BCH, 9/3/96)
71
72 0.09 Fixed a race condition in the transmit algorithm,
73 which causes crashes under heavy load with fast
74 pentium computers. The performance should also
75 improve a bit. The size of RX buffer, and hence
76 TX buffer, can also be changed via lilo or insmod.
77 (BCH, 7/31/96)
78
79 0.08 Implement 32-bit I/O for the 82595TX and 82595FX
80 based lan cards. Disable full-duplex mode if TPE
81 is not used. (BCH, 4/8/96)
82
83 0.07a Fix a stat report which counts every packet as a
84 heart-beat failure. (BCH, 6/3/95)
85
86 0.07 Modified to support all other 82595-based lan cards.
87 The IRQ vector of the EtherExpress Pro will be set
88 according to the value saved in the EEPROM. For other
89 cards, I will do autoirq_request() to grab the next
90 available interrupt vector. (BCH, 3/17/95)
91
92 0.06a,b Interim released. Minor changes in the comments and
93 print out format. (BCH, 3/9/95 and 3/14/95)
94
95 0.06 First stable release that I am comfortable with. (BCH,
96 3/2/95)
97
98 0.05 Complete testing of multicast. (BCH, 2/23/95)
99
100 0.04 Adding multicast support. (BCH, 2/14/95)
101
102 0.03 First widely alpha release for public testing.
103 (BCH, 2/14/95)
104
105*/
106
107static const char version[] =
108 "eepro.c: v0.13b 09/13/2004 aris@cathedrallabs.org\n";
109
110#include <linux/module.h>
111
112/*
113 Sources:
114
115 This driver wouldn't have been written without the availability
116 of the Crynwr's Lan595 driver source code. It helps me to
117 familiarize with the 82595 chipset while waiting for the Intel
118 documentation. I also learned how to detect the 82595 using
119 the packet driver's technique.
120
121 This driver is written by cutting and pasting the skeleton.c driver
122 provided by Donald Becker. I also borrowed the EEPROM routine from
123 Donald Becker's 82586 driver.
124
125 Datasheet for the Intel 82595 (including the TX and FX version). It
126 provides just enough info that the casual reader might think that it
127 documents the i82595.
128
129 The User Manual for the 82595. It provides a lot of the missing
130 information.
131
132*/
133
134#include <linux/kernel.h>
135#include <linux/types.h>
136#include <linux/fcntl.h>
137#include <linux/interrupt.h>
138#include <linux/ioport.h>
139#include <linux/in.h>
140#include <linux/string.h>
141#include <linux/errno.h>
142#include <linux/netdevice.h>
143#include <linux/etherdevice.h>
144#include <linux/skbuff.h>
145#include <linux/spinlock.h>
146#include <linux/init.h>
147#include <linux/delay.h>
148#include <linux/bitops.h>
149#include <linux/ethtool.h>
150
151#include <asm/io.h>
152#include <asm/dma.h>
153
154#define DRV_NAME "eepro"
155#define DRV_VERSION "0.13c"
156
157#define compat_dev_kfree_skb( skb, mode ) dev_kfree_skb( (skb) )
158/* I had reports of looong delays with SLOW_DOWN defined as udelay(2) */
159#define SLOW_DOWN inb(0x80)
160/* udelay(2) */
161#define compat_init_data __initdata
162enum iftype { AUI=0, BNC=1, TPE=2 };
163
164/* First, a few definitions that the brave might change. */
165/* A zero-terminated list of I/O addresses to be probed. */
166static unsigned int eepro_portlist[] compat_init_data =
167 { 0x300, 0x210, 0x240, 0x280, 0x2C0, 0x200, 0x320, 0x340, 0x360, 0};
168/* note: 0x300 is default, the 595FX supports ALL IO Ports
169 from 0x000 to 0x3F0, some of which are reserved in PCs */
170
171/* To try the (not-really PnP Wakeup: */
172/*
173#define PnPWakeup
174*/
175
176/* use 0 for production, 1 for verification, >2 for debug */
177#ifndef NET_DEBUG
178#define NET_DEBUG 0
179#endif
180static unsigned int net_debug = NET_DEBUG;
181
182/* The number of low I/O ports used by the ethercard. */
183#define EEPRO_IO_EXTENT 16
184
185/* Different 82595 chips */
186#define LAN595 0
187#define LAN595TX 1
188#define LAN595FX 2
189#define LAN595FX_10ISA 3
190
191/* Information that need to be kept for each board. */
192struct eepro_local {
193 unsigned rx_start;
194 unsigned tx_start; /* start of the transmit chain */
195 int tx_last; /* pointer to last packet in the transmit chain */
196 unsigned tx_end; /* end of the transmit chain (plus 1) */
197 int eepro; /* 1 for the EtherExpress Pro/10,
198 2 for the EtherExpress Pro/10+,
199 3 for the EtherExpress 10 (blue cards),
200 0 for other 82595-based lan cards. */
201 int version; /* a flag to indicate if this is a TX or FX
202 version of the 82595 chip. */
203 int stepping;
204
205 spinlock_t lock; /* Serializing lock */
206
207 unsigned rcv_ram; /* pre-calculated space for rx */
208 unsigned xmt_ram; /* pre-calculated space for tx */
209 unsigned char xmt_bar;
210 unsigned char xmt_lower_limit_reg;
211 unsigned char xmt_upper_limit_reg;
212 short xmt_lower_limit;
213 short xmt_upper_limit;
214 short rcv_lower_limit;
215 short rcv_upper_limit;
216 unsigned char eeprom_reg;
217 unsigned short word[8];
218};
219
220/* The station (ethernet) address prefix, used for IDing the board. */
221#define SA_ADDR0 0x00 /* Etherexpress Pro/10 */
222#define SA_ADDR1 0xaa
223#define SA_ADDR2 0x00
224
225#define GetBit(x,y) ((x & (1<<y))>>y)
226
227/* EEPROM Word 0: */
228#define ee_PnP 0 /* Plug 'n Play enable bit */
229#define ee_Word1 1 /* Word 1? */
230#define ee_BusWidth 2 /* 8/16 bit */
231#define ee_FlashAddr 3 /* Flash Address */
232#define ee_FlashMask 0x7 /* Mask */
233#define ee_AutoIO 6 /* */
234#define ee_reserved0 7 /* =0! */
235#define ee_Flash 8 /* Flash there? */
236#define ee_AutoNeg 9 /* Auto Negotiation enabled? */
237#define ee_IO0 10 /* IO Address LSB */
238#define ee_IO0Mask 0x /*...*/
239#define ee_IO1 15 /* IO MSB */
240
241/* EEPROM Word 1: */
242#define ee_IntSel 0 /* Interrupt */
243#define ee_IntMask 0x7
244#define ee_LI 3 /* Link Integrity 0= enabled */
245#define ee_PC 4 /* Polarity Correction 0= enabled */
246#define ee_TPE_AUI 5 /* PortSelection 1=TPE */
247#define ee_Jabber 6 /* Jabber prevention 0= enabled */
248#define ee_AutoPort 7 /* Auto Port Selection 1= Disabled */
249#define ee_SMOUT 8 /* SMout Pin Control 0= Input */
250#define ee_PROM 9 /* Flash EPROM / PROM 0=Flash */
251#define ee_reserved1 10 /* .. 12 =0! */
252#define ee_AltReady 13 /* Alternate Ready, 0=normal */
253#define ee_reserved2 14 /* =0! */
254#define ee_Duplex 15
255
256/* Word2,3,4: */
257#define ee_IA5 0 /*bit start for individual Addr Byte 5 */
258#define ee_IA4 8 /*bit start for individual Addr Byte 5 */
259#define ee_IA3 0 /*bit start for individual Addr Byte 5 */
260#define ee_IA2 8 /*bit start for individual Addr Byte 5 */
261#define ee_IA1 0 /*bit start for individual Addr Byte 5 */
262#define ee_IA0 8 /*bit start for individual Addr Byte 5 */
263
264/* Word 5: */
265#define ee_BNC_TPE 0 /* 0=TPE */
266#define ee_BootType 1 /* 00=None, 01=IPX, 10=ODI, 11=NDIS */
267#define ee_BootTypeMask 0x3
268#define ee_NumConn 3 /* Number of Connections 0= One or Two */
269#define ee_FlashSock 4 /* Presence of Flash Socket 0= Present */
270#define ee_PortTPE 5
271#define ee_PortBNC 6
272#define ee_PortAUI 7
273#define ee_PowerMgt 10 /* 0= disabled */
274#define ee_CP 13 /* Concurrent Processing */
275#define ee_CPMask 0x7
276
277/* Word 6: */
278#define ee_Stepping 0 /* Stepping info */
279#define ee_StepMask 0x0F
280#define ee_BoardID 4 /* Manucaturer Board ID, reserved */
281#define ee_BoardMask 0x0FFF
282
283/* Word 7: */
284#define ee_INT_TO_IRQ 0 /* int to IRQ Mapping = 0x1EB8 for Pro/10+ */
285#define ee_FX_INT2IRQ 0x1EB8 /* the _only_ mapping allowed for FX chips */
286
287/*..*/
288#define ee_SIZE 0x40 /* total EEprom Size */
289#define ee_Checksum 0xBABA /* initial and final value for adding checksum */
290
291
292/* Card identification via EEprom: */
293#define ee_addr_vendor 0x10 /* Word offset for EISA Vendor ID */
294#define ee_addr_id 0x11 /* Word offset for Card ID */
295#define ee_addr_SN 0x12 /* Serial Number */
296#define ee_addr_CRC_8 0x14 /* CRC over last thee Bytes */
297
298
299#define ee_vendor_intel0 0x25 /* Vendor ID Intel */
300#define ee_vendor_intel1 0xD4
301#define ee_id_eepro10p0 0x10 /* ID for eepro/10+ */
302#define ee_id_eepro10p1 0x31
303
304#define TX_TIMEOUT ((4*HZ)/10)
305
306/* Index to functions, as function prototypes. */
307
308static int eepro_probe1(struct net_device *dev, int autoprobe);
309static int eepro_open(struct net_device *dev);
310static netdev_tx_t eepro_send_packet(struct sk_buff *skb,
311 struct net_device *dev);
312static irqreturn_t eepro_interrupt(int irq, void *dev_id);
313static void eepro_rx(struct net_device *dev);
314static void eepro_transmit_interrupt(struct net_device *dev);
315static int eepro_close(struct net_device *dev);
316static void set_multicast_list(struct net_device *dev);
317static void eepro_tx_timeout (struct net_device *dev);
318
319static int read_eeprom(int ioaddr, int location, struct net_device *dev);
320static int hardware_send_packet(struct net_device *dev, void *buf, short length);
321static int eepro_grab_irq(struct net_device *dev);
322
323/*
324 Details of the i82595.
325
326You will need either the datasheet or the user manual to understand what
327is going on here. The 82595 is very different from the 82586, 82593.
328
329The receive algorithm in eepro_rx() is just an implementation of the
330RCV ring structure that the Intel 82595 imposes at the hardware level.
331The receive buffer is set at 24K, and the transmit buffer is 8K. I
332am assuming that the total buffer memory is 32K, which is true for the
333Intel EtherExpress Pro/10. If it is less than that on a generic card,
334the driver will be broken.
335
336The transmit algorithm in the hardware_send_packet() is similar to the
337one in the eepro_rx(). The transmit buffer is a ring linked list.
338I just queue the next available packet to the end of the list. In my
339system, the 82595 is so fast that the list seems to always contain a
340single packet. In other systems with faster computers and more congested
341network traffics, the ring linked list should improve performance by
342allowing up to 8K worth of packets to be queued.
343
344The sizes of the receive and transmit buffers can now be changed via lilo
345or insmod. Lilo uses the appended line "ether=io,irq,debug,rx-buffer,eth0"
346where rx-buffer is in KB unit. Modules uses the parameter mem which is
347also in KB unit, for example "insmod io=io-address irq=0 mem=rx-buffer."
348The receive buffer has to be more than 3K or less than 29K. Otherwise,
349it is reset to the default of 24K, and, hence, 8K for the trasnmit
350buffer (transmit-buffer = 32K - receive-buffer).
351
352*/
353#define RAM_SIZE 0x8000
354
355#define RCV_HEADER 8
356#define RCV_DEFAULT_RAM 0x6000
357
358#define XMT_HEADER 8
359#define XMT_DEFAULT_RAM (RAM_SIZE - RCV_DEFAULT_RAM)
360
361#define XMT_START_PRO RCV_DEFAULT_RAM
362#define XMT_START_10 0x0000
363#define RCV_START_PRO 0x0000
364#define RCV_START_10 XMT_DEFAULT_RAM
365
366#define RCV_DONE 0x0008
367#define RX_OK 0x2000
368#define RX_ERROR 0x0d81
369
370#define TX_DONE_BIT 0x0080
371#define TX_OK 0x2000
372#define CHAIN_BIT 0x8000
373#define XMT_STATUS 0x02
374#define XMT_CHAIN 0x04
375#define XMT_COUNT 0x06
376
377#define BANK0_SELECT 0x00
378#define BANK1_SELECT 0x40
379#define BANK2_SELECT 0x80
380
381/* Bank 0 registers */
382#define COMMAND_REG 0x00 /* Register 0 */
383#define MC_SETUP 0x03
384#define XMT_CMD 0x04
385#define DIAGNOSE_CMD 0x07
386#define RCV_ENABLE_CMD 0x08
387#define RCV_DISABLE_CMD 0x0a
388#define STOP_RCV_CMD 0x0b
389#define RESET_CMD 0x0e
390#define POWER_DOWN_CMD 0x18
391#define RESUME_XMT_CMD 0x1c
392#define SEL_RESET_CMD 0x1e
393#define STATUS_REG 0x01 /* Register 1 */
394#define RX_INT 0x02
395#define TX_INT 0x04
396#define EXEC_STATUS 0x30
397#define ID_REG 0x02 /* Register 2 */
398#define R_ROBIN_BITS 0xc0 /* round robin counter */
399#define ID_REG_MASK 0x2c
400#define ID_REG_SIG 0x24
401#define AUTO_ENABLE 0x10
402#define INT_MASK_REG 0x03 /* Register 3 */
403#define RX_STOP_MASK 0x01
404#define RX_MASK 0x02
405#define TX_MASK 0x04
406#define EXEC_MASK 0x08
407#define ALL_MASK 0x0f
408#define IO_32_BIT 0x10
409#define RCV_BAR 0x04 /* The following are word (16-bit) registers */
410#define RCV_STOP 0x06
411
412#define XMT_BAR_PRO 0x0a
413#define XMT_BAR_10 0x0b
414
415#define HOST_ADDRESS_REG 0x0c
416#define IO_PORT 0x0e
417#define IO_PORT_32_BIT 0x0c
418
419/* Bank 1 registers */
420#define REG1 0x01
421#define WORD_WIDTH 0x02
422#define INT_ENABLE 0x80
423#define INT_NO_REG 0x02
424#define RCV_LOWER_LIMIT_REG 0x08
425#define RCV_UPPER_LIMIT_REG 0x09
426
427#define XMT_LOWER_LIMIT_REG_PRO 0x0a
428#define XMT_UPPER_LIMIT_REG_PRO 0x0b
429#define XMT_LOWER_LIMIT_REG_10 0x0b
430#define XMT_UPPER_LIMIT_REG_10 0x0a
431
432/* Bank 2 registers */
433#define XMT_Chain_Int 0x20 /* Interrupt at the end of the transmit chain */
434#define XMT_Chain_ErrStop 0x40 /* Interrupt at the end of the chain even if there are errors */
435#define RCV_Discard_BadFrame 0x80 /* Throw bad frames away, and continue to receive others */
436#define REG2 0x02
437#define PRMSC_Mode 0x01
438#define Multi_IA 0x20
439#define REG3 0x03
440#define TPE_BIT 0x04
441#define BNC_BIT 0x20
442#define REG13 0x0d
443#define FDX 0x00
444#define A_N_ENABLE 0x02
445
446#define I_ADD_REG0 0x04
447#define I_ADD_REG1 0x05
448#define I_ADD_REG2 0x06
449#define I_ADD_REG3 0x07
450#define I_ADD_REG4 0x08
451#define I_ADD_REG5 0x09
452
453#define EEPROM_REG_PRO 0x0a
454#define EEPROM_REG_10 0x0b
455
456#define EESK 0x01
457#define EECS 0x02
458#define EEDI 0x04
459#define EEDO 0x08
460
461/* do a full reset */
462#define eepro_reset(ioaddr) outb(RESET_CMD, ioaddr)
463
464/* do a nice reset */
465#define eepro_sel_reset(ioaddr) { \
466 outb(SEL_RESET_CMD, ioaddr); \
467 SLOW_DOWN; \
468 SLOW_DOWN; \
469 }
470
471/* disable all interrupts */
472#define eepro_dis_int(ioaddr) outb(ALL_MASK, ioaddr + INT_MASK_REG)
473
474/* clear all interrupts */
475#define eepro_clear_int(ioaddr) outb(ALL_MASK, ioaddr + STATUS_REG)
476
477/* enable tx/rx */
478#define eepro_en_int(ioaddr) outb(ALL_MASK & ~(RX_MASK | TX_MASK), \
479 ioaddr + INT_MASK_REG)
480
481/* enable exec event interrupt */
482#define eepro_en_intexec(ioaddr) outb(ALL_MASK & ~(EXEC_MASK), ioaddr + INT_MASK_REG)
483
484/* enable rx */
485#define eepro_en_rx(ioaddr) outb(RCV_ENABLE_CMD, ioaddr)
486
487/* disable rx */
488#define eepro_dis_rx(ioaddr) outb(RCV_DISABLE_CMD, ioaddr)
489
490/* switch bank */
491#define eepro_sw2bank0(ioaddr) outb(BANK0_SELECT, ioaddr)
492#define eepro_sw2bank1(ioaddr) outb(BANK1_SELECT, ioaddr)
493#define eepro_sw2bank2(ioaddr) outb(BANK2_SELECT, ioaddr)
494
495/* enable interrupt line */
496#define eepro_en_intline(ioaddr) outb(inb(ioaddr + REG1) | INT_ENABLE,\
497 ioaddr + REG1)
498
499/* disable interrupt line */
500#define eepro_dis_intline(ioaddr) outb(inb(ioaddr + REG1) & 0x7f, \
501 ioaddr + REG1);
502
503/* set diagnose flag */
504#define eepro_diag(ioaddr) outb(DIAGNOSE_CMD, ioaddr)
505
506/* ack for rx int */
507#define eepro_ack_rx(ioaddr) outb (RX_INT, ioaddr + STATUS_REG)
508
509/* ack for tx int */
510#define eepro_ack_tx(ioaddr) outb (TX_INT, ioaddr + STATUS_REG)
511
512/* a complete sel reset */
513#define eepro_complete_selreset(ioaddr) { \
514 dev->stats.tx_errors++;\
515 eepro_sel_reset(ioaddr);\
516 lp->tx_end = \
517 lp->xmt_lower_limit;\
518 lp->tx_start = lp->tx_end;\
519 lp->tx_last = 0;\
520 dev->trans_start = jiffies;\
521 netif_wake_queue(dev);\
522 eepro_en_rx(ioaddr);\
523 }
524
525/* Check for a network adaptor of this type, and return '0' if one exists.
526 If dev->base_addr == 0, probe all likely locations.
527 If dev->base_addr == 1, always return failure.
528 If dev->base_addr == 2, allocate space for the device and return success
529 (detachable devices only).
530 */
531static int __init do_eepro_probe(struct net_device *dev)
532{
533 int i;
534 int base_addr = dev->base_addr;
535 int irq = dev->irq;
536
537#ifdef PnPWakeup
538 /* XXXX for multiple cards should this only be run once? */
539
540 /* Wakeup: */
541 #define WakeupPort 0x279
542 #define WakeupSeq {0x6A, 0xB5, 0xDA, 0xED, 0xF6, 0xFB, 0x7D, 0xBE,\
543 0xDF, 0x6F, 0x37, 0x1B, 0x0D, 0x86, 0xC3, 0x61,\
544 0xB0, 0x58, 0x2C, 0x16, 0x8B, 0x45, 0xA2, 0xD1,\
545 0xE8, 0x74, 0x3A, 0x9D, 0xCE, 0xE7, 0x73, 0x43}
546
547 {
548 unsigned short int WS[32]=WakeupSeq;
549
550 if (request_region(WakeupPort, 2, "eepro wakeup")) {
551 if (net_debug>5)
552 printk(KERN_DEBUG "Waking UP\n");
553
554 outb_p(0,WakeupPort);
555 outb_p(0,WakeupPort);
556 for (i=0; i<32; i++) {
557 outb_p(WS[i],WakeupPort);
558 if (net_debug>5) printk(KERN_DEBUG ": %#x ",WS[i]);
559 }
560
561 release_region(WakeupPort, 2);
562 } else
563 printk(KERN_WARNING "PnP wakeup region busy!\n");
564 }
565#endif
566
567 if (base_addr > 0x1ff) /* Check a single specified location. */
568 return eepro_probe1(dev, 0);
569
570 else if (base_addr != 0) /* Don't probe at all. */
571 return -ENXIO;
572
573 for (i = 0; eepro_portlist[i]; i++) {
574 dev->base_addr = eepro_portlist[i];
575 dev->irq = irq;
576 if (eepro_probe1(dev, 1) == 0)
577 return 0;
578 }
579
580 return -ENODEV;
581}
582
583#ifndef MODULE
584struct net_device * __init eepro_probe(int unit)
585{
586 struct net_device *dev = alloc_etherdev(sizeof(struct eepro_local));
587 int err;
588
589 if (!dev)
590 return ERR_PTR(-ENODEV);
591
592 sprintf(dev->name, "eth%d", unit);
593 netdev_boot_setup_check(dev);
594
595 err = do_eepro_probe(dev);
596 if (err)
597 goto out;
598 return dev;
599out:
600 free_netdev(dev);
601 return ERR_PTR(err);
602}
603#endif
604
605static void __init printEEPROMInfo(struct net_device *dev)
606{
607 struct eepro_local *lp = netdev_priv(dev);
608 int ioaddr = dev->base_addr;
609 unsigned short Word;
610 int i,j;
611
612 j = ee_Checksum;
613 for (i = 0; i < 8; i++)
614 j += lp->word[i];
615 for ( ; i < ee_SIZE; i++)
616 j += read_eeprom(ioaddr, i, dev);
617
618 printk(KERN_DEBUG "Checksum: %#x\n",j&0xffff);
619
620 Word = lp->word[0];
621 printk(KERN_DEBUG "Word0:\n");
622 printk(KERN_DEBUG " Plug 'n Pray: %d\n",GetBit(Word,ee_PnP));
623 printk(KERN_DEBUG " Buswidth: %d\n",(GetBit(Word,ee_BusWidth)+1)*8 );
624 printk(KERN_DEBUG " AutoNegotiation: %d\n",GetBit(Word,ee_AutoNeg));
625 printk(KERN_DEBUG " IO Address: %#x\n", (Word>>ee_IO0)<<4);
626
627 if (net_debug>4) {
628 Word = lp->word[1];
629 printk(KERN_DEBUG "Word1:\n");
630 printk(KERN_DEBUG " INT: %d\n", Word & ee_IntMask);
631 printk(KERN_DEBUG " LI: %d\n", GetBit(Word,ee_LI));
632 printk(KERN_DEBUG " PC: %d\n", GetBit(Word,ee_PC));
633 printk(KERN_DEBUG " TPE/AUI: %d\n", GetBit(Word,ee_TPE_AUI));
634 printk(KERN_DEBUG " Jabber: %d\n", GetBit(Word,ee_Jabber));
635 printk(KERN_DEBUG " AutoPort: %d\n", !GetBit(Word,ee_AutoPort));
636 printk(KERN_DEBUG " Duplex: %d\n", GetBit(Word,ee_Duplex));
637 }
638
639 Word = lp->word[5];
640 printk(KERN_DEBUG "Word5:\n");
641 printk(KERN_DEBUG " BNC: %d\n",GetBit(Word,ee_BNC_TPE));
642 printk(KERN_DEBUG " NumConnectors: %d\n",GetBit(Word,ee_NumConn));
643 printk(KERN_DEBUG " Has ");
644 if (GetBit(Word,ee_PortTPE)) printk(KERN_DEBUG "TPE ");
645 if (GetBit(Word,ee_PortBNC)) printk(KERN_DEBUG "BNC ");
646 if (GetBit(Word,ee_PortAUI)) printk(KERN_DEBUG "AUI ");
647 printk(KERN_DEBUG "port(s)\n");
648
649 Word = lp->word[6];
650 printk(KERN_DEBUG "Word6:\n");
651 printk(KERN_DEBUG " Stepping: %d\n",Word & ee_StepMask);
652 printk(KERN_DEBUG " BoardID: %d\n",Word>>ee_BoardID);
653
654 Word = lp->word[7];
655 printk(KERN_DEBUG "Word7:\n");
656 printk(KERN_DEBUG " INT to IRQ:\n");
657
658 for (i=0, j=0; i<15; i++)
659 if (GetBit(Word,i)) printk(KERN_DEBUG " INT%d -> IRQ %d;",j++,i);
660
661 printk(KERN_DEBUG "\n");
662}
663
664/* function to recalculate the limits of buffer based on rcv_ram */
665static void eepro_recalc (struct net_device *dev)
666{
667 struct eepro_local * lp;
668
669 lp = netdev_priv(dev);
670 lp->xmt_ram = RAM_SIZE - lp->rcv_ram;
671
672 if (lp->eepro == LAN595FX_10ISA) {
673 lp->xmt_lower_limit = XMT_START_10;
674 lp->xmt_upper_limit = (lp->xmt_ram - 2);
675 lp->rcv_lower_limit = lp->xmt_ram;
676 lp->rcv_upper_limit = (RAM_SIZE - 2);
677 }
678 else {
679 lp->rcv_lower_limit = RCV_START_PRO;
680 lp->rcv_upper_limit = (lp->rcv_ram - 2);
681 lp->xmt_lower_limit = lp->rcv_ram;
682 lp->xmt_upper_limit = (RAM_SIZE - 2);
683 }
684}
685
686/* prints boot-time info */
687static void __init eepro_print_info (struct net_device *dev)
688{
689 struct eepro_local * lp = netdev_priv(dev);
690 int i;
691 const char * ifmap[] = {"AUI", "10Base2", "10BaseT"};
692
693 i = inb(dev->base_addr + ID_REG);
694 printk(KERN_DEBUG " id: %#x ",i);
695 printk(" io: %#x ", (unsigned)dev->base_addr);
696
697 switch (lp->eepro) {
698 case LAN595FX_10ISA:
699 printk("%s: Intel EtherExpress 10 ISA\n at %#x,",
700 dev->name, (unsigned)dev->base_addr);
701 break;
702 case LAN595FX:
703 printk("%s: Intel EtherExpress Pro/10+ ISA\n at %#x,",
704 dev->name, (unsigned)dev->base_addr);
705 break;
706 case LAN595TX:
707 printk("%s: Intel EtherExpress Pro/10 ISA at %#x,",
708 dev->name, (unsigned)dev->base_addr);
709 break;
710 case LAN595:
711 printk("%s: Intel 82595-based lan card at %#x,",
712 dev->name, (unsigned)dev->base_addr);
713 break;
714 }
715
716 printk(" %pM", dev->dev_addr);
717
718 if (net_debug > 3)
719 printk(KERN_DEBUG ", %dK RCV buffer",
720 (int)(lp->rcv_ram)/1024);
721
722 if (dev->irq > 2)
723 printk(", IRQ %d, %s.\n", dev->irq, ifmap[dev->if_port]);
724 else
725 printk(", %s.\n", ifmap[dev->if_port]);
726
727 if (net_debug > 3) {
728 i = lp->word[5];
729 if (i & 0x2000) /* bit 13 of EEPROM word 5 */
730 printk(KERN_DEBUG "%s: Concurrent Processing is "
731 "enabled but not used!\n", dev->name);
732 }
733
734 /* Check the station address for the manufacturer's code */
735 if (net_debug>3)
736 printEEPROMInfo(dev);
737}
738
739static const struct ethtool_ops eepro_ethtool_ops;
740
741static const struct net_device_ops eepro_netdev_ops = {
742 .ndo_open = eepro_open,
743 .ndo_stop = eepro_close,
744 .ndo_start_xmit = eepro_send_packet,
745 .ndo_set_rx_mode = set_multicast_list,
746 .ndo_tx_timeout = eepro_tx_timeout,
747 .ndo_change_mtu = eth_change_mtu,
748 .ndo_set_mac_address = eth_mac_addr,
749 .ndo_validate_addr = eth_validate_addr,
750};
751
752/* This is the real probe routine. Linux has a history of friendly device
753 probes on the ISA bus. A good device probe avoids doing writes, and
754 verifies that the correct device exists and functions. */
755
756static int __init eepro_probe1(struct net_device *dev, int autoprobe)
757{
758 unsigned short station_addr[3], id, counter;
759 int i;
760 struct eepro_local *lp;
761 int ioaddr = dev->base_addr;
762 int err;
763
764 /* Grab the region so we can find another board if autoIRQ fails. */
765 if (!request_region(ioaddr, EEPRO_IO_EXTENT, DRV_NAME)) {
766 if (!autoprobe)
767 printk(KERN_WARNING "EEPRO: io-port 0x%04x in use\n",
768 ioaddr);
769 return -EBUSY;
770 }
771
772 /* Now, we are going to check for the signature of the
773 ID_REG (register 2 of bank 0) */
774
775 id = inb(ioaddr + ID_REG);
776
777 if ((id & ID_REG_MASK) != ID_REG_SIG)
778 goto exit;
779
780 /* We seem to have the 82595 signature, let's
781 play with its counter (last 2 bits of
782 register 2 of bank 0) to be sure. */
783
784 counter = id & R_ROBIN_BITS;
785
786 if ((inb(ioaddr + ID_REG) & R_ROBIN_BITS) != (counter + 0x40))
787 goto exit;
788
789 lp = netdev_priv(dev);
790 memset(lp, 0, sizeof(struct eepro_local));
791 lp->xmt_bar = XMT_BAR_PRO;
792 lp->xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_PRO;
793 lp->xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_PRO;
794 lp->eeprom_reg = EEPROM_REG_PRO;
795 spin_lock_init(&lp->lock);
796
797 /* Now, get the ethernet hardware address from
798 the EEPROM */
799 station_addr[0] = read_eeprom(ioaddr, 2, dev);
800
801 /* FIXME - find another way to know that we've found
802 * an Etherexpress 10
803 */
804 if (station_addr[0] == 0x0000 || station_addr[0] == 0xffff) {
805 lp->eepro = LAN595FX_10ISA;
806 lp->eeprom_reg = EEPROM_REG_10;
807 lp->xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_10;
808 lp->xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_10;
809 lp->xmt_bar = XMT_BAR_10;
810 station_addr[0] = read_eeprom(ioaddr, 2, dev);
811 }
812
813 /* get all words at once. will be used here and for ethtool */
814 for (i = 0; i < 8; i++) {
815 lp->word[i] = read_eeprom(ioaddr, i, dev);
816 }
817 station_addr[1] = lp->word[3];
818 station_addr[2] = lp->word[4];
819
820 if (!lp->eepro) {
821 if (lp->word[7] == ee_FX_INT2IRQ)
822 lp->eepro = 2;
823 else if (station_addr[2] == SA_ADDR1)
824 lp->eepro = 1;
825 }
826
827 /* Fill in the 'dev' fields. */
828 for (i=0; i < 6; i++)
829 dev->dev_addr[i] = ((unsigned char *) station_addr)[5-i];
830
831 /* RX buffer must be more than 3K and less than 29K */
832 if (dev->mem_end < 3072 || dev->mem_end > 29696)
833 lp->rcv_ram = RCV_DEFAULT_RAM;
834
835 /* calculate {xmt,rcv}_{lower,upper}_limit */
836 eepro_recalc(dev);
837
838 if (GetBit(lp->word[5], ee_BNC_TPE))
839 dev->if_port = BNC;
840 else
841 dev->if_port = TPE;
842
843 if (dev->irq < 2 && lp->eepro != 0) {
844 /* Mask off INT number */
845 int count = lp->word[1] & 7;
846 unsigned irqMask = lp->word[7];
847
848 while (count--)
849 irqMask &= irqMask - 1;
850
851 count = ffs(irqMask);
852
853 if (count)
854 dev->irq = count - 1;
855
856 if (dev->irq < 2) {
857 printk(KERN_ERR " Duh! illegal interrupt vector stored in EEPROM.\n");
858 goto exit;
859 } else if (dev->irq == 2) {
860 dev->irq = 9;
861 }
862 }
863
864 dev->netdev_ops = &eepro_netdev_ops;
865 dev->watchdog_timeo = TX_TIMEOUT;
866 dev->ethtool_ops = &eepro_ethtool_ops;
867
868 /* print boot time info */
869 eepro_print_info(dev);
870
871 /* reset 82595 */
872 eepro_reset(ioaddr);
873
874 err = register_netdev(dev);
875 if (err)
876 goto err;
877 return 0;
878exit:
879 err = -ENODEV;
880err:
881 release_region(dev->base_addr, EEPRO_IO_EXTENT);
882 return err;
883}
884
885/* Open/initialize the board. This is called (in the current kernel)
886 sometime after booting when the 'ifconfig' program is run.
887
888 This routine should set everything up anew at each open, even
889 registers that "should" only need to be set once at boot, so that
890 there is non-reboot way to recover if something goes wrong.
891 */
892
893static const char irqrmap[] = {-1,-1,0,1,-1,2,-1,-1,-1,0,3,4,-1,-1,-1,-1};
894static const char irqrmap2[] = {-1,-1,4,0,1,2,-1,3,-1,4,5,6,7,-1,-1,-1};
895static int eepro_grab_irq(struct net_device *dev)
896{
897 static const int irqlist[] = { 3, 4, 5, 7, 9, 10, 11, 12, 0 };
898 const int *irqp = irqlist;
899 int temp_reg, ioaddr = dev->base_addr;
900
901 eepro_sw2bank1(ioaddr); /* be CAREFUL, BANK 1 now */
902
903 /* Enable the interrupt line. */
904 eepro_en_intline(ioaddr);
905
906 /* be CAREFUL, BANK 0 now */
907 eepro_sw2bank0(ioaddr);
908
909 /* clear all interrupts */
910 eepro_clear_int(ioaddr);
911
912 /* Let EXEC event to interrupt */
913 eepro_en_intexec(ioaddr);
914
915 do {
916 eepro_sw2bank1(ioaddr); /* be CAREFUL, BANK 1 now */
917
918 temp_reg = inb(ioaddr + INT_NO_REG);
919 outb((temp_reg & 0xf8) | irqrmap[*irqp], ioaddr + INT_NO_REG);
920
921 eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */
922
923 if (request_irq (*irqp, NULL, IRQF_SHARED, "bogus", dev) != EBUSY) {
924 unsigned long irq_mask;
925 /* Twinkle the interrupt, and check if it's seen */
926 irq_mask = probe_irq_on();
927
928 eepro_diag(ioaddr); /* RESET the 82595 */
929 mdelay(20);
930
931 if (*irqp == probe_irq_off(irq_mask)) /* It's a good IRQ line */
932 break;
933
934 /* clear all interrupts */
935 eepro_clear_int(ioaddr);
936 }
937 } while (*++irqp);
938
939 eepro_sw2bank1(ioaddr); /* Switch back to Bank 1 */
940
941 /* Disable the physical interrupt line. */
942 eepro_dis_intline(ioaddr);
943
944 eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */
945
946 /* Mask all the interrupts. */
947 eepro_dis_int(ioaddr);
948
949 /* clear all interrupts */
950 eepro_clear_int(ioaddr);
951
952 return dev->irq;
953}
954
955static int eepro_open(struct net_device *dev)
956{
957 unsigned short temp_reg, old8, old9;
958 int irqMask;
959 int i, ioaddr = dev->base_addr;
960 struct eepro_local *lp = netdev_priv(dev);
961
962 if (net_debug > 3)
963 printk(KERN_DEBUG "%s: entering eepro_open routine.\n", dev->name);
964
965 irqMask = lp->word[7];
966
967 if (lp->eepro == LAN595FX_10ISA) {
968 if (net_debug > 3) printk(KERN_DEBUG "p->eepro = 3;\n");
969 }
970 else if (irqMask == ee_FX_INT2IRQ) /* INT to IRQ Mask */
971 {
972 lp->eepro = 2; /* Yes, an Intel EtherExpress Pro/10+ */
973 if (net_debug > 3) printk(KERN_DEBUG "p->eepro = 2;\n");
974 }
975
976 else if ((dev->dev_addr[0] == SA_ADDR0 &&
977 dev->dev_addr[1] == SA_ADDR1 &&
978 dev->dev_addr[2] == SA_ADDR2))
979 {
980 lp->eepro = 1;
981 if (net_debug > 3) printk(KERN_DEBUG "p->eepro = 1;\n");
982 } /* Yes, an Intel EtherExpress Pro/10 */
983
984 else lp->eepro = 0; /* No, it is a generic 82585 lan card */
985
986 /* Get the interrupt vector for the 82595 */
987 if (dev->irq < 2 && eepro_grab_irq(dev) == 0) {
988 printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
989 return -EAGAIN;
990 }
991
992 if (request_irq(dev->irq , eepro_interrupt, 0, dev->name, dev)) {
993 printk(KERN_ERR "%s: unable to get IRQ %d.\n", dev->name, dev->irq);
994 return -EAGAIN;
995 }
996
997 /* Initialize the 82595. */
998
999 eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
1000 temp_reg = inb(ioaddr + lp->eeprom_reg);
1001
1002 lp->stepping = temp_reg >> 5; /* Get the stepping number of the 595 */
1003
1004 if (net_debug > 3)
1005 printk(KERN_DEBUG "The stepping of the 82595 is %d\n", lp->stepping);
1006
1007 if (temp_reg & 0x10) /* Check the TurnOff Enable bit */
1008 outb(temp_reg & 0xef, ioaddr + lp->eeprom_reg);
1009 for (i=0; i < 6; i++)
1010 outb(dev->dev_addr[i] , ioaddr + I_ADD_REG0 + i);
1011
1012 temp_reg = inb(ioaddr + REG1); /* Setup Transmit Chaining */
1013 outb(temp_reg | XMT_Chain_Int | XMT_Chain_ErrStop /* and discard bad RCV frames */
1014 | RCV_Discard_BadFrame, ioaddr + REG1);
1015
1016 temp_reg = inb(ioaddr + REG2); /* Match broadcast */
1017 outb(temp_reg | 0x14, ioaddr + REG2);
1018
1019 temp_reg = inb(ioaddr + REG3);
1020 outb(temp_reg & 0x3f, ioaddr + REG3); /* clear test mode */
1021
1022 /* Set the receiving mode */
1023 eepro_sw2bank1(ioaddr); /* be CAREFUL, BANK 1 now */
1024
1025 /* Set the interrupt vector */
1026 temp_reg = inb(ioaddr + INT_NO_REG);
1027 if (lp->eepro == LAN595FX || lp->eepro == LAN595FX_10ISA)
1028 outb((temp_reg & 0xf8) | irqrmap2[dev->irq], ioaddr + INT_NO_REG);
1029 else outb((temp_reg & 0xf8) | irqrmap[dev->irq], ioaddr + INT_NO_REG);
1030
1031
1032 temp_reg = inb(ioaddr + INT_NO_REG);
1033 if (lp->eepro == LAN595FX || lp->eepro == LAN595FX_10ISA)
1034 outb((temp_reg & 0xf0) | irqrmap2[dev->irq] | 0x08,ioaddr+INT_NO_REG);
1035 else outb((temp_reg & 0xf8) | irqrmap[dev->irq], ioaddr + INT_NO_REG);
1036
1037 if (net_debug > 3)
1038 printk(KERN_DEBUG "eepro_open: content of INT Reg is %x\n", temp_reg);
1039
1040
1041 /* Initialize the RCV and XMT upper and lower limits */
1042 outb(lp->rcv_lower_limit >> 8, ioaddr + RCV_LOWER_LIMIT_REG);
1043 outb(lp->rcv_upper_limit >> 8, ioaddr + RCV_UPPER_LIMIT_REG);
1044 outb(lp->xmt_lower_limit >> 8, ioaddr + lp->xmt_lower_limit_reg);
1045 outb(lp->xmt_upper_limit >> 8, ioaddr + lp->xmt_upper_limit_reg);
1046
1047 /* Enable the interrupt line. */
1048 eepro_en_intline(ioaddr);
1049
1050 /* Switch back to Bank 0 */
1051 eepro_sw2bank0(ioaddr);
1052
1053 /* Let RX and TX events to interrupt */
1054 eepro_en_int(ioaddr);
1055
1056 /* clear all interrupts */
1057 eepro_clear_int(ioaddr);
1058
1059 /* Initialize RCV */
1060 outw(lp->rcv_lower_limit, ioaddr + RCV_BAR);
1061 lp->rx_start = lp->rcv_lower_limit;
1062 outw(lp->rcv_upper_limit | 0xfe, ioaddr + RCV_STOP);
1063
1064 /* Initialize XMT */
1065 outw(lp->xmt_lower_limit, ioaddr + lp->xmt_bar);
1066 lp->tx_start = lp->tx_end = lp->xmt_lower_limit;
1067 lp->tx_last = 0;
1068
1069 /* Check for the i82595TX and i82595FX */
1070 old8 = inb(ioaddr + 8);
1071 outb(~old8, ioaddr + 8);
1072
1073 if ((temp_reg = inb(ioaddr + 8)) == old8) {
1074 if (net_debug > 3)
1075 printk(KERN_DEBUG "i82595 detected!\n");
1076 lp->version = LAN595;
1077 }
1078 else {
1079 lp->version = LAN595TX;
1080 outb(old8, ioaddr + 8);
1081 old9 = inb(ioaddr + 9);
1082
1083 if (irqMask==ee_FX_INT2IRQ) {
1084 if (net_debug > 3) {
1085 printk(KERN_DEBUG "IrqMask: %#x\n",irqMask);
1086 printk(KERN_DEBUG "i82595FX detected!\n");
1087 }
1088 lp->version = LAN595FX;
1089 outb(old9, ioaddr + 9);
1090 if (dev->if_port != TPE) { /* Hopefully, this will fix the
1091 problem of using Pentiums and
1092 pro/10 w/ BNC. */
1093 eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
1094 temp_reg = inb(ioaddr + REG13);
1095 /* disable the full duplex mode since it is not
1096 applicable with the 10Base2 cable. */
1097 outb(temp_reg & ~(FDX | A_N_ENABLE), REG13);
1098 eepro_sw2bank0(ioaddr); /* be CAREFUL, BANK 0 now */
1099 }
1100 }
1101 else if (net_debug > 3) {
1102 printk(KERN_DEBUG "temp_reg: %#x ~old9: %#x\n",temp_reg,((~old9)&0xff));
1103 printk(KERN_DEBUG "i82595TX detected!\n");
1104 }
1105 }
1106
1107 eepro_sel_reset(ioaddr);
1108
1109 netif_start_queue(dev);
1110
1111 if (net_debug > 3)
1112 printk(KERN_DEBUG "%s: exiting eepro_open routine.\n", dev->name);
1113
1114 /* enabling rx */
1115 eepro_en_rx(ioaddr);
1116
1117 return 0;
1118}
1119
1120static void eepro_tx_timeout (struct net_device *dev)
1121{
1122 struct eepro_local *lp = netdev_priv(dev);
1123 int ioaddr = dev->base_addr;
1124
1125 /* if (net_debug > 1) */
1126 printk (KERN_ERR "%s: transmit timed out, %s?\n", dev->name,
1127 "network cable problem");
1128 /* This is not a duplicate. One message for the console,
1129 one for the log file */
1130 printk (KERN_DEBUG "%s: transmit timed out, %s?\n", dev->name,
1131 "network cable problem");
1132 eepro_complete_selreset(ioaddr);
1133}
1134
1135
1136static netdev_tx_t eepro_send_packet(struct sk_buff *skb,
1137 struct net_device *dev)
1138{
1139 struct eepro_local *lp = netdev_priv(dev);
1140 unsigned long flags;
1141 int ioaddr = dev->base_addr;
1142 short length = skb->len;
1143
1144 if (net_debug > 5)
1145 printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name);
1146
1147 if (length < ETH_ZLEN) {
1148 if (skb_padto(skb, ETH_ZLEN))
1149 return NETDEV_TX_OK;
1150 length = ETH_ZLEN;
1151 }
1152 netif_stop_queue (dev);
1153
1154 eepro_dis_int(ioaddr);
1155 spin_lock_irqsave(&lp->lock, flags);
1156
1157 {
1158 unsigned char *buf = skb->data;
1159
1160 if (hardware_send_packet(dev, buf, length))
1161 /* we won't wake queue here because we're out of space */
1162 dev->stats.tx_dropped++;
1163 else {
1164 dev->stats.tx_bytes+=skb->len;
1165 netif_wake_queue(dev);
1166 }
1167
1168 }
1169
1170 dev_kfree_skb (skb);
1171
1172 /* You might need to clean up and record Tx statistics here. */
1173 /* dev->stats.tx_aborted_errors++; */
1174
1175 if (net_debug > 5)
1176 printk(KERN_DEBUG "%s: exiting eepro_send_packet routine.\n", dev->name);
1177
1178 eepro_en_int(ioaddr);
1179 spin_unlock_irqrestore(&lp->lock, flags);
1180
1181 return NETDEV_TX_OK;
1182}
1183
1184
1185/* The typical workload of the driver:
1186 Handle the network interface interrupts. */
1187
1188static irqreturn_t
1189eepro_interrupt(int irq, void *dev_id)
1190{
1191 struct net_device *dev = dev_id;
1192 struct eepro_local *lp;
1193 int ioaddr, status, boguscount = 20;
1194 int handled = 0;
1195
1196 lp = netdev_priv(dev);
1197
1198 spin_lock(&lp->lock);
1199
1200 if (net_debug > 5)
1201 printk(KERN_DEBUG "%s: entering eepro_interrupt routine.\n", dev->name);
1202
1203 ioaddr = dev->base_addr;
1204
1205 while (((status = inb(ioaddr + STATUS_REG)) & (RX_INT|TX_INT)) && (boguscount--))
1206 {
1207 handled = 1;
1208 if (status & RX_INT) {
1209 if (net_debug > 4)
1210 printk(KERN_DEBUG "%s: packet received interrupt.\n", dev->name);
1211
1212 eepro_dis_int(ioaddr);
1213
1214 /* Get the received packets */
1215 eepro_ack_rx(ioaddr);
1216 eepro_rx(dev);
1217
1218 eepro_en_int(ioaddr);
1219 }
1220 if (status & TX_INT) {
1221 if (net_debug > 4)
1222 printk(KERN_DEBUG "%s: packet transmit interrupt.\n", dev->name);
1223
1224
1225 eepro_dis_int(ioaddr);
1226
1227 /* Process the status of transmitted packets */
1228 eepro_ack_tx(ioaddr);
1229 eepro_transmit_interrupt(dev);
1230
1231 eepro_en_int(ioaddr);
1232 }
1233 }
1234
1235 if (net_debug > 5)
1236 printk(KERN_DEBUG "%s: exiting eepro_interrupt routine.\n", dev->name);
1237
1238 spin_unlock(&lp->lock);
1239 return IRQ_RETVAL(handled);
1240}
1241
1242static int eepro_close(struct net_device *dev)
1243{
1244 struct eepro_local *lp = netdev_priv(dev);
1245 int ioaddr = dev->base_addr;
1246 short temp_reg;
1247
1248 netif_stop_queue(dev);
1249
1250 eepro_sw2bank1(ioaddr); /* Switch back to Bank 1 */
1251
1252 /* Disable the physical interrupt line. */
1253 temp_reg = inb(ioaddr + REG1);
1254 outb(temp_reg & 0x7f, ioaddr + REG1);
1255
1256 eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */
1257
1258 /* Flush the Tx and disable Rx. */
1259 outb(STOP_RCV_CMD, ioaddr);
1260 lp->tx_start = lp->tx_end = lp->xmt_lower_limit;
1261 lp->tx_last = 0;
1262
1263 /* Mask all the interrupts. */
1264 eepro_dis_int(ioaddr);
1265
1266 /* clear all interrupts */
1267 eepro_clear_int(ioaddr);
1268
1269 /* Reset the 82595 */
1270 eepro_reset(ioaddr);
1271
1272 /* release the interrupt */
1273 free_irq(dev->irq, dev);
1274
1275 /* Update the statistics here. What statistics? */
1276
1277 return 0;
1278}
1279
1280/* Set or clear the multicast filter for this adaptor.
1281 */
1282static void
1283set_multicast_list(struct net_device *dev)
1284{
1285 struct eepro_local *lp = netdev_priv(dev);
1286 short ioaddr = dev->base_addr;
1287 unsigned short mode;
1288 struct netdev_hw_addr *ha;
1289 int mc_count = netdev_mc_count(dev);
1290
1291 if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || mc_count > 63)
1292 {
1293 eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
1294 mode = inb(ioaddr + REG2);
1295 outb(mode | PRMSC_Mode, ioaddr + REG2);
1296 mode = inb(ioaddr + REG3);
1297 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
1298 eepro_sw2bank0(ioaddr); /* Return to BANK 0 now */
1299 }
1300
1301 else if (mc_count == 0)
1302 {
1303 eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
1304 mode = inb(ioaddr + REG2);
1305 outb(mode & 0xd6, ioaddr + REG2); /* Turn off Multi-IA and PRMSC_Mode bits */
1306 mode = inb(ioaddr + REG3);
1307 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
1308 eepro_sw2bank0(ioaddr); /* Return to BANK 0 now */
1309 }
1310
1311 else
1312 {
1313 unsigned short status, *eaddrs;
1314 int i, boguscount = 0;
1315
1316 /* Disable RX and TX interrupts. Necessary to avoid
1317 corruption of the HOST_ADDRESS_REG by interrupt
1318 service routines. */
1319 eepro_dis_int(ioaddr);
1320
1321 eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
1322 mode = inb(ioaddr + REG2);
1323 outb(mode | Multi_IA, ioaddr + REG2);
1324 mode = inb(ioaddr + REG3);
1325 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
1326 eepro_sw2bank0(ioaddr); /* Return to BANK 0 now */
1327 outw(lp->tx_end, ioaddr + HOST_ADDRESS_REG);
1328 outw(MC_SETUP, ioaddr + IO_PORT);
1329 outw(0, ioaddr + IO_PORT);
1330 outw(0, ioaddr + IO_PORT);
1331 outw(6 * (mc_count + 1), ioaddr + IO_PORT);
1332
1333 netdev_for_each_mc_addr(ha, dev) {
1334 eaddrs = (unsigned short *) ha->addr;
1335 outw(*eaddrs++, ioaddr + IO_PORT);
1336 outw(*eaddrs++, ioaddr + IO_PORT);
1337 outw(*eaddrs++, ioaddr + IO_PORT);
1338 }
1339
1340 eaddrs = (unsigned short *) dev->dev_addr;
1341 outw(eaddrs[0], ioaddr + IO_PORT);
1342 outw(eaddrs[1], ioaddr + IO_PORT);
1343 outw(eaddrs[2], ioaddr + IO_PORT);
1344 outw(lp->tx_end, ioaddr + lp->xmt_bar);
1345 outb(MC_SETUP, ioaddr);
1346
1347 /* Update the transmit queue */
1348 i = lp->tx_end + XMT_HEADER + 6 * (mc_count + 1);
1349
1350 if (lp->tx_start != lp->tx_end)
1351 {
1352 /* update the next address and the chain bit in the
1353 last packet */
1354 outw(lp->tx_last + XMT_CHAIN, ioaddr + HOST_ADDRESS_REG);
1355 outw(i, ioaddr + IO_PORT);
1356 outw(lp->tx_last + XMT_COUNT, ioaddr + HOST_ADDRESS_REG);
1357 status = inw(ioaddr + IO_PORT);
1358 outw(status | CHAIN_BIT, ioaddr + IO_PORT);
1359 lp->tx_end = i ;
1360 }
1361 else {
1362 lp->tx_start = lp->tx_end = i ;
1363 }
1364
1365 /* Acknowledge that the MC setup is done */
1366 do { /* We should be doing this in the eepro_interrupt()! */
1367 SLOW_DOWN;
1368 SLOW_DOWN;
1369 if (inb(ioaddr + STATUS_REG) & 0x08)
1370 {
1371 i = inb(ioaddr);
1372 outb(0x08, ioaddr + STATUS_REG);
1373
1374 if (i & 0x20) { /* command ABORTed */
1375 printk(KERN_NOTICE "%s: multicast setup failed.\n",
1376 dev->name);
1377 break;
1378 } else if ((i & 0x0f) == 0x03) { /* MC-Done */
1379 printk(KERN_DEBUG "%s: set Rx mode to %d address%s.\n",
1380 dev->name, mc_count,
1381 mc_count > 1 ? "es":"");
1382 break;
1383 }
1384 }
1385 } while (++boguscount < 100);
1386
1387 /* Re-enable RX and TX interrupts */
1388 eepro_en_int(ioaddr);
1389 }
1390 if (lp->eepro == LAN595FX_10ISA) {
1391 eepro_complete_selreset(ioaddr);
1392 }
1393 else
1394 eepro_en_rx(ioaddr);
1395}
1396
1397/* The horrible routine to read a word from the serial EEPROM. */
1398/* IMPORTANT - the 82595 will be set to Bank 0 after the eeprom is read */
1399
1400/* The delay between EEPROM clock transitions. */
1401#define eeprom_delay() { udelay(40); }
1402#define EE_READ_CMD (6 << 6)
1403
1404static int
1405read_eeprom(int ioaddr, int location, struct net_device *dev)
1406{
1407 int i;
1408 unsigned short retval = 0;
1409 struct eepro_local *lp = netdev_priv(dev);
1410 short ee_addr = ioaddr + lp->eeprom_reg;
1411 int read_cmd = location | EE_READ_CMD;
1412 short ctrl_val = EECS ;
1413
1414 /* XXXX - black magic */
1415 eepro_sw2bank1(ioaddr);
1416 outb(0x00, ioaddr + STATUS_REG);
1417 /* XXXX - black magic */
1418
1419 eepro_sw2bank2(ioaddr);
1420 outb(ctrl_val, ee_addr);
1421
1422 /* Shift the read command bits out. */
1423 for (i = 8; i >= 0; i--) {
1424 short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI
1425 : ctrl_val;
1426 outb(outval, ee_addr);
1427 outb(outval | EESK, ee_addr); /* EEPROM clock tick. */
1428 eeprom_delay();
1429 outb(outval, ee_addr); /* Finish EEPROM a clock tick. */
1430 eeprom_delay();
1431 }
1432 outb(ctrl_val, ee_addr);
1433
1434 for (i = 16; i > 0; i--) {
1435 outb(ctrl_val | EESK, ee_addr); eeprom_delay();
1436 retval = (retval << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
1437 outb(ctrl_val, ee_addr); eeprom_delay();
1438 }
1439
1440 /* Terminate the EEPROM access. */
1441 ctrl_val &= ~EECS;
1442 outb(ctrl_val | EESK, ee_addr);
1443 eeprom_delay();
1444 outb(ctrl_val, ee_addr);
1445 eeprom_delay();
1446 eepro_sw2bank0(ioaddr);
1447 return retval;
1448}
1449
1450static int
1451hardware_send_packet(struct net_device *dev, void *buf, short length)
1452{
1453 struct eepro_local *lp = netdev_priv(dev);
1454 short ioaddr = dev->base_addr;
1455 unsigned status, tx_available, last, end;
1456
1457 if (net_debug > 5)
1458 printk(KERN_DEBUG "%s: entering hardware_send_packet routine.\n", dev->name);
1459
1460 /* determine how much of the transmit buffer space is available */
1461 if (lp->tx_end > lp->tx_start)
1462 tx_available = lp->xmt_ram - (lp->tx_end - lp->tx_start);
1463 else if (lp->tx_end < lp->tx_start)
1464 tx_available = lp->tx_start - lp->tx_end;
1465 else tx_available = lp->xmt_ram;
1466
1467 if (((((length + 3) >> 1) << 1) + 2*XMT_HEADER) >= tx_available) {
1468 /* No space available ??? */
1469 return 1;
1470 }
1471
1472 last = lp->tx_end;
1473 end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
1474
1475 if (end >= lp->xmt_upper_limit + 2) { /* the transmit buffer is wrapped around */
1476 if ((lp->xmt_upper_limit + 2 - last) <= XMT_HEADER) {
1477 /* Arrrr!!!, must keep the xmt header together,
1478 several days were lost to chase this one down. */
1479 last = lp->xmt_lower_limit;
1480 end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
1481 }
1482 else end = lp->xmt_lower_limit + (end -
1483 lp->xmt_upper_limit + 2);
1484 }
1485
1486 outw(last, ioaddr + HOST_ADDRESS_REG);
1487 outw(XMT_CMD, ioaddr + IO_PORT);
1488 outw(0, ioaddr + IO_PORT);
1489 outw(end, ioaddr + IO_PORT);
1490 outw(length, ioaddr + IO_PORT);
1491
1492 if (lp->version == LAN595)
1493 outsw(ioaddr + IO_PORT, buf, (length + 3) >> 1);
1494 else { /* LAN595TX or LAN595FX, capable of 32-bit I/O processing */
1495 unsigned short temp = inb(ioaddr + INT_MASK_REG);
1496 outb(temp | IO_32_BIT, ioaddr + INT_MASK_REG);
1497 outsl(ioaddr + IO_PORT_32_BIT, buf, (length + 3) >> 2);
1498 outb(temp & ~(IO_32_BIT), ioaddr + INT_MASK_REG);
1499 }
1500
1501 /* A dummy read to flush the DRAM write pipeline */
1502 status = inw(ioaddr + IO_PORT);
1503
1504 if (lp->tx_start == lp->tx_end) {
1505 outw(last, ioaddr + lp->xmt_bar);
1506 outb(XMT_CMD, ioaddr);
1507 lp->tx_start = last; /* I don't like to change tx_start here */
1508 }
1509 else {
1510 /* update the next address and the chain bit in the
1511 last packet */
1512
1513 if (lp->tx_end != last) {
1514 outw(lp->tx_last + XMT_CHAIN, ioaddr + HOST_ADDRESS_REG);
1515 outw(last, ioaddr + IO_PORT);
1516 }
1517
1518 outw(lp->tx_last + XMT_COUNT, ioaddr + HOST_ADDRESS_REG);
1519 status = inw(ioaddr + IO_PORT);
1520 outw(status | CHAIN_BIT, ioaddr + IO_PORT);
1521
1522 /* Continue the transmit command */
1523 outb(RESUME_XMT_CMD, ioaddr);
1524 }
1525
1526 lp->tx_last = last;
1527 lp->tx_end = end;
1528
1529 if (net_debug > 5)
1530 printk(KERN_DEBUG "%s: exiting hardware_send_packet routine.\n", dev->name);
1531
1532 return 0;
1533}
1534
1535static void
1536eepro_rx(struct net_device *dev)
1537{
1538 struct eepro_local *lp = netdev_priv(dev);
1539 short ioaddr = dev->base_addr;
1540 short boguscount = 20;
1541 short rcv_car = lp->rx_start;
1542 unsigned rcv_event, rcv_status, rcv_next_frame, rcv_size;
1543
1544 if (net_debug > 5)
1545 printk(KERN_DEBUG "%s: entering eepro_rx routine.\n", dev->name);
1546
1547 /* Set the read pointer to the start of the RCV */
1548 outw(rcv_car, ioaddr + HOST_ADDRESS_REG);
1549
1550 rcv_event = inw(ioaddr + IO_PORT);
1551
1552 while (rcv_event == RCV_DONE) {
1553
1554 rcv_status = inw(ioaddr + IO_PORT);
1555 rcv_next_frame = inw(ioaddr + IO_PORT);
1556 rcv_size = inw(ioaddr + IO_PORT);
1557
1558 if ((rcv_status & (RX_OK | RX_ERROR)) == RX_OK) {
1559
1560 /* Malloc up new buffer. */
1561 struct sk_buff *skb;
1562
1563 dev->stats.rx_bytes+=rcv_size;
1564 rcv_size &= 0x3fff;
1565 skb = netdev_alloc_skb(dev, rcv_size + 5);
1566 if (skb == NULL) {
1567 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
1568 dev->stats.rx_dropped++;
1569 rcv_car = lp->rx_start + RCV_HEADER + rcv_size;
1570 lp->rx_start = rcv_next_frame;
1571 outw(rcv_next_frame, ioaddr + HOST_ADDRESS_REG);
1572
1573 break;
1574 }
1575 skb_reserve(skb,2);
1576
1577 if (lp->version == LAN595)
1578 insw(ioaddr+IO_PORT, skb_put(skb,rcv_size), (rcv_size + 3) >> 1);
1579 else { /* LAN595TX or LAN595FX, capable of 32-bit I/O processing */
1580 unsigned short temp = inb(ioaddr + INT_MASK_REG);
1581 outb(temp | IO_32_BIT, ioaddr + INT_MASK_REG);
1582 insl(ioaddr+IO_PORT_32_BIT, skb_put(skb,rcv_size),
1583 (rcv_size + 3) >> 2);
1584 outb(temp & ~(IO_32_BIT), ioaddr + INT_MASK_REG);
1585 }
1586
1587 skb->protocol = eth_type_trans(skb,dev);
1588 netif_rx(skb);
1589 dev->stats.rx_packets++;
1590 }
1591
1592 else { /* Not sure will ever reach here,
1593 I set the 595 to discard bad received frames */
1594 dev->stats.rx_errors++;
1595
1596 if (rcv_status & 0x0100)
1597 dev->stats.rx_over_errors++;
1598
1599 else if (rcv_status & 0x0400)
1600 dev->stats.rx_frame_errors++;
1601
1602 else if (rcv_status & 0x0800)
1603 dev->stats.rx_crc_errors++;
1604
1605 printk(KERN_DEBUG "%s: event = %#x, status = %#x, next = %#x, size = %#x\n",
1606 dev->name, rcv_event, rcv_status, rcv_next_frame, rcv_size);
1607 }
1608
1609 if (rcv_status & 0x1000)
1610 dev->stats.rx_length_errors++;
1611
1612 rcv_car = lp->rx_start + RCV_HEADER + rcv_size;
1613 lp->rx_start = rcv_next_frame;
1614
1615 if (--boguscount == 0)
1616 break;
1617
1618 outw(rcv_next_frame, ioaddr + HOST_ADDRESS_REG);
1619 rcv_event = inw(ioaddr + IO_PORT);
1620
1621 }
1622 if (rcv_car == 0)
1623 rcv_car = lp->rcv_upper_limit | 0xff;
1624
1625 outw(rcv_car - 1, ioaddr + RCV_STOP);
1626
1627 if (net_debug > 5)
1628 printk(KERN_DEBUG "%s: exiting eepro_rx routine.\n", dev->name);
1629}
1630
1631static void
1632eepro_transmit_interrupt(struct net_device *dev)
1633{
1634 struct eepro_local *lp = netdev_priv(dev);
1635 short ioaddr = dev->base_addr;
1636 short boguscount = 25;
1637 short xmt_status;
1638
1639 while ((lp->tx_start != lp->tx_end) && boguscount--) {
1640
1641 outw(lp->tx_start, ioaddr + HOST_ADDRESS_REG);
1642 xmt_status = inw(ioaddr+IO_PORT);
1643
1644 if (!(xmt_status & TX_DONE_BIT))
1645 break;
1646
1647 xmt_status = inw(ioaddr+IO_PORT);
1648 lp->tx_start = inw(ioaddr+IO_PORT);
1649
1650 netif_wake_queue (dev);
1651
1652 if (xmt_status & TX_OK)
1653 dev->stats.tx_packets++;
1654 else {
1655 dev->stats.tx_errors++;
1656 if (xmt_status & 0x0400) {
1657 dev->stats.tx_carrier_errors++;
1658 printk(KERN_DEBUG "%s: carrier error\n",
1659 dev->name);
1660 printk(KERN_DEBUG "%s: XMT status = %#x\n",
1661 dev->name, xmt_status);
1662 }
1663 else {
1664 printk(KERN_DEBUG "%s: XMT status = %#x\n",
1665 dev->name, xmt_status);
1666 printk(KERN_DEBUG "%s: XMT status = %#x\n",
1667 dev->name, xmt_status);
1668 }
1669 }
1670 if (xmt_status & 0x000f) {
1671 dev->stats.collisions += (xmt_status & 0x000f);
1672 }
1673
1674 if ((xmt_status & 0x0040) == 0x0) {
1675 dev->stats.tx_heartbeat_errors++;
1676 }
1677 }
1678}
1679
1680static int eepro_ethtool_get_settings(struct net_device *dev,
1681 struct ethtool_cmd *cmd)
1682{
1683 struct eepro_local *lp = netdev_priv(dev);
1684
1685 cmd->supported = SUPPORTED_10baseT_Half |
1686 SUPPORTED_10baseT_Full |
1687 SUPPORTED_Autoneg;
1688 cmd->advertising = ADVERTISED_10baseT_Half |
1689 ADVERTISED_10baseT_Full |
1690 ADVERTISED_Autoneg;
1691
1692 if (GetBit(lp->word[5], ee_PortTPE)) {
1693 cmd->supported |= SUPPORTED_TP;
1694 cmd->advertising |= ADVERTISED_TP;
1695 }
1696 if (GetBit(lp->word[5], ee_PortBNC)) {
1697 cmd->supported |= SUPPORTED_BNC;
1698 cmd->advertising |= ADVERTISED_BNC;
1699 }
1700 if (GetBit(lp->word[5], ee_PortAUI)) {
1701 cmd->supported |= SUPPORTED_AUI;
1702 cmd->advertising |= ADVERTISED_AUI;
1703 }
1704
1705 ethtool_cmd_speed_set(cmd, SPEED_10);
1706
1707 if (dev->if_port == TPE && lp->word[1] & ee_Duplex) {
1708 cmd->duplex = DUPLEX_FULL;
1709 }
1710 else {
1711 cmd->duplex = DUPLEX_HALF;
1712 }
1713
1714 cmd->port = dev->if_port;
1715 cmd->phy_address = dev->base_addr;
1716 cmd->transceiver = XCVR_INTERNAL;
1717
1718 if (lp->word[0] & ee_AutoNeg) {
1719 cmd->autoneg = 1;
1720 }
1721
1722 return 0;
1723}
1724
1725static void eepro_ethtool_get_drvinfo(struct net_device *dev,
1726 struct ethtool_drvinfo *drvinfo)
1727{
1728 strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
1729 strlcpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version));
1730 snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
1731 "ISA 0x%lx", dev->base_addr);
1732}
1733
1734static const struct ethtool_ops eepro_ethtool_ops = {
1735 .get_settings = eepro_ethtool_get_settings,
1736 .get_drvinfo = eepro_ethtool_get_drvinfo,
1737};
1738
1739#ifdef MODULE
1740
1741#define MAX_EEPRO 8
1742static struct net_device *dev_eepro[MAX_EEPRO];
1743
1744static int io[MAX_EEPRO] = {
1745 [0 ... MAX_EEPRO-1] = -1
1746};
1747static int irq[MAX_EEPRO];
1748static int mem[MAX_EEPRO] = { /* Size of the rx buffer in KB */
1749 [0 ... MAX_EEPRO-1] = RCV_DEFAULT_RAM/1024
1750};
1751static int autodetect;
1752
1753static int n_eepro;
1754/* For linux 2.1.xx */
1755
1756MODULE_AUTHOR("Pascal Dupuis and others");
1757MODULE_DESCRIPTION("Intel i82595 ISA EtherExpressPro10/10+ driver");
1758MODULE_LICENSE("GPL");
1759
1760module_param_array(io, int, NULL, 0);
1761module_param_array(irq, int, NULL, 0);
1762module_param_array(mem, int, NULL, 0);
1763module_param(autodetect, int, 0);
1764MODULE_PARM_DESC(io, "EtherExpress Pro/10 I/O base address(es)");
1765MODULE_PARM_DESC(irq, "EtherExpress Pro/10 IRQ number(s)");
1766MODULE_PARM_DESC(mem, "EtherExpress Pro/10 Rx buffer size(es) in kB (3-29)");
1767MODULE_PARM_DESC(autodetect, "EtherExpress Pro/10 force board(s) detection (0-1)");
1768
1769int __init init_module(void)
1770{
1771 struct net_device *dev;
1772 int i;
1773 if (io[0] == -1 && autodetect == 0) {
1774 printk(KERN_WARNING "eepro_init_module: Probe is very dangerous in ISA boards!\n");
1775 printk(KERN_WARNING "eepro_init_module: Please add \"autodetect=1\" to force probe\n");
1776 return -ENODEV;
1777 }
1778 else if (autodetect) {
1779 /* if autodetect is set then we must force detection */
1780 for (i = 0; i < MAX_EEPRO; i++) {
1781 io[i] = 0;
1782 }
1783
1784 printk(KERN_INFO "eepro_init_module: Auto-detecting boards (May God protect us...)\n");
1785 }
1786
1787 for (i = 0; i < MAX_EEPRO && io[i] != -1; i++) {
1788 dev = alloc_etherdev(sizeof(struct eepro_local));
1789 if (!dev)
1790 break;
1791
1792 dev->mem_end = mem[i];
1793 dev->base_addr = io[i];
1794 dev->irq = irq[i];
1795
1796 if (do_eepro_probe(dev) == 0) {
1797 dev_eepro[n_eepro++] = dev;
1798 continue;
1799 }
1800 free_netdev(dev);
1801 break;
1802 }
1803
1804 if (n_eepro)
1805 printk(KERN_INFO "%s", version);
1806
1807 return n_eepro ? 0 : -ENODEV;
1808}
1809
1810void __exit
1811cleanup_module(void)
1812{
1813 int i;
1814
1815 for (i=0; i<n_eepro; i++) {
1816 struct net_device *dev = dev_eepro[i];
1817 unregister_netdev(dev);
1818 release_region(dev->base_addr, EEPRO_IO_EXTENT);
1819 free_netdev(dev);
1820 }
1821}
1822#endif /* MODULE */
diff --git a/drivers/net/ethernet/i825xx/eexpress.c b/drivers/net/ethernet/i825xx/eexpress.c
deleted file mode 100644
index 7a6a2f04c5b1..000000000000
--- a/drivers/net/ethernet/i825xx/eexpress.c
+++ /dev/null
@@ -1,1661 +0,0 @@
1/* Intel EtherExpress 16 device driver for Linux
2 *
3 * Written by John Sullivan, 1995
4 * based on original code by Donald Becker, with changes by
5 * Alan Cox and Pauline Middelink.
6 *
7 * Support for 8-bit mode by Zoltan Szilagyi <zoltans@cs.arizona.edu>
8 *
9 * Many modifications, and currently maintained, by
10 * Philip Blundell <philb@gnu.org>
11 * Added the Compaq LTE Alan Cox <alan@lxorguk.ukuu.org.uk>
12 * Added MCA support Adam Fritzler (now deleted)
13 *
14 * Note - this driver is experimental still - it has problems on faster
15 * machines. Someone needs to sit down and go through it line by line with
16 * a databook...
17 */
18
19/* The EtherExpress 16 is a fairly simple card, based on a shared-memory
20 * design using the i82586 Ethernet coprocessor. It bears no relationship,
21 * as far as I know, to the similarly-named "EtherExpress Pro" range.
22 *
23 * Historically, Linux support for these cards has been very bad. However,
24 * things seem to be getting better slowly.
25 */
26
27/* If your card is confused about what sort of interface it has (eg it
28 * persistently reports "10baseT" when none is fitted), running 'SOFTSET /BART'
29 * or 'SOFTSET /LISA' from DOS seems to help.
30 */
31
32/* Here's the scoop on memory mapping.
33 *
34 * There are three ways to access EtherExpress card memory: either using the
35 * shared-memory mapping, or using PIO through the dataport, or using PIO
36 * through the "shadow memory" ports.
37 *
38 * The shadow memory system works by having the card map some of its memory
39 * as follows:
40 *
41 * (the low five bits of the SMPTR are ignored)
42 *
43 * base+0x4000..400f memory at SMPTR+0..15
44 * base+0x8000..800f memory at SMPTR+16..31
45 * base+0xc000..c007 dubious stuff (memory at SMPTR+16..23 apparently)
46 * base+0xc008..c00f memory at 0x0008..0x000f
47 *
48 * This last set (the one at c008) is particularly handy because the SCB
49 * lives at 0x0008. So that set of ports gives us easy random access to data
50 * in the SCB without having to mess around setting up pointers and the like.
51 * We always use this method to access the SCB (via the scb_xx() functions).
52 *
53 * Dataport access works by aiming the appropriate (read or write) pointer
54 * at the first address you're interested in, and then reading or writing from
55 * the dataport. The pointers auto-increment after each transfer. We use
56 * this for data transfer.
57 *
58 * We don't use the shared-memory system because it allegedly doesn't work on
59 * all cards, and because it's a bit more prone to go wrong (it's one more
60 * thing to configure...).
61 */
62
63/* Known bugs:
64 *
65 * - The card seems to want to give us two interrupts every time something
66 * happens, where just one would be better.
67 */
68
69/*
70 *
71 * Note by Zoltan Szilagyi 10-12-96:
72 *
73 * I've succeeded in eliminating the "CU wedged" messages, and hence the
74 * lockups, which were only occurring with cards running in 8-bit mode ("force
75 * 8-bit operation" in Intel's SoftSet utility). This version of the driver
76 * sets the 82586 and the ASIC to 8-bit mode at startup; it also stops the
77 * CU before submitting a packet for transmission, and then restarts it as soon
78 * as the process of handing the packet is complete. This is definitely an
79 * unnecessary slowdown if the card is running in 16-bit mode; therefore one
80 * should detect 16-bit vs 8-bit mode from the EEPROM settings and act
81 * accordingly. In 8-bit mode with this bugfix I'm getting about 150 K/s for
82 * ftp's, which is significantly better than I get in DOS, so the overhead of
83 * stopping and restarting the CU with each transmit is not prohibitive in
84 * practice.
85 *
86 * Update by David Woodhouse 11/5/99:
87 *
88 * I've seen "CU wedged" messages in 16-bit mode, on the Alpha architecture.
89 * I assume that this is because 16-bit accesses are actually handled as two
90 * 8-bit accesses.
91 */
92
93#ifdef __alpha__
94#define LOCKUP16 1
95#endif
96#ifndef LOCKUP16
97#define LOCKUP16 0
98#endif
99
100#include <linux/module.h>
101#include <linux/kernel.h>
102#include <linux/types.h>
103#include <linux/fcntl.h>
104#include <linux/interrupt.h>
105#include <linux/ioport.h>
106#include <linux/string.h>
107#include <linux/in.h>
108#include <linux/delay.h>
109#include <linux/errno.h>
110#include <linux/init.h>
111#include <linux/netdevice.h>
112#include <linux/etherdevice.h>
113#include <linux/skbuff.h>
114#include <linux/spinlock.h>
115#include <linux/bitops.h>
116#include <linux/jiffies.h>
117
118#include <asm/io.h>
119#include <asm/irq.h>
120
121#ifndef NET_DEBUG
122#define NET_DEBUG 4
123#endif
124
125#include "eexpress.h"
126
127#define EEXP_IO_EXTENT 16
128
129/*
130 * Private data declarations
131 */
132
133struct net_local
134{
135 unsigned long last_tx; /* jiffies when last transmit started */
136 unsigned long init_time; /* jiffies when eexp_hw_init586 called */
137 unsigned short rx_first; /* first rx buf, same as RX_BUF_START */
138 unsigned short rx_last; /* last rx buf */
139 unsigned short rx_ptr; /* first rx buf to look at */
140 unsigned short tx_head; /* next free tx buf */
141 unsigned short tx_reap; /* first in-use tx buf */
142 unsigned short tx_tail; /* previous tx buf to tx_head */
143 unsigned short tx_link; /* last known-executing tx buf */
144 unsigned short last_tx_restart; /* set to tx_link when we
145 restart the CU */
146 unsigned char started;
147 unsigned short rx_buf_start;
148 unsigned short rx_buf_end;
149 unsigned short num_tx_bufs;
150 unsigned short num_rx_bufs;
151 unsigned char width; /* 0 for 16bit, 1 for 8bit */
152 unsigned char was_promisc;
153 unsigned char old_mc_count;
154 spinlock_t lock;
155};
156
157/* This is the code and data that is downloaded to the EtherExpress card's
158 * memory at boot time.
159 */
160
161static unsigned short start_code[] = {
162/* 0x0000 */
163 0x0001, /* ISCP: busy - cleared after reset */
164 0x0008,0x0000,0x0000, /* offset,address (lo,hi) of SCB */
165
166 0x0000,0x0000, /* SCB: status, commands */
167 0x0000,0x0000, /* links to first command block,
168 first receive descriptor */
169 0x0000,0x0000, /* CRC error, alignment error counts */
170 0x0000,0x0000, /* out of resources, overrun error counts */
171
172 0x0000,0x0000, /* pad */
173 0x0000,0x0000,
174
175/* 0x20 -- start of 82586 CU program */
176#define CONF_LINK 0x20
177 0x0000,Cmd_Config,
178 0x0032, /* link to next command */
179 0x080c, /* 12 bytes follow : fifo threshold=8 */
180 0x2e40, /* don't rx bad frames
181 * SRDY/ARDY => ext. sync. : preamble len=8
182 * take addresses from data buffers
183 * 6 bytes/address
184 */
185 0x6000, /* default backoff method & priority
186 * interframe spacing = 0x60 */
187 0xf200, /* slot time=0x200
188 * max collision retry = 0xf */
189#define CONF_PROMISC 0x2e
190 0x0000, /* no HDLC : normal CRC : enable broadcast
191 * disable promiscuous/multicast modes */
192 0x003c, /* minimum frame length = 60 octets) */
193
194 0x0000,Cmd_SetAddr,
195 0x003e, /* link to next command */
196#define CONF_HWADDR 0x38
197 0x0000,0x0000,0x0000, /* hardware address placed here */
198
199 0x0000,Cmd_MCast,
200 0x0076, /* link to next command */
201#define CONF_NR_MULTICAST 0x44
202 0x0000, /* number of bytes in multicast address(es) */
203#define CONF_MULTICAST 0x46
204 0x0000, 0x0000, 0x0000, /* some addresses */
205 0x0000, 0x0000, 0x0000,
206 0x0000, 0x0000, 0x0000,
207 0x0000, 0x0000, 0x0000,
208 0x0000, 0x0000, 0x0000,
209 0x0000, 0x0000, 0x0000,
210 0x0000, 0x0000, 0x0000,
211 0x0000, 0x0000, 0x0000,
212
213#define CONF_DIAG_RESULT 0x76
214 0x0000, Cmd_Diag,
215 0x007c, /* link to next command */
216
217 0x0000,Cmd_TDR|Cmd_INT,
218 0x0084,
219#define CONF_TDR_RESULT 0x82
220 0x0000,
221
222 0x0000,Cmd_END|Cmd_Nop, /* end of configure sequence */
223 0x0084 /* dummy link */
224};
225
226/* maps irq number to EtherExpress magic value */
227static char irqrmap[] = { 0,0,1,2,3,4,0,0,0,1,5,6,0,0,0,0 };
228
229/*
230 * Prototypes for Linux interface
231 */
232
233static int eexp_open(struct net_device *dev);
234static int eexp_close(struct net_device *dev);
235static void eexp_timeout(struct net_device *dev);
236static netdev_tx_t eexp_xmit(struct sk_buff *buf,
237 struct net_device *dev);
238
239static irqreturn_t eexp_irq(int irq, void *dev_addr);
240static void eexp_set_multicast(struct net_device *dev);
241
242/*
243 * Prototypes for hardware access functions
244 */
245
246static void eexp_hw_rx_pio(struct net_device *dev);
247static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
248 unsigned short len);
249static int eexp_hw_probe(struct net_device *dev,unsigned short ioaddr);
250static unsigned short eexp_hw_readeeprom(unsigned short ioaddr,
251 unsigned char location);
252
253static unsigned short eexp_hw_lasttxstat(struct net_device *dev);
254static void eexp_hw_txrestart(struct net_device *dev);
255
256static void eexp_hw_txinit (struct net_device *dev);
257static void eexp_hw_rxinit (struct net_device *dev);
258
259static void eexp_hw_init586 (struct net_device *dev);
260static void eexp_setup_filter (struct net_device *dev);
261
262static char *eexp_ifmap[]={"AUI", "BNC", "RJ45"};
263enum eexp_iftype {AUI=0, BNC=1, TPE=2};
264
265#define STARTED_RU 2
266#define STARTED_CU 1
267
268/*
269 * Primitive hardware access functions.
270 */
271
272static inline unsigned short scb_status(struct net_device *dev)
273{
274 return inw(dev->base_addr + 0xc008);
275}
276
277static inline unsigned short scb_rdcmd(struct net_device *dev)
278{
279 return inw(dev->base_addr + 0xc00a);
280}
281
282static inline void scb_command(struct net_device *dev, unsigned short cmd)
283{
284 outw(cmd, dev->base_addr + 0xc00a);
285}
286
287static inline void scb_wrcbl(struct net_device *dev, unsigned short val)
288{
289 outw(val, dev->base_addr + 0xc00c);
290}
291
292static inline void scb_wrrfa(struct net_device *dev, unsigned short val)
293{
294 outw(val, dev->base_addr + 0xc00e);
295}
296
297static inline void set_loopback(struct net_device *dev)
298{
299 outb(inb(dev->base_addr + Config) | 2, dev->base_addr + Config);
300}
301
302static inline void clear_loopback(struct net_device *dev)
303{
304 outb(inb(dev->base_addr + Config) & ~2, dev->base_addr + Config);
305}
306
307static inline unsigned short int SHADOW(short int addr)
308{
309 addr &= 0x1f;
310 if (addr > 0xf) addr += 0x3ff0;
311 return addr + 0x4000;
312}
313
314/*
315 * Linux interface
316 */
317
318/*
319 * checks for presence of EtherExpress card
320 */
321
322static int __init do_express_probe(struct net_device *dev)
323{
324 unsigned short *port;
325 static unsigned short ports[] = { 0x240,0x300,0x310,0x270,0x320,0x340,0 };
326 unsigned short ioaddr = dev->base_addr;
327 int dev_irq = dev->irq;
328 int err;
329
330 dev->if_port = 0xff; /* not set */
331
332 if (ioaddr&0xfe00) {
333 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress"))
334 return -EBUSY;
335 err = eexp_hw_probe(dev,ioaddr);
336 release_region(ioaddr, EEXP_IO_EXTENT);
337 return err;
338 } else if (ioaddr)
339 return -ENXIO;
340
341 for (port=&ports[0] ; *port ; port++ )
342 {
343 unsigned short sum = 0;
344 int i;
345 if (!request_region(*port, EEXP_IO_EXTENT, "EtherExpress"))
346 continue;
347 for ( i=0 ; i<4 ; i++ )
348 {
349 unsigned short t;
350 t = inb(*port + ID_PORT);
351 sum |= (t>>4) << ((t & 0x03)<<2);
352 }
353 if (sum==0xbaba && !eexp_hw_probe(dev,*port)) {
354 release_region(*port, EEXP_IO_EXTENT);
355 return 0;
356 }
357 release_region(*port, EEXP_IO_EXTENT);
358 dev->irq = dev_irq;
359 }
360 return -ENODEV;
361}
362
363#ifndef MODULE
364struct net_device * __init express_probe(int unit)
365{
366 struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
367 int err;
368
369 if (!dev)
370 return ERR_PTR(-ENOMEM);
371
372 sprintf(dev->name, "eth%d", unit);
373 netdev_boot_setup_check(dev);
374
375 err = do_express_probe(dev);
376 if (!err)
377 return dev;
378 free_netdev(dev);
379 return ERR_PTR(err);
380}
381#endif
382
383/*
384 * open and initialize the adapter, ready for use
385 */
386
387static int eexp_open(struct net_device *dev)
388{
389 int ret;
390 unsigned short ioaddr = dev->base_addr;
391 struct net_local *lp = netdev_priv(dev);
392
393#if NET_DEBUG > 6
394 printk(KERN_DEBUG "%s: eexp_open()\n", dev->name);
395#endif
396
397 if (!dev->irq || !irqrmap[dev->irq])
398 return -ENXIO;
399
400 ret = request_irq(dev->irq, eexp_irq, 0, dev->name, dev);
401 if (ret)
402 return ret;
403
404 if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) {
405 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
406 , ioaddr);
407 goto err_out1;
408 }
409 if (!request_region(ioaddr+0x4000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
410 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
411 , ioaddr+0x4000);
412 goto err_out2;
413 }
414 if (!request_region(ioaddr+0x8000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
415 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
416 , ioaddr+0x8000);
417 goto err_out3;
418 }
419 if (!request_region(ioaddr+0xc000, EEXP_IO_EXTENT, "EtherExpress shadow")) {
420 printk(KERN_WARNING "EtherExpress io port %x, is busy.\n"
421 , ioaddr+0xc000);
422 goto err_out4;
423 }
424
425 if (lp->width) {
426 printk("%s: forcing ASIC to 8-bit mode\n", dev->name);
427 outb(inb(dev->base_addr+Config)&~4, dev->base_addr+Config);
428 }
429
430 eexp_hw_init586(dev);
431 netif_start_queue(dev);
432#if NET_DEBUG > 6
433 printk(KERN_DEBUG "%s: leaving eexp_open()\n", dev->name);
434#endif
435 return 0;
436
437 err_out4:
438 release_region(ioaddr+0x8000, EEXP_IO_EXTENT);
439 err_out3:
440 release_region(ioaddr+0x4000, EEXP_IO_EXTENT);
441 err_out2:
442 release_region(ioaddr, EEXP_IO_EXTENT);
443 err_out1:
444 free_irq(dev->irq, dev);
445 return -EBUSY;
446}
447
448/*
449 * close and disable the interface, leaving the 586 in reset.
450 */
451
452static int eexp_close(struct net_device *dev)
453{
454 unsigned short ioaddr = dev->base_addr;
455 struct net_local *lp = netdev_priv(dev);
456
457 int irq = dev->irq;
458
459 netif_stop_queue(dev);
460
461 outb(SIRQ_dis|irqrmap[irq],ioaddr+SET_IRQ);
462 lp->started = 0;
463 scb_command(dev, SCB_CUsuspend|SCB_RUsuspend);
464 outb(0,ioaddr+SIGNAL_CA);
465 free_irq(irq,dev);
466 outb(i586_RST,ioaddr+EEPROM_Ctrl);
467 release_region(ioaddr, EEXP_IO_EXTENT);
468 release_region(ioaddr+0x4000, 16);
469 release_region(ioaddr+0x8000, 16);
470 release_region(ioaddr+0xc000, 16);
471
472 return 0;
473}
474
475/*
476 * This gets called when a higher level thinks we are broken. Check that
477 * nothing has become jammed in the CU.
478 */
479
480static void unstick_cu(struct net_device *dev)
481{
482 struct net_local *lp = netdev_priv(dev);
483 unsigned short ioaddr = dev->base_addr;
484
485 if (lp->started)
486 {
487 if (time_after(jiffies, dev_trans_start(dev) + HZ/2))
488 {
489 if (lp->tx_link==lp->last_tx_restart)
490 {
491 unsigned short boguscount=200,rsst;
492 printk(KERN_WARNING "%s: Retransmit timed out, status %04x, resetting...\n",
493 dev->name, scb_status(dev));
494 eexp_hw_txinit(dev);
495 lp->last_tx_restart = 0;
496 scb_wrcbl(dev, lp->tx_link);
497 scb_command(dev, SCB_CUstart);
498 outb(0,ioaddr+SIGNAL_CA);
499 while (!SCB_complete(rsst=scb_status(dev)))
500 {
501 if (!--boguscount)
502 {
503 boguscount=200;
504 printk(KERN_WARNING "%s: Reset timed out status %04x, retrying...\n",
505 dev->name,rsst);
506 scb_wrcbl(dev, lp->tx_link);
507 scb_command(dev, SCB_CUstart);
508 outb(0,ioaddr+SIGNAL_CA);
509 }
510 }
511 netif_wake_queue(dev);
512 }
513 else
514 {
515 unsigned short status = scb_status(dev);
516 if (SCB_CUdead(status))
517 {
518 unsigned short txstatus = eexp_hw_lasttxstat(dev);
519 printk(KERN_WARNING "%s: Transmit timed out, CU not active status %04x %04x, restarting...\n",
520 dev->name, status, txstatus);
521 eexp_hw_txrestart(dev);
522 }
523 else
524 {
525 unsigned short txstatus = eexp_hw_lasttxstat(dev);
526 if (netif_queue_stopped(dev) && !txstatus)
527 {
528 printk(KERN_WARNING "%s: CU wedged, status %04x %04x, resetting...\n",
529 dev->name,status,txstatus);
530 eexp_hw_init586(dev);
531 netif_wake_queue(dev);
532 }
533 else
534 {
535 printk(KERN_WARNING "%s: transmit timed out\n", dev->name);
536 }
537 }
538 }
539 }
540 }
541 else
542 {
543 if (time_after(jiffies, lp->init_time + 10))
544 {
545 unsigned short status = scb_status(dev);
546 printk(KERN_WARNING "%s: i82586 startup timed out, status %04x, resetting...\n",
547 dev->name, status);
548 eexp_hw_init586(dev);
549 netif_wake_queue(dev);
550 }
551 }
552}
553
554static void eexp_timeout(struct net_device *dev)
555{
556 struct net_local *lp = netdev_priv(dev);
557#ifdef CONFIG_SMP
558 unsigned long flags;
559#endif
560 int status;
561
562 disable_irq(dev->irq);
563
564 /*
565 * Best would be to use synchronize_irq(); spin_lock() here
566 * lets make it work first..
567 */
568
569#ifdef CONFIG_SMP
570 spin_lock_irqsave(&lp->lock, flags);
571#endif
572
573 status = scb_status(dev);
574 unstick_cu(dev);
575 printk(KERN_INFO "%s: transmit timed out, %s?\n", dev->name,
576 (SCB_complete(status)?"lost interrupt":
577 "board on fire"));
578 dev->stats.tx_errors++;
579 lp->last_tx = jiffies;
580 if (!SCB_complete(status)) {
581 scb_command(dev, SCB_CUabort);
582 outb(0,dev->base_addr+SIGNAL_CA);
583 }
584 netif_wake_queue(dev);
585#ifdef CONFIG_SMP
586 spin_unlock_irqrestore(&lp->lock, flags);
587#endif
588}
589
590/*
591 * Called to transmit a packet, or to allow us to right ourselves
592 * if the kernel thinks we've died.
593 */
594static netdev_tx_t eexp_xmit(struct sk_buff *buf, struct net_device *dev)
595{
596 short length = buf->len;
597#ifdef CONFIG_SMP
598 struct net_local *lp = netdev_priv(dev);
599 unsigned long flags;
600#endif
601
602#if NET_DEBUG > 6
603 printk(KERN_DEBUG "%s: eexp_xmit()\n", dev->name);
604#endif
605
606 if (buf->len < ETH_ZLEN) {
607 if (skb_padto(buf, ETH_ZLEN))
608 return NETDEV_TX_OK;
609 length = ETH_ZLEN;
610 }
611
612 disable_irq(dev->irq);
613
614 /*
615 * Best would be to use synchronize_irq(); spin_lock() here
616 * lets make it work first..
617 */
618
619#ifdef CONFIG_SMP
620 spin_lock_irqsave(&lp->lock, flags);
621#endif
622
623 {
624 unsigned short *data = (unsigned short *)buf->data;
625
626 dev->stats.tx_bytes += length;
627
628 eexp_hw_tx_pio(dev,data,length);
629 }
630 dev_kfree_skb(buf);
631#ifdef CONFIG_SMP
632 spin_unlock_irqrestore(&lp->lock, flags);
633#endif
634 enable_irq(dev->irq);
635 return NETDEV_TX_OK;
636}
637
638/*
639 * Handle an EtherExpress interrupt
640 * If we've finished initializing, start the RU and CU up.
641 * If we've already started, reap tx buffers, handle any received packets,
642 * check to make sure we've not become wedged.
643 */
644
645static unsigned short eexp_start_irq(struct net_device *dev,
646 unsigned short status)
647{
648 unsigned short ack_cmd = SCB_ack(status);
649 struct net_local *lp = netdev_priv(dev);
650 unsigned short ioaddr = dev->base_addr;
651 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_CU)) {
652 short diag_status, tdr_status;
653 while (SCB_CUstat(status)==2)
654 status = scb_status(dev);
655#if NET_DEBUG > 4
656 printk("%s: CU went non-active (status %04x)\n",
657 dev->name, status);
658#endif
659
660 outw(CONF_DIAG_RESULT & ~31, ioaddr + SM_PTR);
661 diag_status = inw(ioaddr + SHADOW(CONF_DIAG_RESULT));
662 if (diag_status & 1<<11) {
663 printk(KERN_WARNING "%s: 82586 failed self-test\n",
664 dev->name);
665 } else if (!(diag_status & 1<<13)) {
666 printk(KERN_WARNING "%s: 82586 self-test failed to complete\n", dev->name);
667 }
668
669 outw(CONF_TDR_RESULT & ~31, ioaddr + SM_PTR);
670 tdr_status = inw(ioaddr + SHADOW(CONF_TDR_RESULT));
671 if (tdr_status & (TDR_SHORT|TDR_OPEN)) {
672 printk(KERN_WARNING "%s: TDR reports cable %s at %d tick%s\n", dev->name, (tdr_status & TDR_SHORT)?"short":"broken", tdr_status & TDR_TIME, ((tdr_status & TDR_TIME) != 1) ? "s" : "");
673 }
674 else if (tdr_status & TDR_XCVRPROBLEM) {
675 printk(KERN_WARNING "%s: TDR reports transceiver problem\n", dev->name);
676 }
677 else if (tdr_status & TDR_LINKOK) {
678#if NET_DEBUG > 4
679 printk(KERN_DEBUG "%s: TDR reports link OK\n", dev->name);
680#endif
681 } else {
682 printk("%s: TDR is ga-ga (status %04x)\n", dev->name,
683 tdr_status);
684 }
685
686 lp->started |= STARTED_CU;
687 scb_wrcbl(dev, lp->tx_link);
688 /* if the RU isn't running, start it now */
689 if (!(lp->started & STARTED_RU)) {
690 ack_cmd |= SCB_RUstart;
691 scb_wrrfa(dev, lp->rx_buf_start);
692 lp->rx_ptr = lp->rx_buf_start;
693 lp->started |= STARTED_RU;
694 }
695 ack_cmd |= SCB_CUstart | 0x2000;
696 }
697
698 if ((dev->flags & IFF_UP) && !(lp->started & STARTED_RU) && SCB_RUstat(status)==4)
699 lp->started|=STARTED_RU;
700
701 return ack_cmd;
702}
703
704static void eexp_cmd_clear(struct net_device *dev)
705{
706 unsigned long int oldtime = jiffies;
707 while (scb_rdcmd(dev) && (time_before(jiffies, oldtime + 10)));
708 if (scb_rdcmd(dev)) {
709 printk("%s: command didn't clear\n", dev->name);
710 }
711}
712
713static irqreturn_t eexp_irq(int dummy, void *dev_info)
714{
715 struct net_device *dev = dev_info;
716 struct net_local *lp;
717 unsigned short ioaddr,status,ack_cmd;
718 unsigned short old_read_ptr, old_write_ptr;
719
720 lp = netdev_priv(dev);
721 ioaddr = dev->base_addr;
722
723 spin_lock(&lp->lock);
724
725 old_read_ptr = inw(ioaddr+READ_PTR);
726 old_write_ptr = inw(ioaddr+WRITE_PTR);
727
728 outb(SIRQ_dis|irqrmap[dev->irq], ioaddr+SET_IRQ);
729
730 status = scb_status(dev);
731
732#if NET_DEBUG > 4
733 printk(KERN_DEBUG "%s: interrupt (status %x)\n", dev->name, status);
734#endif
735
736 if (lp->started == (STARTED_CU | STARTED_RU)) {
737
738 do {
739 eexp_cmd_clear(dev);
740
741 ack_cmd = SCB_ack(status);
742 scb_command(dev, ack_cmd);
743 outb(0,ioaddr+SIGNAL_CA);
744
745 eexp_cmd_clear(dev);
746
747 if (SCB_complete(status)) {
748 if (!eexp_hw_lasttxstat(dev)) {
749 printk("%s: tx interrupt but no status\n", dev->name);
750 }
751 }
752
753 if (SCB_rxdframe(status))
754 eexp_hw_rx_pio(dev);
755
756 status = scb_status(dev);
757 } while (status & 0xc000);
758
759 if (SCB_RUdead(status))
760 {
761 printk(KERN_WARNING "%s: RU stopped: status %04x\n",
762 dev->name,status);
763#if 0
764 printk(KERN_WARNING "%s: cur_rfd=%04x, cur_rbd=%04x\n", dev->name, lp->cur_rfd, lp->cur_rbd);
765 outw(lp->cur_rfd, ioaddr+READ_PTR);
766 printk(KERN_WARNING "%s: [%04x]\n", dev->name, inw(ioaddr+DATAPORT));
767 outw(lp->cur_rfd+6, ioaddr+READ_PTR);
768 printk(KERN_WARNING "%s: rbd is %04x\n", dev->name, rbd= inw(ioaddr+DATAPORT));
769 outw(rbd, ioaddr+READ_PTR);
770 printk(KERN_WARNING "%s: [%04x %04x] ", dev->name, inw(ioaddr+DATAPORT), inw(ioaddr+DATAPORT));
771 outw(rbd+8, ioaddr+READ_PTR);
772 printk("[%04x]\n", inw(ioaddr+DATAPORT));
773#endif
774 dev->stats.rx_errors++;
775#if 1
776 eexp_hw_rxinit(dev);
777#else
778 lp->cur_rfd = lp->first_rfd;
779#endif
780 scb_wrrfa(dev, lp->rx_buf_start);
781 scb_command(dev, SCB_RUstart);
782 outb(0,ioaddr+SIGNAL_CA);
783 }
784 } else {
785 if (status & 0x8000)
786 ack_cmd = eexp_start_irq(dev, status);
787 else
788 ack_cmd = SCB_ack(status);
789 scb_command(dev, ack_cmd);
790 outb(0,ioaddr+SIGNAL_CA);
791 }
792
793 eexp_cmd_clear(dev);
794
795 outb(SIRQ_en|irqrmap[dev->irq], ioaddr+SET_IRQ);
796
797#if NET_DEBUG > 6
798 printk("%s: leaving eexp_irq()\n", dev->name);
799#endif
800 outw(old_read_ptr, ioaddr+READ_PTR);
801 outw(old_write_ptr, ioaddr+WRITE_PTR);
802
803 spin_unlock(&lp->lock);
804 return IRQ_HANDLED;
805}
806
807/*
808 * Hardware access functions
809 */
810
811/*
812 * Set the cable type to use.
813 */
814
815static void eexp_hw_set_interface(struct net_device *dev)
816{
817 unsigned char oldval = inb(dev->base_addr + 0x300e);
818 oldval &= ~0x82;
819 switch (dev->if_port) {
820 case TPE:
821 oldval |= 0x2;
822 case BNC:
823 oldval |= 0x80;
824 break;
825 }
826 outb(oldval, dev->base_addr+0x300e);
827 mdelay(20);
828}
829
830/*
831 * Check all the receive buffers, and hand any received packets
832 * to the upper levels. Basic sanity check on each frame
833 * descriptor, though we don't bother trying to fix broken ones.
834 */
835
836static void eexp_hw_rx_pio(struct net_device *dev)
837{
838 struct net_local *lp = netdev_priv(dev);
839 unsigned short rx_block = lp->rx_ptr;
840 unsigned short boguscount = lp->num_rx_bufs;
841 unsigned short ioaddr = dev->base_addr;
842 unsigned short status;
843
844#if NET_DEBUG > 6
845 printk(KERN_DEBUG "%s: eexp_hw_rx()\n", dev->name);
846#endif
847
848 do {
849 unsigned short rfd_cmd, rx_next, pbuf, pkt_len;
850
851 outw(rx_block, ioaddr + READ_PTR);
852 status = inw(ioaddr + DATAPORT);
853
854 if (FD_Done(status))
855 {
856 rfd_cmd = inw(ioaddr + DATAPORT);
857 rx_next = inw(ioaddr + DATAPORT);
858 pbuf = inw(ioaddr + DATAPORT);
859
860 outw(pbuf, ioaddr + READ_PTR);
861 pkt_len = inw(ioaddr + DATAPORT);
862
863 if (rfd_cmd!=0x0000)
864 {
865 printk(KERN_WARNING "%s: rfd_cmd not zero:0x%04x\n",
866 dev->name, rfd_cmd);
867 continue;
868 }
869 else if (pbuf!=rx_block+0x16)
870 {
871 printk(KERN_WARNING "%s: rfd and rbd out of sync 0x%04x 0x%04x\n",
872 dev->name, rx_block+0x16, pbuf);
873 continue;
874 }
875 else if ((pkt_len & 0xc000)!=0xc000)
876 {
877 printk(KERN_WARNING "%s: EOF or F not set on received buffer (%04x)\n",
878 dev->name, pkt_len & 0xc000);
879 continue;
880 }
881 else if (!FD_OK(status))
882 {
883 dev->stats.rx_errors++;
884 if (FD_CRC(status))
885 dev->stats.rx_crc_errors++;
886 if (FD_Align(status))
887 dev->stats.rx_frame_errors++;
888 if (FD_Resrc(status))
889 dev->stats.rx_fifo_errors++;
890 if (FD_DMA(status))
891 dev->stats.rx_over_errors++;
892 if (FD_Short(status))
893 dev->stats.rx_length_errors++;
894 }
895 else
896 {
897 struct sk_buff *skb;
898 pkt_len &= 0x3fff;
899 skb = netdev_alloc_skb(dev, pkt_len + 16);
900 if (skb == NULL)
901 {
902 printk(KERN_WARNING "%s: Memory squeeze, dropping packet\n",dev->name);
903 dev->stats.rx_dropped++;
904 break;
905 }
906 skb_reserve(skb, 2);
907 outw(pbuf+10, ioaddr+READ_PTR);
908 insw(ioaddr+DATAPORT, skb_put(skb,pkt_len),(pkt_len+1)>>1);
909 skb->protocol = eth_type_trans(skb,dev);
910 netif_rx(skb);
911 dev->stats.rx_packets++;
912 dev->stats.rx_bytes += pkt_len;
913 }
914 outw(rx_block, ioaddr+WRITE_PTR);
915 outw(0, ioaddr+DATAPORT);
916 outw(0, ioaddr+DATAPORT);
917 rx_block = rx_next;
918 }
919 } while (FD_Done(status) && boguscount--);
920 lp->rx_ptr = rx_block;
921}
922
923/*
924 * Hand a packet to the card for transmission
925 * If we get here, we MUST have already checked
926 * to make sure there is room in the transmit
927 * buffer region.
928 */
929
930static void eexp_hw_tx_pio(struct net_device *dev, unsigned short *buf,
931 unsigned short len)
932{
933 struct net_local *lp = netdev_priv(dev);
934 unsigned short ioaddr = dev->base_addr;
935
936 if (LOCKUP16 || lp->width) {
937 /* Stop the CU so that there is no chance that it
938 jumps off to a bogus address while we are writing the
939 pointer to the next transmit packet in 8-bit mode --
940 this eliminates the "CU wedged" errors in 8-bit mode.
941 (Zoltan Szilagyi 10-12-96) */
942 scb_command(dev, SCB_CUsuspend);
943 outw(0xFFFF, ioaddr+SIGNAL_CA);
944 }
945
946 outw(lp->tx_head, ioaddr + WRITE_PTR);
947
948 outw(0x0000, ioaddr + DATAPORT);
949 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
950 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
951 outw(lp->tx_head+0x0e, ioaddr + DATAPORT);
952
953 outw(0x0000, ioaddr + DATAPORT);
954 outw(0x0000, ioaddr + DATAPORT);
955 outw(lp->tx_head+0x08, ioaddr + DATAPORT);
956
957 outw(0x8000|len, ioaddr + DATAPORT);
958 outw(-1, ioaddr + DATAPORT);
959 outw(lp->tx_head+0x16, ioaddr + DATAPORT);
960 outw(0, ioaddr + DATAPORT);
961
962 outsw(ioaddr + DATAPORT, buf, (len+1)>>1);
963
964 outw(lp->tx_tail+0xc, ioaddr + WRITE_PTR);
965 outw(lp->tx_head, ioaddr + DATAPORT);
966
967 dev->trans_start = jiffies;
968 lp->tx_tail = lp->tx_head;
969 if (lp->tx_head==TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
970 lp->tx_head = TX_BUF_START;
971 else
972 lp->tx_head += TX_BUF_SIZE;
973 if (lp->tx_head != lp->tx_reap)
974 netif_wake_queue(dev);
975
976 if (LOCKUP16 || lp->width) {
977 /* Restart the CU so that the packet can actually
978 be transmitted. (Zoltan Szilagyi 10-12-96) */
979 scb_command(dev, SCB_CUresume);
980 outw(0xFFFF, ioaddr+SIGNAL_CA);
981 }
982
983 dev->stats.tx_packets++;
984 lp->last_tx = jiffies;
985}
986
987static const struct net_device_ops eexp_netdev_ops = {
988 .ndo_open = eexp_open,
989 .ndo_stop = eexp_close,
990 .ndo_start_xmit = eexp_xmit,
991 .ndo_set_rx_mode = eexp_set_multicast,
992 .ndo_tx_timeout = eexp_timeout,
993 .ndo_change_mtu = eth_change_mtu,
994 .ndo_set_mac_address = eth_mac_addr,
995 .ndo_validate_addr = eth_validate_addr,
996};
997
998/*
999 * Sanity check the suspected EtherExpress card
1000 * Read hardware address, reset card, size memory and initialize buffer
1001 * memory pointers. These are held in netdev_priv(), in case someone has more
1002 * than one card in a machine.
1003 */
1004
1005static int __init eexp_hw_probe(struct net_device *dev, unsigned short ioaddr)
1006{
1007 unsigned short hw_addr[3];
1008 unsigned char buswidth;
1009 unsigned int memory_size;
1010 int i;
1011 unsigned short xsum = 0;
1012 struct net_local *lp = netdev_priv(dev);
1013
1014 printk("%s: EtherExpress 16 at %#x ",dev->name,ioaddr);
1015
1016 outb(ASIC_RST, ioaddr+EEPROM_Ctrl);
1017 outb(0, ioaddr+EEPROM_Ctrl);
1018 udelay(500);
1019 outb(i586_RST, ioaddr+EEPROM_Ctrl);
1020
1021 hw_addr[0] = eexp_hw_readeeprom(ioaddr,2);
1022 hw_addr[1] = eexp_hw_readeeprom(ioaddr,3);
1023 hw_addr[2] = eexp_hw_readeeprom(ioaddr,4);
1024
1025 /* Standard Address or Compaq LTE Address */
1026 if (!((hw_addr[2]==0x00aa && ((hw_addr[1] & 0xff00)==0x0000)) ||
1027 (hw_addr[2]==0x0080 && ((hw_addr[1] & 0xff00)==0x5F00))))
1028 {
1029 printk(" rejected: invalid address %04x%04x%04x\n",
1030 hw_addr[2],hw_addr[1],hw_addr[0]);
1031 return -ENODEV;
1032 }
1033
1034 /* Calculate the EEPROM checksum. Carry on anyway if it's bad,
1035 * though.
1036 */
1037 for (i = 0; i < 64; i++)
1038 xsum += eexp_hw_readeeprom(ioaddr, i);
1039 if (xsum != 0xbaba)
1040 printk(" (bad EEPROM xsum 0x%02x)", xsum);
1041
1042 dev->base_addr = ioaddr;
1043 for ( i=0 ; i<6 ; i++ )
1044 dev->dev_addr[i] = ((unsigned char *)hw_addr)[5-i];
1045
1046 {
1047 static const char irqmap[] = { 0, 9, 3, 4, 5, 10, 11, 0 };
1048 unsigned short setupval = eexp_hw_readeeprom(ioaddr,0);
1049
1050 /* Use the IRQ from EEPROM if none was given */
1051 if (!dev->irq)
1052 dev->irq = irqmap[setupval>>13];
1053
1054 if (dev->if_port == 0xff) {
1055 dev->if_port = !(setupval & 0x1000) ? AUI :
1056 eexp_hw_readeeprom(ioaddr,5) & 0x1 ? TPE : BNC;
1057 }
1058
1059 buswidth = !((setupval & 0x400) >> 10);
1060 }
1061
1062 memset(lp, 0, sizeof(struct net_local));
1063 spin_lock_init(&lp->lock);
1064
1065 printk("(IRQ %d, %s connector, %d-bit bus", dev->irq,
1066 eexp_ifmap[dev->if_port], buswidth?8:16);
1067
1068 if (!request_region(dev->base_addr + 0x300e, 1, "EtherExpress"))
1069 return -EBUSY;
1070
1071 eexp_hw_set_interface(dev);
1072
1073 release_region(dev->base_addr + 0x300e, 1);
1074
1075 /* Find out how much RAM we have on the card */
1076 outw(0, dev->base_addr + WRITE_PTR);
1077 for (i = 0; i < 32768; i++)
1078 outw(0, dev->base_addr + DATAPORT);
1079
1080 for (memory_size = 0; memory_size < 64; memory_size++)
1081 {
1082 outw(memory_size<<10, dev->base_addr + READ_PTR);
1083 if (inw(dev->base_addr+DATAPORT))
1084 break;
1085 outw(memory_size<<10, dev->base_addr + WRITE_PTR);
1086 outw(memory_size | 0x5000, dev->base_addr+DATAPORT);
1087 outw(memory_size<<10, dev->base_addr + READ_PTR);
1088 if (inw(dev->base_addr+DATAPORT) != (memory_size | 0x5000))
1089 break;
1090 }
1091
1092 /* Sort out the number of buffers. We may have 16, 32, 48 or 64k
1093 * of RAM to play with.
1094 */
1095 lp->num_tx_bufs = 4;
1096 lp->rx_buf_end = 0x3ff6;
1097 switch (memory_size)
1098 {
1099 case 64:
1100 lp->rx_buf_end += 0x4000;
1101 case 48:
1102 lp->num_tx_bufs += 4;
1103 lp->rx_buf_end += 0x4000;
1104 case 32:
1105 lp->rx_buf_end += 0x4000;
1106 case 16:
1107 printk(", %dk RAM)\n", memory_size);
1108 break;
1109 default:
1110 printk(") bad memory size (%dk).\n", memory_size);
1111 return -ENODEV;
1112 break;
1113 }
1114
1115 lp->rx_buf_start = TX_BUF_START + (lp->num_tx_bufs*TX_BUF_SIZE);
1116 lp->width = buswidth;
1117
1118 dev->netdev_ops = &eexp_netdev_ops;
1119 dev->watchdog_timeo = 2*HZ;
1120
1121 return register_netdev(dev);
1122}
1123
1124/*
1125 * Read a word from the EtherExpress on-board serial EEPROM.
1126 * The EEPROM contains 64 words of 16 bits.
1127 */
1128static unsigned short __init eexp_hw_readeeprom(unsigned short ioaddr,
1129 unsigned char location)
1130{
1131 unsigned short cmd = 0x180|(location&0x7f);
1132 unsigned short rval = 0,wval = EC_CS|i586_RST;
1133 int i;
1134
1135 outb(EC_CS|i586_RST,ioaddr+EEPROM_Ctrl);
1136 for (i=0x100 ; i ; i>>=1 )
1137 {
1138 if (cmd&i)
1139 wval |= EC_Wr;
1140 else
1141 wval &= ~EC_Wr;
1142
1143 outb(wval,ioaddr+EEPROM_Ctrl);
1144 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1145 eeprom_delay();
1146 outb(wval,ioaddr+EEPROM_Ctrl);
1147 eeprom_delay();
1148 }
1149 wval &= ~EC_Wr;
1150 outb(wval,ioaddr+EEPROM_Ctrl);
1151 for (i=0x8000 ; i ; i>>=1 )
1152 {
1153 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1154 eeprom_delay();
1155 if (inb(ioaddr+EEPROM_Ctrl)&EC_Rd)
1156 rval |= i;
1157 outb(wval,ioaddr+EEPROM_Ctrl);
1158 eeprom_delay();
1159 }
1160 wval &= ~EC_CS;
1161 outb(wval|EC_Clk,ioaddr+EEPROM_Ctrl);
1162 eeprom_delay();
1163 outb(wval,ioaddr+EEPROM_Ctrl);
1164 eeprom_delay();
1165 return rval;
1166}
1167
1168/*
1169 * Reap tx buffers and return last transmit status.
1170 * if ==0 then either:
1171 * a) we're not transmitting anything, so why are we here?
1172 * b) we've died.
1173 * otherwise, Stat_Busy(return) means we've still got some packets
1174 * to transmit, Stat_Done(return) means our buffers should be empty
1175 * again
1176 */
1177
1178static unsigned short eexp_hw_lasttxstat(struct net_device *dev)
1179{
1180 struct net_local *lp = netdev_priv(dev);
1181 unsigned short tx_block = lp->tx_reap;
1182 unsigned short status;
1183
1184 if (!netif_queue_stopped(dev) && lp->tx_head==lp->tx_reap)
1185 return 0x0000;
1186
1187 do
1188 {
1189 outw(tx_block & ~31, dev->base_addr + SM_PTR);
1190 status = inw(dev->base_addr + SHADOW(tx_block));
1191 if (!Stat_Done(status))
1192 {
1193 lp->tx_link = tx_block;
1194 return status;
1195 }
1196 else
1197 {
1198 lp->last_tx_restart = 0;
1199 dev->stats.collisions += Stat_NoColl(status);
1200 if (!Stat_OK(status))
1201 {
1202 char *whatsup = NULL;
1203 dev->stats.tx_errors++;
1204 if (Stat_Abort(status))
1205 dev->stats.tx_aborted_errors++;
1206 if (Stat_TNoCar(status)) {
1207 whatsup = "aborted, no carrier";
1208 dev->stats.tx_carrier_errors++;
1209 }
1210 if (Stat_TNoCTS(status)) {
1211 whatsup = "aborted, lost CTS";
1212 dev->stats.tx_carrier_errors++;
1213 }
1214 if (Stat_TNoDMA(status)) {
1215 whatsup = "FIFO underran";
1216 dev->stats.tx_fifo_errors++;
1217 }
1218 if (Stat_TXColl(status)) {
1219 whatsup = "aborted, too many collisions";
1220 dev->stats.tx_aborted_errors++;
1221 }
1222 if (whatsup)
1223 printk(KERN_INFO "%s: transmit %s\n",
1224 dev->name, whatsup);
1225 }
1226 else
1227 dev->stats.tx_packets++;
1228 }
1229 if (tx_block == TX_BUF_START+((lp->num_tx_bufs-1)*TX_BUF_SIZE))
1230 lp->tx_reap = tx_block = TX_BUF_START;
1231 else
1232 lp->tx_reap = tx_block += TX_BUF_SIZE;
1233 netif_wake_queue(dev);
1234 }
1235 while (lp->tx_reap != lp->tx_head);
1236
1237 lp->tx_link = lp->tx_tail + 0x08;
1238
1239 return status;
1240}
1241
1242/*
1243 * This should never happen. It is called when some higher routine detects
1244 * that the CU has stopped, to try to restart it from the last packet we knew
1245 * we were working on, or the idle loop if we had finished for the time.
1246 */
1247
1248static void eexp_hw_txrestart(struct net_device *dev)
1249{
1250 struct net_local *lp = netdev_priv(dev);
1251 unsigned short ioaddr = dev->base_addr;
1252
1253 lp->last_tx_restart = lp->tx_link;
1254 scb_wrcbl(dev, lp->tx_link);
1255 scb_command(dev, SCB_CUstart);
1256 outb(0,ioaddr+SIGNAL_CA);
1257
1258 {
1259 unsigned short boguscount=50,failcount=5;
1260 while (!scb_status(dev))
1261 {
1262 if (!--boguscount)
1263 {
1264 if (--failcount)
1265 {
1266 printk(KERN_WARNING "%s: CU start timed out, status %04x, cmd %04x\n", dev->name, scb_status(dev), scb_rdcmd(dev));
1267 scb_wrcbl(dev, lp->tx_link);
1268 scb_command(dev, SCB_CUstart);
1269 outb(0,ioaddr+SIGNAL_CA);
1270 boguscount = 100;
1271 }
1272 else
1273 {
1274 printk(KERN_WARNING "%s: Failed to restart CU, resetting board...\n",dev->name);
1275 eexp_hw_init586(dev);
1276 netif_wake_queue(dev);
1277 return;
1278 }
1279 }
1280 }
1281 }
1282}
1283
1284/*
1285 * Writes down the list of transmit buffers into card memory. Each
1286 * entry consists of an 82586 transmit command, followed by a jump
1287 * pointing to itself. When we want to transmit a packet, we write
1288 * the data into the appropriate transmit buffer and then modify the
1289 * preceding jump to point at the new transmit command. This means that
1290 * the 586 command unit is continuously active.
1291 */
1292
1293static void eexp_hw_txinit(struct net_device *dev)
1294{
1295 struct net_local *lp = netdev_priv(dev);
1296 unsigned short tx_block = TX_BUF_START;
1297 unsigned short curtbuf;
1298 unsigned short ioaddr = dev->base_addr;
1299
1300 for ( curtbuf=0 ; curtbuf<lp->num_tx_bufs ; curtbuf++ )
1301 {
1302 outw(tx_block, ioaddr + WRITE_PTR);
1303
1304 outw(0x0000, ioaddr + DATAPORT);
1305 outw(Cmd_INT|Cmd_Xmit, ioaddr + DATAPORT);
1306 outw(tx_block+0x08, ioaddr + DATAPORT);
1307 outw(tx_block+0x0e, ioaddr + DATAPORT);
1308
1309 outw(0x0000, ioaddr + DATAPORT);
1310 outw(0x0000, ioaddr + DATAPORT);
1311 outw(tx_block+0x08, ioaddr + DATAPORT);
1312
1313 outw(0x8000, ioaddr + DATAPORT);
1314 outw(-1, ioaddr + DATAPORT);
1315 outw(tx_block+0x16, ioaddr + DATAPORT);
1316 outw(0x0000, ioaddr + DATAPORT);
1317
1318 tx_block += TX_BUF_SIZE;
1319 }
1320 lp->tx_head = TX_BUF_START;
1321 lp->tx_reap = TX_BUF_START;
1322 lp->tx_tail = tx_block - TX_BUF_SIZE;
1323 lp->tx_link = lp->tx_tail + 0x08;
1324 lp->rx_buf_start = tx_block;
1325
1326}
1327
1328/*
1329 * Write the circular list of receive buffer descriptors to card memory.
1330 * The end of the list isn't marked, which means that the 82586 receive
1331 * unit will loop until buffers become available (this avoids it giving us
1332 * "out of resources" messages).
1333 */
1334
1335static void eexp_hw_rxinit(struct net_device *dev)
1336{
1337 struct net_local *lp = netdev_priv(dev);
1338 unsigned short rx_block = lp->rx_buf_start;
1339 unsigned short ioaddr = dev->base_addr;
1340
1341 lp->num_rx_bufs = 0;
1342 lp->rx_first = lp->rx_ptr = rx_block;
1343 do
1344 {
1345 lp->num_rx_bufs++;
1346
1347 outw(rx_block, ioaddr + WRITE_PTR);
1348
1349 outw(0, ioaddr + DATAPORT); outw(0, ioaddr+DATAPORT);
1350 outw(rx_block + RX_BUF_SIZE, ioaddr+DATAPORT);
1351 outw(0xffff, ioaddr+DATAPORT);
1352
1353 outw(0x0000, ioaddr+DATAPORT);
1354 outw(0xdead, ioaddr+DATAPORT);
1355 outw(0xdead, ioaddr+DATAPORT);
1356 outw(0xdead, ioaddr+DATAPORT);
1357 outw(0xdead, ioaddr+DATAPORT);
1358 outw(0xdead, ioaddr+DATAPORT);
1359 outw(0xdead, ioaddr+DATAPORT);
1360
1361 outw(0x0000, ioaddr+DATAPORT);
1362 outw(rx_block + RX_BUF_SIZE + 0x16, ioaddr+DATAPORT);
1363 outw(rx_block + 0x20, ioaddr+DATAPORT);
1364 outw(0, ioaddr+DATAPORT);
1365 outw(RX_BUF_SIZE-0x20, ioaddr+DATAPORT);
1366
1367 lp->rx_last = rx_block;
1368 rx_block += RX_BUF_SIZE;
1369 } while (rx_block <= lp->rx_buf_end-RX_BUF_SIZE);
1370
1371
1372 /* Make first Rx frame descriptor point to first Rx buffer
1373 descriptor */
1374 outw(lp->rx_first + 6, ioaddr+WRITE_PTR);
1375 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1376
1377 /* Close Rx frame descriptor ring */
1378 outw(lp->rx_last + 4, ioaddr+WRITE_PTR);
1379 outw(lp->rx_first, ioaddr+DATAPORT);
1380
1381 /* Close Rx buffer descriptor ring */
1382 outw(lp->rx_last + 0x16 + 2, ioaddr+WRITE_PTR);
1383 outw(lp->rx_first + 0x16, ioaddr+DATAPORT);
1384
1385}
1386
1387/*
1388 * Un-reset the 586, and start the configuration sequence. We don't wait for
1389 * this to finish, but allow the interrupt handler to start the CU and RU for
1390 * us. We can't start the receive/transmission system up before we know that
1391 * the hardware is configured correctly.
1392 */
1393
1394static void eexp_hw_init586(struct net_device *dev)
1395{
1396 struct net_local *lp = netdev_priv(dev);
1397 unsigned short ioaddr = dev->base_addr;
1398 int i;
1399
1400#if NET_DEBUG > 6
1401 printk("%s: eexp_hw_init586()\n", dev->name);
1402#endif
1403
1404 lp->started = 0;
1405
1406 set_loopback(dev);
1407
1408 outb(SIRQ_dis|irqrmap[dev->irq],ioaddr+SET_IRQ);
1409
1410 /* Download the startup code */
1411 outw(lp->rx_buf_end & ~31, ioaddr + SM_PTR);
1412 outw(lp->width?0x0001:0x0000, ioaddr + 0x8006);
1413 outw(0x0000, ioaddr + 0x8008);
1414 outw(0x0000, ioaddr + 0x800a);
1415 outw(0x0000, ioaddr + 0x800c);
1416 outw(0x0000, ioaddr + 0x800e);
1417
1418 for (i = 0; i < ARRAY_SIZE(start_code) * 2; i+=32) {
1419 int j;
1420 outw(i, ioaddr + SM_PTR);
1421 for (j = 0; j < 16 && (i+j)/2 < ARRAY_SIZE(start_code); j+=2)
1422 outw(start_code[(i+j)/2],
1423 ioaddr+0x4000+j);
1424 for (j = 0; j < 16 && (i+j+16)/2 < ARRAY_SIZE(start_code); j+=2)
1425 outw(start_code[(i+j+16)/2],
1426 ioaddr+0x8000+j);
1427 }
1428
1429 /* Do we want promiscuous mode or multicast? */
1430 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1431 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1432 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1433 ioaddr+SHADOW(CONF_PROMISC));
1434 lp->was_promisc = dev->flags & IFF_PROMISC;
1435#if 0
1436 eexp_setup_filter(dev);
1437#endif
1438
1439 /* Write our hardware address */
1440 outw(CONF_HWADDR & ~31, ioaddr+SM_PTR);
1441 outw(((unsigned short *)dev->dev_addr)[0], ioaddr+SHADOW(CONF_HWADDR));
1442 outw(((unsigned short *)dev->dev_addr)[1],
1443 ioaddr+SHADOW(CONF_HWADDR+2));
1444 outw(((unsigned short *)dev->dev_addr)[2],
1445 ioaddr+SHADOW(CONF_HWADDR+4));
1446
1447 eexp_hw_txinit(dev);
1448 eexp_hw_rxinit(dev);
1449
1450 outb(0,ioaddr+EEPROM_Ctrl);
1451 mdelay(5);
1452
1453 scb_command(dev, 0xf000);
1454 outb(0,ioaddr+SIGNAL_CA);
1455
1456 outw(0, ioaddr+SM_PTR);
1457
1458 {
1459 unsigned short rboguscount=50,rfailcount=5;
1460 while (inw(ioaddr+0x4000))
1461 {
1462 if (!--rboguscount)
1463 {
1464 printk(KERN_WARNING "%s: i82586 reset timed out, kicking...\n",
1465 dev->name);
1466 scb_command(dev, 0);
1467 outb(0,ioaddr+SIGNAL_CA);
1468 rboguscount = 100;
1469 if (!--rfailcount)
1470 {
1471 printk(KERN_WARNING "%s: i82586 not responding, giving up.\n",
1472 dev->name);
1473 return;
1474 }
1475 }
1476 }
1477 }
1478
1479 scb_wrcbl(dev, CONF_LINK);
1480 scb_command(dev, 0xf000|SCB_CUstart);
1481 outb(0,ioaddr+SIGNAL_CA);
1482
1483 {
1484 unsigned short iboguscount=50,ifailcount=5;
1485 while (!scb_status(dev))
1486 {
1487 if (!--iboguscount)
1488 {
1489 if (--ifailcount)
1490 {
1491 printk(KERN_WARNING "%s: i82586 initialization timed out, status %04x, cmd %04x\n",
1492 dev->name, scb_status(dev), scb_rdcmd(dev));
1493 scb_wrcbl(dev, CONF_LINK);
1494 scb_command(dev, 0xf000|SCB_CUstart);
1495 outb(0,ioaddr+SIGNAL_CA);
1496 iboguscount = 100;
1497 }
1498 else
1499 {
1500 printk(KERN_WARNING "%s: Failed to initialize i82586, giving up.\n",dev->name);
1501 return;
1502 }
1503 }
1504 }
1505 }
1506
1507 clear_loopback(dev);
1508 outb(SIRQ_en|irqrmap[dev->irq],ioaddr+SET_IRQ);
1509
1510 lp->init_time = jiffies;
1511#if NET_DEBUG > 6
1512 printk("%s: leaving eexp_hw_init586()\n", dev->name);
1513#endif
1514}
1515
1516static void eexp_setup_filter(struct net_device *dev)
1517{
1518 struct netdev_hw_addr *ha;
1519 unsigned short ioaddr = dev->base_addr;
1520 int count = netdev_mc_count(dev);
1521 int i;
1522 if (count > 8) {
1523 printk(KERN_INFO "%s: too many multicast addresses (%d)\n",
1524 dev->name, count);
1525 count = 8;
1526 }
1527
1528 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
1529 outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST));
1530 i = 0;
1531 netdev_for_each_mc_addr(ha, dev) {
1532 unsigned short *data = (unsigned short *) ha->addr;
1533
1534 if (i == count)
1535 break;
1536 outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR);
1537 outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i)));
1538 outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR);
1539 outw(data[1], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+2));
1540 outw((CONF_MULTICAST+(6*i)+4) & ~31, ioaddr+SM_PTR);
1541 outw(data[2], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+4));
1542 i++;
1543 }
1544}
1545
1546/*
1547 * Set or clear the multicast filter for this adaptor.
1548 */
1549static void
1550eexp_set_multicast(struct net_device *dev)
1551{
1552 unsigned short ioaddr = dev->base_addr;
1553 struct net_local *lp = netdev_priv(dev);
1554 int kick = 0, i;
1555 if ((dev->flags & IFF_PROMISC) != lp->was_promisc) {
1556 outw(CONF_PROMISC & ~31, ioaddr+SM_PTR);
1557 i = inw(ioaddr+SHADOW(CONF_PROMISC));
1558 outw((dev->flags & IFF_PROMISC)?(i|1):(i & ~1),
1559 ioaddr+SHADOW(CONF_PROMISC));
1560 lp->was_promisc = dev->flags & IFF_PROMISC;
1561 kick = 1;
1562 }
1563 if (!(dev->flags & IFF_PROMISC)) {
1564 eexp_setup_filter(dev);
1565 if (lp->old_mc_count != netdev_mc_count(dev)) {
1566 kick = 1;
1567 lp->old_mc_count = netdev_mc_count(dev);
1568 }
1569 }
1570 if (kick) {
1571 unsigned long oj;
1572 scb_command(dev, SCB_CUsuspend);
1573 outb(0, ioaddr+SIGNAL_CA);
1574 outb(0, ioaddr+SIGNAL_CA);
1575#if 0
1576 printk("%s: waiting for CU to go suspended\n", dev->name);
1577#endif
1578 oj = jiffies;
1579 while ((SCB_CUstat(scb_status(dev)) == 2) &&
1580 (time_before(jiffies, oj + 2000)));
1581 if (SCB_CUstat(scb_status(dev)) == 2)
1582 printk("%s: warning, CU didn't stop\n", dev->name);
1583 lp->started &= ~(STARTED_CU);
1584 scb_wrcbl(dev, CONF_LINK);
1585 scb_command(dev, SCB_CUstart);
1586 outb(0, ioaddr+SIGNAL_CA);
1587 }
1588}
1589
1590
1591/*
1592 * MODULE stuff
1593 */
1594
1595#ifdef MODULE
1596
1597#define EEXP_MAX_CARDS 4 /* max number of cards to support */
1598
1599static struct net_device *dev_eexp[EEXP_MAX_CARDS];
1600static int irq[EEXP_MAX_CARDS];
1601static int io[EEXP_MAX_CARDS];
1602
1603module_param_array(io, int, NULL, 0);
1604module_param_array(irq, int, NULL, 0);
1605MODULE_PARM_DESC(io, "EtherExpress 16 I/O base address(es)");
1606MODULE_PARM_DESC(irq, "EtherExpress 16 IRQ number(s)");
1607MODULE_LICENSE("GPL");
1608
1609
1610/* Ideally the user would give us io=, irq= for every card. If any parameters
1611 * are specified, we verify and then use them. If no parameters are given, we
1612 * autoprobe for one card only.
1613 */
1614int __init init_module(void)
1615{
1616 struct net_device *dev;
1617 int this_dev, found = 0;
1618
1619 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1620 dev = alloc_etherdev(sizeof(struct net_local));
1621 dev->irq = irq[this_dev];
1622 dev->base_addr = io[this_dev];
1623 if (io[this_dev] == 0) {
1624 if (this_dev)
1625 break;
1626 printk(KERN_NOTICE "eexpress.c: Module autoprobe not recommended, give io=xx.\n");
1627 }
1628 if (do_express_probe(dev) == 0) {
1629 dev_eexp[this_dev] = dev;
1630 found++;
1631 continue;
1632 }
1633 printk(KERN_WARNING "eexpress.c: Failed to register card at 0x%x.\n", io[this_dev]);
1634 free_netdev(dev);
1635 break;
1636 }
1637 if (found)
1638 return 0;
1639 return -ENXIO;
1640}
1641
1642void __exit cleanup_module(void)
1643{
1644 int this_dev;
1645
1646 for (this_dev = 0; this_dev < EEXP_MAX_CARDS; this_dev++) {
1647 struct net_device *dev = dev_eexp[this_dev];
1648 if (dev) {
1649 unregister_netdev(dev);
1650 free_netdev(dev);
1651 }
1652 }
1653}
1654#endif
1655
1656/*
1657 * Local Variables:
1658 * c-file-style: "linux"
1659 * tab-width: 8
1660 * End:
1661 */
diff --git a/drivers/net/ethernet/i825xx/eexpress.h b/drivers/net/ethernet/i825xx/eexpress.h
deleted file mode 100644
index dc9c6ea289e9..000000000000
--- a/drivers/net/ethernet/i825xx/eexpress.h
+++ /dev/null
@@ -1,179 +0,0 @@
1/*
2 * eexpress.h: Intel EtherExpress16 defines
3 */
4
5/*
6 * EtherExpress card register addresses
7 * as offsets from the base IO region (dev->base_addr)
8 */
9
10#define DATAPORT 0x0000
11#define WRITE_PTR 0x0002
12#define READ_PTR 0x0004
13#define SIGNAL_CA 0x0006
14#define SET_IRQ 0x0007
15#define SM_PTR 0x0008
16#define MEM_Dec 0x000a
17#define MEM_Ctrl 0x000b
18#define MEM_Page_Ctrl 0x000c
19#define Config 0x000d
20#define EEPROM_Ctrl 0x000e
21#define ID_PORT 0x000f
22#define MEM_ECtrl 0x000f
23
24/*
25 * card register defines
26 */
27
28/* SET_IRQ */
29#define SIRQ_en 0x08
30#define SIRQ_dis 0x00
31
32/* EEPROM_Ctrl */
33#define EC_Clk 0x01
34#define EC_CS 0x02
35#define EC_Wr 0x04
36#define EC_Rd 0x08
37#define ASIC_RST 0x40
38#define i586_RST 0x80
39
40#define eeprom_delay() { udelay(40); }
41
42/*
43 * i82586 Memory Configuration
44 */
45
46/* (System Configuration Pointer) System start up block, read after 586_RST */
47#define SCP_START 0xfff6
48
49/* Intermediate System Configuration Pointer */
50#define ISCP_START 0x0000
51
52/* System Command Block */
53#define SCB_START 0x0008
54
55/* Start of buffer region. Everything before this is used for control
56 * structures and the CU configuration program. The memory layout is
57 * determined in eexp_hw_probe(), once we know how much memory is
58 * available on the card.
59 */
60
61#define TX_BUF_START 0x0100
62
63#define TX_BUF_SIZE ((24+ETH_FRAME_LEN+31)&~0x1f)
64#define RX_BUF_SIZE ((32+ETH_FRAME_LEN+31)&~0x1f)
65
66/*
67 * SCB defines
68 */
69
70/* these functions take the SCB status word and test the relevant status bit */
71#define SCB_complete(s) (((s) & 0x8000) != 0)
72#define SCB_rxdframe(s) (((s) & 0x4000) != 0)
73#define SCB_CUdead(s) (((s) & 0x2000) != 0)
74#define SCB_RUdead(s) (((s) & 0x1000) != 0)
75#define SCB_ack(s) ((s) & 0xf000)
76
77/* Command unit status: 0=idle, 1=suspended, 2=active */
78#define SCB_CUstat(s) (((s)&0x0300)>>8)
79
80/* Receive unit status: 0=idle, 1=suspended, 2=out of resources, 4=ready */
81#define SCB_RUstat(s) (((s)&0x0070)>>4)
82
83/* SCB commands */
84#define SCB_CUnop 0x0000
85#define SCB_CUstart 0x0100
86#define SCB_CUresume 0x0200
87#define SCB_CUsuspend 0x0300
88#define SCB_CUabort 0x0400
89#define SCB_resetchip 0x0080
90
91#define SCB_RUnop 0x0000
92#define SCB_RUstart 0x0010
93#define SCB_RUresume 0x0020
94#define SCB_RUsuspend 0x0030
95#define SCB_RUabort 0x0040
96
97/*
98 * Command block defines
99 */
100
101#define Stat_Done(s) (((s) & 0x8000) != 0)
102#define Stat_Busy(s) (((s) & 0x4000) != 0)
103#define Stat_OK(s) (((s) & 0x2000) != 0)
104#define Stat_Abort(s) (((s) & 0x1000) != 0)
105#define Stat_STFail (((s) & 0x0800) != 0)
106#define Stat_TNoCar(s) (((s) & 0x0400) != 0)
107#define Stat_TNoCTS(s) (((s) & 0x0200) != 0)
108#define Stat_TNoDMA(s) (((s) & 0x0100) != 0)
109#define Stat_TDefer(s) (((s) & 0x0080) != 0)
110#define Stat_TColl(s) (((s) & 0x0040) != 0)
111#define Stat_TXColl(s) (((s) & 0x0020) != 0)
112#define Stat_NoColl(s) ((s) & 0x000f)
113
114/* Cmd_END will end AFTER the command if this is the first
115 * command block after an SCB_CUstart, but BEFORE the command
116 * for all subsequent commands. Best strategy is to place
117 * Cmd_INT on the last command in the sequence, followed by a
118 * dummy Cmd_Nop with Cmd_END after this.
119 */
120
121#define Cmd_END 0x8000
122#define Cmd_SUS 0x4000
123#define Cmd_INT 0x2000
124
125#define Cmd_Nop 0x0000
126#define Cmd_SetAddr 0x0001
127#define Cmd_Config 0x0002
128#define Cmd_MCast 0x0003
129#define Cmd_Xmit 0x0004
130#define Cmd_TDR 0x0005
131#define Cmd_Dump 0x0006
132#define Cmd_Diag 0x0007
133
134
135/*
136 * Frame Descriptor (Receive block) defines
137 */
138
139#define FD_Done(s) (((s) & 0x8000) != 0)
140#define FD_Busy(s) (((s) & 0x4000) != 0)
141#define FD_OK(s) (((s) & 0x2000) != 0)
142
143#define FD_CRC(s) (((s) & 0x0800) != 0)
144#define FD_Align(s) (((s) & 0x0400) != 0)
145#define FD_Resrc(s) (((s) & 0x0200) != 0)
146#define FD_DMA(s) (((s) & 0x0100) != 0)
147#define FD_Short(s) (((s) & 0x0080) != 0)
148#define FD_NoEOF(s) (((s) & 0x0040) != 0)
149
150struct rfd_header {
151 volatile unsigned long flags;
152 volatile unsigned short link;
153 volatile unsigned short rbd_offset;
154 volatile unsigned short dstaddr1;
155 volatile unsigned short dstaddr2;
156 volatile unsigned short dstaddr3;
157 volatile unsigned short srcaddr1;
158 volatile unsigned short srcaddr2;
159 volatile unsigned short srcaddr3;
160 volatile unsigned short length;
161
162 /* This is actually a Receive Buffer Descriptor. The way we
163 * arrange memory means that an RBD always follows the RFD that
164 * points to it, so they might as well be in the same structure.
165 */
166 volatile unsigned short actual_count;
167 volatile unsigned short next_rbd;
168 volatile unsigned short buf_addr1;
169 volatile unsigned short buf_addr2;
170 volatile unsigned short size;
171};
172
173/* Returned data from the Time Domain Reflectometer */
174
175#define TDR_LINKOK (1<<15)
176#define TDR_XCVRPROBLEM (1<<14)
177#define TDR_OPEN (1<<13)
178#define TDR_SHORT (1<<12)
179#define TDR_TIME 0x7ff