xref: /titanic_52/usr/src/uts/common/io/afe/afe.h (revision 0dc974a9a2e66d676505db23524ebff105fb36a9)
1 /*
2  * Solaris DLPI driver for ethernet cards based on the ADMtek Centaur
3  *
4  * Copyright (c) 2007 by Garrett D'Amore <garrett@damore.org>.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the author nor the names of any co-contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef	_AFE_H
33 #define	_AFE_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * These are conveniently defined to have the same values
43  * as are used by the NDD utility, which is an undocumented
44  * interface.  YMMV.
45  */
46 #define	NDIOC	('N' << 8)
47 #define	NDIOC_GET	(NDIOC|0)
48 #define	NDIOC_SET	(NDIOC|1)
49 
50 /*
51  * Registers and values are here, becuase they can be exported to userland
52  * via the AFEIOC_GETCSR and friends ioctls.  These are private to this
53  * driver and the bundled diagnostic utility, and should not be used by
54  * end user application programs.
55  */
56 
57 /*
58  * AFE register definitions.
59  */
60 /* PCI configuration registers */
61 #define	PCI_VID		0x00	/* Loaded vendor ID */
62 #define	PCI_DID		0x02	/* Loaded device ID */
63 #define	PCI_CMD		0x04	/* Configuration command register */
64 #define	PCI_STAT	0x06	/* Configuration status register */
65 #define	PCI_RID		0x08	/* Revision ID */
66 #define	PCI_CLS		0x0c	/* Cache line size */
67 #define	PCI_SVID	0x2c	/* Subsystem vendor ID */
68 #define	PCI_SSID	0x2e	/* Subsystem ID */
69 #define	PCI_MINGNT	0x3e	/* Minimum Grant */
70 #define	PCI_MAXLAT	0x3f	/* Maximum latency */
71 #define	PCI_SIG		0x80	/* Signature of AN983 */
72 #define	PCI_PMR0	0xc0	/* Power Management Register 0 */
73 #define	PCI_PMR1	0xc4	/* Power Management Register 1 */
74 
75 /*
76  * Bits for PCI command register.
77  */
78 #define	PCI_CMD_MWIE	0x0010	/* memory write-invalidate enable */
79 #define	PCI_CMD_BME	0x0004	/* bus master enable */
80 #define	PCI_CMD_MAE	0x0002	/* memory access enable */
81 #define	PCI_CMD_IOE	0x0001	/* I/O access enable */
82 
83 /*
84  * Signature values for PCI_SIG
85  */
86 #define	SIG_AN983	0x09811317
87 #define	SIG_AN985	0x09851317
88 #define	SIG_ADM9511	0x69851317
89 
90 /* Ordinary control/status registers */
91 #define	CSR_PAR		0x00	/* PCI access register */
92 #define	CSR_TDR		0x08	/* Transmit demand register */
93 #define	CSR_RDR		0x10	/* Receive demand register */
94 #define	CSR_RDB		0x18	/* Receive descriptor base address */
95 #define	CSR_TDB		0x20	/* Transmit descriptor base address */
96 #define	CSR_SR		0x28	/* Status register */
97 #define	CSR_NAR		0x30	/* Network access register */
98 #define	CSR_IER		0x38	/* Interrupt enable register */
99 #define	CSR_LPC		0x40	/* Lost packet counter */
100 #define	CSR_SPR		0x48	/* Serial port register */
101 #define	CSR_TIMER	0x58	/* Timer */
102 #define	CSR_SR2		0x80	/* Status register 2 */
103 #define	CSR_IER2	0x84	/* Interrupt enable register 2 */
104 #define	CSR_CR		0x88	/* Command register */
105 #define	CSR_PMCSR	0x90	/* Power Management Command and Status */
106 #define	CSR_PAR0	0xa4	/* Physical address register 0 */
107 #define	CSR_PAR1	0xa8	/* Physical address register 1 */
108 #define	CSR_MAR0	0xac	/* Multicast address hash table register 0 */
109 #define	CSR_MAR1	0xb0	/* Multicast address hash table register 1 */
110 #define	CSR_BMCR	0xb4	/* PHY BMCR (comet only) */
111 #define	CSR_BMSR	0xb8	/* PHY BMSR (comet only) */
112 #define	CSR_PHYIDR1	0xbc	/* PHY PHYIDR1 (comet only) */
113 #define	CSR_PHYIDR2	0xc0	/* PHY PHYIDR2 (comet only) */
114 #define	CSR_ANAR	0xc4	/* PHY ANAR (comet only) */
115 #define	CSR_ANLPAR	0xc8	/* PHY ANLPAR (comet only) */
116 #define	CSR_ANER	0xcc	/* PHY ANER (comet only) */
117 #define	CSR_XMC		0xd0	/* XCVR mode control (comet only) */
118 #define	CSR_XCIIS	0xd4	/* XCVR config info/int status (comet only) */
119 #define	CSR_XIE		0xd8	/* XCVR interupt enable (comet only) */
120 #define	CSR_OPM		0xfc	/* Opmode register (centaur only) */
121 
122 /*
123  * Bits for PCI access register.
124  */
125 #define	PAR_RESET	0x00000001U	/* Reset the entire chip */
126 #define	PAR_MWIE	0x01000000U	/* PCI memory-write-invalidate */
127 #define	PAR_MRLE	0x00800000U	/* PCI memory-read-line */
128 #define	PAR_MRME	0x00200000U	/* PCI memory-read-multiple */
129 #define	PAR_TXHIPRI	0x00000002U	/* Transmit higher priority */
130 #define	PAR_DESCSKIP	0x0000007cU	/* Descriptor skip length in DW */
131 #define	PAR_BIGENDIAN	0x00000080U	/* Use big endian data buffers */
132 #define	PAR_TXAUTOPOLL	0x00060000U	/* Programmable TX autopoll interval */
133 #define	PAR_RXFIFO_100	0x00009000U	/* RX FIFO control, Centaur only */
134 #define	PAR_RXFIFO_10	0x00002800U	/* RX FIFO control, Centaur only */
135 #define	PAR_CALIGN_NONE	0x00000000U	/* No cache alignment, Comet */
136 #define	PAR_CALIGN_8	0x00004000U	/* 8 DW cache alignment, Comet */
137 #define	PAR_CALIGN_16	0x00008000U	/* 16 DW cache alignment, Comet */
138 #define	PAR_CALIGN_32	0x0000c000U	/* 32 DW cache alignment, Comet */
139 #define	PAR_BURSTLEN	0x00003F00U	/* Programmable burst length, Comet */
140 #define	PAR_BURSTUNL	0x00000000U	/* Unlimited burst length, Comet */
141 #define	PAR_BURST_1	0x00000100U	/* 1 DW burst length, Comet */
142 #define	PAR_BURST_2	0x00000200U	/* 2 DW burst length, Comet */
143 #define	PAR_BURST_4	0x00000400U	/* 4 DW burst length, Comet */
144 #define	PAR_BURST_8	0x00000800U	/* 8 DW burst length, Comet */
145 #define	PAR_BURST_16	0x00001000U	/* 16 DW burst length, Comet */
146 #define	PAR_BURST_32	0x00002000U	/* 32 DW burst length, Comet */
147 
148 /*
149  * Bits for status register.
150  */
151 #define	SR_BERR_TYPE		0x03800000U	/* bus error type */
152 #define	SR_BERR_PARITY		0x00000000U	/* parity error */
153 #define	SR_BERR_TARGET_ABORT	0x01000000U	/* target abort */
154 #define	SR_BERR_MASTER_ABORT	0x00800000U	/* master abort */
155 #define	SR_TX_STATE		0x00700000U	/* transmit state */
156 #define	SR_RX_STATE		0x000E0000U	/* receive state */
157 
158 /*
159  * Interrupts.  These are in IER2 and SR2.  Some of them also appear
160  * in SR and IER, but we only use the ADMtek specific IER2 and SR2.
161  */
162 #define	INT_TXEARLY		0x80000000U	/* transmit early interrupt */
163 #define	INT_RXEARLY		0x40000000U	/* receive early interrupt */
164 #define	INT_LINKCHG		0x20000000U	/* link status changed */
165 #define	INT_TXDEFER		0x10000000U	/* transmit defer interrupt */
166 #define	INT_PAUSE		0x04000000U	/* pause frame received */
167 #define	INT_NORMAL		0x00010000U	/* normal interrupt */
168 #define	INT_ABNORMAL		0x00008000U	/* abnormal interrupt */
169 #define	INT_BUSERR		0x00002000U	/* fatal bus error */
170 #define	INT_TIMER		0x00000800U	/* onboard timer */
171 #define	INT_RXJABBER		0x00000200U	/* receive watchdog */
172 #define	INT_RXSTOPPED		0x00000100U	/* receive stopped */
173 #define	INT_RXNOBUF		0x00000080U	/* no rcv descriptor */
174 #define	INT_RXOK		0x00000040U	/* receive complete */
175 #define	INT_TXUNDERFLOW		0x00000020U	/* transmit underflow */
176 #define	INT_TXJABBER		0x00000008U	/* transmit jabber timeout */
177 #define	INT_TXNOBUF		0x00000004U	/* no xmt descriptor */
178 #define	INT_TXSTOPPED		0x00000002U	/* transmit stopped */
179 #define	INT_TXOK		0x00000001U	/* transmit ok interrupt */
180 
181 #define	INT_NONE		0x00000000U	/* no interrupts */
182 #define	INT_ALL			0xf401abefU	/* all interrupts */
183 #define	INT_WANTED		(INT_NORMAL | INT_ABNORMAL | \
184 				INT_BUSERR | INT_RXJABBER | \
185 				INT_RXOK | INT_RXNOBUF | \
186 				INT_TIMER | INT_LINKCHG | \
187 				INT_RXSTOPPED | INT_TXSTOPPED | \
188 				INT_TXUNDERFLOW | INT_TXJABBER)
189 
190 /*
191  * Bits for network access register.
192  */
193 #define	NAR_TX_ENABLE	0x00002000U	/* Enable transmit */
194 #define	NAR_RX_MULTI	0x00000080U	/* Receive all multicast packets */
195 #define	NAR_RX_PROMISC	0x00000040U	/* Receive any good packet */
196 #define	NAR_RX_BAD	0x00000008U	/* Pass bad packets */
197 #define	NAR_RX_ENABLE	0x00000002U	/* Enable receive */
198 #define	NAR_TR		0x0000c000U	/* Transmit threshold mask */
199 #define	NAR_TR_72	0x00000000U	/* 72 B (128 @ 100Mbps) tx thresh */
200 #define	NAR_TR_96	0x00004000U	/* 96 B (256 @ 100Mbps) tx thresh */
201 #define	NAR_TR_128	0x00008000U	/* 128 B (512 @ 100Mbps) tx thresh */
202 #define	NAR_TR_160	0x0000c000U	/* 160 B (1K @ 100Mbsp) tx thresh */
203 #define	NAR_SF		0x00200000U	/* store and forward */
204 #define	NAR_HBD		0x00080000U	/* Disable SQE heartbeat */
205 #define	NAR_FCOLL	0x00001000U	/* force collision */
206 #define	NAR_MODE	0x00000c00U	/* mode (loopback, etc.) */
207 #define	NAR_MACLOOP	0x00000400U	/* mac loop back */
208 
209 /*
210  * Bits for lost packet counter.
211  */
212 #define	LPC_COUNT	0x0000FFFFU	/* Count of missed frames */
213 #define	LPC_OFLOW	0x00010000U	/* Counter overflow bit */
214 
215 /*
216  * Bits for CSR_SPR (MII and SROM access)
217  */
218 #define	SPR_MII_DIN	0x00080000U	/* MII data input */
219 #define	SPR_MII_CTRL	0x00040000U	/* MII management control, 1=read */
220 #define	SPR_MII_DOUT	0x00020000U	/* MII data output */
221 #define	SPR_MII_CLOCK	0x00010000U	/* MII data clock */
222 #define	SPR_SROM_READ	0x00004000U	/* Serial EEPROM read control */
223 #define	SPR_SROM_WRITE	0x00002000U	/* Serial EEPROM write control */
224 #define	SPR_SROM_SEL	0x00000800U	/* Serial EEPROM select */
225 #define	SPR_SROM_DOUT	0x00000008U	/* Serial EEPROM data out */
226 #define	SPR_SROM_DIN	0x00000004U	/* Serial EEPROM data in */
227 #define	SPR_SROM_CLOCK	0x00000002U	/* Serial EEPROM clock */
228 #define	SPR_SROM_CHIP	0x00000001U	/* Serial EEPROM chip select */
229 #define	SROM_ENADDR		0x4	/* Offset of ethernet address */
230 #define	SROM_READCMD		0x6	/* command to read SROM */
231 
232 /*
233  * Bits for CSR_TIMER
234  */
235 #define	TIMER_LOOP	0x00010000U	/* continuous operating mode */
236 #define	TIMER_USEC		204		/* usecs per timer count */
237 
238 /*
239  * Bits for CSR_CR
240  */
241 #define	CR_TXURAUTOR	0x00000001U	/* transmit underrun auto recovery */
242 
243 /*
244  * Bits for XMC (Comet specific)
245  */
246 #define	XMC_LDIS	0x0800		/* long distance 10Base-T cable */
247 
248 /*
249  * Bits for XCIIS (Comet specific)
250  */
251 #define	XCIIS_SPEED		0x0200	/* 100 Mbps mode */
252 #define	XCIIS_DUPLEX		0x0100	/* full duplex mode */
253 #define	XCIIS_FLOWCTL		0x0080	/* flow control support */
254 #define	XCIIS_ANC		0x0040	/* autonegotiation complete */
255 #define	XCIIS_RF		0x0020	/* remote fault detected */
256 #define	XCIIS_LFAIL		0x0010	/* link fail */
257 #define	XCIIS_ANLPAR		0x0008	/* anar received from link partner */
258 #define	XCIIS_PDF		0x0004	/* parallel detection fault */
259 #define	XCIIS_ANPR		0x0002	/* autoneg. page received */
260 #define	XCIIS_REF		0x0001	/* receive error counter full */
261 
262 /*
263  * Bits for XIE (Comet specific)
264  */
265 #define	XIE_ANCE		0x0040	/* aneg complete interrupt enable */
266 #define	XIE_RFE			0x0020	/* remote fault interrupt enable */
267 #define	XIE_LDE			0x0010	/* link fail interrupt enable */
268 #define	XIE_ANAE		0x0008	/* aneg. ack. interrupt enable */
269 #define	XIE_PDFE		0x0004	/* parallel det. fault int. enable */
270 #define	XIE_ANPE		0x0002	/* autoneg. page rec'd int. enable */
271 #define	XIE_REFE		0x0001	/* receive error full int. enable */
272 
273 /*
274  * Centaur 1.1 extensions to MII.
275  */
276 #define	PHY_PILR	0x10		/* an983b 1.1 - polarity/int lvl */
277 #define	PHY_MCR		0x15		/* an983b 1.1 - mode control */
278 
279 #define	PILR_NOSQE	0x0800		/* disable 10BaseT SQE */
280 #define	MCR_FIBER	0x0001		/* enable fiber */
281 
282 /*
283  * Bits for Opmode (Centaur specific)
284  */
285 #define	OPM_SPEED	0x80000000U	/* 100 Mbps */
286 #define	OPM_DUPLEX	0x40000000U	/* full duplex */
287 #define	OPM_LINK	0x20000000U	/* link up? */
288 #define	OPM_MODE	0x00000007U	/* mode mask */
289 #define	OPM_INTPHY	0x00000007U	/* single chip mode, internal PHY */
290 #define	OPM_MACONLY	0x00000004U	/* MAC ony mode, external PHY */
291 
292 #ifdef	_KERNEL
293 /*
294  * Put exported kernel interfaces here.  (There should be none.)
295  */
296 #endif	/* _KERNEL */
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 #endif	/* _AFE_H */
303