xref: /linux/drivers/net/ethernet/via/via-velocity.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1d9c98161SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2f2148a47SJeff Kirsher /*
3f2148a47SJeff Kirsher  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
4f2148a47SJeff Kirsher  * All rights reserved.
5f2148a47SJeff Kirsher  *
6f2148a47SJeff Kirsher  * File: via-velocity.h
7f2148a47SJeff Kirsher  *
8f2148a47SJeff Kirsher  * Purpose: Header file to define driver's private structures.
9f2148a47SJeff Kirsher  *
10f2148a47SJeff Kirsher  * Author: Chuang Liang-Shing, AJ Jiang
11f2148a47SJeff Kirsher  *
12f2148a47SJeff Kirsher  * Date: Jan 24, 2003
13f2148a47SJeff Kirsher  */
14f2148a47SJeff Kirsher 
15f2148a47SJeff Kirsher 
16f2148a47SJeff Kirsher #ifndef VELOCITY_H
17f2148a47SJeff Kirsher #define VELOCITY_H
18f2148a47SJeff Kirsher 
19f2148a47SJeff Kirsher #define VELOCITY_TX_CSUM_SUPPORT
20f2148a47SJeff Kirsher 
21f2148a47SJeff Kirsher #define VELOCITY_NAME          "via-velocity"
22f2148a47SJeff Kirsher #define VELOCITY_FULL_DRV_NAM  "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
23f2148a47SJeff Kirsher #define VELOCITY_VERSION       "1.15"
24f2148a47SJeff Kirsher 
25f2148a47SJeff Kirsher #define VELOCITY_IO_SIZE	256
26f2148a47SJeff Kirsher 
27f2148a47SJeff Kirsher #define PKT_BUF_SZ          1540
28f2148a47SJeff Kirsher 
29f2148a47SJeff Kirsher #define MAX_UNITS           8
30f2148a47SJeff Kirsher #define OPTION_DEFAULT      { [0 ... MAX_UNITS-1] = -1}
31f2148a47SJeff Kirsher 
32f2148a47SJeff Kirsher #define REV_ID_VT6110       (0)
33f2148a47SJeff Kirsher 
34f2148a47SJeff Kirsher #define BYTE_REG_BITS_ON(x,p)       do { writeb(readb((p))|(x),(p));} while (0)
35f2148a47SJeff Kirsher #define WORD_REG_BITS_ON(x,p)       do { writew(readw((p))|(x),(p));} while (0)
36f2148a47SJeff Kirsher #define DWORD_REG_BITS_ON(x,p)      do { writel(readl((p))|(x),(p));} while (0)
37f2148a47SJeff Kirsher 
38f2148a47SJeff Kirsher #define BYTE_REG_BITS_IS_ON(x,p)    (readb((p)) & (x))
39f2148a47SJeff Kirsher #define WORD_REG_BITS_IS_ON(x,p)    (readw((p)) & (x))
40f2148a47SJeff Kirsher #define DWORD_REG_BITS_IS_ON(x,p)   (readl((p)) & (x))
41f2148a47SJeff Kirsher 
42f2148a47SJeff Kirsher #define BYTE_REG_BITS_OFF(x,p)      do { writeb(readb((p)) & (~(x)),(p));} while (0)
43f2148a47SJeff Kirsher #define WORD_REG_BITS_OFF(x,p)      do { writew(readw((p)) & (~(x)),(p));} while (0)
44f2148a47SJeff Kirsher #define DWORD_REG_BITS_OFF(x,p)     do { writel(readl((p)) & (~(x)),(p));} while (0)
45f2148a47SJeff Kirsher 
46f2148a47SJeff Kirsher #define BYTE_REG_BITS_SET(x,m,p)    do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0)
47f2148a47SJeff Kirsher #define WORD_REG_BITS_SET(x,m,p)    do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0)
48f2148a47SJeff Kirsher #define DWORD_REG_BITS_SET(x,m,p)   do { writel( (readl((p)) & (~(m)))|(x),(p));}  while (0)
49f2148a47SJeff Kirsher 
50f2148a47SJeff Kirsher #define VAR_USED(p)     do {(p)=(p);} while (0)
51f2148a47SJeff Kirsher 
52f2148a47SJeff Kirsher /*
53f2148a47SJeff Kirsher  * Purpose: Structures for MAX RX/TX descriptors.
54f2148a47SJeff Kirsher  */
55f2148a47SJeff Kirsher 
56f2148a47SJeff Kirsher 
57f2148a47SJeff Kirsher #define B_OWNED_BY_CHIP     1
58f2148a47SJeff Kirsher #define B_OWNED_BY_HOST     0
59f2148a47SJeff Kirsher 
60f2148a47SJeff Kirsher /*
61f2148a47SJeff Kirsher  * Bits in the RSR0 register
62f2148a47SJeff Kirsher  */
63f2148a47SJeff Kirsher 
64f2148a47SJeff Kirsher #define RSR_DETAG	cpu_to_le16(0x0080)
65f2148a47SJeff Kirsher #define RSR_SNTAG	cpu_to_le16(0x0040)
66f2148a47SJeff Kirsher #define RSR_RXER	cpu_to_le16(0x0020)
67f2148a47SJeff Kirsher #define RSR_RL		cpu_to_le16(0x0010)
68f2148a47SJeff Kirsher #define RSR_CE		cpu_to_le16(0x0008)
69f2148a47SJeff Kirsher #define RSR_FAE		cpu_to_le16(0x0004)
70f2148a47SJeff Kirsher #define RSR_CRC		cpu_to_le16(0x0002)
71f2148a47SJeff Kirsher #define RSR_VIDM	cpu_to_le16(0x0001)
72f2148a47SJeff Kirsher 
73f2148a47SJeff Kirsher /*
74f2148a47SJeff Kirsher  * Bits in the RSR1 register
75f2148a47SJeff Kirsher  */
76f2148a47SJeff Kirsher 
77f2148a47SJeff Kirsher #define RSR_RXOK	cpu_to_le16(0x8000) // rx OK
78f2148a47SJeff Kirsher #define RSR_PFT		cpu_to_le16(0x4000) // Perfect filtering address match
79f2148a47SJeff Kirsher #define RSR_MAR		cpu_to_le16(0x2000) // MAC accept multicast address packet
80f2148a47SJeff Kirsher #define RSR_BAR		cpu_to_le16(0x1000) // MAC accept broadcast address packet
81f2148a47SJeff Kirsher #define RSR_PHY		cpu_to_le16(0x0800) // MAC accept physical address packet
82f2148a47SJeff Kirsher #define RSR_VTAG	cpu_to_le16(0x0400) // 802.1p/1q tagging packet indicator
83f2148a47SJeff Kirsher #define RSR_STP		cpu_to_le16(0x0200) // start of packet
84f2148a47SJeff Kirsher #define RSR_EDP		cpu_to_le16(0x0100) // end of packet
85f2148a47SJeff Kirsher 
86f2148a47SJeff Kirsher /*
87f2148a47SJeff Kirsher  * Bits in the CSM register
88f2148a47SJeff Kirsher  */
89f2148a47SJeff Kirsher 
90f2148a47SJeff Kirsher #define CSM_IPOK            0x40	//IP Checksum validation ok
91f2148a47SJeff Kirsher #define CSM_TUPOK           0x20	//TCP/UDP Checksum validation ok
92f2148a47SJeff Kirsher #define CSM_FRAG            0x10	//Fragment IP datagram
93f2148a47SJeff Kirsher #define CSM_IPKT            0x04	//Received an IP packet
94f2148a47SJeff Kirsher #define CSM_TCPKT           0x02	//Received a TCP packet
95f2148a47SJeff Kirsher #define CSM_UDPKT           0x01	//Received a UDP packet
96f2148a47SJeff Kirsher 
97f2148a47SJeff Kirsher /*
98f2148a47SJeff Kirsher  * Bits in the TSR0 register
99f2148a47SJeff Kirsher  */
100f2148a47SJeff Kirsher 
101f2148a47SJeff Kirsher #define TSR0_ABT	cpu_to_le16(0x0080) // Tx abort because of excessive collision
102f2148a47SJeff Kirsher #define TSR0_OWT	cpu_to_le16(0x0040) // Jumbo frame Tx abort
103f2148a47SJeff Kirsher #define TSR0_OWC	cpu_to_le16(0x0020) // Out of window collision
104f2148a47SJeff Kirsher #define TSR0_COLS	cpu_to_le16(0x0010) // experience collision in this transmit event
105f2148a47SJeff Kirsher #define TSR0_NCR3	cpu_to_le16(0x0008) // collision retry counter[3]
106f2148a47SJeff Kirsher #define TSR0_NCR2	cpu_to_le16(0x0004) // collision retry counter[2]
107f2148a47SJeff Kirsher #define TSR0_NCR1	cpu_to_le16(0x0002) // collision retry counter[1]
108f2148a47SJeff Kirsher #define TSR0_NCR0	cpu_to_le16(0x0001) // collision retry counter[0]
109f2148a47SJeff Kirsher #define TSR0_TERR	cpu_to_le16(0x8000) //
110f2148a47SJeff Kirsher #define TSR0_FDX	cpu_to_le16(0x4000) // current transaction is serviced by full duplex mode
111f2148a47SJeff Kirsher #define TSR0_GMII	cpu_to_le16(0x2000) // current transaction is serviced by GMII mode
112f2148a47SJeff Kirsher #define TSR0_LNKFL	cpu_to_le16(0x1000) // packet serviced during link down
113f2148a47SJeff Kirsher #define TSR0_SHDN	cpu_to_le16(0x0400) // shutdown case
114f2148a47SJeff Kirsher #define TSR0_CRS	cpu_to_le16(0x0200) // carrier sense lost
115f2148a47SJeff Kirsher #define TSR0_CDH	cpu_to_le16(0x0100) // AQE test fail (CD heartbeat)
116f2148a47SJeff Kirsher 
117f2148a47SJeff Kirsher //
118f2148a47SJeff Kirsher // Bits in the TCR0 register
119f2148a47SJeff Kirsher //
120f2148a47SJeff Kirsher #define TCR0_TIC            0x80	// assert interrupt immediately while descriptor has been send complete
121f2148a47SJeff Kirsher #define TCR0_PIC            0x40	// priority interrupt request, INA# is issued over adaptive interrupt scheme
122f2148a47SJeff Kirsher #define TCR0_VETAG          0x20	// enable VLAN tag
123f2148a47SJeff Kirsher #define TCR0_IPCK           0x10	// request IP  checksum calculation.
124f2148a47SJeff Kirsher #define TCR0_UDPCK          0x08	// request UDP checksum calculation.
125f2148a47SJeff Kirsher #define TCR0_TCPCK          0x04	// request TCP checksum calculation.
126f2148a47SJeff Kirsher #define TCR0_JMBO           0x02	// indicate a jumbo packet in GMAC side
127f2148a47SJeff Kirsher #define TCR0_CRC            0x01	// disable CRC generation
128f2148a47SJeff Kirsher 
129f2148a47SJeff Kirsher #define TCPLS_NORMAL        3
130f2148a47SJeff Kirsher #define TCPLS_START         2
131f2148a47SJeff Kirsher #define TCPLS_END           1
132f2148a47SJeff Kirsher #define TCPLS_MED           0
133f2148a47SJeff Kirsher 
134f2148a47SJeff Kirsher 
135f2148a47SJeff Kirsher // max transmit or receive buffer size
136f2148a47SJeff Kirsher #define CB_RX_BUF_SIZE     2048UL	// max buffer size
137f2148a47SJeff Kirsher 					// NOTE: must be multiple of 4
138f2148a47SJeff Kirsher 
139f2148a47SJeff Kirsher #define CB_MAX_RD_NUM       512	// MAX # of RD
140f2148a47SJeff Kirsher #define CB_MAX_TD_NUM       256	// MAX # of TD
141f2148a47SJeff Kirsher 
142f2148a47SJeff Kirsher #define CB_INIT_RD_NUM_3119 128	// init # of RD, for setup VT3119
143f2148a47SJeff Kirsher #define CB_INIT_TD_NUM_3119 64	// init # of TD, for setup VT3119
144f2148a47SJeff Kirsher 
145f2148a47SJeff Kirsher #define CB_INIT_RD_NUM      128	// init # of RD, for setup default
146f2148a47SJeff Kirsher #define CB_INIT_TD_NUM      64	// init # of TD, for setup default
147f2148a47SJeff Kirsher 
148f2148a47SJeff Kirsher // for 3119
149f2148a47SJeff Kirsher #define CB_TD_RING_NUM      4	// # of TD rings.
150f2148a47SJeff Kirsher #define CB_MAX_SEG_PER_PKT  7	// max data seg per packet (Tx)
151f2148a47SJeff Kirsher 
152f2148a47SJeff Kirsher 
153f2148a47SJeff Kirsher /*
154f2148a47SJeff Kirsher  *	If collisions excess 15 times , tx will abort, and
155f2148a47SJeff Kirsher  *	if tx fifo underflow, tx will fail
156f2148a47SJeff Kirsher  *	we should try to resend it
157f2148a47SJeff Kirsher  */
158f2148a47SJeff Kirsher 
159f2148a47SJeff Kirsher #define CB_MAX_TX_ABORT_RETRY   3
160f2148a47SJeff Kirsher 
161f2148a47SJeff Kirsher /*
162f2148a47SJeff Kirsher  *	Receive descriptor
163f2148a47SJeff Kirsher  */
164f2148a47SJeff Kirsher 
165f2148a47SJeff Kirsher struct rdesc0 {
166f2148a47SJeff Kirsher 	__le16 RSR;		/* Receive status */
167f2148a47SJeff Kirsher 	__le16 len;		/* bits 0--13; bit 15 - owner */
168f2148a47SJeff Kirsher };
169f2148a47SJeff Kirsher 
170f2148a47SJeff Kirsher struct rdesc1 {
171f2148a47SJeff Kirsher 	__le16 PQTAG;
172f2148a47SJeff Kirsher 	u8 CSM;
173f2148a47SJeff Kirsher 	u8 IPKT;
174f2148a47SJeff Kirsher };
175f2148a47SJeff Kirsher 
176f2148a47SJeff Kirsher enum {
177f2148a47SJeff Kirsher 	RX_INTEN = cpu_to_le16(0x8000)
178f2148a47SJeff Kirsher };
179f2148a47SJeff Kirsher 
180f2148a47SJeff Kirsher struct rx_desc {
181f2148a47SJeff Kirsher 	struct rdesc0 rdesc0;
182f2148a47SJeff Kirsher 	struct rdesc1 rdesc1;
183f2148a47SJeff Kirsher 	__le32 pa_low;		/* Low 32 bit PCI address */
184f2148a47SJeff Kirsher 	__le16 pa_high;		/* Next 16 bit PCI address (48 total) */
185f2148a47SJeff Kirsher 	__le16 size;		/* bits 0--14 - frame size, bit 15 - enable int. */
186f2148a47SJeff Kirsher } __packed;
187f2148a47SJeff Kirsher 
188f2148a47SJeff Kirsher /*
189f2148a47SJeff Kirsher  *	Transmit descriptor
190f2148a47SJeff Kirsher  */
191f2148a47SJeff Kirsher 
192f2148a47SJeff Kirsher struct tdesc0 {
193f2148a47SJeff Kirsher 	__le16 TSR;		/* Transmit status register */
194f2148a47SJeff Kirsher 	__le16 len;		/* bits 0--13 - size of frame, bit 15 - owner */
195f2148a47SJeff Kirsher };
196f2148a47SJeff Kirsher 
197f2148a47SJeff Kirsher struct tdesc1 {
198f2148a47SJeff Kirsher 	__le16 vlan;
199f2148a47SJeff Kirsher 	u8 TCR;
200f2148a47SJeff Kirsher 	u8 cmd;			/* bits 0--1 - TCPLS, bits 4--7 - CMDZ */
201f2148a47SJeff Kirsher } __packed;
202f2148a47SJeff Kirsher 
203f2148a47SJeff Kirsher enum {
204f2148a47SJeff Kirsher 	TD_QUEUE = cpu_to_le16(0x8000)
205f2148a47SJeff Kirsher };
206f2148a47SJeff Kirsher 
207f2148a47SJeff Kirsher struct td_buf {
208f2148a47SJeff Kirsher 	__le32 pa_low;
209f2148a47SJeff Kirsher 	__le16 pa_high;
210f2148a47SJeff Kirsher 	__le16 size;		/* bits 0--13 - size, bit 15 - queue */
211f2148a47SJeff Kirsher } __packed;
212f2148a47SJeff Kirsher 
213f2148a47SJeff Kirsher struct tx_desc {
214f2148a47SJeff Kirsher 	struct tdesc0 tdesc0;
215f2148a47SJeff Kirsher 	struct tdesc1 tdesc1;
216f2148a47SJeff Kirsher 	struct td_buf td_buf[7];
217f2148a47SJeff Kirsher };
218f2148a47SJeff Kirsher 
219f2148a47SJeff Kirsher struct velocity_rd_info {
220f2148a47SJeff Kirsher 	struct sk_buff *skb;
221f2148a47SJeff Kirsher 	dma_addr_t skb_dma;
222f2148a47SJeff Kirsher };
223f2148a47SJeff Kirsher 
224f2148a47SJeff Kirsher /*
225f2148a47SJeff Kirsher  *	Used to track transmit side buffers.
226f2148a47SJeff Kirsher  */
227f2148a47SJeff Kirsher 
228f2148a47SJeff Kirsher struct velocity_td_info {
229f2148a47SJeff Kirsher 	struct sk_buff *skb;
230f2148a47SJeff Kirsher 	int nskb_dma;
231f2148a47SJeff Kirsher 	dma_addr_t skb_dma[7];
232f2148a47SJeff Kirsher };
233f2148a47SJeff Kirsher 
234f2148a47SJeff Kirsher enum  velocity_owner {
235f2148a47SJeff Kirsher 	OWNED_BY_HOST = 0,
236f2148a47SJeff Kirsher 	OWNED_BY_NIC = cpu_to_le16(0x8000)
237f2148a47SJeff Kirsher };
238f2148a47SJeff Kirsher 
239f2148a47SJeff Kirsher 
240f2148a47SJeff Kirsher /*
241f2148a47SJeff Kirsher  *	MAC registers and macros.
242f2148a47SJeff Kirsher  */
243f2148a47SJeff Kirsher 
244f2148a47SJeff Kirsher 
245f2148a47SJeff Kirsher #define MCAM_SIZE           64
246f2148a47SJeff Kirsher #define VCAM_SIZE           64
247f2148a47SJeff Kirsher #define TX_QUEUE_NO         4
248f2148a47SJeff Kirsher 
249f2148a47SJeff Kirsher #define MAX_HW_MIB_COUNTER  32
250f2148a47SJeff Kirsher #define VELOCITY_MIN_MTU    (64)
251f2148a47SJeff Kirsher #define VELOCITY_MAX_MTU    (9000)
252f2148a47SJeff Kirsher 
253f2148a47SJeff Kirsher /*
254f2148a47SJeff Kirsher  *	Registers in the MAC
255f2148a47SJeff Kirsher  */
256f2148a47SJeff Kirsher 
257f2148a47SJeff Kirsher #define MAC_REG_PAR         0x00	// physical address
258f2148a47SJeff Kirsher #define MAC_REG_RCR         0x06
259f2148a47SJeff Kirsher #define MAC_REG_TCR         0x07
260f2148a47SJeff Kirsher #define MAC_REG_CR0_SET     0x08
261f2148a47SJeff Kirsher #define MAC_REG_CR1_SET     0x09
262f2148a47SJeff Kirsher #define MAC_REG_CR2_SET     0x0A
263f2148a47SJeff Kirsher #define MAC_REG_CR3_SET     0x0B
264f2148a47SJeff Kirsher #define MAC_REG_CR0_CLR     0x0C
265f2148a47SJeff Kirsher #define MAC_REG_CR1_CLR     0x0D
266f2148a47SJeff Kirsher #define MAC_REG_CR2_CLR     0x0E
267f2148a47SJeff Kirsher #define MAC_REG_CR3_CLR     0x0F
268f2148a47SJeff Kirsher #define MAC_REG_MAR         0x10
269f2148a47SJeff Kirsher #define MAC_REG_CAM         0x10
270f2148a47SJeff Kirsher #define MAC_REG_DEC_BASE_HI 0x18
271f2148a47SJeff Kirsher #define MAC_REG_DBF_BASE_HI 0x1C
272f2148a47SJeff Kirsher #define MAC_REG_ISR_CTL     0x20
273f2148a47SJeff Kirsher #define MAC_REG_ISR_HOTMR   0x20
274f2148a47SJeff Kirsher #define MAC_REG_ISR_TSUPTHR 0x20
275f2148a47SJeff Kirsher #define MAC_REG_ISR_RSUPTHR 0x20
276f2148a47SJeff Kirsher #define MAC_REG_ISR_CTL1    0x21
277f2148a47SJeff Kirsher #define MAC_REG_TXE_SR      0x22
278f2148a47SJeff Kirsher #define MAC_REG_RXE_SR      0x23
279f2148a47SJeff Kirsher #define MAC_REG_ISR         0x24
280f2148a47SJeff Kirsher #define MAC_REG_ISR0        0x24
281f2148a47SJeff Kirsher #define MAC_REG_ISR1        0x25
282f2148a47SJeff Kirsher #define MAC_REG_ISR2        0x26
283f2148a47SJeff Kirsher #define MAC_REG_ISR3        0x27
284f2148a47SJeff Kirsher #define MAC_REG_IMR         0x28
285f2148a47SJeff Kirsher #define MAC_REG_IMR0        0x28
286f2148a47SJeff Kirsher #define MAC_REG_IMR1        0x29
287f2148a47SJeff Kirsher #define MAC_REG_IMR2        0x2A
288f2148a47SJeff Kirsher #define MAC_REG_IMR3        0x2B
289f2148a47SJeff Kirsher #define MAC_REG_TDCSR_SET   0x30
290f2148a47SJeff Kirsher #define MAC_REG_RDCSR_SET   0x32
291f2148a47SJeff Kirsher #define MAC_REG_TDCSR_CLR   0x34
292f2148a47SJeff Kirsher #define MAC_REG_RDCSR_CLR   0x36
293f2148a47SJeff Kirsher #define MAC_REG_RDBASE_LO   0x38
294f2148a47SJeff Kirsher #define MAC_REG_RDINDX      0x3C
295f2148a47SJeff Kirsher #define MAC_REG_TDBASE_LO   0x40
296f2148a47SJeff Kirsher #define MAC_REG_RDCSIZE     0x50
297f2148a47SJeff Kirsher #define MAC_REG_TDCSIZE     0x52
298f2148a47SJeff Kirsher #define MAC_REG_TDINDX      0x54
299f2148a47SJeff Kirsher #define MAC_REG_TDIDX0      0x54
300f2148a47SJeff Kirsher #define MAC_REG_TDIDX1      0x56
301f2148a47SJeff Kirsher #define MAC_REG_TDIDX2      0x58
302f2148a47SJeff Kirsher #define MAC_REG_TDIDX3      0x5A
303f2148a47SJeff Kirsher #define MAC_REG_PAUSE_TIMER 0x5C
304f2148a47SJeff Kirsher #define MAC_REG_RBRDU       0x5E
305f2148a47SJeff Kirsher #define MAC_REG_FIFO_TEST0  0x60
306f2148a47SJeff Kirsher #define MAC_REG_FIFO_TEST1  0x64
307f2148a47SJeff Kirsher #define MAC_REG_CAMADDR     0x68
308f2148a47SJeff Kirsher #define MAC_REG_CAMCR       0x69
309f2148a47SJeff Kirsher #define MAC_REG_GFTEST      0x6A
310f2148a47SJeff Kirsher #define MAC_REG_FTSTCMD     0x6B
311f2148a47SJeff Kirsher #define MAC_REG_MIICFG      0x6C
312f2148a47SJeff Kirsher #define MAC_REG_MIISR       0x6D
313f2148a47SJeff Kirsher #define MAC_REG_PHYSR0      0x6E
314f2148a47SJeff Kirsher #define MAC_REG_PHYSR1      0x6F
315f2148a47SJeff Kirsher #define MAC_REG_MIICR       0x70
316f2148a47SJeff Kirsher #define MAC_REG_MIIADR      0x71
317f2148a47SJeff Kirsher #define MAC_REG_MIIDATA     0x72
318f2148a47SJeff Kirsher #define MAC_REG_SOFT_TIMER0 0x74
319f2148a47SJeff Kirsher #define MAC_REG_SOFT_TIMER1 0x76
320f2148a47SJeff Kirsher #define MAC_REG_CFGA        0x78
321f2148a47SJeff Kirsher #define MAC_REG_CFGB        0x79
322f2148a47SJeff Kirsher #define MAC_REG_CFGC        0x7A
323f2148a47SJeff Kirsher #define MAC_REG_CFGD        0x7B
324f2148a47SJeff Kirsher #define MAC_REG_DCFG0       0x7C
325f2148a47SJeff Kirsher #define MAC_REG_DCFG1       0x7D
326f2148a47SJeff Kirsher #define MAC_REG_MCFG0       0x7E
327f2148a47SJeff Kirsher #define MAC_REG_MCFG1       0x7F
328f2148a47SJeff Kirsher 
329f2148a47SJeff Kirsher #define MAC_REG_TBIST       0x80
330f2148a47SJeff Kirsher #define MAC_REG_RBIST       0x81
331f2148a47SJeff Kirsher #define MAC_REG_PMCC        0x82
332f2148a47SJeff Kirsher #define MAC_REG_STICKHW     0x83
333f2148a47SJeff Kirsher #define MAC_REG_MIBCR       0x84
334f2148a47SJeff Kirsher #define MAC_REG_EERSV       0x85
335f2148a47SJeff Kirsher #define MAC_REG_REVID       0x86
336f2148a47SJeff Kirsher #define MAC_REG_MIBREAD     0x88
337f2148a47SJeff Kirsher #define MAC_REG_BPMA        0x8C
338f2148a47SJeff Kirsher #define MAC_REG_EEWR_DATA   0x8C
339f2148a47SJeff Kirsher #define MAC_REG_BPMD_WR     0x8F
340f2148a47SJeff Kirsher #define MAC_REG_BPCMD       0x90
341f2148a47SJeff Kirsher #define MAC_REG_BPMD_RD     0x91
342f2148a47SJeff Kirsher #define MAC_REG_EECHKSUM    0x92
343f2148a47SJeff Kirsher #define MAC_REG_EECSR       0x93
344f2148a47SJeff Kirsher #define MAC_REG_EERD_DATA   0x94
345f2148a47SJeff Kirsher #define MAC_REG_EADDR       0x96
346f2148a47SJeff Kirsher #define MAC_REG_EMBCMD      0x97
347f2148a47SJeff Kirsher #define MAC_REG_JMPSR0      0x98
348f2148a47SJeff Kirsher #define MAC_REG_JMPSR1      0x99
349f2148a47SJeff Kirsher #define MAC_REG_JMPSR2      0x9A
350f2148a47SJeff Kirsher #define MAC_REG_JMPSR3      0x9B
351f2148a47SJeff Kirsher #define MAC_REG_CHIPGSR     0x9C
352f2148a47SJeff Kirsher #define MAC_REG_TESTCFG     0x9D
353f2148a47SJeff Kirsher #define MAC_REG_DEBUG       0x9E
354f2148a47SJeff Kirsher #define MAC_REG_CHIPGCR     0x9F	/* Chip Operation and Diagnostic Control */
355f2148a47SJeff Kirsher #define MAC_REG_WOLCR0_SET  0xA0
356f2148a47SJeff Kirsher #define MAC_REG_WOLCR1_SET  0xA1
357f2148a47SJeff Kirsher #define MAC_REG_PWCFG_SET   0xA2
358f2148a47SJeff Kirsher #define MAC_REG_WOLCFG_SET  0xA3
359f2148a47SJeff Kirsher #define MAC_REG_WOLCR0_CLR  0xA4
360f2148a47SJeff Kirsher #define MAC_REG_WOLCR1_CLR  0xA5
361f2148a47SJeff Kirsher #define MAC_REG_PWCFG_CLR   0xA6
362f2148a47SJeff Kirsher #define MAC_REG_WOLCFG_CLR  0xA7
363f2148a47SJeff Kirsher #define MAC_REG_WOLSR0_SET  0xA8
364f2148a47SJeff Kirsher #define MAC_REG_WOLSR1_SET  0xA9
365f2148a47SJeff Kirsher #define MAC_REG_WOLSR0_CLR  0xAC
366f2148a47SJeff Kirsher #define MAC_REG_WOLSR1_CLR  0xAD
367f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC0  0xB0
368f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC1  0xB2
369f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC2  0xB4
370f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC3  0xB6
371f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC4  0xB8
372f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC5  0xBA
373f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC6  0xBC
374f2148a47SJeff Kirsher #define MAC_REG_PATRN_CRC7  0xBE
375f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK0_0  0xC0
376f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK0_1  0xC4
377f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK0_2  0xC8
378f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK0_3  0xCC
379f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK1_0  0xD0
380f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK1_1  0xD4
381f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK1_2  0xD8
382f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK1_3  0xDC
383f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK2_0  0xE0
384f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK2_1  0xE4
385f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK2_2  0xE8
386f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK2_3  0xEC
387f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK3_0  0xF0
388f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK3_1  0xF4
389f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK3_2  0xF8
390f2148a47SJeff Kirsher #define MAC_REG_BYTEMSK3_3  0xFC
391f2148a47SJeff Kirsher 
392f2148a47SJeff Kirsher /*
393f2148a47SJeff Kirsher  *	Bits in the RCR register
394f2148a47SJeff Kirsher  */
395f2148a47SJeff Kirsher 
396f2148a47SJeff Kirsher #define RCR_AS              0x80
397f2148a47SJeff Kirsher #define RCR_AP              0x40
398f2148a47SJeff Kirsher #define RCR_AL              0x20
399f2148a47SJeff Kirsher #define RCR_PROM            0x10
400f2148a47SJeff Kirsher #define RCR_AB              0x08
401f2148a47SJeff Kirsher #define RCR_AM              0x04
402f2148a47SJeff Kirsher #define RCR_AR              0x02
403f2148a47SJeff Kirsher #define RCR_SEP             0x01
404f2148a47SJeff Kirsher 
405f2148a47SJeff Kirsher /*
406f2148a47SJeff Kirsher  *	Bits in the TCR register
407f2148a47SJeff Kirsher  */
408f2148a47SJeff Kirsher 
409f2148a47SJeff Kirsher #define TCR_TB2BDIS         0x80
410f2148a47SJeff Kirsher #define TCR_COLTMC1         0x08
411f2148a47SJeff Kirsher #define TCR_COLTMC0         0x04
412f2148a47SJeff Kirsher #define TCR_LB1             0x02	/* loopback[1] */
413f2148a47SJeff Kirsher #define TCR_LB0             0x01	/* loopback[0] */
414f2148a47SJeff Kirsher 
415f2148a47SJeff Kirsher /*
416f2148a47SJeff Kirsher  *	Bits in the CR0 register
417f2148a47SJeff Kirsher  */
418f2148a47SJeff Kirsher 
419f2148a47SJeff Kirsher #define CR0_TXON            0x00000008UL
420f2148a47SJeff Kirsher #define CR0_RXON            0x00000004UL
421f2148a47SJeff Kirsher #define CR0_STOP            0x00000002UL	/* stop MAC, default = 1 */
422f2148a47SJeff Kirsher #define CR0_STRT            0x00000001UL	/* start MAC */
423f2148a47SJeff Kirsher #define CR0_SFRST           0x00008000UL	/* software reset */
424f2148a47SJeff Kirsher #define CR0_TM1EN           0x00004000UL
425f2148a47SJeff Kirsher #define CR0_TM0EN           0x00002000UL
426f2148a47SJeff Kirsher #define CR0_DPOLL           0x00000800UL	/* disable rx/tx auto polling */
427f2148a47SJeff Kirsher #define CR0_DISAU           0x00000100UL
428f2148a47SJeff Kirsher #define CR0_XONEN           0x00800000UL
429f2148a47SJeff Kirsher #define CR0_FDXTFCEN        0x00400000UL	/* full-duplex TX flow control enable */
430f2148a47SJeff Kirsher #define CR0_FDXRFCEN        0x00200000UL	/* full-duplex RX flow control enable */
431f2148a47SJeff Kirsher #define CR0_HDXFCEN         0x00100000UL	/* half-duplex flow control enable */
432f2148a47SJeff Kirsher #define CR0_XHITH1          0x00080000UL	/* TX XON high threshold 1 */
433f2148a47SJeff Kirsher #define CR0_XHITH0          0x00040000UL	/* TX XON high threshold 0 */
434f2148a47SJeff Kirsher #define CR0_XLTH1           0x00020000UL	/* TX pause frame low threshold 1 */
435f2148a47SJeff Kirsher #define CR0_XLTH0           0x00010000UL	/* TX pause frame low threshold 0 */
436f2148a47SJeff Kirsher #define CR0_GSPRST          0x80000000UL
437f2148a47SJeff Kirsher #define CR0_FORSRST         0x40000000UL
438f2148a47SJeff Kirsher #define CR0_FPHYRST         0x20000000UL
439f2148a47SJeff Kirsher #define CR0_DIAG            0x10000000UL
440f2148a47SJeff Kirsher #define CR0_INTPCTL         0x04000000UL
441f2148a47SJeff Kirsher #define CR0_GINTMSK1        0x02000000UL
442f2148a47SJeff Kirsher #define CR0_GINTMSK0        0x01000000UL
443f2148a47SJeff Kirsher 
444f2148a47SJeff Kirsher /*
445f2148a47SJeff Kirsher  *	Bits in the CR1 register
446f2148a47SJeff Kirsher  */
447f2148a47SJeff Kirsher 
448f2148a47SJeff Kirsher #define CR1_SFRST           0x80	/* software reset */
449f2148a47SJeff Kirsher #define CR1_TM1EN           0x40
450f2148a47SJeff Kirsher #define CR1_TM0EN           0x20
451f2148a47SJeff Kirsher #define CR1_DPOLL           0x08	/* disable rx/tx auto polling */
452f2148a47SJeff Kirsher #define CR1_DISAU           0x01
453f2148a47SJeff Kirsher 
454f2148a47SJeff Kirsher /*
455f2148a47SJeff Kirsher  *	Bits in the CR2 register
456f2148a47SJeff Kirsher  */
457f2148a47SJeff Kirsher 
458f2148a47SJeff Kirsher #define CR2_XONEN           0x80
459f2148a47SJeff Kirsher #define CR2_FDXTFCEN        0x40	/* full-duplex TX flow control enable */
460f2148a47SJeff Kirsher #define CR2_FDXRFCEN        0x20	/* full-duplex RX flow control enable */
461f2148a47SJeff Kirsher #define CR2_HDXFCEN         0x10	/* half-duplex flow control enable */
462f2148a47SJeff Kirsher #define CR2_XHITH1          0x08	/* TX XON high threshold 1 */
463f2148a47SJeff Kirsher #define CR2_XHITH0          0x04	/* TX XON high threshold 0 */
464f2148a47SJeff Kirsher #define CR2_XLTH1           0x02	/* TX pause frame low threshold 1 */
465f2148a47SJeff Kirsher #define CR2_XLTH0           0x01	/* TX pause frame low threshold 0 */
466f2148a47SJeff Kirsher 
467f2148a47SJeff Kirsher /*
468f2148a47SJeff Kirsher  *	Bits in the CR3 register
469f2148a47SJeff Kirsher  */
470f2148a47SJeff Kirsher 
471f2148a47SJeff Kirsher #define CR3_GSPRST          0x80
472f2148a47SJeff Kirsher #define CR3_FORSRST         0x40
473f2148a47SJeff Kirsher #define CR3_FPHYRST         0x20
474f2148a47SJeff Kirsher #define CR3_DIAG            0x10
475f2148a47SJeff Kirsher #define CR3_INTPCTL         0x04
476f2148a47SJeff Kirsher #define CR3_GINTMSK1        0x02
477f2148a47SJeff Kirsher #define CR3_GINTMSK0        0x01
478f2148a47SJeff Kirsher 
479f2148a47SJeff Kirsher #define ISRCTL_UDPINT       0x8000
480f2148a47SJeff Kirsher #define ISRCTL_TSUPDIS      0x4000
481f2148a47SJeff Kirsher #define ISRCTL_RSUPDIS      0x2000
482f2148a47SJeff Kirsher #define ISRCTL_PMSK1        0x1000
483f2148a47SJeff Kirsher #define ISRCTL_PMSK0        0x0800
484f2148a47SJeff Kirsher #define ISRCTL_INTPD        0x0400
485f2148a47SJeff Kirsher #define ISRCTL_HCRLD        0x0200
486f2148a47SJeff Kirsher #define ISRCTL_SCRLD        0x0100
487f2148a47SJeff Kirsher 
488f2148a47SJeff Kirsher /*
489f2148a47SJeff Kirsher  *	Bits in the ISR_CTL1 register
490f2148a47SJeff Kirsher  */
491f2148a47SJeff Kirsher 
492f2148a47SJeff Kirsher #define ISRCTL1_UDPINT      0x80
493f2148a47SJeff Kirsher #define ISRCTL1_TSUPDIS     0x40
494f2148a47SJeff Kirsher #define ISRCTL1_RSUPDIS     0x20
495f2148a47SJeff Kirsher #define ISRCTL1_PMSK1       0x10
496f2148a47SJeff Kirsher #define ISRCTL1_PMSK0       0x08
497f2148a47SJeff Kirsher #define ISRCTL1_INTPD       0x04
498f2148a47SJeff Kirsher #define ISRCTL1_HCRLD       0x02
499f2148a47SJeff Kirsher #define ISRCTL1_SCRLD       0x01
500f2148a47SJeff Kirsher 
501f2148a47SJeff Kirsher /*
502f2148a47SJeff Kirsher  *	Bits in the TXE_SR register
503f2148a47SJeff Kirsher  */
504f2148a47SJeff Kirsher 
505f2148a47SJeff Kirsher #define TXESR_TFDBS         0x08
506f2148a47SJeff Kirsher #define TXESR_TDWBS         0x04
507f2148a47SJeff Kirsher #define TXESR_TDRBS         0x02
508f2148a47SJeff Kirsher #define TXESR_TDSTR         0x01
509f2148a47SJeff Kirsher 
510f2148a47SJeff Kirsher /*
511f2148a47SJeff Kirsher  *	Bits in the RXE_SR register
512f2148a47SJeff Kirsher  */
513f2148a47SJeff Kirsher 
514f2148a47SJeff Kirsher #define RXESR_RFDBS         0x08
515f2148a47SJeff Kirsher #define RXESR_RDWBS         0x04
516f2148a47SJeff Kirsher #define RXESR_RDRBS         0x02
517f2148a47SJeff Kirsher #define RXESR_RDSTR         0x01
518f2148a47SJeff Kirsher 
519f2148a47SJeff Kirsher /*
520f2148a47SJeff Kirsher  *	Bits in the ISR register
521f2148a47SJeff Kirsher  */
522f2148a47SJeff Kirsher 
523f2148a47SJeff Kirsher #define ISR_ISR3            0x80000000UL
524f2148a47SJeff Kirsher #define ISR_ISR2            0x40000000UL
525f2148a47SJeff Kirsher #define ISR_ISR1            0x20000000UL
526f2148a47SJeff Kirsher #define ISR_ISR0            0x10000000UL
527f2148a47SJeff Kirsher #define ISR_TXSTLI          0x02000000UL
528f2148a47SJeff Kirsher #define ISR_RXSTLI          0x01000000UL
529f2148a47SJeff Kirsher #define ISR_HFLD            0x00800000UL
530f2148a47SJeff Kirsher #define ISR_UDPI            0x00400000UL
531f2148a47SJeff Kirsher #define ISR_MIBFI           0x00200000UL
532f2148a47SJeff Kirsher #define ISR_SHDNI           0x00100000UL
533f2148a47SJeff Kirsher #define ISR_PHYI            0x00080000UL
534f2148a47SJeff Kirsher #define ISR_PWEI            0x00040000UL
535f2148a47SJeff Kirsher #define ISR_TMR1I           0x00020000UL
536f2148a47SJeff Kirsher #define ISR_TMR0I           0x00010000UL
537f2148a47SJeff Kirsher #define ISR_SRCI            0x00008000UL
538f2148a47SJeff Kirsher #define ISR_LSTPEI          0x00004000UL
539f2148a47SJeff Kirsher #define ISR_LSTEI           0x00002000UL
540f2148a47SJeff Kirsher #define ISR_OVFI            0x00001000UL
541f2148a47SJeff Kirsher #define ISR_FLONI           0x00000800UL
542f2148a47SJeff Kirsher #define ISR_RACEI           0x00000400UL
543f2148a47SJeff Kirsher #define ISR_TXWB1I          0x00000200UL
544f2148a47SJeff Kirsher #define ISR_TXWB0I          0x00000100UL
545f2148a47SJeff Kirsher #define ISR_PTX3I           0x00000080UL
546f2148a47SJeff Kirsher #define ISR_PTX2I           0x00000040UL
547f2148a47SJeff Kirsher #define ISR_PTX1I           0x00000020UL
548f2148a47SJeff Kirsher #define ISR_PTX0I           0x00000010UL
549f2148a47SJeff Kirsher #define ISR_PTXI            0x00000008UL
550f2148a47SJeff Kirsher #define ISR_PRXI            0x00000004UL
551f2148a47SJeff Kirsher #define ISR_PPTXI           0x00000002UL
552f2148a47SJeff Kirsher #define ISR_PPRXI           0x00000001UL
553f2148a47SJeff Kirsher 
554f2148a47SJeff Kirsher /*
555f2148a47SJeff Kirsher  *	Bits in the IMR register
556f2148a47SJeff Kirsher  */
557f2148a47SJeff Kirsher 
558f2148a47SJeff Kirsher #define IMR_TXSTLM          0x02000000UL
559f2148a47SJeff Kirsher #define IMR_UDPIM           0x00400000UL
560f2148a47SJeff Kirsher #define IMR_MIBFIM          0x00200000UL
561f2148a47SJeff Kirsher #define IMR_SHDNIM          0x00100000UL
562f2148a47SJeff Kirsher #define IMR_PHYIM           0x00080000UL
563f2148a47SJeff Kirsher #define IMR_PWEIM           0x00040000UL
564f2148a47SJeff Kirsher #define IMR_TMR1IM          0x00020000UL
565f2148a47SJeff Kirsher #define IMR_TMR0IM          0x00010000UL
566f2148a47SJeff Kirsher 
567f2148a47SJeff Kirsher #define IMR_SRCIM           0x00008000UL
568f2148a47SJeff Kirsher #define IMR_LSTPEIM         0x00004000UL
569f2148a47SJeff Kirsher #define IMR_LSTEIM          0x00002000UL
570f2148a47SJeff Kirsher #define IMR_OVFIM           0x00001000UL
571f2148a47SJeff Kirsher #define IMR_FLONIM          0x00000800UL
572f2148a47SJeff Kirsher #define IMR_RACEIM          0x00000400UL
573f2148a47SJeff Kirsher #define IMR_TXWB1IM         0x00000200UL
574f2148a47SJeff Kirsher #define IMR_TXWB0IM         0x00000100UL
575f2148a47SJeff Kirsher 
576f2148a47SJeff Kirsher #define IMR_PTX3IM          0x00000080UL
577f2148a47SJeff Kirsher #define IMR_PTX2IM          0x00000040UL
578f2148a47SJeff Kirsher #define IMR_PTX1IM          0x00000020UL
579f2148a47SJeff Kirsher #define IMR_PTX0IM          0x00000010UL
580f2148a47SJeff Kirsher #define IMR_PTXIM           0x00000008UL
581f2148a47SJeff Kirsher #define IMR_PRXIM           0x00000004UL
582f2148a47SJeff Kirsher #define IMR_PPTXIM          0x00000002UL
583f2148a47SJeff Kirsher #define IMR_PPRXIM          0x00000001UL
584f2148a47SJeff Kirsher 
585f2148a47SJeff Kirsher /* 0x0013FB0FUL  =  initial value of IMR */
586f2148a47SJeff Kirsher 
587f2148a47SJeff Kirsher #define INT_MASK_DEF        (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\
588f2148a47SJeff Kirsher                             IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\
589f2148a47SJeff Kirsher                             IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\
590f2148a47SJeff Kirsher                             IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM)
591f2148a47SJeff Kirsher 
592f2148a47SJeff Kirsher /*
593f2148a47SJeff Kirsher  *	Bits in the TDCSR0/1, RDCSR0 register
594f2148a47SJeff Kirsher  */
595f2148a47SJeff Kirsher 
596f2148a47SJeff Kirsher #define TRDCSR_DEAD         0x0008
597f2148a47SJeff Kirsher #define TRDCSR_WAK          0x0004
598f2148a47SJeff Kirsher #define TRDCSR_ACT          0x0002
599f2148a47SJeff Kirsher #define TRDCSR_RUN	    0x0001
600f2148a47SJeff Kirsher 
601f2148a47SJeff Kirsher /*
602f2148a47SJeff Kirsher  *	Bits in the CAMADDR register
603f2148a47SJeff Kirsher  */
604f2148a47SJeff Kirsher 
605f2148a47SJeff Kirsher #define CAMADDR_CAMEN       0x80
606f2148a47SJeff Kirsher #define CAMADDR_VCAMSL      0x40
607f2148a47SJeff Kirsher 
608f2148a47SJeff Kirsher /*
609f2148a47SJeff Kirsher  *	Bits in the CAMCR register
610f2148a47SJeff Kirsher  */
611f2148a47SJeff Kirsher 
612f2148a47SJeff Kirsher #define CAMCR_PS1           0x80
613f2148a47SJeff Kirsher #define CAMCR_PS0           0x40
614f2148a47SJeff Kirsher #define CAMCR_AITRPKT       0x20
615f2148a47SJeff Kirsher #define CAMCR_AITR16        0x10
616f2148a47SJeff Kirsher #define CAMCR_CAMRD         0x08
617f2148a47SJeff Kirsher #define CAMCR_CAMWR         0x04
618f2148a47SJeff Kirsher #define CAMCR_PS_CAM_MASK   0x40
619f2148a47SJeff Kirsher #define CAMCR_PS_CAM_DATA   0x80
620f2148a47SJeff Kirsher #define CAMCR_PS_MAR        0x00
621f2148a47SJeff Kirsher 
622f2148a47SJeff Kirsher /*
623f2148a47SJeff Kirsher  *	Bits in the MIICFG register
624f2148a47SJeff Kirsher  */
625f2148a47SJeff Kirsher 
626f2148a47SJeff Kirsher #define MIICFG_MPO1         0x80
627f2148a47SJeff Kirsher #define MIICFG_MPO0         0x40
628f2148a47SJeff Kirsher #define MIICFG_MFDC         0x20
629f2148a47SJeff Kirsher 
630f2148a47SJeff Kirsher /*
631f2148a47SJeff Kirsher  *	Bits in the MIISR register
632f2148a47SJeff Kirsher  */
633f2148a47SJeff Kirsher 
634f2148a47SJeff Kirsher #define MIISR_MIDLE         0x80
635f2148a47SJeff Kirsher 
636f2148a47SJeff Kirsher /*
637f2148a47SJeff Kirsher  *	 Bits in the PHYSR0 register
638f2148a47SJeff Kirsher  */
639f2148a47SJeff Kirsher 
640f2148a47SJeff Kirsher #define PHYSR0_PHYRST       0x80
641f2148a47SJeff Kirsher #define PHYSR0_LINKGD       0x40
642f2148a47SJeff Kirsher #define PHYSR0_FDPX         0x10
643f2148a47SJeff Kirsher #define PHYSR0_SPDG         0x08
644f2148a47SJeff Kirsher #define PHYSR0_SPD10        0x04
645f2148a47SJeff Kirsher #define PHYSR0_RXFLC        0x02
646f2148a47SJeff Kirsher #define PHYSR0_TXFLC        0x01
647f2148a47SJeff Kirsher 
648f2148a47SJeff Kirsher /*
649f2148a47SJeff Kirsher  *	Bits in the PHYSR1 register
650f2148a47SJeff Kirsher  */
651f2148a47SJeff Kirsher 
652f2148a47SJeff Kirsher #define PHYSR1_PHYTBI       0x01
653f2148a47SJeff Kirsher 
654f2148a47SJeff Kirsher /*
655f2148a47SJeff Kirsher  *	Bits in the MIICR register
656f2148a47SJeff Kirsher  */
657f2148a47SJeff Kirsher 
658f2148a47SJeff Kirsher #define MIICR_MAUTO         0x80
659f2148a47SJeff Kirsher #define MIICR_RCMD          0x40
660f2148a47SJeff Kirsher #define MIICR_WCMD          0x20
661f2148a47SJeff Kirsher #define MIICR_MDPM          0x10
662f2148a47SJeff Kirsher #define MIICR_MOUT          0x08
663f2148a47SJeff Kirsher #define MIICR_MDO           0x04
664f2148a47SJeff Kirsher #define MIICR_MDI           0x02
665f2148a47SJeff Kirsher #define MIICR_MDC           0x01
666f2148a47SJeff Kirsher 
667f2148a47SJeff Kirsher /*
668f2148a47SJeff Kirsher  *	Bits in the MIIADR register
669f2148a47SJeff Kirsher  */
670f2148a47SJeff Kirsher 
671f2148a47SJeff Kirsher #define MIIADR_SWMPL        0x80
672f2148a47SJeff Kirsher 
673f2148a47SJeff Kirsher /*
674f2148a47SJeff Kirsher  *	Bits in the CFGA register
675f2148a47SJeff Kirsher  */
676f2148a47SJeff Kirsher 
677f2148a47SJeff Kirsher #define CFGA_PMHCTG         0x08
678f2148a47SJeff Kirsher #define CFGA_GPIO1PD        0x04
679f2148a47SJeff Kirsher #define CFGA_ABSHDN         0x02
680f2148a47SJeff Kirsher #define CFGA_PACPI          0x01
681f2148a47SJeff Kirsher 
682f2148a47SJeff Kirsher /*
683f2148a47SJeff Kirsher  *	Bits in the CFGB register
684f2148a47SJeff Kirsher  */
685f2148a47SJeff Kirsher 
686f2148a47SJeff Kirsher #define CFGB_GTCKOPT        0x80
687f2148a47SJeff Kirsher #define CFGB_MIIOPT         0x40
688f2148a47SJeff Kirsher #define CFGB_CRSEOPT        0x20
689f2148a47SJeff Kirsher #define CFGB_OFSET          0x10
690f2148a47SJeff Kirsher #define CFGB_CRANDOM        0x08
691f2148a47SJeff Kirsher #define CFGB_CAP            0x04
692f2148a47SJeff Kirsher #define CFGB_MBA            0x02
693f2148a47SJeff Kirsher #define CFGB_BAKOPT         0x01
694f2148a47SJeff Kirsher 
695f2148a47SJeff Kirsher /*
696f2148a47SJeff Kirsher  *	Bits in the CFGC register
697f2148a47SJeff Kirsher  */
698f2148a47SJeff Kirsher 
699f2148a47SJeff Kirsher #define CFGC_EELOAD         0x80
700f2148a47SJeff Kirsher #define CFGC_BROPT          0x40
701f2148a47SJeff Kirsher #define CFGC_DLYEN          0x20
702f2148a47SJeff Kirsher #define CFGC_DTSEL          0x10
703f2148a47SJeff Kirsher #define CFGC_BTSEL          0x08
704f2148a47SJeff Kirsher #define CFGC_BPS2           0x04	/* bootrom select[2] */
705f2148a47SJeff Kirsher #define CFGC_BPS1           0x02	/* bootrom select[1] */
706f2148a47SJeff Kirsher #define CFGC_BPS0           0x01	/* bootrom select[0] */
707f2148a47SJeff Kirsher 
708f2148a47SJeff Kirsher /*
709f2148a47SJeff Kirsher  * Bits in the CFGD register
710f2148a47SJeff Kirsher  */
711f2148a47SJeff Kirsher 
712f2148a47SJeff Kirsher #define CFGD_IODIS          0x80
713f2148a47SJeff Kirsher #define CFGD_MSLVDACEN      0x40
714f2148a47SJeff Kirsher #define CFGD_CFGDACEN       0x20
715f2148a47SJeff Kirsher #define CFGD_PCI64EN        0x10
716f2148a47SJeff Kirsher #define CFGD_HTMRL4         0x08
717f2148a47SJeff Kirsher 
718f2148a47SJeff Kirsher /*
719f2148a47SJeff Kirsher  *	Bits in the DCFG1 register
720f2148a47SJeff Kirsher  */
721f2148a47SJeff Kirsher 
722f2148a47SJeff Kirsher #define DCFG_XMWI           0x8000
723f2148a47SJeff Kirsher #define DCFG_XMRM           0x4000
724f2148a47SJeff Kirsher #define DCFG_XMRL           0x2000
725f2148a47SJeff Kirsher #define DCFG_PERDIS         0x1000
726f2148a47SJeff Kirsher #define DCFG_MRWAIT         0x0400
727f2148a47SJeff Kirsher #define DCFG_MWWAIT         0x0200
728f2148a47SJeff Kirsher #define DCFG_LATMEN         0x0100
729f2148a47SJeff Kirsher 
730f2148a47SJeff Kirsher /*
731f2148a47SJeff Kirsher  *	Bits in the MCFG0 register
732f2148a47SJeff Kirsher  */
733f2148a47SJeff Kirsher 
734f2148a47SJeff Kirsher #define MCFG_RXARB          0x0080
735f2148a47SJeff Kirsher #define MCFG_RFT1           0x0020
736f2148a47SJeff Kirsher #define MCFG_RFT0           0x0010
737f2148a47SJeff Kirsher #define MCFG_LOWTHOPT       0x0008
738f2148a47SJeff Kirsher #define MCFG_PQEN           0x0004
739f2148a47SJeff Kirsher #define MCFG_RTGOPT         0x0002
740f2148a47SJeff Kirsher #define MCFG_VIDFR          0x0001
741f2148a47SJeff Kirsher 
742f2148a47SJeff Kirsher /*
743f2148a47SJeff Kirsher  *	Bits in the MCFG1 register
744f2148a47SJeff Kirsher  */
745f2148a47SJeff Kirsher 
746f2148a47SJeff Kirsher #define MCFG_TXARB          0x8000
747f2148a47SJeff Kirsher #define MCFG_TXQBK1         0x0800
748f2148a47SJeff Kirsher #define MCFG_TXQBK0         0x0400
749f2148a47SJeff Kirsher #define MCFG_TXQNOBK        0x0200
750f2148a47SJeff Kirsher #define MCFG_SNAPOPT        0x0100
751f2148a47SJeff Kirsher 
752f2148a47SJeff Kirsher /*
753f2148a47SJeff Kirsher  *	Bits in the PMCC  register
754f2148a47SJeff Kirsher  */
755f2148a47SJeff Kirsher 
756f2148a47SJeff Kirsher #define PMCC_DSI            0x80
757f2148a47SJeff Kirsher #define PMCC_D2_DIS         0x40
758f2148a47SJeff Kirsher #define PMCC_D1_DIS         0x20
759f2148a47SJeff Kirsher #define PMCC_D3C_EN         0x10
760f2148a47SJeff Kirsher #define PMCC_D3H_EN         0x08
761f2148a47SJeff Kirsher #define PMCC_D2_EN          0x04
762f2148a47SJeff Kirsher #define PMCC_D1_EN          0x02
763f2148a47SJeff Kirsher #define PMCC_D0_EN          0x01
764f2148a47SJeff Kirsher 
765f2148a47SJeff Kirsher /*
766f2148a47SJeff Kirsher  *	Bits in STICKHW
767f2148a47SJeff Kirsher  */
768f2148a47SJeff Kirsher 
769f2148a47SJeff Kirsher #define STICKHW_SWPTAG      0x10
770f2148a47SJeff Kirsher #define STICKHW_WOLSR       0x08
771f2148a47SJeff Kirsher #define STICKHW_WOLEN       0x04
772f2148a47SJeff Kirsher #define STICKHW_DS1         0x02	/* R/W by software/cfg cycle */
773f2148a47SJeff Kirsher #define STICKHW_DS0         0x01	/* suspend well DS write port */
774f2148a47SJeff Kirsher 
775f2148a47SJeff Kirsher /*
776f2148a47SJeff Kirsher  *	Bits in the MIBCR register
777f2148a47SJeff Kirsher  */
778f2148a47SJeff Kirsher 
779f2148a47SJeff Kirsher #define MIBCR_MIBISTOK      0x80
780f2148a47SJeff Kirsher #define MIBCR_MIBISTGO      0x40
781f2148a47SJeff Kirsher #define MIBCR_MIBINC        0x20
782f2148a47SJeff Kirsher #define MIBCR_MIBHI         0x10
783f2148a47SJeff Kirsher #define MIBCR_MIBFRZ        0x08
784f2148a47SJeff Kirsher #define MIBCR_MIBFLSH       0x04
785f2148a47SJeff Kirsher #define MIBCR_MPTRINI       0x02
786f2148a47SJeff Kirsher #define MIBCR_MIBCLR        0x01
787f2148a47SJeff Kirsher 
788f2148a47SJeff Kirsher /*
789f2148a47SJeff Kirsher  *	Bits in the EERSV register
790f2148a47SJeff Kirsher  */
791f2148a47SJeff Kirsher 
792f2148a47SJeff Kirsher #define EERSV_BOOT_RPL      ((u8) 0x01)	 /* Boot method selection for VT6110 */
793f2148a47SJeff Kirsher 
794f2148a47SJeff Kirsher #define EERSV_BOOT_MASK     ((u8) 0x06)
795f2148a47SJeff Kirsher #define EERSV_BOOT_INT19    ((u8) 0x00)
796f2148a47SJeff Kirsher #define EERSV_BOOT_INT18    ((u8) 0x02)
797f2148a47SJeff Kirsher #define EERSV_BOOT_LOCAL    ((u8) 0x04)
798f2148a47SJeff Kirsher #define EERSV_BOOT_BEV      ((u8) 0x06)
799f2148a47SJeff Kirsher 
800f2148a47SJeff Kirsher 
801f2148a47SJeff Kirsher /*
802f2148a47SJeff Kirsher  *	Bits in BPCMD
803f2148a47SJeff Kirsher  */
804f2148a47SJeff Kirsher 
805f2148a47SJeff Kirsher #define BPCMD_BPDNE         0x80
806f2148a47SJeff Kirsher #define BPCMD_EBPWR         0x02
807f2148a47SJeff Kirsher #define BPCMD_EBPRD         0x01
808f2148a47SJeff Kirsher 
809f2148a47SJeff Kirsher /*
810f2148a47SJeff Kirsher  *	Bits in the EECSR register
811f2148a47SJeff Kirsher  */
812f2148a47SJeff Kirsher 
813f2148a47SJeff Kirsher #define EECSR_EMBP          0x40	/* eeprom embedded programming */
814f2148a47SJeff Kirsher #define EECSR_RELOAD        0x20	/* eeprom content reload */
815f2148a47SJeff Kirsher #define EECSR_DPM           0x10	/* eeprom direct programming */
816f2148a47SJeff Kirsher #define EECSR_ECS           0x08	/* eeprom CS pin */
817f2148a47SJeff Kirsher #define EECSR_ECK           0x04	/* eeprom CK pin */
818f2148a47SJeff Kirsher #define EECSR_EDI           0x02	/* eeprom DI pin */
819f2148a47SJeff Kirsher #define EECSR_EDO           0x01	/* eeprom DO pin */
820f2148a47SJeff Kirsher 
821f2148a47SJeff Kirsher /*
822f2148a47SJeff Kirsher  *	Bits in the EMBCMD register
823f2148a47SJeff Kirsher  */
824f2148a47SJeff Kirsher 
825f2148a47SJeff Kirsher #define EMBCMD_EDONE        0x80
826f2148a47SJeff Kirsher #define EMBCMD_EWDIS        0x08
827f2148a47SJeff Kirsher #define EMBCMD_EWEN         0x04
828f2148a47SJeff Kirsher #define EMBCMD_EWR          0x02
829f2148a47SJeff Kirsher #define EMBCMD_ERD          0x01
830f2148a47SJeff Kirsher 
831f2148a47SJeff Kirsher /*
832f2148a47SJeff Kirsher  *	Bits in TESTCFG register
833f2148a47SJeff Kirsher  */
834f2148a47SJeff Kirsher 
835f2148a47SJeff Kirsher #define TESTCFG_HBDIS       0x80
836f2148a47SJeff Kirsher 
837f2148a47SJeff Kirsher /*
838f2148a47SJeff Kirsher  *	Bits in CHIPGCR register
839f2148a47SJeff Kirsher  */
840f2148a47SJeff Kirsher 
841f2148a47SJeff Kirsher #define CHIPGCR_FCGMII      0x80	/* force GMII (else MII only) */
842f2148a47SJeff Kirsher #define CHIPGCR_FCFDX       0x40	/* force full duplex */
843f2148a47SJeff Kirsher #define CHIPGCR_FCRESV      0x20
844f2148a47SJeff Kirsher #define CHIPGCR_FCMODE      0x10	/* enable MAC forced mode */
845f2148a47SJeff Kirsher #define CHIPGCR_LPSOPT      0x08
846f2148a47SJeff Kirsher #define CHIPGCR_TM1US       0x04
847f2148a47SJeff Kirsher #define CHIPGCR_TM0US       0x02
848f2148a47SJeff Kirsher #define CHIPGCR_PHYINTEN    0x01
849f2148a47SJeff Kirsher 
850f2148a47SJeff Kirsher /*
851f2148a47SJeff Kirsher  *	Bits in WOLCR0
852f2148a47SJeff Kirsher  */
853f2148a47SJeff Kirsher 
854f2148a47SJeff Kirsher #define WOLCR_MSWOLEN7      0x0080	/* enable pattern match filtering */
855f2148a47SJeff Kirsher #define WOLCR_MSWOLEN6      0x0040
856f2148a47SJeff Kirsher #define WOLCR_MSWOLEN5      0x0020
857f2148a47SJeff Kirsher #define WOLCR_MSWOLEN4      0x0010
858f2148a47SJeff Kirsher #define WOLCR_MSWOLEN3      0x0008
859f2148a47SJeff Kirsher #define WOLCR_MSWOLEN2      0x0004
860f2148a47SJeff Kirsher #define WOLCR_MSWOLEN1      0x0002
861f2148a47SJeff Kirsher #define WOLCR_MSWOLEN0      0x0001
862f2148a47SJeff Kirsher #define WOLCR_ARP_EN        0x0001
863f2148a47SJeff Kirsher 
864f2148a47SJeff Kirsher /*
865f2148a47SJeff Kirsher  *	Bits in WOLCR1
866f2148a47SJeff Kirsher  */
867f2148a47SJeff Kirsher 
868f2148a47SJeff Kirsher #define WOLCR_LINKOFF_EN      0x0800	/* link off detected enable */
869f2148a47SJeff Kirsher #define WOLCR_LINKON_EN       0x0400	/* link on detected enable */
870f2148a47SJeff Kirsher #define WOLCR_MAGIC_EN        0x0200	/* magic packet filter enable */
871f2148a47SJeff Kirsher #define WOLCR_UNICAST_EN      0x0100	/* unicast filter enable */
872f2148a47SJeff Kirsher 
873f2148a47SJeff Kirsher 
874f2148a47SJeff Kirsher /*
875f2148a47SJeff Kirsher  *	Bits in PWCFG
876f2148a47SJeff Kirsher  */
877f2148a47SJeff Kirsher 
878f2148a47SJeff Kirsher #define PWCFG_PHYPWOPT          0x80	/* internal MII I/F timing */
879f2148a47SJeff Kirsher #define PWCFG_PCISTICK          0x40	/* PCI sticky R/W enable */
880f2148a47SJeff Kirsher #define PWCFG_WOLTYPE           0x20	/* pulse(1) or button (0) */
881f2148a47SJeff Kirsher #define PWCFG_LEGCY_WOL         0x10
882f2148a47SJeff Kirsher #define PWCFG_PMCSR_PME_SR      0x08
883f2148a47SJeff Kirsher #define PWCFG_PMCSR_PME_EN      0x04	/* control by PCISTICK */
884f2148a47SJeff Kirsher #define PWCFG_LEGACY_WOLSR      0x02	/* Legacy WOL_SR shadow */
885f2148a47SJeff Kirsher #define PWCFG_LEGACY_WOLEN      0x01	/* Legacy WOL_EN shadow */
886f2148a47SJeff Kirsher 
887f2148a47SJeff Kirsher /*
888f2148a47SJeff Kirsher  *	Bits in WOLCFG
889f2148a47SJeff Kirsher  */
890f2148a47SJeff Kirsher 
891f2148a47SJeff Kirsher #define WOLCFG_PMEOVR           0x80	/* for legacy use, force PMEEN always */
892f2148a47SJeff Kirsher #define WOLCFG_SAM              0x20	/* accept multicast case reset, default=0 */
893f2148a47SJeff Kirsher #define WOLCFG_SAB              0x10	/* accept broadcast case reset, default=0 */
894f2148a47SJeff Kirsher #define WOLCFG_SMIIACC          0x08	/* ?? */
895f2148a47SJeff Kirsher #define WOLCFG_SGENWH           0x02
896f2148a47SJeff Kirsher #define WOLCFG_PHYINTEN         0x01	/* 0:PHYINT trigger enable, 1:use internal MII
897f2148a47SJeff Kirsher 					  to report status change */
898f2148a47SJeff Kirsher /*
899f2148a47SJeff Kirsher  *	Bits in WOLSR1
900f2148a47SJeff Kirsher  */
901f2148a47SJeff Kirsher 
902f2148a47SJeff Kirsher #define WOLSR_LINKOFF_INT      0x0800
903f2148a47SJeff Kirsher #define WOLSR_LINKON_INT       0x0400
904f2148a47SJeff Kirsher #define WOLSR_MAGIC_INT        0x0200
905f2148a47SJeff Kirsher #define WOLSR_UNICAST_INT      0x0100
906f2148a47SJeff Kirsher 
907f2148a47SJeff Kirsher /*
908f2148a47SJeff Kirsher  *	Ethernet address filter type
909f2148a47SJeff Kirsher  */
910f2148a47SJeff Kirsher 
911f2148a47SJeff Kirsher #define PKT_TYPE_NONE               0x0000	/* Turn off receiver */
912f2148a47SJeff Kirsher #define PKT_TYPE_DIRECTED           0x0001	/* obselete, directed address is always accepted */
913f2148a47SJeff Kirsher #define PKT_TYPE_MULTICAST          0x0002
914f2148a47SJeff Kirsher #define PKT_TYPE_ALL_MULTICAST      0x0004
915f2148a47SJeff Kirsher #define PKT_TYPE_BROADCAST          0x0008
916f2148a47SJeff Kirsher #define PKT_TYPE_PROMISCUOUS        0x0020
917f2148a47SJeff Kirsher #define PKT_TYPE_LONG               0x2000	/* NOTE.... the definition of LONG is >2048 bytes in our chip */
918f2148a47SJeff Kirsher #define PKT_TYPE_RUNT               0x4000
919f2148a47SJeff Kirsher #define PKT_TYPE_ERROR              0x8000	/* Accept error packets, e.g. CRC error */
920f2148a47SJeff Kirsher 
921f2148a47SJeff Kirsher /*
922f2148a47SJeff Kirsher  *	Loopback mode
923f2148a47SJeff Kirsher  */
924f2148a47SJeff Kirsher 
925f2148a47SJeff Kirsher #define MAC_LB_NONE         0x00
926f2148a47SJeff Kirsher #define MAC_LB_INTERNAL     0x01
927f2148a47SJeff Kirsher #define MAC_LB_EXTERNAL     0x02
928f2148a47SJeff Kirsher 
929f2148a47SJeff Kirsher /*
930f2148a47SJeff Kirsher  *	Enabled mask value of irq
931f2148a47SJeff Kirsher  */
932f2148a47SJeff Kirsher 
933f2148a47SJeff Kirsher #if defined(_SIM)
934f2148a47SJeff Kirsher #define IMR_MASK_VALUE      0x0033FF0FUL	/* initial value of IMR
935f2148a47SJeff Kirsher 						   set IMR0 to 0x0F according to spec */
936f2148a47SJeff Kirsher 
937f2148a47SJeff Kirsher #else
938f2148a47SJeff Kirsher #define IMR_MASK_VALUE      0x0013FB0FUL	/* initial value of IMR
939f2148a47SJeff Kirsher 						   ignore MIBFI,RACEI to
940f2148a47SJeff Kirsher 						   reduce intr. frequency
9411377a5b2SJilin Yuan 						   NOTE.... do not enable NoBuf int mask at driver
942f2148a47SJeff Kirsher 						      when (1) NoBuf -> RxThreshold = SF
943f2148a47SJeff Kirsher 							   (2) OK    -> RxThreshold = original value
944f2148a47SJeff Kirsher 						 */
945f2148a47SJeff Kirsher #endif
946f2148a47SJeff Kirsher 
947f2148a47SJeff Kirsher /*
948f2148a47SJeff Kirsher  *	Revision id
949f2148a47SJeff Kirsher  */
950f2148a47SJeff Kirsher 
951f2148a47SJeff Kirsher #define REV_ID_VT3119_A0	0x00
952f2148a47SJeff Kirsher #define REV_ID_VT3119_A1	0x01
953f2148a47SJeff Kirsher #define REV_ID_VT3216_A0	0x10
954f2148a47SJeff Kirsher 
955f2148a47SJeff Kirsher /*
956f2148a47SJeff Kirsher  *	Max time out delay time
957f2148a47SJeff Kirsher  */
958f2148a47SJeff Kirsher 
959f2148a47SJeff Kirsher #define W_MAX_TIMEOUT       0x0FFFU
960f2148a47SJeff Kirsher 
961f2148a47SJeff Kirsher 
962f2148a47SJeff Kirsher /*
963f2148a47SJeff Kirsher  *	MAC registers as a structure. Cannot be directly accessed this
964f2148a47SJeff Kirsher  *	way but generates offsets for readl/writel() calls
965f2148a47SJeff Kirsher  */
966f2148a47SJeff Kirsher 
967f2148a47SJeff Kirsher struct mac_regs {
968f2148a47SJeff Kirsher 	volatile u8 PAR[6];		/* 0x00 */
969f2148a47SJeff Kirsher 	volatile u8 RCR;
970f2148a47SJeff Kirsher 	volatile u8 TCR;
971f2148a47SJeff Kirsher 
972f2148a47SJeff Kirsher 	volatile __le32 CR0Set;		/* 0x08 */
973f2148a47SJeff Kirsher 	volatile __le32 CR0Clr;		/* 0x0C */
974f2148a47SJeff Kirsher 
975f2148a47SJeff Kirsher 	volatile u8 MARCAM[8];		/* 0x10 */
976f2148a47SJeff Kirsher 
977f2148a47SJeff Kirsher 	volatile __le32 DecBaseHi;	/* 0x18 */
978f2148a47SJeff Kirsher 	volatile __le16 DbfBaseHi;	/* 0x1C */
979f2148a47SJeff Kirsher 	volatile __le16 reserved_1E;
980f2148a47SJeff Kirsher 
981f2148a47SJeff Kirsher 	volatile __le16 ISRCTL;		/* 0x20 */
982f2148a47SJeff Kirsher 	volatile u8 TXESR;
983f2148a47SJeff Kirsher 	volatile u8 RXESR;
984f2148a47SJeff Kirsher 
985f2148a47SJeff Kirsher 	volatile __le32 ISR;		/* 0x24 */
986f2148a47SJeff Kirsher 	volatile __le32 IMR;
987f2148a47SJeff Kirsher 
988f2148a47SJeff Kirsher 	volatile __le32 TDStatusPort;	/* 0x2C */
989f2148a47SJeff Kirsher 
990f2148a47SJeff Kirsher 	volatile __le16 TDCSRSet;	/* 0x30 */
991f2148a47SJeff Kirsher 	volatile u8 RDCSRSet;
992f2148a47SJeff Kirsher 	volatile u8 reserved_33;
993f2148a47SJeff Kirsher 	volatile __le16 TDCSRClr;
994f2148a47SJeff Kirsher 	volatile u8 RDCSRClr;
995f2148a47SJeff Kirsher 	volatile u8 reserved_37;
996f2148a47SJeff Kirsher 
997f2148a47SJeff Kirsher 	volatile __le32 RDBaseLo;	/* 0x38 */
998f2148a47SJeff Kirsher 	volatile __le16 RDIdx;		/* 0x3C */
999f2148a47SJeff Kirsher 	volatile u8 TQETMR;		/* 0x3E, VT3216 and above only */
1000f2148a47SJeff Kirsher 	volatile u8 RQETMR;		/* 0x3F, VT3216 and above only */
1001f2148a47SJeff Kirsher 
1002f2148a47SJeff Kirsher 	volatile __le32 TDBaseLo[4];	/* 0x40 */
1003f2148a47SJeff Kirsher 
1004f2148a47SJeff Kirsher 	volatile __le16 RDCSize;	/* 0x50 */
1005f2148a47SJeff Kirsher 	volatile __le16 TDCSize;	/* 0x52 */
1006f2148a47SJeff Kirsher 	volatile __le16 TDIdx[4];	/* 0x54 */
1007f2148a47SJeff Kirsher 	volatile __le16 tx_pause_timer;	/* 0x5C */
1008f2148a47SJeff Kirsher 	volatile __le16 RBRDU;		/* 0x5E */
1009f2148a47SJeff Kirsher 
1010f2148a47SJeff Kirsher 	volatile __le32 FIFOTest0;	/* 0x60 */
1011f2148a47SJeff Kirsher 	volatile __le32 FIFOTest1;	/* 0x64 */
1012f2148a47SJeff Kirsher 
1013f2148a47SJeff Kirsher 	volatile u8 CAMADDR;		/* 0x68 */
1014f2148a47SJeff Kirsher 	volatile u8 CAMCR;		/* 0x69 */
1015f2148a47SJeff Kirsher 	volatile u8 GFTEST;		/* 0x6A */
1016f2148a47SJeff Kirsher 	volatile u8 FTSTCMD;		/* 0x6B */
1017f2148a47SJeff Kirsher 
1018f2148a47SJeff Kirsher 	volatile u8 MIICFG;		/* 0x6C */
1019f2148a47SJeff Kirsher 	volatile u8 MIISR;
1020f2148a47SJeff Kirsher 	volatile u8 PHYSR0;
1021f2148a47SJeff Kirsher 	volatile u8 PHYSR1;
1022f2148a47SJeff Kirsher 	volatile u8 MIICR;
1023f2148a47SJeff Kirsher 	volatile u8 MIIADR;
1024f2148a47SJeff Kirsher 	volatile __le16 MIIDATA;
1025f2148a47SJeff Kirsher 
1026f2148a47SJeff Kirsher 	volatile __le16 SoftTimer0;	/* 0x74 */
1027f2148a47SJeff Kirsher 	volatile __le16 SoftTimer1;
1028f2148a47SJeff Kirsher 
1029f2148a47SJeff Kirsher 	volatile u8 CFGA;		/* 0x78 */
1030f2148a47SJeff Kirsher 	volatile u8 CFGB;
1031f2148a47SJeff Kirsher 	volatile u8 CFGC;
1032f2148a47SJeff Kirsher 	volatile u8 CFGD;
1033f2148a47SJeff Kirsher 
1034f2148a47SJeff Kirsher 	volatile __le16 DCFG;		/* 0x7C */
1035f2148a47SJeff Kirsher 	volatile __le16 MCFG;
1036f2148a47SJeff Kirsher 
1037f2148a47SJeff Kirsher 	volatile u8 TBIST;		/* 0x80 */
1038f2148a47SJeff Kirsher 	volatile u8 RBIST;
1039f2148a47SJeff Kirsher 	volatile u8 PMCPORT;
1040f2148a47SJeff Kirsher 	volatile u8 STICKHW;
1041f2148a47SJeff Kirsher 
1042f2148a47SJeff Kirsher 	volatile u8 MIBCR;		/* 0x84 */
1043f2148a47SJeff Kirsher 	volatile u8 reserved_85;
1044f2148a47SJeff Kirsher 	volatile u8 rev_id;
1045f2148a47SJeff Kirsher 	volatile u8 PORSTS;
1046f2148a47SJeff Kirsher 
1047f2148a47SJeff Kirsher 	volatile __le32 MIBData;	/* 0x88 */
1048f2148a47SJeff Kirsher 
1049f2148a47SJeff Kirsher 	volatile __le16 EEWrData;
1050f2148a47SJeff Kirsher 
1051f2148a47SJeff Kirsher 	volatile u8 reserved_8E;
1052f2148a47SJeff Kirsher 	volatile u8 BPMDWr;
1053f2148a47SJeff Kirsher 	volatile u8 BPCMD;
1054f2148a47SJeff Kirsher 	volatile u8 BPMDRd;
1055f2148a47SJeff Kirsher 
1056f2148a47SJeff Kirsher 	volatile u8 EECHKSUM;		/* 0x92 */
1057f2148a47SJeff Kirsher 	volatile u8 EECSR;
1058f2148a47SJeff Kirsher 
1059f2148a47SJeff Kirsher 	volatile __le16 EERdData;	/* 0x94 */
1060f2148a47SJeff Kirsher 	volatile u8 EADDR;
1061f2148a47SJeff Kirsher 	volatile u8 EMBCMD;
1062f2148a47SJeff Kirsher 
1063f2148a47SJeff Kirsher 
1064f2148a47SJeff Kirsher 	volatile u8 JMPSR0;		/* 0x98 */
1065f2148a47SJeff Kirsher 	volatile u8 JMPSR1;
1066f2148a47SJeff Kirsher 	volatile u8 JMPSR2;
1067f2148a47SJeff Kirsher 	volatile u8 JMPSR3;
1068f2148a47SJeff Kirsher 	volatile u8 CHIPGSR;		/* 0x9C */
1069f2148a47SJeff Kirsher 	volatile u8 TESTCFG;
1070f2148a47SJeff Kirsher 	volatile u8 DEBUG;
1071f2148a47SJeff Kirsher 	volatile u8 CHIPGCR;
1072f2148a47SJeff Kirsher 
1073f2148a47SJeff Kirsher 	volatile __le16 WOLCRSet;	/* 0xA0 */
1074f2148a47SJeff Kirsher 	volatile u8 PWCFGSet;
1075f2148a47SJeff Kirsher 	volatile u8 WOLCFGSet;
1076f2148a47SJeff Kirsher 
1077f2148a47SJeff Kirsher 	volatile __le16 WOLCRClr;	/* 0xA4 */
1078f2148a47SJeff Kirsher 	volatile u8 PWCFGCLR;
1079f2148a47SJeff Kirsher 	volatile u8 WOLCFGClr;
1080f2148a47SJeff Kirsher 
1081f2148a47SJeff Kirsher 	volatile __le16 WOLSRSet;	/* 0xA8 */
1082f2148a47SJeff Kirsher 	volatile __le16 reserved_AA;
1083f2148a47SJeff Kirsher 
1084f2148a47SJeff Kirsher 	volatile __le16 WOLSRClr;	/* 0xAC */
1085f2148a47SJeff Kirsher 	volatile __le16 reserved_AE;
1086f2148a47SJeff Kirsher 
1087f2148a47SJeff Kirsher 	volatile __le16 PatternCRC[8];	/* 0xB0 */
1088f2148a47SJeff Kirsher 	volatile __le32 ByteMask[4][4];	/* 0xC0 */
1089f2148a47SJeff Kirsher };
1090f2148a47SJeff Kirsher 
1091f2148a47SJeff Kirsher 
1092f2148a47SJeff Kirsher enum hw_mib {
1093f2148a47SJeff Kirsher 	HW_MIB_ifRxAllPkts = 0,
1094f2148a47SJeff Kirsher 	HW_MIB_ifRxOkPkts,
1095f2148a47SJeff Kirsher 	HW_MIB_ifTxOkPkts,
1096f2148a47SJeff Kirsher 	HW_MIB_ifRxErrorPkts,
1097f2148a47SJeff Kirsher 	HW_MIB_ifRxRuntOkPkt,
1098f2148a47SJeff Kirsher 	HW_MIB_ifRxRuntErrPkt,
1099f2148a47SJeff Kirsher 	HW_MIB_ifRx64Pkts,
1100f2148a47SJeff Kirsher 	HW_MIB_ifTx64Pkts,
1101f2148a47SJeff Kirsher 	HW_MIB_ifRx65To127Pkts,
1102f2148a47SJeff Kirsher 	HW_MIB_ifTx65To127Pkts,
1103f2148a47SJeff Kirsher 	HW_MIB_ifRx128To255Pkts,
1104f2148a47SJeff Kirsher 	HW_MIB_ifTx128To255Pkts,
1105f2148a47SJeff Kirsher 	HW_MIB_ifRx256To511Pkts,
1106f2148a47SJeff Kirsher 	HW_MIB_ifTx256To511Pkts,
1107f2148a47SJeff Kirsher 	HW_MIB_ifRx512To1023Pkts,
1108f2148a47SJeff Kirsher 	HW_MIB_ifTx512To1023Pkts,
1109f2148a47SJeff Kirsher 	HW_MIB_ifRx1024To1518Pkts,
1110f2148a47SJeff Kirsher 	HW_MIB_ifTx1024To1518Pkts,
1111f2148a47SJeff Kirsher 	HW_MIB_ifTxEtherCollisions,
1112f2148a47SJeff Kirsher 	HW_MIB_ifRxPktCRCE,
1113f2148a47SJeff Kirsher 	HW_MIB_ifRxJumboPkts,
1114f2148a47SJeff Kirsher 	HW_MIB_ifTxJumboPkts,
1115f2148a47SJeff Kirsher 	HW_MIB_ifRxMacControlFrames,
1116f2148a47SJeff Kirsher 	HW_MIB_ifTxMacControlFrames,
1117f2148a47SJeff Kirsher 	HW_MIB_ifRxPktFAE,
1118f2148a47SJeff Kirsher 	HW_MIB_ifRxLongOkPkt,
1119f2148a47SJeff Kirsher 	HW_MIB_ifRxLongPktErrPkt,
1120f2148a47SJeff Kirsher 	HW_MIB_ifTXSQEErrors,
1121f2148a47SJeff Kirsher 	HW_MIB_ifRxNobuf,
1122f2148a47SJeff Kirsher 	HW_MIB_ifRxSymbolErrors,
1123f2148a47SJeff Kirsher 	HW_MIB_ifInRangeLengthErrors,
1124f2148a47SJeff Kirsher 	HW_MIB_ifLateCollisions,
1125f2148a47SJeff Kirsher 	HW_MIB_SIZE
1126f2148a47SJeff Kirsher };
1127f2148a47SJeff Kirsher 
1128f2148a47SJeff Kirsher enum chip_type {
1129f2148a47SJeff Kirsher 	CHIP_TYPE_VT6110 = 1,
1130f2148a47SJeff Kirsher };
1131f2148a47SJeff Kirsher 
1132f2148a47SJeff Kirsher struct velocity_info_tbl {
1133f2148a47SJeff Kirsher 	enum chip_type chip_id;
1134f2148a47SJeff Kirsher 	const char *name;
1135f2148a47SJeff Kirsher 	int txqueue;
1136f2148a47SJeff Kirsher 	u32 flags;
1137f2148a47SJeff Kirsher };
1138f2148a47SJeff Kirsher 
1139f2148a47SJeff Kirsher #define mac_hw_mibs_init(regs) {\
1140f2148a47SJeff Kirsher 	BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1141f2148a47SJeff Kirsher 	BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\
1142f2148a47SJeff Kirsher 	do {}\
1143f2148a47SJeff Kirsher 		while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\
1144f2148a47SJeff Kirsher 	BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\
1145f2148a47SJeff Kirsher }
1146f2148a47SJeff Kirsher 
1147f2148a47SJeff Kirsher #define mac_read_isr(regs)  		readl(&((regs)->ISR))
1148f2148a47SJeff Kirsher #define mac_write_isr(regs, x)  	writel((x),&((regs)->ISR))
1149f2148a47SJeff Kirsher #define mac_clear_isr(regs) 		writel(0xffffffffL,&((regs)->ISR))
1150f2148a47SJeff Kirsher 
1151f2148a47SJeff Kirsher #define mac_write_int_mask(mask, regs) 	writel((mask),&((regs)->IMR));
1152f2148a47SJeff Kirsher #define mac_disable_int(regs)       	writel(CR0_GINTMSK1,&((regs)->CR0Clr))
1153f2148a47SJeff Kirsher #define mac_enable_int(regs)    	writel(CR0_GINTMSK1,&((regs)->CR0Set))
1154f2148a47SJeff Kirsher 
1155f2148a47SJeff Kirsher #define mac_set_dma_length(regs, n) {\
1156f2148a47SJeff Kirsher 	BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\
1157f2148a47SJeff Kirsher }
1158f2148a47SJeff Kirsher 
1159f2148a47SJeff Kirsher #define mac_set_rx_thresh(regs, n) {\
1160f2148a47SJeff Kirsher 	BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\
1161f2148a47SJeff Kirsher }
1162f2148a47SJeff Kirsher 
1163f2148a47SJeff Kirsher #define mac_rx_queue_run(regs) {\
1164f2148a47SJeff Kirsher 	writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\
1165f2148a47SJeff Kirsher }
1166f2148a47SJeff Kirsher 
1167f2148a47SJeff Kirsher #define mac_rx_queue_wake(regs) {\
1168f2148a47SJeff Kirsher 	writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\
1169f2148a47SJeff Kirsher }
1170f2148a47SJeff Kirsher 
1171f2148a47SJeff Kirsher #define mac_tx_queue_run(regs, n) {\
1172f2148a47SJeff Kirsher 	writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\
1173f2148a47SJeff Kirsher }
1174f2148a47SJeff Kirsher 
1175f2148a47SJeff Kirsher #define mac_tx_queue_wake(regs, n) {\
1176f2148a47SJeff Kirsher 	writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\
1177f2148a47SJeff Kirsher }
1178f2148a47SJeff Kirsher 
mac_eeprom_reload(struct mac_regs __iomem * regs)1179f2148a47SJeff Kirsher static inline void mac_eeprom_reload(struct mac_regs __iomem * regs) {
1180f2148a47SJeff Kirsher 	int i=0;
1181f2148a47SJeff Kirsher 
1182f2148a47SJeff Kirsher 	BYTE_REG_BITS_ON(EECSR_RELOAD,&(regs->EECSR));
1183f2148a47SJeff Kirsher 	do {
1184f2148a47SJeff Kirsher 		udelay(10);
1185f2148a47SJeff Kirsher 		if (i++>0x1000)
1186f2148a47SJeff Kirsher 			break;
1187f2148a47SJeff Kirsher 	} while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&(regs->EECSR)));
1188f2148a47SJeff Kirsher }
1189f2148a47SJeff Kirsher 
1190f2148a47SJeff Kirsher /*
1191f2148a47SJeff Kirsher  * Header for WOL definitions. Used to compute hashes
1192f2148a47SJeff Kirsher  */
1193f2148a47SJeff Kirsher 
1194f2148a47SJeff Kirsher typedef u8 MCAM_ADDR[ETH_ALEN];
1195f2148a47SJeff Kirsher 
1196f2148a47SJeff Kirsher struct arp_packet {
1197f2148a47SJeff Kirsher 	u8 dest_mac[ETH_ALEN];
1198f2148a47SJeff Kirsher 	u8 src_mac[ETH_ALEN];
1199f2148a47SJeff Kirsher 	__be16 type;
1200f2148a47SJeff Kirsher 	__be16 ar_hrd;
1201f2148a47SJeff Kirsher 	__be16 ar_pro;
1202f2148a47SJeff Kirsher 	u8 ar_hln;
1203f2148a47SJeff Kirsher 	u8 ar_pln;
1204f2148a47SJeff Kirsher 	__be16 ar_op;
1205f2148a47SJeff Kirsher 	u8 ar_sha[ETH_ALEN];
1206f2148a47SJeff Kirsher 	u8 ar_sip[4];
1207f2148a47SJeff Kirsher 	u8 ar_tha[ETH_ALEN];
1208f2148a47SJeff Kirsher 	u8 ar_tip[4];
1209f2148a47SJeff Kirsher } __packed;
1210f2148a47SJeff Kirsher 
1211f2148a47SJeff Kirsher struct _magic_packet {
1212f2148a47SJeff Kirsher 	u8 dest_mac[6];
1213f2148a47SJeff Kirsher 	u8 src_mac[6];
1214f2148a47SJeff Kirsher 	__be16 type;
1215f2148a47SJeff Kirsher 	u8 MAC[16][6];
1216f2148a47SJeff Kirsher 	u8 password[6];
1217f2148a47SJeff Kirsher } __packed;
1218f2148a47SJeff Kirsher 
1219f2148a47SJeff Kirsher /*
1220f2148a47SJeff Kirsher  *	Store for chip context when saving and restoring status. Not
1221f2148a47SJeff Kirsher  *	all fields are saved/restored currently.
1222f2148a47SJeff Kirsher  */
1223f2148a47SJeff Kirsher 
1224f2148a47SJeff Kirsher struct velocity_context {
1225f2148a47SJeff Kirsher 	u8 mac_reg[256];
1226f2148a47SJeff Kirsher 	MCAM_ADDR cam_addr[MCAM_SIZE];
1227f2148a47SJeff Kirsher 	u16 vcam[VCAM_SIZE];
1228f2148a47SJeff Kirsher 	u32 cammask[2];
1229f2148a47SJeff Kirsher 	u32 patcrc[2];
1230f2148a47SJeff Kirsher 	u32 pattern[8];
1231f2148a47SJeff Kirsher };
1232f2148a47SJeff Kirsher 
1233f2148a47SJeff Kirsher /*
1234f2148a47SJeff Kirsher  *	Registers in the MII (offset unit is WORD)
1235f2148a47SJeff Kirsher  */
1236f2148a47SJeff Kirsher 
1237f2148a47SJeff Kirsher // Marvell 88E1000/88E1000S
1238f2148a47SJeff Kirsher #define MII_REG_PSCR        0x10	// PHY specific control register
1239f2148a47SJeff Kirsher 
1240f2148a47SJeff Kirsher //
1241f2148a47SJeff Kirsher // Bits in the Silicon revision register
1242f2148a47SJeff Kirsher //
1243f2148a47SJeff Kirsher 
1244f2148a47SJeff Kirsher #define TCSR_ECHODIS        0x2000	//
1245f2148a47SJeff Kirsher #define AUXCR_MDPPS         0x0004	//
1246f2148a47SJeff Kirsher 
1247f2148a47SJeff Kirsher // Bits in the PLED register
1248f2148a47SJeff Kirsher #define PLED_LALBE			0x0004	//
1249f2148a47SJeff Kirsher 
1250f2148a47SJeff Kirsher // Marvell 88E1000/88E1000S Bits in the PHY specific control register (10h)
1251f2148a47SJeff Kirsher #define PSCR_ACRSTX         0x0800	// Assert CRS on Transmit
1252f2148a47SJeff Kirsher 
1253f2148a47SJeff Kirsher #define PHYID_CICADA_CS8201 0x000FC410UL
1254f2148a47SJeff Kirsher #define PHYID_VT3216_32BIT  0x000FC610UL
1255f2148a47SJeff Kirsher #define PHYID_VT3216_64BIT  0x000FC600UL
1256f2148a47SJeff Kirsher #define PHYID_MARVELL_1000  0x01410C50UL
1257f2148a47SJeff Kirsher #define PHYID_MARVELL_1000S 0x01410C40UL
12586dffbe53STony Prisk #define PHYID_ICPLUS_IP101A 0x02430C54UL
1259f2148a47SJeff Kirsher #define PHYID_REV_ID_MASK   0x0000000FUL
1260f2148a47SJeff Kirsher 
1261f2148a47SJeff Kirsher #define PHYID_GET_PHY_ID(i)         ((i) & ~PHYID_REV_ID_MASK)
1262f2148a47SJeff Kirsher 
1263f2148a47SJeff Kirsher #define MII_REG_BITS_ON(x,i,p) do {\
1264f2148a47SJeff Kirsher     u16 w;\
1265f2148a47SJeff Kirsher     velocity_mii_read((p),(i),&(w));\
1266f2148a47SJeff Kirsher     (w)|=(x);\
1267f2148a47SJeff Kirsher     velocity_mii_write((p),(i),(w));\
1268f2148a47SJeff Kirsher } while (0)
1269f2148a47SJeff Kirsher 
1270f2148a47SJeff Kirsher #define MII_REG_BITS_OFF(x,i,p) do {\
1271f2148a47SJeff Kirsher     u16 w;\
1272f2148a47SJeff Kirsher     velocity_mii_read((p),(i),&(w));\
1273f2148a47SJeff Kirsher     (w)&=(~(x));\
1274f2148a47SJeff Kirsher     velocity_mii_write((p),(i),(w));\
1275f2148a47SJeff Kirsher } while (0)
1276f2148a47SJeff Kirsher 
1277f2148a47SJeff Kirsher #define MII_REG_BITS_IS_ON(x,i,p) ({\
1278f2148a47SJeff Kirsher     u16 w;\
1279f2148a47SJeff Kirsher     velocity_mii_read((p),(i),&(w));\
1280f2148a47SJeff Kirsher     ((int) ((w) & (x)));})
1281f2148a47SJeff Kirsher 
1282f2148a47SJeff Kirsher #define MII_GET_PHY_ID(p) ({\
1283f2148a47SJeff Kirsher     u32 id;\
1284f2148a47SJeff Kirsher     velocity_mii_read((p),MII_PHYSID2,(u16 *) &id);\
1285f2148a47SJeff Kirsher     velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\
1286f2148a47SJeff Kirsher     (id);})
1287f2148a47SJeff Kirsher 
1288f2148a47SJeff Kirsher #define     VELOCITY_WOL_MAGIC             0x00000000UL
1289f2148a47SJeff Kirsher #define     VELOCITY_WOL_PHY               0x00000001UL
1290f2148a47SJeff Kirsher #define     VELOCITY_WOL_ARP               0x00000002UL
1291f2148a47SJeff Kirsher #define     VELOCITY_WOL_UCAST             0x00000004UL
1292f2148a47SJeff Kirsher #define     VELOCITY_WOL_BCAST             0x00000010UL
1293f2148a47SJeff Kirsher #define     VELOCITY_WOL_MCAST             0x00000020UL
1294f2148a47SJeff Kirsher #define     VELOCITY_WOL_MAGIC_SEC         0x00000040UL
1295f2148a47SJeff Kirsher 
1296f2148a47SJeff Kirsher /*
1297f2148a47SJeff Kirsher  *	Flags for options
1298f2148a47SJeff Kirsher  */
1299f2148a47SJeff Kirsher 
1300f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_TAGGING         0x00000001UL
1301f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_RX_CSUM         0x00000004UL
1302f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_IP_ALIGN        0x00000008UL
1303f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_VAL_PKT_LEN     0x00000010UL
1304f2148a47SJeff Kirsher 
1305f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_FLOW_CTRL       0x01000000UL
1306f2148a47SJeff Kirsher 
1307f2148a47SJeff Kirsher /*
1308f2148a47SJeff Kirsher  *	Flags for driver status
1309f2148a47SJeff Kirsher  */
1310f2148a47SJeff Kirsher 
1311f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_OPENED          0x00010000UL
1312f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_VMNS_CONNECTED  0x00020000UL
1313f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_VMNS_COMMITTED  0x00040000UL
1314f2148a47SJeff Kirsher #define     VELOCITY_FLAGS_WOL_ENABLED     0x00080000UL
1315f2148a47SJeff Kirsher 
1316f2148a47SJeff Kirsher /*
1317f2148a47SJeff Kirsher  *	Flags for MII status
1318f2148a47SJeff Kirsher  */
1319f2148a47SJeff Kirsher 
1320f2148a47SJeff Kirsher #define     VELOCITY_LINK_FAIL             0x00000001UL
1321f2148a47SJeff Kirsher #define     VELOCITY_SPEED_10              0x00000002UL
1322f2148a47SJeff Kirsher #define     VELOCITY_SPEED_100             0x00000004UL
1323f2148a47SJeff Kirsher #define     VELOCITY_SPEED_1000            0x00000008UL
1324f2148a47SJeff Kirsher #define     VELOCITY_DUPLEX_FULL           0x00000010UL
1325f2148a47SJeff Kirsher #define     VELOCITY_AUTONEG_ENABLE        0x00000020UL
1326f2148a47SJeff Kirsher #define     VELOCITY_FORCED_BY_EEPROM      0x00000040UL
1327f2148a47SJeff Kirsher 
1328f2148a47SJeff Kirsher /*
1329f2148a47SJeff Kirsher  *	For velocity_set_media_duplex
1330f2148a47SJeff Kirsher  */
1331f2148a47SJeff Kirsher 
1332f2148a47SJeff Kirsher #define     VELOCITY_LINK_CHANGE           0x00000001UL
1333f2148a47SJeff Kirsher 
1334f2148a47SJeff Kirsher enum speed_opt {
1335f2148a47SJeff Kirsher 	SPD_DPX_AUTO = 0,
1336f2148a47SJeff Kirsher 	SPD_DPX_100_HALF = 1,
1337f2148a47SJeff Kirsher 	SPD_DPX_100_FULL = 2,
1338f2148a47SJeff Kirsher 	SPD_DPX_10_HALF = 3,
1339f2148a47SJeff Kirsher 	SPD_DPX_10_FULL = 4,
1340f2148a47SJeff Kirsher 	SPD_DPX_1000_FULL = 5
1341f2148a47SJeff Kirsher };
1342f2148a47SJeff Kirsher 
1343f2148a47SJeff Kirsher enum velocity_init_type {
1344f2148a47SJeff Kirsher 	VELOCITY_INIT_COLD = 0,
1345f2148a47SJeff Kirsher 	VELOCITY_INIT_RESET,
1346f2148a47SJeff Kirsher 	VELOCITY_INIT_WOL
1347f2148a47SJeff Kirsher };
1348f2148a47SJeff Kirsher 
1349f2148a47SJeff Kirsher enum velocity_flow_cntl_type {
1350f2148a47SJeff Kirsher 	FLOW_CNTL_DEFAULT = 1,
1351f2148a47SJeff Kirsher 	FLOW_CNTL_TX,
1352f2148a47SJeff Kirsher 	FLOW_CNTL_RX,
1353f2148a47SJeff Kirsher 	FLOW_CNTL_TX_RX,
1354f2148a47SJeff Kirsher 	FLOW_CNTL_DISABLE,
1355f2148a47SJeff Kirsher };
1356f2148a47SJeff Kirsher 
1357f2148a47SJeff Kirsher struct velocity_opt {
1358f2148a47SJeff Kirsher 	int numrx;			/* Number of RX descriptors */
1359f2148a47SJeff Kirsher 	int numtx;			/* Number of TX descriptors */
1360f2148a47SJeff Kirsher 	enum speed_opt spd_dpx;		/* Media link mode */
1361f2148a47SJeff Kirsher 
1362f2148a47SJeff Kirsher 	int DMA_length;			/* DMA length */
1363f2148a47SJeff Kirsher 	int rx_thresh;			/* RX_THRESH */
1364f2148a47SJeff Kirsher 	int flow_cntl;
1365f2148a47SJeff Kirsher 	int wol_opts;			/* Wake on lan options */
1366f2148a47SJeff Kirsher 	int td_int_count;
1367f2148a47SJeff Kirsher 	int int_works;
1368f2148a47SJeff Kirsher 	int rx_bandwidth_hi;
1369f2148a47SJeff Kirsher 	int rx_bandwidth_lo;
1370f2148a47SJeff Kirsher 	int rx_bandwidth_en;
1371f2148a47SJeff Kirsher 	int rxqueue_timer;
1372f2148a47SJeff Kirsher 	int txqueue_timer;
1373f2148a47SJeff Kirsher 	int tx_intsup;
1374f2148a47SJeff Kirsher 	int rx_intsup;
1375f2148a47SJeff Kirsher 	u32 flags;
1376f2148a47SJeff Kirsher };
1377f2148a47SJeff Kirsher 
1378f2148a47SJeff Kirsher #define AVAIL_TD(p,q)   ((p)->options.numtx-((p)->tx.used[(q)]))
1379f2148a47SJeff Kirsher 
1380f2148a47SJeff Kirsher #define GET_RD_BY_IDX(vptr, idx)   (vptr->rd_ring[idx])
1381f2148a47SJeff Kirsher 
1382f2148a47SJeff Kirsher struct velocity_info {
1383e2c41f14STony Prisk 	struct device *dev;
1384f2148a47SJeff Kirsher 	struct pci_dev *pdev;
1385a9683c94STony Prisk 	struct net_device *netdev;
1386*1a87e641SRob Herring 	bool no_eeprom;
1387f2148a47SJeff Kirsher 
1388f2148a47SJeff Kirsher 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
1389f2148a47SJeff Kirsher 	u8 ip_addr[4];
1390f2148a47SJeff Kirsher 	enum chip_type chip_id;
1391f2148a47SJeff Kirsher 
1392f2148a47SJeff Kirsher 	struct mac_regs __iomem * mac_regs;
1393f2148a47SJeff Kirsher 	unsigned long memaddr;
1394f2148a47SJeff Kirsher 	unsigned long ioaddr;
1395f2148a47SJeff Kirsher 
1396f2148a47SJeff Kirsher 	struct tx_info {
1397f2148a47SJeff Kirsher 		int numq;
1398f2148a47SJeff Kirsher 
1399f2148a47SJeff Kirsher 		/* FIXME: the locality of the data seems rather poor. */
1400f2148a47SJeff Kirsher 		int used[TX_QUEUE_NO];
1401f2148a47SJeff Kirsher 		int curr[TX_QUEUE_NO];
1402f2148a47SJeff Kirsher 		int tail[TX_QUEUE_NO];
1403f2148a47SJeff Kirsher 		struct tx_desc *rings[TX_QUEUE_NO];
1404f2148a47SJeff Kirsher 		struct velocity_td_info *infos[TX_QUEUE_NO];
1405f2148a47SJeff Kirsher 		dma_addr_t pool_dma[TX_QUEUE_NO];
1406f2148a47SJeff Kirsher 	} tx;
1407f2148a47SJeff Kirsher 
1408f2148a47SJeff Kirsher 	struct rx_info {
1409f2148a47SJeff Kirsher 		int buf_sz;
1410f2148a47SJeff Kirsher 
1411f2148a47SJeff Kirsher 		int dirty;
1412f2148a47SJeff Kirsher 		int curr;
1413f2148a47SJeff Kirsher 		u32 filled;
1414f2148a47SJeff Kirsher 		struct rx_desc *ring;
1415f2148a47SJeff Kirsher 		struct velocity_rd_info *info;	/* It's an array */
1416f2148a47SJeff Kirsher 		dma_addr_t pool_dma;
1417f2148a47SJeff Kirsher 	} rx;
1418f2148a47SJeff Kirsher 
1419f2148a47SJeff Kirsher 	u32 mib_counter[MAX_HW_MIB_COUNTER];
1420f2148a47SJeff Kirsher 	struct velocity_opt options;
1421f2148a47SJeff Kirsher 
1422f2148a47SJeff Kirsher 	u32 int_mask;
1423f2148a47SJeff Kirsher 
1424f2148a47SJeff Kirsher 	u32 flags;
1425f2148a47SJeff Kirsher 
1426f2148a47SJeff Kirsher 	u32 mii_status;
1427f2148a47SJeff Kirsher 	u32 phy_id;
1428f2148a47SJeff Kirsher 	int multicast_limit;
1429f2148a47SJeff Kirsher 
1430f2148a47SJeff Kirsher 	u8 vCAMmask[(VCAM_SIZE / 8)];
1431f2148a47SJeff Kirsher 	u8 mCAMmask[(MCAM_SIZE / 8)];
1432f2148a47SJeff Kirsher 
1433f2148a47SJeff Kirsher 	spinlock_t lock;
1434f2148a47SJeff Kirsher 
1435f2148a47SJeff Kirsher 	int wol_opts;
1436f2148a47SJeff Kirsher 	u8 wol_passwd[6];
1437f2148a47SJeff Kirsher 
1438f2148a47SJeff Kirsher 	struct velocity_context context;
1439f2148a47SJeff Kirsher 
1440f2148a47SJeff Kirsher 	u32 ticks;
144171f711a4SMichal Kubecek 	u32 ethtool_ops_nesting;
1442f2148a47SJeff Kirsher 
1443f2148a47SJeff Kirsher 	u8 rev_id;
1444f2148a47SJeff Kirsher 
1445f2148a47SJeff Kirsher 	struct napi_struct napi;
1446f2148a47SJeff Kirsher };
1447f2148a47SJeff Kirsher 
1448f2148a47SJeff Kirsher /**
1449f2148a47SJeff Kirsher  *	velocity_get_ip		-	find an IP address for the device
1450f2148a47SJeff Kirsher  *	@vptr: Velocity to query
1451f2148a47SJeff Kirsher  *
1452f2148a47SJeff Kirsher  *	Dig out an IP address for this interface so that we can
1453f2148a47SJeff Kirsher  *	configure wakeup with WOL for ARP. If there are multiple IP
1454f2148a47SJeff Kirsher  *	addresses on this chain then we use the first - multi-IP WOL is not
1455f2148a47SJeff Kirsher  *	supported.
1456f2148a47SJeff Kirsher  *
1457f2148a47SJeff Kirsher  */
1458f2148a47SJeff Kirsher 
velocity_get_ip(struct velocity_info * vptr)1459f2148a47SJeff Kirsher static inline int velocity_get_ip(struct velocity_info *vptr)
1460f2148a47SJeff Kirsher {
1461f2148a47SJeff Kirsher 	struct in_device *in_dev;
1462f2148a47SJeff Kirsher 	struct in_ifaddr *ifa;
1463f2148a47SJeff Kirsher 	int res = -ENOENT;
1464f2148a47SJeff Kirsher 
1465f2148a47SJeff Kirsher 	rcu_read_lock();
1466a9683c94STony Prisk 	in_dev = __in_dev_get_rcu(vptr->netdev);
1467f2148a47SJeff Kirsher 	if (in_dev != NULL) {
14682638eb8bSFlorian Westphal 		ifa = rcu_dereference(in_dev->ifa_list);
1469f2148a47SJeff Kirsher 		if (ifa != NULL) {
1470f2148a47SJeff Kirsher 			memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
1471f2148a47SJeff Kirsher 			res = 0;
1472f2148a47SJeff Kirsher 		}
1473f2148a47SJeff Kirsher 	}
1474f2148a47SJeff Kirsher 	rcu_read_unlock();
1475f2148a47SJeff Kirsher 	return res;
1476f2148a47SJeff Kirsher }
1477f2148a47SJeff Kirsher 
1478f2148a47SJeff Kirsher /**
1479f2148a47SJeff Kirsher  *	velocity_update_hw_mibs	-	fetch MIB counters from chip
1480f2148a47SJeff Kirsher  *	@vptr: velocity to update
1481f2148a47SJeff Kirsher  *
1482f2148a47SJeff Kirsher  *	The velocity hardware keeps certain counters in the hardware
1483f2148a47SJeff Kirsher  * 	side. We need to read these when the user asks for statistics
1484f2148a47SJeff Kirsher  *	or when they overflow (causing an interrupt). The read of the
1485f2148a47SJeff Kirsher  *	statistic clears it, so we keep running master counters in user
1486f2148a47SJeff Kirsher  *	space.
1487f2148a47SJeff Kirsher  */
1488f2148a47SJeff Kirsher 
velocity_update_hw_mibs(struct velocity_info * vptr)1489f2148a47SJeff Kirsher static inline void velocity_update_hw_mibs(struct velocity_info *vptr)
1490f2148a47SJeff Kirsher {
1491f2148a47SJeff Kirsher 	u32 tmp;
1492f2148a47SJeff Kirsher 	int i;
1493f2148a47SJeff Kirsher 	BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR));
1494f2148a47SJeff Kirsher 
1495f2148a47SJeff Kirsher 	while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)));
1496f2148a47SJeff Kirsher 
1497f2148a47SJeff Kirsher 	BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR));
1498f2148a47SJeff Kirsher 	for (i = 0; i < HW_MIB_SIZE; i++) {
1499f2148a47SJeff Kirsher 		tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL;
1500f2148a47SJeff Kirsher 		vptr->mib_counter[i] += tmp;
1501f2148a47SJeff Kirsher 	}
1502f2148a47SJeff Kirsher }
1503f2148a47SJeff Kirsher 
1504f2148a47SJeff Kirsher /**
1505f2148a47SJeff Kirsher  *	init_flow_control_register 	-	set up flow control
1506f2148a47SJeff Kirsher  *	@vptr: velocity to configure
1507f2148a47SJeff Kirsher  *
1508f2148a47SJeff Kirsher  *	Configure the flow control registers for this velocity device.
1509f2148a47SJeff Kirsher  */
1510f2148a47SJeff Kirsher 
init_flow_control_register(struct velocity_info * vptr)1511f2148a47SJeff Kirsher static inline void init_flow_control_register(struct velocity_info *vptr)
1512f2148a47SJeff Kirsher {
1513f2148a47SJeff Kirsher 	struct mac_regs __iomem * regs = vptr->mac_regs;
1514f2148a47SJeff Kirsher 
1515f2148a47SJeff Kirsher 	/* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1}
1516f2148a47SJeff Kirsher 	   depend on RD=64, and Turn on XNOEN in FlowCR1 */
1517f2148a47SJeff Kirsher 	writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), &regs->CR0Set);
1518f2148a47SJeff Kirsher 	writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), &regs->CR0Clr);
1519f2148a47SJeff Kirsher 
1520f2148a47SJeff Kirsher 	/* Set TxPauseTimer to 0xFFFF */
1521f2148a47SJeff Kirsher 	writew(0xFFFF, &regs->tx_pause_timer);
1522f2148a47SJeff Kirsher 
1523f2148a47SJeff Kirsher 	/* Initialize RBRDU to Rx buffer count. */
1524f2148a47SJeff Kirsher 	writew(vptr->options.numrx, &regs->RBRDU);
1525f2148a47SJeff Kirsher }
1526f2148a47SJeff Kirsher 
1527f2148a47SJeff Kirsher 
1528f2148a47SJeff Kirsher #endif
1529