xref: /titanic_51/usr/src/uts/sun/io/eri/eri_mac.h (revision 297a64e7779d7bd7140d1f3f2fa5db171aa21569)
1*297a64e7Sgd78059 /*
2*297a64e7Sgd78059  * CDDL HEADER START
3*297a64e7Sgd78059  *
4*297a64e7Sgd78059  * The contents of this file are subject to the terms of the
5*297a64e7Sgd78059  * Common Development and Distribution License (the "License").
6*297a64e7Sgd78059  * You may not use this file except in compliance with the License.
7*297a64e7Sgd78059  *
8*297a64e7Sgd78059  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*297a64e7Sgd78059  * or http://www.opensolaris.org/os/licensing.
10*297a64e7Sgd78059  * See the License for the specific language governing permissions
11*297a64e7Sgd78059  * and limitations under the License.
12*297a64e7Sgd78059  *
13*297a64e7Sgd78059  * When distributing Covered Code, include this CDDL HEADER in each
14*297a64e7Sgd78059  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*297a64e7Sgd78059  * If applicable, add the following below this CDDL HEADER, with the
16*297a64e7Sgd78059  * fields enclosed by brackets "[]" replaced with your own identifying
17*297a64e7Sgd78059  * information: Portions Copyright [yyyy] [name of copyright owner]
18*297a64e7Sgd78059  *
19*297a64e7Sgd78059  * CDDL HEADER END
20*297a64e7Sgd78059  */
21*297a64e7Sgd78059 /*
22*297a64e7Sgd78059  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*297a64e7Sgd78059  * Use is subject to license terms.
24*297a64e7Sgd78059  */
25*297a64e7Sgd78059 
26*297a64e7Sgd78059 #ifndef	_SYS_ERI_MAC_H
27*297a64e7Sgd78059 #define	_SYS_ERI_MAC_H
28*297a64e7Sgd78059 
29*297a64e7Sgd78059 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*297a64e7Sgd78059 
31*297a64e7Sgd78059 #ifdef	__cplusplus
32*297a64e7Sgd78059 extern "C" {
33*297a64e7Sgd78059 #endif
34*297a64e7Sgd78059 
35*297a64e7Sgd78059 /*
36*297a64e7Sgd78059  * HOST MEMORY DATA STRUCTURES
37*297a64e7Sgd78059  * Transmit and Receive Descriptor Rings
38*297a64e7Sgd78059  */
39*297a64e7Sgd78059 
40*297a64e7Sgd78059 /* The Descriptor Ring base Addresses must be 2K-byte aligned */
41*297a64e7Sgd78059 
42*297a64e7Sgd78059 #define	ERI_GMDALIGN	(2048)
43*297a64e7Sgd78059 
44*297a64e7Sgd78059 /*
45*297a64e7Sgd78059  * The transmit and receiver Descriptor Rings are organized as "wrap-around
46*297a64e7Sgd78059  * descriptors and are of programmable size.
47*297a64e7Sgd78059  * Each descriptor consists of two double-word entries: a control/status entry
48*297a64e7Sgd78059  * and a pointer to a data buffer.
49*297a64e7Sgd78059  * The no. of entries is programmable in binary increments, from 32 to 8192.
50*297a64e7Sgd78059  * TBD: Even though the Receive Desriptor ring size is 8k, provide for a user
51*297a64e7Sgd78059  * configurable variable to specify the max.no. of Rx buffers posted.
52*297a64e7Sgd78059  */
53*297a64e7Sgd78059 
54*297a64e7Sgd78059 #define	ERI_TMDMAX	(4096)	/* Transmit descriptor ring size */
55*297a64e7Sgd78059 #define	ERI_RMDMAX	(4096)	/* Receive descriptor ring size */
56*297a64e7Sgd78059 
57*297a64e7Sgd78059 /*
58*297a64e7Sgd78059  * -----------------------------
59*297a64e7Sgd78059  * Transmit descriptor structure
60*297a64e7Sgd78059  * -----------------------------
61*297a64e7Sgd78059  */
62*297a64e7Sgd78059 
63*297a64e7Sgd78059 struct eri_tmd {
64*297a64e7Sgd78059 	uint64_t	tmd_flags;	/* INTME, SOP, EOP, cksum, bufsize */
65*297a64e7Sgd78059 	uint64_t	tmd_addr;	/* buffer address */
66*297a64e7Sgd78059 };
67*297a64e7Sgd78059 
68*297a64e7Sgd78059 /* fields in the tmd_flags */
69*297a64e7Sgd78059 
70*297a64e7Sgd78059 #define	ERI_TMD_BUFSIZE	(0x7fff << 0)	/* 0-14 : Tx Data buffer size */
71*297a64e7Sgd78059 					/* valid values in range 0 - 17k */
72*297a64e7Sgd78059 #define	ERI_TMD_CSSTART	(0x3f << 15)	/* 15-20 : Checksum start offset */
73*297a64e7Sgd78059 					/* value must be even */
74*297a64e7Sgd78059 #define	ERI_TMD_CSSTUFF	(0xff << 21)	/* 21-28 : Checksum stuff offset */
75*297a64e7Sgd78059 					/* value must be even */
76*297a64e7Sgd78059 #define	ERI_TMD_CSENABL	(1 << 29)	/* 29 : Enable checksum computation */
77*297a64e7Sgd78059 #define	ERI_TMD_EOP	(1 << 30)	/* 30 : End Of Packet flag */
78*297a64e7Sgd78059 #define	ERI_TMD_SOP	((uint64_t)1 << 31)	/* 31 : Packet Start flag */
79*297a64e7Sgd78059 #define	ERI_TMD_INTME	((uint64_t)1 << 32)	/* 32 : Interrupt me now */
80*297a64e7Sgd78059 #define	ERI_TMD_NOCRC	((uint64_t)1 << 33)	/* 33 : Do not insert CRC */
81*297a64e7Sgd78059 
82*297a64e7Sgd78059 #define	ERI_TMD_CSSTART_SHIFT 15	/* checksum start bit position */
83*297a64e7Sgd78059 #define	ERI_TMD_CSSTUFF_SHIFT 21	/* checksum stuff bit position */
84*297a64e7Sgd78059 
85*297a64e7Sgd78059 /*
86*297a64e7Sgd78059  * TCP Header offset within Ethernet Packet:
87*297a64e7Sgd78059  * 14 Bytes Ethernet Header + 20 IP Header.
88*297a64e7Sgd78059  */
89*297a64e7Sgd78059 
90*297a64e7Sgd78059 #define	ERI_TCPHDR_OFFSET	34
91*297a64e7Sgd78059 #define	ERI_IPHDR_OFFSET 	20
92*297a64e7Sgd78059 
93*297a64e7Sgd78059 /*
94*297a64e7Sgd78059  * TCP Checksum stuff offset within Ethernet packet:
95*297a64e7Sgd78059  * 34 Bytes up to TCP Header + 16 Bytes within TCP header
96*297a64e7Sgd78059  */
97*297a64e7Sgd78059 
98*297a64e7Sgd78059 #define	ERI_TCPCSUM_OFFSET	50
99*297a64e7Sgd78059 #define	ERI_TMDCSUM_CTL		(ERI_TMD_CSENABL | \
100*297a64e7Sgd78059 				(ERI_TCPHDR_OFFSET << ERI_TMD_CSSTART_SHIFT) | \
101*297a64e7Sgd78059 				(ERI_TCPCSUM_OFFSET << ERI_TMD_CSSTUFF_SHIFT))
102*297a64e7Sgd78059 /*
103*297a64e7Sgd78059  *	Programming Notes:
104*297a64e7Sgd78059  *
105*297a64e7Sgd78059  *	1. TX Kick Register is used to hand over TX descriptors to the hardware.
106*297a64e7Sgd78059  *	TX Completion Register is used by hardware to handover TX descriptors
107*297a64e7Sgd78059  *	back to the software.
108*297a64e7Sgd78059  *
109*297a64e7Sgd78059  *	2. ERI never writes back TX descriptors.
110*297a64e7Sgd78059  *
111*297a64e7Sgd78059  *	2. If a packet resides in more than one buffer, the Checksum_Enable,
112*297a64e7Sgd78059  *	Checksum_Stuff_Offset, Checksum_Start_Offset and Int_me fields need to
113*297a64e7Sgd78059  *	be set only in the first descriptor for the packet.
114*297a64e7Sgd78059  *
115*297a64e7Sgd78059  *	3. The hardware implementation relies on the fact that if a buffer
116*297a64e7Sgd78059  *	starts at an "odd" boundary, the DMA state machine can "rewind"
117*297a64e7Sgd78059  *	to the nearest burst boundary and execute a full DVMA burst Read.
118*297a64e7Sgd78059  *
119*297a64e7Sgd78059  *	There is no other alignment restriction for the transmit data buffer.
120*297a64e7Sgd78059  */
121*297a64e7Sgd78059 
122*297a64e7Sgd78059 /*
123*297a64e7Sgd78059  * -----------------------------
124*297a64e7Sgd78059  * Receive Descriptor structure
125*297a64e7Sgd78059  * ----------------------------
126*297a64e7Sgd78059  */
127*297a64e7Sgd78059 
128*297a64e7Sgd78059 struct rmd {
129*297a64e7Sgd78059 	uint64_t	rmd_flags;
130*297a64e7Sgd78059 		/* hash_val, hash_pass, bad, OWN, buf/data size, cksum */
131*297a64e7Sgd78059 	uint64_t	rmd_addr;	/* 8-byte aligned buffer address */
132*297a64e7Sgd78059 };
133*297a64e7Sgd78059 
134*297a64e7Sgd78059 /*
135*297a64e7Sgd78059  * fields in the rmd_flags
136*297a64e7Sgd78059  */
137*297a64e7Sgd78059 #define	ERI_RMD_CKSUM	(0xffff << 0)	/* 0-15 : checksum computed */
138*297a64e7Sgd78059 #define	ERI_RMD_BUFSIZE	(0x7fff << 16)	/* 16-30 : buffer/frame size */
139*297a64e7Sgd78059 #define	ERI_RMD_OWN	((uint64_t)1 << 31)	/* 31 : Ownership flag */
140*297a64e7Sgd78059 					/* 0 - owned by software */
141*297a64e7Sgd78059 					/* 1 - owned by hardware */
142*297a64e7Sgd78059 #define	ERI_RMD_RESERVED1	((uint64_t)0xfff << 32)	/* 32-43 : Reserved */
143*297a64e7Sgd78059 #define	ERI_RMD_HASHVAL	((uint64_t)0xffff << 44)	/* 44-59 : hash value */
144*297a64e7Sgd78059 #define	ERI_RMD_HASHPASS ((uint64_t)1 << 60)	/* 60 : pass hash filter */
145*297a64e7Sgd78059 #define	ERI_RMD_ALTERNATE	((uint64_t)1 << 61)
146*297a64e7Sgd78059 					/* 61 : matched alternate MAC adrs */
147*297a64e7Sgd78059 #define	ERI_RMD_BAD	((uint64_t)1 << 62)	/* 62 : bad CRC frame */
148*297a64e7Sgd78059 #define	ERI_RMD_RESERVED2	((uint64_t)1 << 63)	/* 63 : Reserved */
149*297a64e7Sgd78059 
150*297a64e7Sgd78059 #define	ERI_RMD_BUFSIZE_SHIFT 16	/* buffer/data size bit position */
151*297a64e7Sgd78059 
152*297a64e7Sgd78059 #define	ERI__RMD_BUFALIGN	8
153*297a64e7Sgd78059 
154*297a64e7Sgd78059 /*
155*297a64e7Sgd78059  * ERI REGISTER SPACE
156*297a64e7Sgd78059  * The comments are in the following format:
157*297a64e7Sgd78059  * Addres_Offset R/W Default Actual_size(bits) Description
158*297a64e7Sgd78059  */
159*297a64e7Sgd78059 
160*297a64e7Sgd78059 /*
161*297a64e7Sgd78059  * Global Register Space : Paritally Modified for ERI
162*297a64e7Sgd78059  */
163*297a64e7Sgd78059 struct global {
164*297a64e7Sgd78059     uint32_t seb_state;	/* 0x0000 RO   0x00000000 03 SEB State Register */
165*297a64e7Sgd78059     uint32_t config;	/* 0x0004 RW   0x00000000 17 Configuration Register */
166*297a64e7Sgd78059     uint32_t reserved2;	/* 0x0008 */
167*297a64e7Sgd78059     uint32_t status;	/* 0x000C R-AC 0x00000000 25 Int. Status Register */
168*297a64e7Sgd78059     uint32_t intmask;	/* 0x0010 RW   0xFFFFFFFF 12 Interrupt Mask Reg */
169*297a64e7Sgd78059     uint32_t intack;	/* 0x0014 WO   0x00000000 06 Interrupt Ack Register */
170*297a64e7Sgd78059     uint32_t reserved3;	/* 0x0018 */
171*297a64e7Sgd78059     uint32_t status_alias; /* 0x001C RO   0x00000000 25 Int. Stat Reg Alias */
172*297a64e7Sgd78059     uint32_t reserved4[1016];	/* To skip to 0x1000 */
173*297a64e7Sgd78059     uint32_t err_status; /* 0x1000 R-AC 0x00000000 03 PCI Error Status Reg. */
174*297a64e7Sgd78059     uint32_t reset;	/* 0x1010 RW-AC 0x00	  3  Software Reset Reg */
175*297a64e7Sgd78059 };
176*297a64e7Sgd78059 
177*297a64e7Sgd78059 /*
178*297a64e7Sgd78059  *
179*297a64e7Sgd78059  * SBus IO configuration (RW)
180*297a64e7Sgd78059  * To configure parameters that define the DMA burst and internal arbitration.
181*297a64e7Sgd78059  */
182*297a64e7Sgd78059 #define	ERI_SIOCFG_BSIZE32	(0x1 << 0) /* 32 byte burst sizeb state */
183*297a64e7Sgd78059 #define	ERI_SIOCFG_BSIZE64	(0x1 << 1) /* 64 byte burst sizeb state */
184*297a64e7Sgd78059 #define	ERI_SIOCFG_BSIZE128	(0x1 << 2) /* 128 byte burst sizeb state */
185*297a64e7Sgd78059 #define	ERI_SIOCFG_BMODE64	(0x1 << 3) /* Sbus 64 bit mode */
186*297a64e7Sgd78059 #define	ERI_SIOCFG_PARITY	(0x1 << 9) /* Sbus Parity enabled. */
187*297a64e7Sgd78059 
188*297a64e7Sgd78059 /*
189*297a64e7Sgd78059  * SEB State Register (RO)
190*297a64e7Sgd78059  * Reflects the internal state of the arbitration between TX and RX
191*297a64e7Sgd78059  * DMA Channels. Used for diagnostics only
192*297a64e7Sgd78059  */
193*297a64e7Sgd78059 #define	ERI_SEB_ARBSTS	(0x2 << 0)	/* Arbiter state */
194*297a64e7Sgd78059 #define	ERI_SEB_RXWON	(1 << 2)	/* RX won the arbitration */
195*297a64e7Sgd78059 
196*297a64e7Sgd78059 /*
197*297a64e7Sgd78059  * Global Configuration Register (RW)
198*297a64e7Sgd78059  * To configure parameters that define the DMA burst and internal arbitration.
199*297a64e7Sgd78059  * TX/RX_DMA_LIMIT: No. of data transfers in 64-byte multiples
200*297a64e7Sgd78059  *			0 - peririty changes at packet boundaries
201*297a64e7Sgd78059  * default:	0x042
202*297a64e7Sgd78059  */
203*297a64e7Sgd78059 #define	ERI_G_CONFIG_BURST_SIZE	(0x1 << 0)	/* 0:infinite/64-byte burst */
204*297a64e7Sgd78059 #define	ERI_G_CONFIG_TX_DMA_LIM	(0x1f << 1)	/* 5-1: TX_DMA_Limit */
205*297a64e7Sgd78059 #define	ERI_G_CONFIG_RX_DMA_LIM	(0x1f << 6)	/* 10-6: RX_DMA_Limit */
206*297a64e7Sgd78059 
207*297a64e7Sgd78059 #define	ERI_G_CONFIG_BURST_64	0x0	/* max burst size 64 */
208*297a64e7Sgd78059 #define	ERI_G_CONFIG_BURST_INF	0x1	/* infinite burst for whole pkt len */
209*297a64e7Sgd78059 
210*297a64e7Sgd78059 #define	ERI_G_CONFIG_TX_DMA_LIM_SHIFT	1
211*297a64e7Sgd78059 #define	ERI_G_CONFIG_RX_DMA_LIM_SHIFT	6
212*297a64e7Sgd78059 
213*297a64e7Sgd78059 /*
214*297a64e7Sgd78059  * Global Interrupt Status Register (R-AC)
215*297a64e7Sgd78059  * size:	32 bits: 0-31
216*297a64e7Sgd78059  * default:	0x00000000
217*297a64e7Sgd78059  * This is the top level register used to communicate to the software events
218*297a64e7Sgd78059  * that were detected by the hardware.
219*297a64e7Sgd78059  * Top level bits 0-6 are automatically cleared to 0 when the Status Register
220*297a64e7Sgd78059  * is read.
221*297a64e7Sgd78059  * Second level interrupts reported by bits 13-18 are cleared at the source.
222*297a64e7Sgd78059  * The value of the TX Completion Register is replicated in bits 19-31.
223*297a64e7Sgd78059  */
224*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_INT_ME	(1 << 0)
225*297a64e7Sgd78059 	/* 0 - set when a frame with INT_ME bit set is transferred to FIFO */
226*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_ALL	(1 << 1)	/* 1 - TX desc. ring empty */
227*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_DONE	(1 << 2)	/* 2 - from host to TX FIFO */
228*297a64e7Sgd78059 #define	ERI_G_STATUS_RES1	(1 << 3)	/* 3 - reserved */
229*297a64e7Sgd78059 #define	ERI_G_STATUS_RX_DONE	(1 << 4)	/* 4 - from RXFIFO to host */
230*297a64e7Sgd78059 #define	ERI_G_STATUS_RX_NO_BUF	(1 << 5)	/* 5 - no RX buff available */
231*297a64e7Sgd78059 #define	ERI_G_STATUS_RX_TAG_ERR	(1 << 6)	/* 6 - RX tag error */
232*297a64e7Sgd78059 #define	ERI_G_STATUS_PERR_INT	(1 << 7)	/* 7 - Parity Err sts reg */
233*297a64e7Sgd78059 #define	ERI_G_STATUS_RES2	(0x3f << 7)	/* 7-12 : reserved */
234*297a64e7Sgd78059 #define	ERI_G_STATUS_PCS_INT	(1 << 13)	/* 13 - PCS Interrupt */
235*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_MAC_INT	(1 << 14)	/* 14 - TX MAC stat reg set */
236*297a64e7Sgd78059 #define	ERI_G_STATUS_RX_MAC_INT	(1 << 15)	/* 15 - RX MAC stat reg set */
237*297a64e7Sgd78059 #define	ERI_G_STATUS_MAC_CTRL_INT	(1 << 16) /* 16 - MAC control reg  */
238*297a64e7Sgd78059 #define	ERI_G_STATUS_MIF_INT	(1 << 17)	/* 17 - MIF status reg set */
239*297a64e7Sgd78059 #define	ERI_G_STATUS_BUS_ERR_INT	(1 << 18) /* 18 - BUS Err sts reg */
240*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_COMPL	(0xfff80000)	/* 19-31: TX Completion reg */
241*297a64e7Sgd78059 
242*297a64e7Sgd78059 #define	ERI_G_STATUS_INTR	(0xffffffff & ~(ERI_G_STATUS_TX_DONE |\
243*297a64e7Sgd78059 	ERI_G_STATUS_TX_ALL |\
244*297a64e7Sgd78059 	ERI_G_STATUS_MAC_CTRL_INT | ERI_G_STATUS_TX_COMPL))
245*297a64e7Sgd78059 
246*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_INT	(ERI_G_STATUS_TX_DONE | ERI_G_STATUS_TX_ALL)
247*297a64e7Sgd78059 #define	ERI_G_STATUS_RX_INT	(~ERI_G_STATUS_TX_COMPL & ~ERI_G_STATUS_TX_INT)
248*297a64e7Sgd78059 
249*297a64e7Sgd78059 #define	ERI_G_STATUS_FATAL_ERR		(ERI_G_STATUS_RX_TAG_ERR | \
250*297a64e7Sgd78059 					ERI_G_STATUS_PERR_INT | \
251*297a64e7Sgd78059 					ERI_G_STATUS_BUS_ERR_INT)
252*297a64e7Sgd78059 
253*297a64e7Sgd78059 #define	ERI_G_STATUS_NONFATAL_ERR	(ERI_G_STATUS_TX_MAC_INT | \
254*297a64e7Sgd78059 					ERI_G_STATUS_RX_MAC_INT | \
255*297a64e7Sgd78059 					ERI_G_STATUS_MAC_CTRL_INT)
256*297a64e7Sgd78059 
257*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_COMPL_SHIFT	19
258*297a64e7Sgd78059 #define	ERI_G_STATUS_TX_COMPL_MASK	0x1fff
259*297a64e7Sgd78059 
260*297a64e7Sgd78059 /*
261*297a64e7Sgd78059  * Global Interrupt Mask register (RW)
262*297a64e7Sgd78059  * size:	32 bits
263*297a64e7Sgd78059  * default:	0xFFFFFFFF
264*297a64e7Sgd78059  * There is one-to-one correspondence between the bits in this register and
265*297a64e7Sgd78059  * the Global Status register.
266*297a64e7Sgd78059  * If a mask bit is 0, the corresponding event causes an interrupt.
267*297a64e7Sgd78059  */
268*297a64e7Sgd78059 
269*297a64e7Sgd78059 
270*297a64e7Sgd78059 #define	ERI_G_MASK_TX_INT_ME	(1 << 0)
271*297a64e7Sgd78059 	/* 0 - set when a frame with INT_ME bit set is transferred to FIFO */
272*297a64e7Sgd78059 #define	ERI_G_MASK_TX_ALL	(1 << 1)	/* 1 - TX desc. ring empty */
273*297a64e7Sgd78059 #define	ERI_G_MASK_TX_DONE	(1 << 2)	/* 2 - from host to TX FIFO */
274*297a64e7Sgd78059 #define	ERI_G_MASK_RES1		(1 << 3)	/* 3 - reserved */
275*297a64e7Sgd78059 #define	ERI_G_MASK_RX_DONE	(1 << 4)	/* 4 - from RXFIFO to host */
276*297a64e7Sgd78059 #define	ERI_G_MASK_RX_NO_BUF	(1 << 5)	/* 5 - no RX bufer available */
277*297a64e7Sgd78059 #define	ERI_G_MASK_RX_TAG_ERR	(1 << 6)	/* 6 - RX tag error */
278*297a64e7Sgd78059 #define	ERI_G_MASK_RES2		(0x3f << 7)	/* 7-13 : reserved */
279*297a64e7Sgd78059 #define	ERI_G_MASK_PCS_INT	(1 << 13)	/* 13 - PCS Interrupt */
280*297a64e7Sgd78059 #define	ERI_G_MASK_TX_MAC_INT	(1 << 14)	/* 14 - TX MAC status reg set */
281*297a64e7Sgd78059 #define	ERI_G_MASK_RX_MAC_INT	(1 << 15)	/* 15 - RX MAC status reg set */
282*297a64e7Sgd78059 #define	ERI_G_MASK_MAC_CTRL_INT	(1 << 16)	/* 16 - MAC control reg set */
283*297a64e7Sgd78059 #define	ERI_G_MASK_MIF_INT	(1 << 17)	/* 17 - MIF status reg set */
284*297a64e7Sgd78059 #define	ERI_G_MASK_BUS_ERR_INT	(1 << 18)	/* 18 - BUS Error sts reg set */
285*297a64e7Sgd78059 
286*297a64e7Sgd78059 #define	ERI_G_MASK_INTR		(~ERI_G_STATUS_INTR | ERI_G_MASK_PCS_INT)
287*297a64e7Sgd78059 #define	ERI_G_MASK_ALL		(0xffffffffu)
288*297a64e7Sgd78059 
289*297a64e7Sgd78059 
290*297a64e7Sgd78059 /*
291*297a64e7Sgd78059  * Interrupt Ack Register (WO)
292*297a64e7Sgd78059  * Its layout corresponds to the layout of the top level bits of the Interrupt
293*297a64e7Sgd78059  * Status register.
294*297a64e7Sgd78059  * Bit positions written high will be cleared, while bit positions written low
295*297a64e7Sgd78059  * have no effect on the Interrupt Status Register.
296*297a64e7Sgd78059  */
297*297a64e7Sgd78059 
298*297a64e7Sgd78059 /*
299*297a64e7Sgd78059  * Status Register Alias (RO)
300*297a64e7Sgd78059  * This location presents the same view as the Interrupt Status Register, except
301*297a64e7Sgd78059  * that reading from this location does not automatically clear any of the
302*297a64e7Sgd78059  * register bits.
303*297a64e7Sgd78059  */
304*297a64e7Sgd78059 
305*297a64e7Sgd78059 /*
306*297a64e7Sgd78059  * PCI Error Status Register (R-AC)
307*297a64e7Sgd78059  * Other PCI bus errors : The specific error may be read from
308*297a64e7Sgd78059  * the PCI Status Register in PCI Configuration space
309*297a64e7Sgd78059  */
310*297a64e7Sgd78059 #define	ERI_G_STS_BADACK	(1 << 0)	/* no ACK64# during ABS64 */
311*297a64e7Sgd78059 #define	ERI_G_STS_DTRTO		(1 << 1)	/* Delayed trans timeout */
312*297a64e7Sgd78059 #define	ERI_G_STS_OTHERS	(1 << 2)
313*297a64e7Sgd78059 
314*297a64e7Sgd78059 /*
315*297a64e7Sgd78059  * PCI Error Mask Register (RW)
316*297a64e7Sgd78059  * size: 	32 bits
317*297a64e7Sgd78059  * default:	0xffffffff
318*297a64e7Sgd78059  * Same layout as the PCI Error Status Register
319*297a64e7Sgd78059  */
320*297a64e7Sgd78059 #define	ERI_G_PCI_ERROR_MASK	0x00
321*297a64e7Sgd78059 
322*297a64e7Sgd78059 /*
323*297a64e7Sgd78059  * BIF Configuration Register
324*297a64e7Sgd78059  * default: 0x0
325*297a64e7Sgd78059  * Used to configure specific system information for the BIF block to optimize.
326*297a64e7Sgd78059  * Default values indicate no special knowledge is assumed by BIF.
327*297a64e7Sgd78059  * M66EN is RO bit.
328*297a64e7Sgd78059  * 66 MHz operation (RO) May be used by the driver to sense
329*297a64e7Sgd78059  * whether ERI is operating in a 66MHz or 33 MHz PCI segment
330*297a64e7Sgd78059  */
331*297a64e7Sgd78059 #define	ERI_G_BIFCFG_SLOWCLK	(1 << 0)	/* for parity error timing */
332*297a64e7Sgd78059 #define	ERI_G_BIFCFG_HOST_64	(1 << 1)	/* 64-bit host */
333*297a64e7Sgd78059 #define	ERI_G_BIFCFG_B64D_DIS	(1 << 2)	/* no 64-bit wide data */
334*297a64e7Sgd78059 #define	ERI_G_BIFCFG_M66EN	(1 << 3)
335*297a64e7Sgd78059 
336*297a64e7Sgd78059 /*
337*297a64e7Sgd78059  * BIF Diagnostic register (RW)
338*297a64e7Sgd78059  * TBD
339*297a64e7Sgd78059  */
340*297a64e7Sgd78059 
341*297a64e7Sgd78059 /*
342*297a64e7Sgd78059  * Global Software Reset Register - RW-AC
343*297a64e7Sgd78059  * The lower 2bits are used to perform an individual Software Reset to the
344*297a64e7Sgd78059  * TX or RX functions (when the corresponding bit is set), or
345*297a64e7Sgd78059  * a Global Software Reset to the ERI (when both bits are set).
346*297a64e7Sgd78059  * These bits become "self cleared" after the corresponding reset command
347*297a64e7Sgd78059  * has been executed. After a reset, the software must poll this register
348*297a64e7Sgd78059  * till both the bits are read as 0's.
349*297a64e7Sgd78059  * The third bit (RSTOUT) is not self clearing and is used to activate
350*297a64e7Sgd78059  * the RSTOUT# pin, when set. When clear, RSTOUT# follows the level of the
351*297a64e7Sgd78059  * PCI reset input pin.
352*297a64e7Sgd78059  */
353*297a64e7Sgd78059 #define	ERI_G_RESET_ETX	(1 << 0)	/* Reset ETX */
354*297a64e7Sgd78059 #define	ERI_G_RESET_ERX	(1 << 1)	/* Reset ERX */
355*297a64e7Sgd78059 #define	ERI_G_RESET_RSTOUT (1 << 2)	/* force the RSTOUT# pin active */
356*297a64e7Sgd78059 #define	ERI_G_CACHE_BIT	16
357*297a64e7Sgd78059 #define	ERI_G_CACHE_LINE_SIZE_16 16	/* cache line size of 64 bytes  */
358*297a64e7Sgd78059 #define	ERI_G_CACHE_LINE_SIZE_32 32	/* cache line size of 128 bytes  */
359*297a64e7Sgd78059 #define	ERI_G_CACHE_16 (ERI_G_CACHE_LINE_SIZE_16 << ERI_G_CACHE_BIT)
360*297a64e7Sgd78059 #define	ERI_G_CACHE_32 (ERI_G_CACHE_LINE_SIZE_32 << ERI_G_CACHE_BIT)
361*297a64e7Sgd78059 
362*297a64e7Sgd78059 #define	ERI_G_RESET_GLOBAL (ERI_G_RESET_ETX | ERI_G_RESET_ERX)
363*297a64e7Sgd78059 
364*297a64e7Sgd78059 /*
365*297a64e7Sgd78059  * Transmit DMA Register set
366*297a64e7Sgd78059  * tx_kick and tx_completion registers are set to 0 when ETX is reset.
367*297a64e7Sgd78059  */
368*297a64e7Sgd78059 
369*297a64e7Sgd78059 struct etx {
370*297a64e7Sgd78059     uint32_t tx_kick;		/* 0x2000 RW Transmit Kick Register */
371*297a64e7Sgd78059     uint32_t config;		/* 0x2004 RW ETX Configuration Register */
372*297a64e7Sgd78059     uint32_t txring_lo;		/* 0x2008 RW Transmit Descriptor Base Low */
373*297a64e7Sgd78059     uint32_t txring_hi;		/* 0x200C RW Transmit Descriptor Base Low */
374*297a64e7Sgd78059     uint32_t reserved1;		/* 0x2010 */
375*297a64e7Sgd78059     uint32_t txfifo_wr_ptr;	/* 0x2014 RW TxFIFO Write Pointer */
376*297a64e7Sgd78059     uint32_t txfifo_sdwr_ptr;	/* 0x2018 RW TxFIFO Shadow Write Pointer */
377*297a64e7Sgd78059     uint32_t txfifo_rd_ptr;	/* 0x201C RW TxFIFO Read Pointer */
378*297a64e7Sgd78059     uint32_t txfifo_sdrd_ptr;	/* 0x2020 RW TxFIFO Shadow Read Pointer */
379*297a64e7Sgd78059     uint32_t txfifo_pkt_cnt;	/* 0x2024 RO TxFIFO Packet Counter */
380*297a64e7Sgd78059     uint32_t state_mach;	/* 0x2028 RO ETX State Machine Reg */
381*297a64e7Sgd78059     uint32_t reserved2;		/* 0x202C */
382*297a64e7Sgd78059     uint32_t txdata_ptr_lo;	/* 0x2030 RO ETX State Machine Register */
383*297a64e7Sgd78059     uint32_t txdata_ptr_hi;	/* 0x2034 RO ETX State Machine Register */
384*297a64e7Sgd78059     uint32_t reserved3[50];	/* 0x2038 - 0x20FC */
385*297a64e7Sgd78059 
386*297a64e7Sgd78059     uint32_t tx_completion;	/* 0x2100 RO ETX Completion Register */
387*297a64e7Sgd78059     uint32_t txfifo_adrs;	/* 0x2104 RW ETX FIFO address */
388*297a64e7Sgd78059     uint32_t txfifo_tag;	/* 0x2108 RO ETX FIFO tag */
389*297a64e7Sgd78059     uint32_t txfifo_data_lo;	/* 0x210C RW ETX FIFO data low */
390*297a64e7Sgd78059     uint32_t txfifo_data_hi_T1;	/* 0x2110 RW ETX FIFO data high T1 */
391*297a64e7Sgd78059     uint32_t txfifo_data_hi_T0;	/* 0x2114 RW ETX FIFO data high T0 */
392*297a64e7Sgd78059     uint32_t txfifo_size;	/* 0x2118 RO ETX FIFO size */
393*297a64e7Sgd78059 
394*297a64e7Sgd78059     uint32_t reserved4[964];	/* 0x211C - 0x3024 */
395*297a64e7Sgd78059 
396*297a64e7Sgd78059     uint32_t txdebug;		/* 0x3028 RW ETX Debug Register */
397*297a64e7Sgd78059 };
398*297a64e7Sgd78059 
399*297a64e7Sgd78059 
400*297a64e7Sgd78059 /*
401*297a64e7Sgd78059  * TX Kick Register (RW)
402*297a64e7Sgd78059  * size:	13-bits
403*297a64e7Sgd78059  * default:	0x0
404*297a64e7Sgd78059  * Written by the host CPU with the descriptor value that follows the last
405*297a64e7Sgd78059  * valid Transmit descriptor.
406*297a64e7Sgd78059  */
407*297a64e7Sgd78059 
408*297a64e7Sgd78059 /*
409*297a64e7Sgd78059  * TX Completion Register
410*297a64e7Sgd78059  * size:	13-bits
411*297a64e7Sgd78059  * default:	0x0
412*297a64e7Sgd78059  * This register stores the descriptor value that follows the last descriptor
413*297a64e7Sgd78059  * already processed by ERI.
414*297a64e7Sgd78059  *
415*297a64e7Sgd78059  */
416*297a64e7Sgd78059 #define	ETX_COMPLETION_MASK	0x1fff
417*297a64e7Sgd78059 
418*297a64e7Sgd78059 /*
419*297a64e7Sgd78059  * ETX Configuration Register
420*297a64e7Sgd78059  * default: 0x118010
421*297a64e7Sgd78059  * This register stores parameters that control the operation of the transmit
422*297a64e7Sgd78059  * DMA channel.
423*297a64e7Sgd78059  * If the desire is to buffer an entire standard Ethernet frame before its
424*297a64e7Sgd78059  * transmission is enabled, the Tx-FIFO-Threshold field has to be programmed
425*297a64e7Sgd78059  * to a value = > 0xC8. (CHECK). Default value is 0x460.
426*297a64e7Sgd78059  * Matewos: Changed the above to 0x400. Getting FIFO Underflow in the
427*297a64e7Sgd78059  * case if Giga bit speed.
428*297a64e7Sgd78059  * Bit 21 is used to modify the functionality of the Tx_All interrupt.
429*297a64e7Sgd78059  * If it is 0, Tx_All interrupt is generated after processing the last
430*297a64e7Sgd78059  * transmit descriptor.
431*297a64e7Sgd78059  * If it is 1, Tx_All interrupt is generated only after the entire
432*297a64e7Sgd78059  * Transmit FIFO has been drained.
433*297a64e7Sgd78059  */
434*297a64e7Sgd78059 
435*297a64e7Sgd78059 #define	GET_CONFIG_TXDMA_EN	(1 << 0)	/* 0 - Enable Tx DMA */
436*297a64e7Sgd78059 #define	GET_CONFIG_TXRING_SZ	(0xf << 1)	/* 1-4:Tx desc ring size */
437*297a64e7Sgd78059 #define	GET_CONFIG_RESERVED	(0x1f << 5)	/* 5-9: Reserved */
438*297a64e7Sgd78059 #define	GET_CONFIG_TXFIFOTH	(0x7ff << 10)	/* 10-20 :TX FIFO Threshold */
439*297a64e7Sgd78059 /*
440*297a64e7Sgd78059  * RIO specific value: TXFIFO threshold needs to be set to 1518/8.
441*297a64e7Sgd78059  *			It was set to (0x4FF << 10) for GEM.
442*297a64e7Sgd78059  *			set it back to 0x4ff.
443*297a64e7Sgd78059  *			set it to 190 receive TXMAC underrun and hang
444*297a64e7Sgd78059  *			try 0x100
445*297a64e7Sgd78059  *			try 0x4ff
446*297a64e7Sgd78059  *			try 0x100
447*297a64e7Sgd78059  */
448*297a64e7Sgd78059 #define	ETX_ERI_THRESHOLD	0x100
449*297a64e7Sgd78059 #define	ETX_CONFIG_THRESHOLD	(ETX_ERI_THRESHOLD << 10)
450*297a64e7Sgd78059 
451*297a64e7Sgd78059 #define	GET_CONFIG_PACED_MODE	(1 << 21)	/* 21 - TX_all_int mod */
452*297a64e7Sgd78059 
453*297a64e7Sgd78059 #define	GET_CONFIG_THRESHOLD	(0x400 << 10)	/* For Ethernet Packets */
454*297a64e7Sgd78059 #define	GET_CONFIG_RINGSZ	(ERI_TMDMAX << 1) /* for 2048 descriptors */
455*297a64e7Sgd78059 /*
456*297a64e7Sgd78059  * ETX TX ring size
457*297a64e7Sgd78059  * This is a 4-bit value to determine the no. of descriptor entries in the
458*297a64e7Sgd78059  * TX-ring. The number of entries can vary from 32 through 8192 in multiples
459*297a64e7Sgd78059  * of 2.
460*297a64e7Sgd78059  */
461*297a64e7Sgd78059 #define	ERI_TX_RINGSZ_SHIFT	1
462*297a64e7Sgd78059 
463*297a64e7Sgd78059 #define	ETX_RINGSZ_32	0
464*297a64e7Sgd78059 #define	ETX_RINGSZ_64	1
465*297a64e7Sgd78059 #define	ETX_RINGSZ_128	2
466*297a64e7Sgd78059 #define	ETX_RINGSZ_256	3
467*297a64e7Sgd78059 #define	ETX_RINGSZ_512	4
468*297a64e7Sgd78059 #define	ETX_RINGSZ_1024	5
469*297a64e7Sgd78059 #define	ETX_RINGSZ_2048	6
470*297a64e7Sgd78059 #define	ETX_RINGSZ_4096	7
471*297a64e7Sgd78059 #define	ETX_RINGSZ_8192	8
472*297a64e7Sgd78059 /* values 9-15 are reserved. */
473*297a64e7Sgd78059 
474*297a64e7Sgd78059 /*
475*297a64e7Sgd78059  * Transmit Descriptor Base Low and High (RW)
476*297a64e7Sgd78059  * The 53 most significant bits are used as the base address for the TX
477*297a64e7Sgd78059  * descriptor ring. The 11 least significant bits are not stored and assumed
478*297a64e7Sgd78059  * to be 0.
479*297a64e7Sgd78059  * This register should be initialized to a 2KByte-aligned value after power-on
480*297a64e7Sgd78059  * or Software Reset.
481*297a64e7Sgd78059  */
482*297a64e7Sgd78059 
483*297a64e7Sgd78059 
484*297a64e7Sgd78059 /*
485*297a64e7Sgd78059  * TX FIFO size (RO)
486*297a64e7Sgd78059  * This 11-bit RO register indicates the size, in 64 byte multiples, of the
487*297a64e7Sgd78059  * TX FIFO.
488*297a64e7Sgd78059  * The value of this register is 0x90, indicating a 9Kbyte TX FIFO.
489*297a64e7Sgd78059  */
490*297a64e7Sgd78059 
491*297a64e7Sgd78059 
492*297a64e7Sgd78059 /*
493*297a64e7Sgd78059  * ERX Register Set
494*297a64e7Sgd78059  */
495*297a64e7Sgd78059 
496*297a64e7Sgd78059 struct erx {
497*297a64e7Sgd78059     uint32_t config;		/* 0x4000 RW ERX Configuration Register */
498*297a64e7Sgd78059     uint32_t rxring_lo;		/* 0x4004 RW Receive Descriptor Base low */
499*297a64e7Sgd78059     uint32_t rxring_hi;		/* 0x4008 RW Receive Descriptor Base high */
500*297a64e7Sgd78059     uint32_t rxfifo_wr_ptr;	/* 0x400C RW RxFIFO Write Pointer */
501*297a64e7Sgd78059     uint32_t rxfifo_sdwr_ptr;	/* 0x4010 RW RxFIFO Shadow Write Pointer */
502*297a64e7Sgd78059     uint32_t rxfifo_rd_ptr;	/* 0x4014 RW RxFIFO Read pointer */
503*297a64e7Sgd78059     uint32_t rxfifo_pkt_cnt;	/* 0x4018 RO RxFIFO Packet Counter */
504*297a64e7Sgd78059     uint32_t state_mach;	/* 0x401C RO ERX State Machine Register */
505*297a64e7Sgd78059     uint32_t rx_pause_threshold; /* 0x4020 RW ERX Pause thresholds */
506*297a64e7Sgd78059     uint32_t rxdata_ptr_lo;	/* 0x4024 RO ERX Data Pointer low */
507*297a64e7Sgd78059     uint32_t rxdata_ptr_hi;	/* 0x4028 RO ERX Data Pointer high */
508*297a64e7Sgd78059     uint32_t reserved1[53];	/* 0x402C - 0x40FC */
509*297a64e7Sgd78059 
510*297a64e7Sgd78059     uint32_t rx_kick;		/* 0x4100 RW ERX Kick Register */
511*297a64e7Sgd78059     uint32_t rx_completion;	/* 0x4104 RO ERX Completion Register */
512*297a64e7Sgd78059     uint32_t rx_blanking;	/* 0x4108 RO ERX Blanking Register */
513*297a64e7Sgd78059     uint32_t rxfifo_adrs;	/* 0x410C RW ERX FIFO address */
514*297a64e7Sgd78059     uint32_t rxfifo_tag;	/* 0x4110 RO ERX FIFO tag */
515*297a64e7Sgd78059     uint32_t rxfifo_data_lo;	/* 0x4114 RW ERX FIFO data low */
516*297a64e7Sgd78059     uint32_t rxfifo_data_hi_T0;	/* 0x4118 RW ERX FIFO data high T0 */
517*297a64e7Sgd78059     uint32_t rxfifo_data_hi_T1;	/* 0x411C RW ERX FIFO data high T1 */
518*297a64e7Sgd78059     uint32_t rxfifo_size;	/* 0x4120 RW ERX FIFO size */
519*297a64e7Sgd78059 };
520*297a64e7Sgd78059 
521*297a64e7Sgd78059 /*
522*297a64e7Sgd78059  * ERX Configuration Register - RW
523*297a64e7Sgd78059  * This 27-bit register determines the ERX-specific parameters that control the
524*297a64e7Sgd78059  * operation of the receive DMA channel.
525*297a64e7Sgd78059  * Default : 0x1000010
526*297a64e7Sgd78059  */
527*297a64e7Sgd78059 
528*297a64e7Sgd78059 #define	GET_CONFIG_RXDMA_EN	(1 << 0)	/* 0 : Enable Rx DMA */
529*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RXRING_SZ	(0xf << 1)	/* 1-4 : RX ring size */
530*297a64e7Sgd78059 #define	ERI_RX_CONFIG_BATDIS	(1 << 5)	/* Disable RX desc batching */
531*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RES1	(0xf << 6)	/* 6-9 : reserverd */
532*297a64e7Sgd78059 #define	ERI_RX_CONFIG_FBOFFSET	(0x7 << 10)	/* 10-12 : 1st Byte Offset */
533*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RX_CSSTART (0x7f << 13)	/* 13-19:cksum start offset */
534*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RES2	(0xf << 20)	/* 20-23 : reserve */
535*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RXFIFOTH	(0x7 << 24)	/* 24-26:RX DMA threshold */
536*297a64e7Sgd78059 
537*297a64e7Sgd78059 #define	ERI_RX_RINGSZ_SHIFT	1
538*297a64e7Sgd78059 #define	ERI_RX_CONFIG_FBO_SHIFT	10
539*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RX_CSSTART_SHIFT	13
540*297a64e7Sgd78059 #define	ERI_RX_CONFIG_RXFIFOTH_SHIFT	24
541*297a64e7Sgd78059 
542*297a64e7Sgd78059 #define	ERX_RINGSZ_32	0
543*297a64e7Sgd78059 #define	ERX_RINGSZ_64	1
544*297a64e7Sgd78059 #define	ERX_RINGSZ_128	2
545*297a64e7Sgd78059 #define	ERX_RINGSZ_256	3
546*297a64e7Sgd78059 #define	ERX_RINGSZ_512	4
547*297a64e7Sgd78059 #define	ERX_RINGSZ_1024	5
548*297a64e7Sgd78059 #define	ERX_RINGSZ_2048	6
549*297a64e7Sgd78059 #define	ERX_RINGSZ_4096	7
550*297a64e7Sgd78059 #define	ERX_RINGSZ_8192	8
551*297a64e7Sgd78059 /* values 9-15 are reserved. */
552*297a64e7Sgd78059 
553*297a64e7Sgd78059 
554*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_64	0
555*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_128	1
556*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_256	2
557*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_512	3
558*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_1024	4
559*297a64e7Sgd78059 #define	ERI_RX_FIFOTH_2048	5
560*297a64e7Sgd78059 /* 6 & 7 are reserved values */
561*297a64e7Sgd78059 
562*297a64e7Sgd78059 /*
563*297a64e7Sgd78059  * Receive Descriptor Base Low and High (RW)
564*297a64e7Sgd78059  * The 53 most significant bits are used as the base address for the RX
565*297a64e7Sgd78059  * descriptor ring. The 11 least significant bits are not stored and assumed
566*297a64e7Sgd78059  * to be 0.
567*297a64e7Sgd78059  * This register should be initialized to a 2KByte-aligned value after power-on
568*297a64e7Sgd78059  * or Software Reset.
569*297a64e7Sgd78059  */
570*297a64e7Sgd78059 
571*297a64e7Sgd78059 
572*297a64e7Sgd78059 /*
573*297a64e7Sgd78059  * Pause Thresholds Register (RW)
574*297a64e7Sgd78059  * default: 0x000f8
575*297a64e7Sgd78059  * Two PAUSE thresholds are used to define when PAUSE flow control frames are
576*297a64e7Sgd78059  * emitted by ERI. The granularity of these thresholds is in 64 byte increments.
577*297a64e7Sgd78059  * XOFF PAUSE frames use the pause_time value pre-programmed in the
578*297a64e7Sgd78059  * Send PAUSE MAC Register.
579*297a64e7Sgd78059  * XON PAUSE frames use a pause_time of 0.
580*297a64e7Sgd78059  */
581*297a64e7Sgd78059 
582*297a64e7Sgd78059 #define	ERI_RX_PTH_OFFTH	(0x1ff << 0)
583*297a64e7Sgd78059 			/*
584*297a64e7Sgd78059 			 * 0-8: XOFF PAUSE emitted when RX FIFO
585*297a64e7Sgd78059 			 * occupancy rises above this value (times 64 bytes)
586*297a64e7Sgd78059 			 */
587*297a64e7Sgd78059 #define	ERI_RX_PTH_RES	(0x7 << 9)	/* 9-11: reserved */
588*297a64e7Sgd78059 #define	ERI_RX_PTH_ONTH	(0x1ff << 12)
589*297a64e7Sgd78059 			/*
590*297a64e7Sgd78059 			 * 12-20: XON PAUSE emitted when RX FIFO
591*297a64e7Sgd78059 			 * occupancy falls below this value (times 64 bytes)
592*297a64e7Sgd78059 			 */
593*297a64e7Sgd78059 
594*297a64e7Sgd78059 #define	ERI_RX_PTH_ONTH_SHIFT	12
595*297a64e7Sgd78059 
596*297a64e7Sgd78059 /*
597*297a64e7Sgd78059  * ------------------------------------------------------------------------
598*297a64e7Sgd78059  * RX Kick Register (RW)
599*297a64e7Sgd78059  * This is a 13-bit register written by the host CPU.
600*297a64e7Sgd78059  * The last valid RX descriptor is the one right before the value of the
601*297a64e7Sgd78059  * register.
602*297a64e7Sgd78059  * Initially set to 0 on reset.
603*297a64e7Sgd78059  * RX descriptors must be posted in multiples of 4.
604*297a64e7Sgd78059  * The first descriptor should be cache-line aligned for best performance.
605*297a64e7Sgd78059  * -------------------------------------------------------------------------
606*297a64e7Sgd78059  */
607*297a64e7Sgd78059 
608*297a64e7Sgd78059 /*
609*297a64e7Sgd78059  * RX Completion Register (RO)
610*297a64e7Sgd78059  * This 13-bit register indicates which descriptors are already used by ERI
611*297a64e7Sgd78059  * for receive frames.
612*297a64e7Sgd78059  * All descriptors upto but excluding the register value are ready to be
613*297a64e7Sgd78059  * processed by the host.
614*297a64e7Sgd78059  */
615*297a64e7Sgd78059 
616*297a64e7Sgd78059 /*
617*297a64e7Sgd78059  * RX Blanking Register (RW)
618*297a64e7Sgd78059  * Defines the values used for receive interrupt blanking.
619*297a64e7Sgd78059  * For INTR_TIME field, every count is 2048 PCI clock time. For 66 Mhz, each
620*297a64e7Sgd78059  * count is about 16 us.
621*297a64e7Sgd78059  */
622*297a64e7Sgd78059 #define	ERI_RX_BLNK_INTR_PACKETS	(0x1ff << 0)
623*297a64e7Sgd78059 			/*
624*297a64e7Sgd78059 			 * 0-8:no.of pkts to be recvd since the last RX_DONE
625*297a64e7Sgd78059 			 * interrupt, before a new interrupt
626*297a64e7Sgd78059 			 */
627*297a64e7Sgd78059 #define	ERI_RX_BLNK_RESERVED	(0x7 << 9)	/* 9-11 : reserved */
628*297a64e7Sgd78059 #define	ERI_RX_BLNK_INTR_TIME	(0xff << 12)
629*297a64e7Sgd78059 			/*
630*297a64e7Sgd78059 			 * 12-19 : no. of clocks to be counted since the last
631*297a64e7Sgd78059 			 * RX_DONE interrupt, before a new interrupt
632*297a64e7Sgd78059 			 */
633*297a64e7Sgd78059 
634*297a64e7Sgd78059 #define	ERI_RX_BLNK_INTR_TIME_SHIFT	12
635*297a64e7Sgd78059 
636*297a64e7Sgd78059 /*
637*297a64e7Sgd78059  * RX FIFO Size (RO)
638*297a64e7Sgd78059  * This 11-bit RO register indicates the size, in 64-bit multiples, of the
639*297a64e7Sgd78059  * RX FIFO. Software should use it to properly configure the PAUSE thresholds.
640*297a64e7Sgd78059  * The value read is 0x140, indicating a 20kbyte RX FIFO.
641*297a64e7Sgd78059  */
642*297a64e7Sgd78059 
643*297a64e7Sgd78059 
644*297a64e7Sgd78059 /*
645*297a64e7Sgd78059  * Declarations and definitions specific to the ERI MAC functional block.
646*297a64e7Sgd78059  *
647*297a64e7Sgd78059  * The ERI MAC block will provide the MAC functons for 10 or 100 Mbps or
648*297a64e7Sgd78059  * 1 Gbps CSMA/CD-protocol-based or full-duplex interface.
649*297a64e7Sgd78059  */
650*297a64e7Sgd78059 
651*297a64e7Sgd78059 /*
652*297a64e7Sgd78059  * ERI MAC Register Set.
653*297a64e7Sgd78059  * ERI MAC addresses map on a word boundry. So all registers are
654*297a64e7Sgd78059  * declared for a size of 32 bits. Registers that use fewer than 32
655*297a64e7Sgd78059  * bits will return 0 in the bits not used.
656*297a64e7Sgd78059  * TBD: Define the constant values which should be used for initializing
657*297a64e7Sgd78059  * these registers.
658*297a64e7Sgd78059  */
659*297a64e7Sgd78059 struct	bmac {
660*297a64e7Sgd78059 	uint32_t	txrst;	/* 0x6000 tx software reset (RW) */
661*297a64e7Sgd78059 	uint32_t	rxrst;	/* 0x6004 rx software reset Reg (RW) */
662*297a64e7Sgd78059 	uint32_t	spcmd;	/* 0x6008 Send Pause Command Reg (RW) */
663*297a64e7Sgd78059 	uint32_t	res1;	/* 0x600C reserved */
664*297a64e7Sgd78059 	uint32_t	txsts;	/* 0x6010 tx MAC status reg (R-AC) */
665*297a64e7Sgd78059 	uint32_t	rxsts;	/* 0x6014 rx MAC status reg (R-AC) */
666*297a64e7Sgd78059 	uint32_t	macctl_sts; /* 0x6018 MAC Control Stat Reg (R-AC) */
667*297a64e7Sgd78059 	uint32_t	res2;	/* 0x601C reserved */
668*297a64e7Sgd78059 	uint32_t	txmask;	/* 0x6020 tx MAC Mask Register (RW) */
669*297a64e7Sgd78059 	uint32_t	rxmask;	/* 0x6024 rx MAC Mask register (RW) */
670*297a64e7Sgd78059 	uint32_t	macctl_mask; /* 0x6028 MAC Control Mask Reg (RW) */
671*297a64e7Sgd78059 	uint32_t	res3;	/* 0x602C reserved */
672*297a64e7Sgd78059 	uint32_t	txcfg;	/* 0x6030 tx config reg [8-0] (RW) */
673*297a64e7Sgd78059 	uint32_t	rxcfg;	/* 0x6034 rx config reg [7-0] (RW) */
674*297a64e7Sgd78059 	uint32_t	macctl_cfg; /* 0x6038 MAC Control Config Reg (RW) */
675*297a64e7Sgd78059 	uint32_t	xifc;	/* 0x603C XIF Config. reg [7-0] (RW) */
676*297a64e7Sgd78059 	uint32_t	ipg0;	/* 0x6040 Inter pkt Gap 0 [7-0] (RW) */
677*297a64e7Sgd78059 	uint32_t	ipg1;	/* 0x6044 Inter pkt Gap 1 [7-0] (RW) */
678*297a64e7Sgd78059 	uint32_t	ipg2;	/* 0x6048 Inter pkt Gap 2 [7-0] (RW) */
679*297a64e7Sgd78059 	uint32_t	slot;	/* 0x604C slot time reg [7-0] (RW) */
680*297a64e7Sgd78059 	uint32_t	macmin;	/* 0x6050 MAC min frame sze [9-0](RW) */
681*297a64e7Sgd78059 	uint32_t	macmax;	/* 0x6054 MAC max pkt sze [14-0] (RW) */
682*297a64e7Sgd78059 	uint32_t	palen;	/* 0x6058 preamble len reg [9-0] (RW) */
683*297a64e7Sgd78059 	uint32_t	jam;	/* 0x605C jam size reg [3-0] (RW) */
684*297a64e7Sgd78059 	uint32_t	alimit;	/* 0x6060 attempt limit reg [7-0](RW) */
685*297a64e7Sgd78059 	uint32_t	macctl_type; /* 0x6064 MAC Control Type Reg (RW) */
686*297a64e7Sgd78059 	uint32_t	res4[6]; /* reserved 0x6068 - 0x607C	*/
687*297a64e7Sgd78059 	uint32_t	madd0;	/* 0x6080 Norm MAC adrs 0 [15-0] (RW) */
688*297a64e7Sgd78059 	uint32_t	madd1;	/* 0x6084 Norm MAC adrs 1 [31-16](RW) */
689*297a64e7Sgd78059 	uint32_t	madd2;	/* 0x6088 Norm MAC adrs 2 [47-32](RW) */
690*297a64e7Sgd78059 	uint32_t	madd3;	/* 0x608C Alt. MAC adrs 0 [15-0](RW) */
691*297a64e7Sgd78059 	uint32_t	madd4;	/* 0x6090 Alt. MAC adrs 1 [31-16](RW) */
692*297a64e7Sgd78059 	uint32_t	madd5;	/* 0x6094 Alt. MAC adrs 2 [47-32](RW) */
693*297a64e7Sgd78059 	uint32_t	madd6;	/* 0x6098 Control MAC adrs 0 [15-0](RW) */
694*297a64e7Sgd78059 	uint32_t	madd7;	/* 0x609C Control MAC adrs 1 [31-16](RW) */
695*297a64e7Sgd78059 	uint32_t	madd8;	/* 0x60A0 Control MAC adrs 2 [47-32](RW) */
696*297a64e7Sgd78059 	uint32_t	afr0;	/* 0x60A4 addr filt reg 0_0 [15-0](RW) */
697*297a64e7Sgd78059 	uint32_t	afr1;	/* 0x60A8 addr filt reg 0_1 [15-0](RW) */
698*297a64e7Sgd78059 	uint32_t	afr2;	/* 0x60AC addr filt reg 0_2 [15-0](RW) */
699*297a64e7Sgd78059 	uint32_t	afmr1_2; /* 0x60B0 addr filt msk reg 1,2 [8-0](RW) */
700*297a64e7Sgd78059 	uint32_t	afmr0;	/* 0x60B4 addr filt msk reg 0 [15-0](RW) */
701*297a64e7Sgd78059 	uint32_t	res5[2]; /* 0x60B8 - 0x60BC Reserved	*/
702*297a64e7Sgd78059 	uint32_t	hash0;	/* 0x60C0 h-table 0 [15-0] (RW) */
703*297a64e7Sgd78059 	uint32_t	hash1;	/* 0x60C4 h-table 1 [31-16] (RW) */
704*297a64e7Sgd78059 	uint32_t	hash2;	/* 0x60C8 h-table 2 [47-32] (RW) */
705*297a64e7Sgd78059 	uint32_t	hash3;	/* 0x60CC h-table 3 [63-48] (RW) */
706*297a64e7Sgd78059 	uint32_t	hash4;	/* 0x60D0 h-table  4 [79-64] (RW) */
707*297a64e7Sgd78059 	uint32_t	hash5;	/* 0x60D4 h-table  5 [95-80] (RW) */
708*297a64e7Sgd78059 	uint32_t	hash6;	/* 0x60D8 h-table  6 [111-96] (RW) */
709*297a64e7Sgd78059 	uint32_t	hash7;	/* 0x60DC h-table  7 [127-112] (RW) */
710*297a64e7Sgd78059 	uint32_t	hash8;	/* 0x60E0 h-table  8 [143-128] (RW) */
711*297a64e7Sgd78059 	uint32_t	hash9;	/* 0x60E4 h-table  9 [159-144] (RW) */
712*297a64e7Sgd78059 	uint32_t	hash10;	/* 0x60E8 h-table 10 [175-160] (RW) */
713*297a64e7Sgd78059 	uint32_t	hash11;	/* 0x60EC h-table 11 [191-176] (RW) */
714*297a64e7Sgd78059 	uint32_t	hash12;	/* 0x60F0 h-table 12 [207-192] (RW) */
715*297a64e7Sgd78059 	uint32_t	hash13;	/* 0x60F4 h-table 13 [223-208] (RW) */
716*297a64e7Sgd78059 	uint32_t	hash14;	/* 0x60F8 h-table 14 [239-224] (RW) */
717*297a64e7Sgd78059 	uint32_t	hash15;	/* 0x60FC h-table 15 [255-240] (RW) */
718*297a64e7Sgd78059 	uint32_t	nccnt;	/* 0x6100 normal coll cnt [15-0] (RW) */
719*297a64e7Sgd78059 	uint32_t	fccnt;	/* 0x6104 1st succes coll [15-0] (RW) */
720*297a64e7Sgd78059 	uint32_t	excnt;	/* 0x6108 excess coll cnt[15-0] (RW) */
721*297a64e7Sgd78059 	uint32_t	ltcnt;	/* 0x610C late coll cnt [15-0] (RW) */
722*297a64e7Sgd78059 	uint32_t	dcnt;	/* 0x6110 defer timer cnt [15-0] (RW) */
723*297a64e7Sgd78059 	uint32_t	pattempts; /* 0x6114 peak attempt reg [7-0] (RW) */
724*297a64e7Sgd78059 	uint32_t	frcnt;	/* 0x6118 rcv frame cnt [15-0] (RW) */
725*297a64e7Sgd78059 	uint32_t	lecnt;	/* 0x611C rx len err cnt [15-0] (RW) */
726*297a64e7Sgd78059 	uint32_t	aecnt;	/* 0x6120 rx align err cnt[15-0] (RW) */
727*297a64e7Sgd78059 	uint32_t	fecnt;	/* 0x6124 rcv crc err cnt [15-0] (RW) */
728*297a64e7Sgd78059 	uint32_t	rxcv;	/* 0x6128 rx code viol reg [15-0](RW) */
729*297a64e7Sgd78059 	uint32_t	res6;	/* 0x612C Reserved */
730*297a64e7Sgd78059 	uint32_t	rseed;	/* 0x6130 random num seed [9-0] (RW) */
731*297a64e7Sgd78059 	uint32_t	macsm;	/* 0x6134 MAC state mach reg [7-0](R) */
732*297a64e7Sgd78059 };
733*297a64e7Sgd78059 
734*297a64e7Sgd78059 #define	BMAC_OVERFLOW_STATE	0x03800000
735*297a64e7Sgd78059 
736*297a64e7Sgd78059 /*
737*297a64e7Sgd78059  * Constants used for initializing the MAC registers
738*297a64e7Sgd78059  */
739*297a64e7Sgd78059 
740*297a64e7Sgd78059 #define	BMAC_SEND_PAUSE_CMD	0x1BF0
741*297a64e7Sgd78059 #define	BMAC_IPG0		0x00
742*297a64e7Sgd78059 #define	BMAC_IPG1		0x08
743*297a64e7Sgd78059 #define	BMAC_IPG2		0x04
744*297a64e7Sgd78059 #define	BMAC_SLOT_TIME		0x40
745*297a64e7Sgd78059 #define	BMAC_EXT_SLOT_TIME	0x200
746*297a64e7Sgd78059 #define	BMAC_MIN_FRAME_SIZE	0x40
747*297a64e7Sgd78059 #define	BMAC_MAX_FRAME_SIZE	(ETHERMTU + 18 + 4)	/* enet + vlan */
748*297a64e7Sgd78059 
749*297a64e7Sgd78059 /*
750*297a64e7Sgd78059  *	Hardware bug: set MAC_FRAME_SIZE to 0x7fff to
751*297a64e7Sgd78059  *	get around the problem of tag errors
752*297a64e7Sgd78059  */
753*297a64e7Sgd78059 #ifdef	ERI_RX_TAG_ERROR_WORKAROUND
754*297a64e7Sgd78059 #define	BMAC_MAX_FRAME_SIZE_TAG	0x7fff
755*297a64e7Sgd78059 #endif
756*297a64e7Sgd78059 
757*297a64e7Sgd78059 #define	BMAC_MAX_BURST		(0x2000 << 16)
758*297a64e7Sgd78059 #define	BMAC_PREAMBLE_SIZE	0x07
759*297a64e7Sgd78059 #define	BMAC_JAM_SIZE		0x04
760*297a64e7Sgd78059 #define	BMAC_ATTEMPT_LIMIT	0x10
761*297a64e7Sgd78059 #define	BMAC_CONTROL_TYPE	0x8808
762*297a64e7Sgd78059 #define	BMAC_ADDRESS_3		0x0000
763*297a64e7Sgd78059 #define	BMAC_ADDRESS_4		0x0000
764*297a64e7Sgd78059 #define	BMAC_ADDRESS_5		0x0000
765*297a64e7Sgd78059 #define	BMAC_ADDRESS_6		0x0001
766*297a64e7Sgd78059 #define	BMAC_ADDRESS_7		0xC200
767*297a64e7Sgd78059 #define	BMAC_ADDRESS_8		0x0180
768*297a64e7Sgd78059 #define	BMAC_AF_0		0x0000
769*297a64e7Sgd78059 #define	BMAC_AF_1		0x0000
770*297a64e7Sgd78059 #define	BMAC_AF_2		0x0000
771*297a64e7Sgd78059 #define	BMAC_AF21_MASK		0x00
772*297a64e7Sgd78059 #define	BMAC_AF0_MASK		0x0000
773*297a64e7Sgd78059 #define	BMAC_COUNTER		0x0000	/* for all MAC Counters */
774*297a64e7Sgd78059 
775*297a64e7Sgd78059 /*
776*297a64e7Sgd78059  * ERI MAC Register Bit Masks.
777*297a64e7Sgd78059  */
778*297a64e7Sgd78059 
779*297a64e7Sgd78059 /*
780*297a64e7Sgd78059  * TX_MAC Software Reset Command Register (RW)
781*297a64e7Sgd78059  * This bit is set to 1 when a PIO write is done. This bit becomes self-cleared.
782*297a64e7Sgd78059  * after the command has been executed.
783*297a64e7Sgd78059  */
784*297a64e7Sgd78059 
785*297a64e7Sgd78059 #define	BMAC_TX_RESET		(1 << 0)	/* TX_MAC Reset Command */
786*297a64e7Sgd78059 
787*297a64e7Sgd78059 
788*297a64e7Sgd78059 /*
789*297a64e7Sgd78059  * RX_MAC Software Reset Command Register (RW)
790*297a64e7Sgd78059  * This bit is set to 1 when a PIO write is done. This bit becomes self-cleared.
791*297a64e7Sgd78059  * after the command has been executed.
792*297a64e7Sgd78059  */
793*297a64e7Sgd78059 
794*297a64e7Sgd78059 #define	BMAC_RX_RESET		(1 << 0)	/* RX_MAC Reset Command */
795*297a64e7Sgd78059 
796*297a64e7Sgd78059 /*
797*297a64e7Sgd78059  * Send Pause Command Register (RW)
798*297a64e7Sgd78059  * This command register executes a Pause Flow Control frame transmission.
799*297a64e7Sgd78059  * Pause_Time_Sent field indicates to the MAC the value of the pause_time
800*297a64e7Sgd78059  * operand that should be sent on the network using either the Send_Pause
801*297a64e7Sgd78059  * Command bit or the flow control handshake on the RxDMA < - > MAC interface.
802*297a64e7Sgd78059  * The pause-time is interpreted in terms of Slot times.
803*297a64e7Sgd78059  */
804*297a64e7Sgd78059 
805*297a64e7Sgd78059 /*
806*297a64e7Sgd78059  * 0-15: value of pause_time operand
807*297a64e7Sgd78059  * in terms of slot time
808*297a64e7Sgd78059  */
809*297a64e7Sgd78059 
810*297a64e7Sgd78059 #define	ERI_MCTLSP_TIME	(0xffff << 0)
811*297a64e7Sgd78059 #define	ERI_MCTLSP_SEND	(1 << 16)	/* send Pause flow control frame */
812*297a64e7Sgd78059 
813*297a64e7Sgd78059 
814*297a64e7Sgd78059 /*
815*297a64e7Sgd78059  * TX_MAC Status Register (R-AC)
816*297a64e7Sgd78059  */
817*297a64e7Sgd78059 
818*297a64e7Sgd78059 #define	BMAC_TXSTS_XMIT_DONE	(1 << 0)	/* Frame transmitted */
819*297a64e7Sgd78059 #define	BMAC_TXSTS_TX_URUN	(1 << 1)	/* TX MAC Underrun */
820*297a64e7Sgd78059 #define	BMAC_TXSTS_MAXPKT_ERR	(1 << 2)	/* packet len exceeds max len */
821*297a64e7Sgd78059 #define	BMAC_TXSTS_NCC_EXP	(1 << 3)	/* Normal Collision cnt exp */
822*297a64e7Sgd78059 #define	BMAC_TXSTS_ECC_EXP	(1 << 4)	/* Excess Collision cnt exp */
823*297a64e7Sgd78059 #define	BMAC_TXSTS_LCC_EXP	(1 << 5)	/* Late Collision cnt exp */
824*297a64e7Sgd78059 #define	BMAC_TXSTS_FCC_EXP	(1 << 6)	/* First Collision cnt exp */
825*297a64e7Sgd78059 #define	BMAC_TXSTS_DEFER_EXP	(1 << 7)	/* Defer Timer exp */
826*297a64e7Sgd78059 #define	BMAC_TXSTS_PEAK_EXP	(1 << 8)	/* Peak attempts cnt exp */
827*297a64e7Sgd78059 
828*297a64e7Sgd78059 /*
829*297a64e7Sgd78059  * TX_MAC Mask Register (RW)
830*297a64e7Sgd78059  */
831*297a64e7Sgd78059 
832*297a64e7Sgd78059 #define	BMAC_TXMASK_XMIT_DONE	(1 << 0)	/* Frame transmitted */
833*297a64e7Sgd78059 #define	BMAC_TXMASK_TX_URUN	(1 << 1)	/* TX MAC Underrun */
834*297a64e7Sgd78059 #define	BMAC_TXMASK_MAXPKT_ERR	(1 << 2)	/* packet len exceeds max len */
835*297a64e7Sgd78059 #define	BMAC_TXMASK_NCC_EXP	(1 << 3)	/* Normal Collision cnt exp */
836*297a64e7Sgd78059 #define	BMAC_TXMASK_ECC_EXP	(1 << 4)	/* Excess Collision cnt exp */
837*297a64e7Sgd78059 #define	BMAC_TXMASK_LCC_EXP	(1 << 5)	/* Late Collision cnt exp */
838*297a64e7Sgd78059 #define	BMAC_TXMASK_FCC_EXP	(1 << 6)	/* First Collision cnt exp */
839*297a64e7Sgd78059 #define	BMAC_TXMASK_DEFER_EXP	(1 << 7)	/* Defer Timer exp */
840*297a64e7Sgd78059 #define	BMAC_TXMASK_PEAK_EXP	(1 << 8)	/* Peak attempts cnt exp */
841*297a64e7Sgd78059 /* Matewos added defer counter */
842*297a64e7Sgd78059 #define	BMAC_TXINTR_MASK	(BMAC_TXMASK_XMIT_DONE | BMAC_TXMASK_DEFER_EXP)
843*297a64e7Sgd78059 
844*297a64e7Sgd78059 /*
845*297a64e7Sgd78059  * RX_MAC Status Register (R-AC)
846*297a64e7Sgd78059  */
847*297a64e7Sgd78059 #define	BMAC_RXSTS_RX_DONE	(1 << 0)	/* Frame Received */
848*297a64e7Sgd78059 #define	BMAC_RXSTS_RX_OVF	(1 << 1)	/* RX MAC data path overflow */
849*297a64e7Sgd78059 #define	BMAC_RXSTS_FRMCNT_EXP	(1 << 2)	/* RX Frame counter exp */
850*297a64e7Sgd78059 #define	BMAC_RXSTS_ALE_EXP	(1 << 3)	/* RX Alignment error cnt exp */
851*297a64e7Sgd78059 #define	BMAC_RXSTS_CRC_EXP	(1 << 4)	/* RX CRC error cnt exp */
852*297a64e7Sgd78059 #define	BMAC_RXSTS_LEN_EXP	(1 << 5)	/* RX Length error cnt exp */
853*297a64e7Sgd78059 #define	BMAC_RXSTS_CVI_EXP	(1 << 6)    /* RX Code violate err cnt exp */
854*297a64e7Sgd78059 
855*297a64e7Sgd78059 /*
856*297a64e7Sgd78059  * RX_MAC Mask Register (R-AC)
857*297a64e7Sgd78059  */
858*297a64e7Sgd78059 #define	BMAC_RXMASK_RX_DONE	(1 << 0)	/* Frame Received */
859*297a64e7Sgd78059 #define	BMAC_RXMASK_RX_OVF	(1 << 1)	/* RX MAC data path overflow */
860*297a64e7Sgd78059 #define	BMAC_RXMASK_FRMCNT_EXP	(1 << 2)	/* RX Frame counter exp */
861*297a64e7Sgd78059 #define	BMAC_RXMASK_ALE_EXP	(1 << 3)	/* RX Alignment error cnt exp */
862*297a64e7Sgd78059 #define	BMAC_RXMASK_CRC_EXP	(1 << 4)	/* RX CRC error cnt exp */
863*297a64e7Sgd78059 #define	BMAC_RXMASK_LEN_EXP	(1 << 5)	/* RX Length error cnt exp */
864*297a64e7Sgd78059 #define	BMAC_RXMASK_CVI_EXP	(1 << 6)    /* RX Code violate err cnt exp */
865*297a64e7Sgd78059 
866*297a64e7Sgd78059 #define	BMAC_RXINTR_MASK	(BMAC_RXMASK_RX_DONE | BMAC_RXMASK_FRMCNT_EXP)
867*297a64e7Sgd78059 
868*297a64e7Sgd78059 /*
869*297a64e7Sgd78059  * MAC Control Status Register (R-AC)
870*297a64e7Sgd78059  */
871*297a64e7Sgd78059 #define	ERI_MCTLSTS_PAUSE_RCVD	(1 << 0)	/* PAUSE received */
872*297a64e7Sgd78059 #define	ERI_MCTLSTS_PAUSE_STATE	(1 << 1)	/* transition to PAUSE state */
873*297a64e7Sgd78059 #define	ERI_MCTLSTS_NONPAUSE	(1 << 2)	/* change to non-PAUSE state */
874*297a64e7Sgd78059 #define	ERI_MCTLSTS_RESERVED	(0x1fff << 3)	/* 3-15: reserved */
875*297a64e7Sgd78059 #define	ERI_MCTLSTS_PAUSE_TIME	(0xffff0000)	/* 16-31: Pause time recvd */
876*297a64e7Sgd78059 
877*297a64e7Sgd78059 #define	ERI_MCTLSTS_PAUSE_TIME_SHIFT	16
878*297a64e7Sgd78059 
879*297a64e7Sgd78059 /*
880*297a64e7Sgd78059  * MAC Control Mask Register (RW)
881*297a64e7Sgd78059  * pause time is in slot-time units.
882*297a64e7Sgd78059  */
883*297a64e7Sgd78059 #define	ERI_MCTLMASK_PAUSE_RCVD	(1 << 0)	/* PAUSE received */
884*297a64e7Sgd78059 #define	ERI_MCTLMASK_PAUSE_STATE (1 << 1)	/* transition to PAUSE state */
885*297a64e7Sgd78059 #define	ERI_MCTLMASK_NONPAUSE	(1 << 2)	/* change to non-PAUSE state */
886*297a64e7Sgd78059 #define	ERI_MCTLMASK_RESERVED	(0x1fff << 3)	/* 3-15: reserved */
887*297a64e7Sgd78059 #define	ERI_MCTLMASK_PAUSE_TIME	(0xffff << 16)	/* 16-31: Pause time recvd */
888*297a64e7Sgd78059 
889*297a64e7Sgd78059 #define	ERI_MACCTL_INTR_MASK	0x00000000
890*297a64e7Sgd78059 
891*297a64e7Sgd78059 /*
892*297a64e7Sgd78059  * XIF Configuration Register
893*297a64e7Sgd78059  * This register determines the parameters that control the operation of the
894*297a64e7Sgd78059  * transceiver interface.
895*297a64e7Sgd78059  * The Disable-echo bit should be 0 for full-duplex mode.
896*297a64e7Sgd78059  * Default: 0x00
897*297a64e7Sgd78059  */
898*297a64e7Sgd78059 
899*297a64e7Sgd78059 #define	BMAC_XIFC_TX_MII_OE	(1 << 0)	/* Enable XIF output drivers */
900*297a64e7Sgd78059 #define	BMAC_XIFC_MIILPBK	(1 << 1)	/* Enable MII Loopback mode */
901*297a64e7Sgd78059 #define	BMAC_XIFC_DIS_ECHO	(1 << 2)	/* Disable echo */
902*297a64e7Sgd78059 #define	BMAC_XIFC_MII_MODE	(1 << 3)	/* Selects GMII/MII mode */
903*297a64e7Sgd78059 #define	BMAC_XIFC_MIIBUF_OE	(1 << 4)	/* Enable MII Recv Buffers */
904*297a64e7Sgd78059 #define	BMAC_XIFC_LINK_LED	(1 << 5)	/* force LINKLED# active */
905*297a64e7Sgd78059 #define	BMAC_XIFC_FDPLX_LED	(1 << 6)	/* force FDPLXLED# active */
906*297a64e7Sgd78059 
907*297a64e7Sgd78059 /*
908*297a64e7Sgd78059  * TX_MAC Configuration Register
909*297a64e7Sgd78059  * Ignore_Carrier_Sense should be set to 1 for full-duplex operation and
910*297a64e7Sgd78059  * cleared to 0 for half-duplex operation..
911*297a64e7Sgd78059  * Ignore_collisions should be set to 1 for full-duplex operation and cleared
912*297a64e7Sgd78059  * to 0 for half-duplex operation..
913*297a64e7Sgd78059  * To Ensure proper operation of the TX_MAC, the TX_MAC_Enable bit must always
914*297a64e7Sgd78059  * be cleared to 0 and a delay imposed before a PIO write to any of the other
915*297a64e7Sgd78059  * bits in the TX_MAC Configuration register or any of the MAC parameter
916*297a64e7Sgd78059  * registers is done.
917*297a64e7Sgd78059  * The amount of delay required depends on the time required to transmit a max.
918*297a64e7Sgd78059  * size frame.
919*297a64e7Sgd78059  * Default: TBD
920*297a64e7Sgd78059  */
921*297a64e7Sgd78059 
922*297a64e7Sgd78059 #define	BMACTXRSTDELAY		(125)		/* 125 us wait period */
923*297a64e7Sgd78059 /* CHECK */
924*297a64e7Sgd78059 
925*297a64e7Sgd78059 #define	BMAC_TXCFG_ENAB		(1 << 0)	/* tx enable */
926*297a64e7Sgd78059 #define	BMAC_TXCFG_IGNCS	(1 << 1)	/* Ignore carrier sense */
927*297a64e7Sgd78059 #define	BMAC_TXCFG_IGCOLL	(1 << 2)	/* Ignore collisions */
928*297a64e7Sgd78059 #define	BMAC_TXCFG_ENIPG0	(1 << 3)	/* Extend Rx-to-Tx IPG */
929*297a64e7Sgd78059 #define	BMAC_TXCFG_NGU		(1 << 4)	/* Never Give Up */
930*297a64e7Sgd78059 #define	BMAC_TXCFG_NGU_LIMIT	(1 << 5)	/* Never Give Up limit */
931*297a64e7Sgd78059 #define	BMAC_TXCFG_NBKOFF	(1 << 6)	/* No Backoff */
932*297a64e7Sgd78059 #define	BMAC_TXCFG_SLOWDOWN	(1 << 7)	/* Slow down */
933*297a64e7Sgd78059 #define	BMAC_TXCFG_NFCS		(1 << 8)	/* no FCS will be generated */
934*297a64e7Sgd78059 #define	BMAC_TXCFG_CARR_EXT	(1 << 9)
935*297a64e7Sgd78059 			/*
936*297a64e7Sgd78059 			 * Enable TX Carrier Extension Carrier Extension is
937*297a64e7Sgd78059 			 * required for half-duplex operation at Gbps
938*297a64e7Sgd78059 			 */
939*297a64e7Sgd78059 
940*297a64e7Sgd78059 #define	BMAC_TXCFG_FDX	(BMAC_TXCFG_IGNCS | BMAC_TXCFG_IGCOLL)
941*297a64e7Sgd78059 
942*297a64e7Sgd78059 /*
943*297a64e7Sgd78059  * RX_MAC Configuration Register
944*297a64e7Sgd78059  * A delay of 3.2 ms should be allowed after clearing Rx_MAC_Enable or
945*297a64e7Sgd78059  * Hash_Filter_enable or Address_Filter_Enable bits.
946*297a64e7Sgd78059  * Default: TBD
947*297a64e7Sgd78059  */
948*297a64e7Sgd78059 /* CHECK 3ms or us */
949*297a64e7Sgd78059 /* GEM specification: 3.2msec (3200 usec) */
950*297a64e7Sgd78059 
951*297a64e7Sgd78059 #define	BMACRXRSTDELAY		(3200)		/* 3.2 ms wait period */
952*297a64e7Sgd78059 
953*297a64e7Sgd78059 #define	BMAC_RXCFG_ENAB		(1 << 0)	/* rx enable */
954*297a64e7Sgd78059 #define	BMAC_RXCFG_STRIP_PAD	(1 << 1)	/* rx strip pad bytes */
955*297a64e7Sgd78059 #define	BMAC_RXCFG_STRIP_CRC	(1 << 2)	/* rx enable CRC stripping */
956*297a64e7Sgd78059 #define	BMAC_RXCFG_PROMIS	(1 << 3)	/* rx enable promiscous */
957*297a64e7Sgd78059 #define	BMAC_RXCFG_GRPROM	(1 << 4)	/* rx promiscuous group mode */
958*297a64e7Sgd78059 #define	BMAC_RXCFG_HASH		(1 << 5)	/* rx enable hash filter */
959*297a64e7Sgd78059 #define	BMAC_RXCFG_ADDR		(1 << 6)	/* rx enable address filter */
960*297a64e7Sgd78059 #define	BMAC_RXCFG_ERR		(1 << 7)	/* rx disable error checking */
961*297a64e7Sgd78059 #define	BMAC_RXCFG_CARR_EXT	(1 << 8)
962*297a64e7Sgd78059 			/*
963*297a64e7Sgd78059 			 * Enable RX Carrier Extension.
964*297a64e7Sgd78059 			 * Enables the reception of packet bursts
965*297a64e7Sgd78059 			 * generated by Carrier Extension with
966*297a64e7Sgd78059 			 * packet bursting senders
967*297a64e7Sgd78059 			 */
968*297a64e7Sgd78059 
969*297a64e7Sgd78059 /*
970*297a64e7Sgd78059  * MAC Control Configuration Register (RW)
971*297a64e7Sgd78059  * Default: 0x00
972*297a64e7Sgd78059  */
973*297a64e7Sgd78059 
974*297a64e7Sgd78059 #define	ERI_MCTLCFG_TXPAUSE	(1 << 0)	/* Send_PAUSE Enable */
975*297a64e7Sgd78059 #define	ERI_MCTLCFG_RXPAUSE	(1 << 1)	/* Receive_PAUSE Enable */
976*297a64e7Sgd78059 #define	ERI_MCTLCFG_PASSPAUSE	(1 << 2)	/* Pass PAUSE up */
977*297a64e7Sgd78059 
978*297a64e7Sgd78059 /*
979*297a64e7Sgd78059  * MAC Control Type Register (RW)
980*297a64e7Sgd78059  * This 16-bit register specifies the "type" field for the MAC Control frame.
981*297a64e7Sgd78059  * Default: 0x8808
982*297a64e7Sgd78059  */
983*297a64e7Sgd78059 
984*297a64e7Sgd78059 
985*297a64e7Sgd78059 /*
986*297a64e7Sgd78059  * MAC Address Registers 0, 1, 2
987*297a64e7Sgd78059  * Station's Normal peririty MAC address which must be a unicast address.
988*297a64e7Sgd78059  * 0 - [15:0], 1 - [31:16], 2 - [47:32]
989*297a64e7Sgd78059  */
990*297a64e7Sgd78059 
991*297a64e7Sgd78059 /*
992*297a64e7Sgd78059  * MAC Address Registers 3, 4, 5
993*297a64e7Sgd78059  * Station's Alternate MAC address which may be a unicast or multicast address.
994*297a64e7Sgd78059  * 3 - [15:0], 4 - [31:16], 5 - [47:32]
995*297a64e7Sgd78059  */
996*297a64e7Sgd78059 
997*297a64e7Sgd78059 /*
998*297a64e7Sgd78059  * MAC Address Registers 6, 7, 8
999*297a64e7Sgd78059  * Station's Control MAC address which must be the reserved multicast
1000*297a64e7Sgd78059  * address for MAC Control frames.
1001*297a64e7Sgd78059  * 6 - [15:0], 7 - [31:16], 8 - [47:32]
1002*297a64e7Sgd78059  */
1003*297a64e7Sgd78059 
1004*297a64e7Sgd78059 /*
1005*297a64e7Sgd78059  * MII Transceiver Interface
1006*297a64e7Sgd78059  *
1007*297a64e7Sgd78059  * The Management Interface (MIF) allows the host to program and collect status
1008*297a64e7Sgd78059  * from two transceivers connected to the MII. MIF supports three modes of
1009*297a64e7Sgd78059  * operation:
1010*297a64e7Sgd78059  *	1. Bit-Bang Mode
1011*297a64e7Sgd78059  *	   This mode is imlemented using three 1-bit registers: data, clock,
1012*297a64e7Sgd78059  *	   and output_enable.
1013*297a64e7Sgd78059  *
1014*297a64e7Sgd78059  *	2. Frame Mode
1015*297a64e7Sgd78059  *	   This mode is supported using one 32-bit register: Frame register.
1016*297a64e7Sgd78059  *	   The software loads the Frame Register with avalid instaruction
1017*297a64e7Sgd78059  *	   ("frame"), and polls the Valid Bit for completion.
1018*297a64e7Sgd78059  *
1019*297a64e7Sgd78059  *	3. Polling Mode
1020*297a64e7Sgd78059  *	   The Polling mechanism is used for detecting a status change in the
1021*297a64e7Sgd78059  *	   transceiver. When this mode is enabled, the MIF will continuously
1022*297a64e7Sgd78059  *	   poll a specified transceiver register and generate a maskable
1023*297a64e7Sgd78059  *	   interrupt when a status change is detected. This mode of operation
1024*297a64e7Sgd78059  *	   can only be used when the MIF is in the "Frame mode".
1025*297a64e7Sgd78059  *
1026*297a64e7Sgd78059  */
1027*297a64e7Sgd78059 
1028*297a64e7Sgd78059 struct mif {
1029*297a64e7Sgd78059 	uint32_t mif_bbclk;	/* 0x6200 (RW) MIF Bit Bang Clock */
1030*297a64e7Sgd78059 	uint32_t mif_bbdata;	/* 0x6204 (RW) MIF Bit Bang Data */
1031*297a64e7Sgd78059 	uint32_t mif_bbopenb;	/* 0x6208 (RW) MIF Bit Bang Output Enable */
1032*297a64e7Sgd78059 	uint32_t mif_frame;	/* 0x620C (RW) MIF Frame - ctl and data */
1033*297a64e7Sgd78059 	uint32_t mif_cfg;	/* 0x6210 (RW) MIF Configuration */
1034*297a64e7Sgd78059 	uint32_t mif_imask;	/* 0x6214 (RW) MIF Interrupt mask */
1035*297a64e7Sgd78059 	uint32_t mif_bsts;	/* 0x6218 (R-AC) MIF Basic/Status register */
1036*297a64e7Sgd78059 	uint32_t mif_fsm;	/* 0x621C (RO) MIF State machine register */
1037*297a64e7Sgd78059 };
1038*297a64e7Sgd78059 
1039*297a64e7Sgd78059 /*
1040*297a64e7Sgd78059  * mif_bbclk - Bit Bang Clock register
1041*297a64e7Sgd78059  */
1042*297a64e7Sgd78059 #define	ERI_MIF_BBCLK	(1 << 0);	/* Bit Babg Clock */
1043*297a64e7Sgd78059 
1044*297a64e7Sgd78059 #define	ERI_BBCLK_LOW 0
1045*297a64e7Sgd78059 #define	ERI_BBCLK_HIGH 1
1046*297a64e7Sgd78059 
1047*297a64e7Sgd78059 /* mif_bbdata - bit Bang Data register */
1048*297a64e7Sgd78059 #define	ERI_MIF_BBDATA	(1 << 0);	/* Bit Bang Data */
1049*297a64e7Sgd78059 
1050*297a64e7Sgd78059 /* mif_bbopenb - Bit Bang oOutput Enable register */
1051*297a64e7Sgd78059 #define	ERI_MIF_BBOPENB	(1 << 0);	/* Bit Bang output Enable */
1052*297a64e7Sgd78059 
1053*297a64e7Sgd78059 /*
1054*297a64e7Sgd78059  * Management Frame Structure:
1055*297a64e7Sgd78059  * <IDLE> <ST><OP><PHYAD><REGAD><TA>	 <DATA>		   <IDLE>
1056*297a64e7Sgd78059  * READ:  <01><10><AAAAA><RRRRR><Z0><DDDDDDDDDDDDDDDD>
1057*297a64e7Sgd78059  * WRITE: <01><01><AAAAA><RRRRR><10><DDDDDDDDDDDDDDDD>
1058*297a64e7Sgd78059  */
1059*297a64e7Sgd78059 
1060*297a64e7Sgd78059 /*
1061*297a64e7Sgd78059  * mif_frame - MIF control and data register
1062*297a64e7Sgd78059  */
1063*297a64e7Sgd78059 #define	ERI_MIF_FRDATA	(0xffff << 0)	/* 0-15 : data bits */
1064*297a64e7Sgd78059 #define	ERI_MIF_FRTA0	(0x1 << 16)	/* 16 : TA bit, 1 for completion */
1065*297a64e7Sgd78059 #define	ERI_MIF_FRTA1	(0x1 << 17)	/* 16-17 : TA bits */
1066*297a64e7Sgd78059 #define	ERI_MIF_FRREGAD	(0x1f << 18)	/* 18-22 : register address bits */
1067*297a64e7Sgd78059 #define	ERI_MIF_FRPHYAD	(0x1f << 23)	/* 23-27 : PHY ad, should be 0 */
1068*297a64e7Sgd78059 #define	ERI_MIF_FROP	(0x3 << 28)	/* 28-29 : Operation - Write/Read */
1069*297a64e7Sgd78059 #define	ERI_MIF_FRST	(0xc0000000)	/* 30-31 : START bits */
1070*297a64e7Sgd78059 
1071*297a64e7Sgd78059 #define	ERI_MIF_FRREGAD_SHIFT	18
1072*297a64e7Sgd78059 #define	ERI_MIF_FRPHYAD_SHIFT	23
1073*297a64e7Sgd78059 #define	ERI_MIF_FRREAD		0x60020000
1074*297a64e7Sgd78059 #define	ERI_MIF_FRWRITE		0x50020000
1075*297a64e7Sgd78059 
1076*297a64e7Sgd78059 /*
1077*297a64e7Sgd78059  * maximum delay for MIF Register Read/Write operation
1078*297a64e7Sgd78059  */
1079*297a64e7Sgd78059 #define	ERI_MAX_MIF_DELAY	(100)
1080*297a64e7Sgd78059 
1081*297a64e7Sgd78059 /*
1082*297a64e7Sgd78059  * maximum delay for Transceiver Reset
1083*297a64e7Sgd78059  */
1084*297a64e7Sgd78059 #define	ERI_PHYRST_MAXDELAY	(500)
1085*297a64e7Sgd78059 #define	ERI_PCS_PHYRST_MAXDELAY	(500)
1086*297a64e7Sgd78059 
1087*297a64e7Sgd78059 /*
1088*297a64e7Sgd78059  * mif_cfg - MIF Configuration Register
1089*297a64e7Sgd78059  */
1090*297a64e7Sgd78059 #define	ERI_MIF_CFGPS	(1 << 0)	/* PHY Select */
1091*297a64e7Sgd78059 #define	ERI_MIF_CFGPE	(1 << 1)	/* Poll Enable */
1092*297a64e7Sgd78059 #define	ERI_MIF_CFGBB	(1 << 2)	/* Bit Bang Enable */
1093*297a64e7Sgd78059 #define	ERI_MIF_CFGPR	(0x1f << 3)	/* Poll Register address */
1094*297a64e7Sgd78059 #define	ERI_MIF_CFGM0	(1 << 8)	/* MDIO_0 Data / MDIO_0 attached */
1095*297a64e7Sgd78059 #define	ERI_MIF_CFGM1	(1 << 9)	/* MDIO_1 Data / MDIO_1 attached */
1096*297a64e7Sgd78059 #define	ERI_MIF_CFGPD	(0x1f << 10)	/* Poll Device PHY address */
1097*297a64e7Sgd78059 
1098*297a64e7Sgd78059 #define	ERI_MIF_CFGPR_SHIFT	3
1099*297a64e7Sgd78059 #define	ERI_MIF_CFGPD_SHIFT	10
1100*297a64e7Sgd78059 #define	ERI_MIF_POLL_DELAY	200
1101*297a64e7Sgd78059 
1102*297a64e7Sgd78059 /*
1103*297a64e7Sgd78059  * MDIO_0 corresponds to the On Board Transceiver.
1104*297a64e7Sgd78059  * MDIO_1 corresponds to the External Transceiver.
1105*297a64e7Sgd78059  * The PHYAD for both is 0.
1106*297a64e7Sgd78059  */
1107*297a64e7Sgd78059 #define	ERI_INTERNAL_PHYAD	1	/* PHY address for int. transceiver */
1108*297a64e7Sgd78059 #define	ERI_EXTERNAL_PHYAD	0	/* PHY address for ext. transceiver */
1109*297a64e7Sgd78059 #define	ERI_NOXCVR_PHYAD	99	/* PHY address for no   transceiver */
1110*297a64e7Sgd78059 
1111*297a64e7Sgd78059 
1112*297a64e7Sgd78059 /* mif_imask - MIF Interrupt Mask Register */
1113*297a64e7Sgd78059 /*
1114*297a64e7Sgd78059  * This register is bit-to-bit same as Basic/Status Register
1115*297a64e7Sgd78059  */
1116*297a64e7Sgd78059 #define	ERI_MIF_INTMASK	(0xffff << 0)	/* 0-15 : Interrupt mask */
1117*297a64e7Sgd78059 
1118*297a64e7Sgd78059 /* mif_bassts - MIF Basic - Status register */
1119*297a64e7Sgd78059 /*
1120*297a64e7Sgd78059  * The Basic portion of this register indicates the last value of the register
1121*297a64e7Sgd78059  * read indicated in the POLL REG field of the Configuration Register.
1122*297a64e7Sgd78059  * The Status portion indicates bit(s) that have changed.
1123*297a64e7Sgd78059  * The MIF Mask register is corresponding to this register in terms of the
1124*297a64e7Sgd78059  * bit(s) that need to be masked for generating interrupt on the MIF Interrupt
1125*297a64e7Sgd78059  * Bit of the Global Status Rgister.
1126*297a64e7Sgd78059  */
1127*297a64e7Sgd78059 
1128*297a64e7Sgd78059 #define	ERI_MIF_STATUS	(0xffff << 0)	/* 0-15 : Status */
1129*297a64e7Sgd78059 #define	ERI_MIF_BASIC	(0xffff << 16)	/* 16-31 : Basic register */
1130*297a64e7Sgd78059 
1131*297a64e7Sgd78059 /* mif_fsm - MIF State Machine register */
1132*297a64e7Sgd78059 
1133*297a64e7Sgd78059 #define	ERI_MIF_FSM	(0x3ff << 0)  /* 0-9 : MIF state */
1134*297a64e7Sgd78059 
1135*297a64e7Sgd78059 /*
1136*297a64e7Sgd78059  * ERI PCS/Serial-Link
1137*297a64e7Sgd78059  */
1138*297a64e7Sgd78059 struct pcslink {
1139*297a64e7Sgd78059 	uint32_t pcs_ctl;	/* 0x9000 (RW) PCS MII Control Reg */
1140*297a64e7Sgd78059 	uint32_t pcs_sts;	/* 0x9004 (RO) PCS MII Status Register */
1141*297a64e7Sgd78059 	uint32_t pcs_anar;	/* 0x9008 (RW) PCS MII Avertisement Reg */
1142*297a64e7Sgd78059 	uint32_t pcs_anlpar;    /* 0x900C (RW) PCS MII LP Ability Reg */
1143*297a64e7Sgd78059 	uint32_t pcs_cfg;	/* 0x9010 (RW) PCS Configuration Register */
1144*297a64e7Sgd78059 	uint32_t pcs_smr;	/* 0x9014 (RW) PCS State Machine Reg */
1145*297a64e7Sgd78059 	uint32_t pcs_intsts;    /* 0x9018 (R-AC) PCS Interrupt Status Reg */
1146*297a64e7Sgd78059 	uint32_t res1[13];	/* 0x901C - 0x904C Reserved */
1147*297a64e7Sgd78059 	uint32_t pcs_dmode;	/* 0x9050 (RW) Datapath mode register */
1148*297a64e7Sgd78059 	uint32_t slink_ctl;	/* 0x9054 (RW) Serial Link Control register */
1149*297a64e7Sgd78059 	uint32_t pcs_opsel;	/* 0x9058 (RW) Shared Output Select register */
1150*297a64e7Sgd78059 	uint32_t slink_sts;	/* 0x905C (RO) Serial Link Status register */
1151*297a64e7Sgd78059 };
1152*297a64e7Sgd78059 
1153*297a64e7Sgd78059 /*
1154*297a64e7Sgd78059  *  PCS MII	 Basic Mode Control Register
1155*297a64e7Sgd78059  * Auto-Negotiation should always be used for 802.3z 8B/10B
1156*297a64e7Sgd78059  * link configuration. May be cleared for diagnostic purposes, or
1157*297a64e7Sgd78059  * as a workaround for possible early product interoperability problems.
1158*297a64e7Sgd78059  */
1159*297a64e7Sgd78059 
1160*297a64e7Sgd78059 #define	PCS_BMCR_RESET	(1 << 15)	/* Resets the PCS when set */
1161*297a64e7Sgd78059 #define	PCS_BMCR_LPBK	(1 << 14)	/* Loopback of the 10-bit i/f */
1162*297a64e7Sgd78059 #define	PCS_BMCR_1000M	(1 << 13)	/* Speed selection, always 0 */
1163*297a64e7Sgd78059 #define	PCS_BMCR_ANE	(1 << 12)	/* Auto Negotiation Enabled when set */
1164*297a64e7Sgd78059 #define	PCS_BMCR_PWRDN	(1 << 11)	/* Power down, always 0 */
1165*297a64e7Sgd78059 #define	PCS_BMCR_ISOLATE (1 << 10)	/* Isolate PHY from MII, always 0 */
1166*297a64e7Sgd78059 #define	PCS_BMCR_RAN	(1 << 9)	/* Set to Restart Auto Negotiation */
1167*297a64e7Sgd78059 #define	PCS_BMCR_FDX	(1 << 8)	/* Full Duplex, always 0 */
1168*297a64e7Sgd78059 #define	PCS_BMCR_COLTST	(1 << 7)	/* Collision Test */
1169*297a64e7Sgd78059 #define	PCS_BMCR_RES1	(0x7f << 0)	/* 0-6 Reserved */
1170*297a64e7Sgd78059 
1171*297a64e7Sgd78059 #define	PCS_AUTONEG_DISABLE	0
1172*297a64e7Sgd78059 
1173*297a64e7Sgd78059 /*
1174*297a64e7Sgd78059  * ------------------------------------------------------------------------
1175*297a64e7Sgd78059  * PCS MII	 Basic Mode Status Register
1176*297a64e7Sgd78059  * -------------------------------------------------------------------------
1177*297a64e7Sgd78059  */
1178*297a64e7Sgd78059 
1179*297a64e7Sgd78059 
1180*297a64e7Sgd78059 #define	PCS_BMSR_RES2	(0x1f << 11)	/* 11-15 reserved, always 0 */
1181*297a64e7Sgd78059 #define	PCS_BMSR_GBFDX	(1 << 10)	/* PCS able to perform GBit FDX */
1182*297a64e7Sgd78059 #define	PCS_BMSR_GBHDX	(1 << 9)	/* PCS able to perform Gbit HDX */
1183*297a64e7Sgd78059 #define	PCS_BMSR_RES1	(0x7 << 6)	/* 6-8 reserved */
1184*297a64e7Sgd78059 #define	PCS_BMSR_ANC	(1 << 5)	/* Auto Negotiation Completed */
1185*297a64e7Sgd78059 #define	PCS_BMSR_REMFLT	(1 << 4)	/* Remote Fault detected */
1186*297a64e7Sgd78059 #define	PCS_BMSR_ACFG	(1 << 3)	/* Able to do Auto Link Negotiation,1 */
1187*297a64e7Sgd78059 #define	PCS_BMSR_LNKSTS	(1 << 2)	/* Link Status */
1188*297a64e7Sgd78059 #define	PCS_BMSR_JABDET	(1 << 1)	/* Jabber Condition Detected, 0 */
1189*297a64e7Sgd78059 #define	PCS_BMSR_EXTCAP	(1 << 0)	/* Extended Register Capability, 0 */
1190*297a64e7Sgd78059 
1191*297a64e7Sgd78059 #define	PCS_CAPABILITY_MASK (PCS_BMSR_GBFDX | PCS_BMSR_GBHDX)
1192*297a64e7Sgd78059 
1193*297a64e7Sgd78059 
1194*297a64e7Sgd78059 /*
1195*297a64e7Sgd78059  * ------------------------------------------------------------------------
1196*297a64e7Sgd78059  * PCS MII	Auto-Negotiation Advertisement Register (nway1Reg)
1197*297a64e7Sgd78059  * This register will hold the different modes of operation to be advertised to
1198*297a64e7Sgd78059  * the far-end PHY.
1199*297a64e7Sgd78059  * -------------------------------------------------------------------------
1200*297a64e7Sgd78059  */
1201*297a64e7Sgd78059 
1202*297a64e7Sgd78059 #define	PCS_ANAR_NP	(1 << 15)	/* Next Page bit, RO, always 0 */
1203*297a64e7Sgd78059 #define	PCS_ANAR_ACK	(1 << 14)	/* Acks reception of Link Partner */
1204*297a64e7Sgd78059 					/* Capability word  */
1205*297a64e7Sgd78059 #define	PCS_ANAR_RF	(0x2 << 12)	/* Advertise Remote Fault det. cap. */
1206*297a64e7Sgd78059 #define	PCS_ANAR_RES1	(0x7 << 9)	/* 9-11 reserved */
1207*297a64e7Sgd78059 #define	PCS_ANAR_PTX	(1 << 8)	/* Pause TX */
1208*297a64e7Sgd78059 #define	PCS_ANAR_PRX	(1 << 7)	/* Pause RX */
1209*297a64e7Sgd78059 #define	PCS_ANAR_PAUSE	(1 << 7)	/* Pause  */
1210*297a64e7Sgd78059 #define	PCS_ANAR_ASM_DIR	(1 << 8)	/* Asymetric Direction */
1211*297a64e7Sgd78059 #define	PCS_ANAR_GBFDX	(1 << 5)	/* Advertise Gbit FDX Capability */
1212*297a64e7Sgd78059 #define	PCS_ANAR_GBHDX	(1 << 6)	/* Advertise Gbit HDX Capability */
1213*297a64e7Sgd78059 #define	PCS_ANAR_RES	(0x1f << 0)	/* 0-5 Reserved */
1214*297a64e7Sgd78059 
1215*297a64e7Sgd78059 
1216*297a64e7Sgd78059 /* ************************************************************************ */
1217*297a64e7Sgd78059 /*
1218*297a64e7Sgd78059  * PCS MII	 Auto-Negotiation Link Partner Ability Reg
1219*297a64e7Sgd78059  * This register contains the Link Partners capabilities after NWay
1220*297a64e7Sgd78059  * Auto-Negotiation is complete.
1221*297a64e7Sgd78059  */
1222*297a64e7Sgd78059 
1223*297a64e7Sgd78059 #define	PCS_ANLPAR_NP	(1 << 15)	/* Next Page bit, RO, always 0 */
1224*297a64e7Sgd78059 #define	PCS_ANLPAR_ACK	(1 << 14)	/* Acks reception of Link Partner */
1225*297a64e7Sgd78059 					/* Capability word  */
1226*297a64e7Sgd78059 #define	PCS_ANLPAR_RF	(0x2 << 12)	/* Advertise Remote Fault det. cap. */
1227*297a64e7Sgd78059 #define	PCS_ANLPAR_RES1	(0x7 << 9)	/* 9-11 reserved */
1228*297a64e7Sgd78059 #define	PCS_ANLPAR_PTX	(1 << 8)	/* Pause TX */
1229*297a64e7Sgd78059 #define	PCS_ANLPAR_PRX	(1 << 7)	/* Pause RX */
1230*297a64e7Sgd78059 #define	PCS_ANLPAR_GBFDX (1 << 5)	/* Advertise Gbit FDX Capability */
1231*297a64e7Sgd78059 #define	PCS_ANLPAR_GBHDX (1 << 6)	/* Advertise Gbit HDX Capability */
1232*297a64e7Sgd78059 #define	PCS_ANLPAR_RES	(0x1f << 0)	/* 0-5 Reserved */
1233*297a64e7Sgd78059 
1234*297a64e7Sgd78059 
1235*297a64e7Sgd78059 /*
1236*297a64e7Sgd78059  * ------------------------------------------------------------------------
1237*297a64e7Sgd78059  * PCS Configuration Register
1238*297a64e7Sgd78059  * Default = 0x8
1239*297a64e7Sgd78059  * -------------------------------------------------------------------------
1240*297a64e7Sgd78059  */
1241*297a64e7Sgd78059 
1242*297a64e7Sgd78059 #define	PCS_CFG_RES	(0xfff << 4)	/* 4-15 Reserved */
1243*297a64e7Sgd78059 #define	PCS_CFG_TIMER	(0x7 << 1)
1244*297a64e7Sgd78059 	/* Timer values used for the 802.3z Clause 36 Link Monitor s/m timers */
1245*297a64e7Sgd78059 #define	PCS_CFG_ENABLE	(1 << 0)	/* Enable PCS, when set to 1 */
1246*297a64e7Sgd78059 
1247*297a64e7Sgd78059 
1248*297a64e7Sgd78059 /*
1249*297a64e7Sgd78059  * ------------------------------------------------------------------------
1250*297a64e7Sgd78059  * PCS Interrupt State Register
1251*297a64e7Sgd78059  * Presently only one bit is implemented, reflecting transitions on the link
1252*297a64e7Sgd78059  * status. Note that there is no mask register at this level.
1253*297a64e7Sgd78059  * THe PCS_INT bit may be masked at the Interrupt Status Register level.
1254*297a64e7Sgd78059  * -------------------------------------------------------------------------
1255*297a64e7Sgd78059  */
1256*297a64e7Sgd78059 
1257*297a64e7Sgd78059 #define	PCS_STS_LNKSTS	2	/* Link Status Change */
1258*297a64e7Sgd78059 
1259*297a64e7Sgd78059 
1260*297a64e7Sgd78059 /*
1261*297a64e7Sgd78059  * ------------------------------------------------------------------------
1262*297a64e7Sgd78059  * Datapath Mode Register (RW)
1263*297a64e7Sgd78059  * This register controls which network interface is used.
1264*297a64e7Sgd78059  * Only one bit should be set in this register.
1265*297a64e7Sgd78059  * Default: 0x1
1266*297a64e7Sgd78059  * -------------------------------------------------------------------------
1267*297a64e7Sgd78059  */
1268*297a64e7Sgd78059 /*
1269*297a64e7Sgd78059  * Select MII/GMII and not PCS.
1270*297a64e7Sgd78059  * Selection between MII and GMII is
1271*297a64e7Sgd78059  * controlled by the XIF register
1272*297a64e7Sgd78059  */
1273*297a64e7Sgd78059 #define	ERI_PCS_MII	(1 << 2)
1274*297a64e7Sgd78059 /*
1275*297a64e7Sgd78059  * Applicable only in Serial Mode
1276*297a64e7Sgd78059  * When set, makes the 10-bit Xmit data
1277*297a64e7Sgd78059  * visible at the GMII
1278*297a64e7Sgd78059  */
1279*297a64e7Sgd78059 #define	ERI_PCS_GMIIOUTEN (1 << 3)
1280*297a64e7Sgd78059 
1281*297a64e7Sgd78059 
1282*297a64e7Sgd78059 /*
1283*297a64e7Sgd78059  * ------------------------------------------------------------------------
1284*297a64e7Sgd78059  * Serial Link Control register (RW)
1285*297a64e7Sgd78059  * This register controls the Serial link
1286*297a64e7Sgd78059  * Default: 0x000
1287*297a64e7Sgd78059  * -------------------------------------------------------------------------
1288*297a64e7Sgd78059  */
1289*297a64e7Sgd78059 #define	ERI_SLC_LOOPBACK (1 << 0)	/* Enables loopback at the SL o/p */
1290*297a64e7Sgd78059 #define	ERI_SLC_ENSYNCDT (1 << 1)	/* Enable Sync char detection */
1291*297a64e7Sgd78059 #define	ERI_SLC_LOCKREF	(1 << 2)	/* Lock to reference clock */
1292*297a64e7Sgd78059 #define	ERI_SLC_EMP	(0x2 << 3)	/* Control o/p driver emphasis */
1293*297a64e7Sgd78059 #define	ERI_SLC_RES	(1 << 5)	/* Reserved */
1294*297a64e7Sgd78059 #define	ERI_SLC_SELFTEST (0x7 << 6)	/* To select built-in self tests */
1295*297a64e7Sgd78059 #define	ERI_SLC_SW_PDOWN (1 << 9)	/* Power down Serial link block */
1296*297a64e7Sgd78059 
1297*297a64e7Sgd78059 /*
1298*297a64e7Sgd78059  * ------------------------------------------------------------------------
1299*297a64e7Sgd78059  * Shared Output Select Register (RW)
1300*297a64e7Sgd78059  * Default: 0x00
1301*297a64e7Sgd78059  * -------------------------------------------------------------------------
1302*297a64e7Sgd78059  */
1303*297a64e7Sgd78059 
1304*297a64e7Sgd78059 /*
1305*297a64e7Sgd78059  * ------------------------------------------------------------------------
1306*297a64e7Sgd78059  * Serial Link State Register (RO)
1307*297a64e7Sgd78059  * Indicates the progress of the Serial link boot up
1308*297a64e7Sgd78059  * 00 - Undergoing test
1309*297a64e7Sgd78059  * 01 - Waiting 500us while lockrefn is asserted
1310*297a64e7Sgd78059  * 10 - Waiting for comma detect
1311*297a64e7Sgd78059  * 11 - Receive Data is synchronized
1312*297a64e7Sgd78059  * -------------------------------------------------------------------------
1313*297a64e7Sgd78059  */
1314*297a64e7Sgd78059 #define	ERI_SLS_STATE	(0x2 << 0)	/* state */
1315*297a64e7Sgd78059 
1316*297a64e7Sgd78059 
1317*297a64e7Sgd78059 
1318*297a64e7Sgd78059 /* ************************************************************************ */
1319*297a64e7Sgd78059 /*
1320*297a64e7Sgd78059  * Definition for the time required to wait after a software
1321*297a64e7Sgd78059  * reset has been issued.
1322*297a64e7Sgd78059  */
1323*297a64e7Sgd78059 #define	ERI_MAX_RST_DELAY	(200)
1324*297a64e7Sgd78059 #define	ERI_PERIOD	(20)	/* period to wait */
1325*297a64e7Sgd78059 #define	ERI_WAITPERIOD	ERI_PERIOD
1326*297a64e7Sgd78059 
1327*297a64e7Sgd78059 #define	ERI_DELAY(c, n) \
1328*297a64e7Sgd78059 	{ \
1329*297a64e7Sgd78059 		register int N = n / ERI_WAITPERIOD; \
1330*297a64e7Sgd78059 		while (--N > 0) { \
1331*297a64e7Sgd78059 			if (c) \
1332*297a64e7Sgd78059 				break; \
1333*297a64e7Sgd78059 			drv_usecwait(ERI_WAITPERIOD); \
1334*297a64e7Sgd78059 		} \
1335*297a64e7Sgd78059 	}
1336*297a64e7Sgd78059 
1337*297a64e7Sgd78059 #define	MIF_ERIDELAY(n, phyad, regad) \
1338*297a64e7Sgd78059 	{ \
1339*297a64e7Sgd78059 		register int N = n / ERI_WAITPERIOD; \
1340*297a64e7Sgd78059 		PUT_MIFREG(mif_frame, \
1341*297a64e7Sgd78059 			(ERI_MIF_FRREAD | (phyad << ERI_MIF_FRPHYAD_SHIFT) | \
1342*297a64e7Sgd78059 			(regad << ERI_MIF_FRREGAD_SHIFT))); \
1343*297a64e7Sgd78059 		while (--N > 0) { \
1344*297a64e7Sgd78059 			if (GET_MIFREG(mif_frame) & ERI_MIF_FRTA0) \
1345*297a64e7Sgd78059 				break; \
1346*297a64e7Sgd78059 			drv_usecwait(ERI_WAITPERIOD); \
1347*297a64e7Sgd78059 		} \
1348*297a64e7Sgd78059 	}
1349*297a64e7Sgd78059 
1350*297a64e7Sgd78059 
1351*297a64e7Sgd78059 #ifdef	__cplusplus
1352*297a64e7Sgd78059 }
1353*297a64e7Sgd78059 #endif
1354*297a64e7Sgd78059 
1355*297a64e7Sgd78059 #endif	/* _SYS_ERI_MAC_H */
1356