xref: /netbsd/sys/dev/pci/if_casreg.h (revision 66a4ca44)
1 /*	$NetBSD: if_casreg.h,v 1.6 2022/05/28 10:36:23 andvar Exp $ */
2 /*	$OpenBSD: if_casreg.h,v 1.10 2008/05/31 22:49:03 kettenis Exp $	*/
3 
4 /*
5  *
6  * Copyright (C) 2007 Mark Kettenis.
7  * Copyright (C) 2001 Eduardo Horvath.
8  * All rights reserved.
9  *
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR  BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef	_IF_CASREG_H
35 #define	_IF_CASREG_H
36 
37 /*
38  * Register definitions for Sun Cassini ethernet controllers.
39  */
40 
41 /*
42  * First bank: these registers live at the start of the PCI mapping.
43  */
44 #define	CAS_SEB_STATE		0x0000	/* SEB state reg, R/O */
45 #define	CAS_CONFIG		0x0004	/* config reg */
46 #define	CAS_STATUS		0x000c	/* status reg */
47 /* Note: Reading the status reg clears bits 0-6 */
48 #define	CAS_INTMASK		0x0010
49 #define	CAS_INTACK		0x0014	/* Interrupt acknowledge, W/O */
50 #define	CAS_STATUS_ALIAS	0x001c
51 /* Note: Same as CAS_STATUS but reading it does not clear bits. */
52 
53 #define	CAS_ERROR_STATUS	0x1000  /* PCI error status R/C */
54 #define	CAS_ERROR_MASK		0x0004
55 #define	CAS_BIF_CONFIG		0x0008  /* BIF config reg */
56 #define	CAS_BIF_DIAG		0x000c
57 #define	CAS_RESET		0x1010  /* Software reset register */
58 #define	CAS_SATURN_PCFG		0x106c	/* internal MACPHY pin configuration */
59 
60 /* Bits in CAS_SEB register */
61 #define	CAS_SEB_ARB		0x000000002	/* Arbitration status */
62 #define	CAS_SEB_RXWON		0x000000004
63 
64 /* Bits in CAS_CONFIG register */
65 #define	CAS_CONFIG_BURST_64	0x000000000	/* 0->infinity, 1->64KB */
66 #define	CAS_CONFIG_BURST_INF	0x000000001	/* 0->infinity, 1->64KB */
67 #define	CAS_CONFIG_TXDMA_LIMIT	0x00000003e
68 #define	CAS_CONFIG_RXDMA_LIMIT	0x0000007c0
69 
70 #define	CAS_CONFIG_TXDMA_LIMIT_SHIFT	1
71 #define	CAS_CONFIG_RXDMA_LIMIT_SHIFT	6
72 
73 /* Top part of CAS_STATUS has TX completion information */
74 #define	CAS_STATUS_TX_COMPL	0xfff800000	/* TX completion reg. */
75 
76 /*
77  * Interrupt bits, for both the CAS_STATUS and CAS_INTMASK regs.
78  * Bits 0-6 auto-clear when read.
79  */
80 #define	CAS_INTR_TX_INTME	0x000000001	/* Frame w/INTME bit set sent */
81 #define	CAS_INTR_TX_EMPTY	0x000000002	/* TX ring empty */
82 #define	CAS_INTR_TX_DONE	0x000000004	/* TX complete */
83 #define	CAS_INTR_TX_TAG_ERR	0x000000008
84 #define	CAS_INTR_RX_DONE	0x000000010	/* Got a packet */
85 #define	CAS_INTR_RX_NOBUF	0x000000020
86 #define	CAS_INTR_RX_TAG_ERR	0x000000040
87 #define	CAS_INTR_RX_COMP_FULL	0x000000080
88 #define	CAS_INTR_PCS		0x000002000	/* Physical Code Sub-layer */
89 #define	CAS_INTR_TX_MAC		0x000004000
90 #define	CAS_INTR_RX_MAC		0x000008000
91 #define	CAS_INTR_MAC_CONTROL	0x000010000	/* MAC control interrupt */
92 #define	CAS_INTR_MIF		0x000020000
93 #define	CAS_INTR_BERR		0x000040000	/* Bus error interrupt */
94 #define CAS_INTR_BITS	"\020"					\
95 			"\1INTME\2TXEMPTY\3TXDONE\4TX_TAG_ERR"	\
96 			"\5RXDONE\6RXNOBUF\7RX_TAG_ERR"		\
97 			"\10RX_COMP_FULL"			\
98 			"\16PCS\17TXMAC\20RXMAC"		\
99 			"\21MACCONTROL\22MIF\23BERR"
100 
101 /* CAS_ERROR_STATUS and CAS_ERROR_MASK PCI error bits */
102 #define	CAS_ERROR_STAT_BADACK	0x000000001	/* No ACK64# */
103 #define	CAS_ERROR_STAT_DTRTO	0x000000002	/* Delayed xaction timeout */
104 #define	CAS_ERROR_STAT_OTHERS	0x000000004
105 
106 /* CAS_BIF_CONFIG register bits */
107 #define	CAS_BIF_CONFIG_SLOWCLK	0x000000001	/* Parity error timing */
108 #define	CAS_BIF_CONFIG_HOST_64	0x000000002	/* 64-bit host */
109 #define	CAS_BIF_CONFIG_B64D_DIS	0x000000004	/* no 64-bit data cycle */
110 #define	CAS_BIF_CONFIG_M66EN	0x000000008
111 
112 /* CAS_RESET register bits -- TX and RX self clear when complete. */
113 #define	CAS_RESET_TX		0x000000001	/* Reset TX half */
114 #define	CAS_RESET_RX		0x000000002	/* Reset RX half */
115 #define	CAS_RESET_RSTOUT	0x000000004	/* Force PCI RSTOUT# */
116 #define	CAS_RESET_BLOCK_PCS	0x00000008	/* Block PCS reset */
117 
118 /* CAS_SATURN_PCFG register bits */
119 #define	CAS_SATURN_PCFG_TLA	0x00000001	/* PHY activity LED */
120 #define	CAS_SATURN_PCFG_FLA	0x00000002	/* PHY 10MBit/sec LED */
121 #define	CAS_SATURN_PCFG_CLA	0x00000004	/* PHY 100MBit/sec LED */
122 #define	CAS_SATURN_PCFG_LLA	0x00000008	/* PHY 1000MBit/sec LED */
123 #define	CAS_SATURN_PCFG_RLA	0x00000010	/* PHY full-duplex LED */
124 #define	CAS_SATURN_PCFG_PDS	0x00000020	/* PHY debug mode */
125 #define	CAS_SATURN_PCFG_MTP	0x00000080	/* test point select */
126 #define	CAS_SATURN_PCFG_GMO	0x00000100	/* GMII observe */
127 #define	CAS_SATURN_PCFG_FSI	0x00000200	/* freeze GMII/SERDES */
128 #define	CAS_SATURN_PCFG_LAD	0x00000800	/* MAC LED control active low */
129 
130 /* TX DMA registers */
131 #define	CAS_TX_CONFIG		0x2004
132 
133 #define	CAS_TX_FIFO_WR_PTR	0x2014		/* FIFO write pointer */
134 #define	CAS_TX_FIFO_SDWR_PTR	0x2018		/* FIFO shadow write pointer */
135 #define	CAS_TX_FIFO_RD_PTR	0x201c		/* FIFO read pointer */
136 #define	CAS_TX_FIFO_SDRD_PTR	0x2020		/* FIFO shadow read pointer */
137 #define	CAS_TX_FIFO_PKT_CNT	0x2024		/* FIFO packet counter */
138 
139 #define	CAS_TX_STATE_MACHINE	0x2028		/* ETX state machine reg */
140 #define	CAS_TX_DATA_PTR		0x2030		/* ETX state machine reg (64-bit)*/
141 
142 #define	CAS_TX_KICK1		0x2038		/* Write last valid desc + 1 */
143 #define	CAS_TX_KICK2		0x203c
144 #define	CAS_TX_KICK3		0x2040
145 #define	CAS_TX_KICK4		0x2044
146 #define	CAS_TX_COMPLETION1	0x2048
147 #define	CAS_TX_COMPLETION2	0x204c
148 #define	CAS_TX_COMPLETION3	0x2050
149 #define	CAS_TX_COMPLETION4	0x2054
150 #define	CAS_TX_RING_PTR_LO1	0x2060
151 #define	CAS_TX_RING_PTR_HI1	0x2064
152 #define	CAS_TX_RING_PTR_LO2	0x2068
153 #define	CAS_TX_RING_PTR_HI2	0x206c
154 #define	CAS_TX_RING_PTR_LO3	0x2070
155 #define	CAS_TX_RING_PTR_HI3	0x2074
156 #define	CAS_TX_RING_PTR_LO4	0x2078
157 #define	CAS_TX_RING_PTR_HI4	0x207c
158 #define	CAS_TX_MAXBURST1	0x2080
159 #define	CAS_TX_MAXBURST2	0x2084
160 #define	CAS_TX_MAXBURST3	0x2088
161 #define	CAS_TX_MAXBURST4	0x208c
162 
163 #define CAS_TX_KICK		CAS_TX_KICK3
164 #define CAS_TX_COMPLETION	CAS_TX_COMPLETION3
165 #define CAS_TX_RING_PTR_LO	CAS_TX_RING_PTR_LO3
166 #define CAS_TX_RING_PTR_HI	CAS_TX_RING_PTR_HI3
167 
168 #define	CAS_TX_FIFO_ADDRESS	0x2104
169 #define	CAS_TX_FIFO_TAG		0x2108
170 #define	CAS_TX_FIFO_DATA_LO	0x210c
171 #define	CAS_TX_FIFO_DATA_HI_T1	0x2110
172 #define	CAS_TX_FIFO_DATA_HI_T0	0x2114
173 #define	CAS_TX_FIFO_SIZE	0x2118
174 #define	CAS_TX_DEBUG		0x3028
175 
176 /* CAS_TX_CONFIG register bits. */
177 #define	CAS_TX_CONFIG_TXDMA_EN	0x00000001	/* TX DMA enable */
178 #define	CAS_TX_CONFIG_TXRING_SZ	0x0000003c	/* TX ring size */
179 #define	CAS_TX_CONFIG_PACED	0x00100000	/* TX_all_int modifier */
180 
181 #define	CAS_RING_SZ_32		0	/* 32 descriptors */
182 #define	CAS_RING_SZ_64		1
183 #define	CAS_RING_SZ_128		2
184 #define	CAS_RING_SZ_256		3
185 #define	CAS_RING_SZ_512		4
186 #define	CAS_RING_SZ_1024	5
187 #define	CAS_RING_SZ_2048	6
188 #define	CAS_RING_SZ_4096	7
189 #define	CAS_RING_SZ_8192	8
190 
191 /* CAS_TX_COMPLETION register bits */
192 #define	CAS_TX_COMPLETION_MASK	0x00001fff	/* # of last descriptor */
193 
194 /* RX DMA registers */
195 #define	CAS_RX_CONFIG		0x4000
196 #define	CAS_RX_PAGE_SIZE	0x4004
197 #define	CAS_RX_FIFO_WR_PTR	0x4008		/* FIFO write pointer */
198 #define	CAS_RX_FIFO_RD_PTR	0x400c		/* FIFO read pointer */
199 #define	CAS_RX_IPPFIFO_WR_PTR	0x4010		/* IPP FIFO write pointer */
200 #define	CAS_RX_IPPFIFO_RD_PTR	0x4014		/* IPP FIFO read pointer */
201 #define	CAS_RX_IPPFIFO_SDWR_PTR	0x4018		/* FIFO shadow write pointer */
202 #define	CAS_RX_DEBUG		0x401c		/* Debug reg */
203 #define	CAS_RX_PAUSE_THRESH	0x4020
204 #define	CAS_RX_KICK		0x4024		/* Write last valid desc + 1 */
205 #define	CAS_RX_DRING_PTR_LO	0x4028
206 #define	CAS_RX_DRING_PTR_HI	0x402c
207 #define	CAS_RX_CRING_PTR_LO	0x4030
208 #define	CAS_RX_CRING_PTR_HI	0x4034
209 #define	CAS_RX_COMPLETION	0x4038		/* First pending desc */
210 #define	CAS_RX_COMP_HEAD	0x403c
211 #define	CAS_RX_COMP_TAIL	0x4040
212 #define	CAS_RX_BLANKING		0x4044		/* Interrupt blanking reg */
213 #define	CAS_RX_RED		0x404c		/* Random Early Detection */
214 
215 #define	CAS_RX_IPP_PKT_CNT	0x4054		/* IPP packet counter */
216 
217 #define	CAS_RX_FIFO_ADDRESS	0x4080
218 #define	CAS_RX_FIFO_TAG		0x4084
219 #define	CAS_RX_FIFO_DATA_LO	0x4088
220 #define	CAS_RX_FIFO_DATA_HI_T0	0x408c
221 #define	CAS_RX_FIFO_DATA_HI_T1	0x4090
222 
223 /* The following registers only exist on Cassini+. */
224 #define	CAS_RX_DRING_PTR_LO2	0x4200
225 #define	CAS_RX_DRING_PTR_HI2	0x4204
226 #define	CAS_RX_CRING_PTR_LO2	0x4208
227 #define	CAS_RX_CRING_PTR_HI2	0x420c
228 #define	CAS_RX_CRING_PTR_LO3	0x4210
229 #define	CAS_RX_CRING_PTR_HI3	0x4214
230 #define	CAS_RX_CRING_PTR_LO4	0x4218
231 #define	CAS_RX_CRING_PTR_HI4	0x421c
232 #define	CAS_RX_KICK2		0x4220
233 #define	CAS_RX_COMPLETION2	0x4224
234 #define	CAS_RX_COMP_HEAD2	0x4228
235 #define	CAS_RX_COMP_TAIL2	0x422c
236 #define	CAS_RX_COMP_HEAD3	0x4230
237 #define	CAS_RX_COMP_TAIL3	0x4234
238 #define	CAS_RX_COMP_HEAD4	0x4238
239 #define	CAS_RX_COMP_TAIL4	0x423c
240 
241 /* CAS_RX_CONFIG register bits. */
242 #define	CAS_RX_CONFIG_RXDMA_EN	0x00000001	/* RX DMA enable */
243 #define	CAS_RX_CONFIG_RXDRNG_SZ	0x0000001e	/* RX descriptor ring size */
244 #define	CAS_RX_CONFIG_RXCRNG_SZ	0x000001e0	/* RX completion ring size */
245 #define	CAS_RX_CONFIG_BATCH_DIS	0x00000200	/* desc batching disable */
246 #define	CAS_RX_CONFIG_FBOFF	0x00001c00	/* first byte offset */
247 
248 #define	CAS_RX_CONFIG_RXDRNG_SZ_SHIFT	1
249 #define	CAS_RX_CONFIG_RXCRNG_SZ_SHIFT	5
250 #define	CAS_RX_CONFIG_FBOFF_SHFT	10
251 #define	CAS_RX_CONFIG_RXDRNG2_SZ_SHIFT	16	/* Cassini+ */
252 
253 /* CAS_RX_PAGE_SIZE register bits. */
254 #define	CAS_RX_PAGE_SIZE_SZ	0x00000003	/* Page size */
255 #define	CAS_RX_PAGE_SIZE_COUNT	0x00007800	/* MTU buffers per page */
256 #define	CAS_RX_PAGE_SIZE_STRIDE	0x18000000	/* MTU buffer separation */
257 #define	CAS_RX_PAGE_SIZE_FBOFF	0xc0000000	/* First byte offset */
258 
259 #define	CAS_RX_PAGE_SIZE_COUNT_SHIFT	11
260 #define	CAS_RX_PAGE_SIZE_STRIDE_SHIFT	27
261 #define	CAS_RX_PAGE_SIZE_FBOFF_SHIFT	30
262 
263 /* CAS_RX_PAUSE_THRESH register bits -- sizes in multiples of 64 bytes */
264 #define	CAS_RX_PTH_XOFF_THRESH	0x000001ff
265 #define	CAS_RX_PTH_XON_THRESH	0x07fc0000
266 
267 /* CAS_RX_BLANKING register bits */
268 #define	CAS_RX_BLANKING_PACKETS	0x000001ff	/* Delay intr for x packets */
269 #define	CAS_RX_BLANKING_TIME	0x03fc0000	/* Delay intr for x ticks */
270 /* One tick is 1048 PCI clocks, or 16us at 66MHz */
271 
272 /* CAS_MAC registers */
273 #define	CAS_MAC_TXRESET		0x6000		/* Store 1, cleared when done */
274 #define	CAS_MAC_RXRESET		0x6004		/* ditto */
275 #define	CAS_MAC_SEND_PAUSE_CMD	0x6008
276 #define	CAS_MAC_TX_STATUS	0x6010
277 #define	CAS_MAC_RX_STATUS	0x6014
278 #define	CAS_MAC_CONTROL_STATUS	0x6018		/* MAC control status reg */
279 #define	CAS_MAC_TX_MASK		0x6020		/* TX MAC mask register */
280 #define	CAS_MAC_RX_MASK		0x6024
281 #define	CAS_MAC_CONTROL_MASK	0x6028
282 #define	CAS_MAC_TX_CONFIG	0x6030
283 #define	CAS_MAC_RX_CONFIG	0x6034
284 #define	CAS_MAC_CONTROL_CONFIG	0x6038
285 #define	CAS_MAC_XIF_CONFIG	0x603c
286 #define	CAS_MAC_IPG0		0x6040		/* inter packet gap 0 */
287 #define	CAS_MAC_IPG1		0x6044		/* inter packet gap 1 */
288 #define	CAS_MAC_IPG2		0x6048		/* inter packet gap 2 */
289 #define	CAS_MAC_SLOT_TIME	0x604c		/* slot time, bits 0-7 */
290 #define	CAS_MAC_MAC_MIN_FRAME	0x6050
291 #define	CAS_MAC_MAC_MAX_FRAME	0x6054
292 #define	CAS_MAC_PREAMBLE_LEN	0x6058
293 #define	CAS_MAC_JAM_SIZE	0x605c
294 #define	CAS_MAC_ATTEMPT_LIMIT	0x6060
295 #define	CAS_MAC_CONTROL_TYPE	0x6064
296 
297 #define	CAS_MAC_ADDR0		0x6080		/* Normal MAC address 0 */
298 #define	CAS_MAC_ADDR1		0x6084
299 #define	CAS_MAC_ADDR2		0x6088
300 #define	CAS_MAC_ADDR3		0x608c		/* Alternate MAC address 0 */
301 #define	CAS_MAC_ADDR4		0x6090
302 #define	CAS_MAC_ADDR5		0x6094
303 #define	CAS_MAC_ADDR42		0x6128		/* Control MAC address 0 */
304 #define	CAS_MAC_ADDR43		0x612c
305 #define	CAS_MAC_ADDR44		0x6130
306 
307 #define	CAS_MAC_ADDR_FILTER0	0x614c
308 #define	CAS_MAC_ADDR_FILTER1	0x6150
309 #define	CAS_MAC_ADDR_FILTER2	0x6154
310 #define	CAS_MAC_ADR_FLT_MASK1_2	0x6158		/* Address filter mask 1,2 */
311 #define	CAS_MAC_ADR_FLT_MASK0	0x615c		/* Address filter mask 0 reg */
312 
313 #define	CAS_MAC_HASH0		0x6160		/* Hash table 0 */
314 #define	CAS_MAC_HASH1		0x6164
315 #define	CAS_MAC_HASH2		0x6168
316 #define	CAS_MAC_HASH3		0x616c
317 #define	CAS_MAC_HASH4		0x6170
318 #define	CAS_MAC_HASH5		0x6174
319 #define	CAS_MAC_HASH6		0x6178
320 #define	CAS_MAC_HASH7		0x617c
321 #define	CAS_MAC_HASH8		0x6180
322 #define	CAS_MAC_HASH9		0x6184
323 #define	CAS_MAC_HASH10		0x6188
324 #define	CAS_MAC_HASH11		0x618c
325 #define	CAS_MAC_HASH12		0x6190
326 #define	CAS_MAC_HASH13		0x6194
327 #define	CAS_MAC_HASH14		0x6198
328 #define	CAS_MAC_HASH15		0x619c
329 
330 #define	CAS_MAC_NORM_COLL_CNT	0x61a0		/* Normal collision counter */
331 #define	CAS_MAC_FIRST_COLL_CNT	0x61a4		/* 1st successful collision cntr */
332 #define	CAS_MAC_EXCESS_COLL_CNT	0x61a8		/* Excess collision counter */
333 #define	CAS_MAC_LATE_COLL_CNT	0x61ac		/* Late collision counter */
334 #define	CAS_MAC_DEFER_TMR_CNT	0x61b0		/* defer timer counter */
335 #define	CAS_MAC_PEAK_ATTEMPTS	0x61b4
336 #define	CAS_MAC_RX_FRAME_COUNT	0x61b8
337 #define	CAS_MAC_RX_LEN_ERR_CNT	0x61bc
338 #define	CAS_MAC_RX_ALIGN_ERR	0x61c0
339 #define	CAS_MAC_RX_CRC_ERR_CNT	0x61c4
340 #define	CAS_MAC_RX_CODE_VIOL	0x61c8
341 #define	CAS_MAC_RANDOM_SEED	0x61cc
342 #define	CAS_MAC_MAC_STATE	0x61d0		/* MAC state machine reg */
343 
344 /* CAS_MAC_SEND_PAUSE_CMD register bits */
345 #define	CAS_MAC_PAUSE_CMD_TIME	0x0000ffff
346 #define	CAS_MAC_PAUSE_CMD_SEND	0x00010000
347 
348 /* CAS_MAC_TX_STATUS and _MASK register bits */
349 #define	CAS_MAC_TX_XMIT_DONE	0x00000001
350 #define	CAS_MAC_TX_UNDERRUN	0x00000002
351 #define	CAS_MAC_TX_PKT_TOO_LONG	0x00000004
352 #define	CAS_MAC_TX_NCC_EXP	0x00000008	/* Normal collision cnt exp */
353 #define	CAS_MAC_TX_ECC_EXP	0x00000010
354 #define	CAS_MAC_TX_LCC_EXP	0x00000020
355 #define	CAS_MAC_TX_FCC_EXP	0x00000040
356 #define	CAS_MAC_TX_DEFER_EXP	0x00000080
357 #define	CAS_MAC_TX_PEAK_EXP	0x00000100
358 
359 /* CAS_MAC_RX_STATUS and _MASK register bits */
360 #define	CAS_MAC_RX_DONE		0x00000001
361 #define	CAS_MAC_RX_OVERFLOW	0x00000002
362 #define	CAS_MAC_RX_FRAME_CNT	0x00000004
363 #define	CAS_MAC_RX_ALIGN_EXP	0x00000008
364 #define	CAS_MAC_RX_CRC_EXP	0x00000010
365 #define	CAS_MAC_RX_LEN_EXP	0x00000020
366 #define	CAS_MAC_RX_CVI_EXP	0x00000040	/* Code violation */
367 
368 /* CAS_MAC_CONTROL_STATUS and CAS_MAC_CONTROL_MASK register bits */
369 #define	CAS_MAC_PAUSED		0x00000001	/* Pause received */
370 #define	CAS_MAC_PAUSE		0x00000002	/* enter pause state */
371 #define	CAS_MAC_RESUME		0x00000004	/* exit pause state */
372 #define	CAS_MAC_PAUSE_TIME	0xffff0000
373 
374 /* CAS_MAC_XIF_CONFIG register bits */
375 #define	CAS_MAC_XIF_TX_MII_ENA	0x00000001	/* Enable XIF output drivers */
376 #define	CAS_MAC_XIF_MII_LOOPBK	0x00000002	/* Enable MII loopback mode */
377 #define	CAS_MAC_XIF_ECHO_DISABL	0x00000004	/* Disable echo */
378 #define	CAS_MAC_XIF_GMII_MODE	0x00000008	/* Select GMII/MII mode */
379 #define	CAS_MAC_XIF_MII_BUF_ENA	0x00000010	/* Enable MII recv buffers */
380 #define	CAS_MAC_XIF_LINK_LED	0x00000020	/* force link LED active */
381 #define	CAS_MAC_XIF_FDPLX_LED	0x00000040	/* force FDPLX LED active */
382 
383 /* CAS_MAC_SLOT_TIME register bits */
384 #define	CAS_MAC_SLOT_INT	0x40
385 #define	CAS_MAC_SLOT_EXT	0x200		/* external phy */
386 
387 /* CAS_MAC_TX_CONFIG register bits */
388 #define	CAS_MAC_TX_ENABLE	0x00000001	/* TX enable */
389 #define	CAS_MAC_TX_IGN_CARRIER	0x00000002	/* Ignore carrier sense */
390 #define	CAS_MAC_TX_IGN_COLLIS	0x00000004	/* ignore collisions */
391 #define	CAS_MAC_TX_ENA_IPG0	0x00000008	/* extend Rx-to-TX IPG */
392 #define	CAS_MAC_TX_NGU		0x00000010	/* Never give up */
393 #define	CAS_MAC_TX_NGU_LIMIT	0x00000020	/* Never give up limit */
394 #define	CAS_MAC_TX_NO_BACKOFF	0x00000040
395 #define	CAS_MAC_TX_SLOWDOWN	0x00000080
396 #define	CAS_MAC_TX_NO_FCS	0x00000100	/* no FCS will be generated */
397 #define	CAS_MAC_TX_CARR_EXTEND	0x00000200	/* Ena TX Carrier Extension */
398 /* Carrier Extension is required for half duplex Gbps operation */
399 
400 /* CAS_MAC_RX_CONFIG register bits */
401 #define	CAS_MAC_RX_ENABLE	0x00000001	/* RX enable */
402 #define	CAS_MAC_RX_STRIP_PAD	0x00000002	/* strip pad bytes */
403 #define	CAS_MAC_RX_STRIP_CRC	0x00000004
404 #define	CAS_MAC_RX_PROMISCUOUS	0x00000008	/* promiscuous mode */
405 #define	CAS_MAC_RX_PROMISC_GRP	0x00000010	/* promiscuous group mode */
406 #define	CAS_MAC_RX_HASH_FILTER	0x00000020	/* enable hash filter */
407 #define	CAS_MAC_RX_ADDR_FILTER	0x00000040	/* enable address filter */
408 #define	CAS_MAC_RX_ERRCHK_DIS	0x00000080	/* disable error checking */
409 #define	CAS_MAC_RX_CARR_EXTEND	0x00000100	/* Ena RX Carrier Extension */
410 /*
411  * Carrier Extension enables reception of packet bursts generated by
412  * senders with carrier extension enabled.
413  */
414 
415 /* CAS_MAC_CONTROL_CONFIG bits */
416 #define	CAS_MAC_CC_TX_PAUSE	0x00000001	/* send pause enabled */
417 #define	CAS_MAC_CC_RX_PAUSE	0x00000002	/* receive pause enabled */
418 #define	CAS_MAC_CC_PASS_PAUSE	0x00000004	/* pass pause up */
419 
420 /* Cassini MIF registers */
421 /* Bit bang registers use low bit only */
422 #define	CAS_MIF_BB_CLOCK	0x6200		/* bit bang clock */
423 #define	CAS_MIF_BB_DATA		0x6204		/* bit bang data */
424 #define	CAS_MIF_BB_OUTPUT_ENAB	0x6208
425 #define	CAS_MIF_FRAME		0x620c		/* MIF frame - ctl and data */
426 #define	CAS_MIF_CONFIG		0x6210
427 #define	CAS_MIF_INTERRUPT_MASK	0x6214
428 #define	CAS_MIF_BASIC_STATUS	0x6218
429 #define	CAS_MIF_STATE_MACHINE	0x621c
430 
431 /* CAS_MIF_FRAME bits */
432 #define	CAS_MIF_FRAME_DATA	0x0000ffff
433 #define	CAS_MIF_FRAME_TA0	0x00010000	/* TA bit, 1 for completion */
434 #define	CAS_MIF_FRAME_TA1	0x00020000	/* TA bits */
435 #define	CAS_MIF_FRAME_REG_ADDR	0x007c0000
436 #define	CAS_MIF_FRAME_PHY_ADDR	0x0f800000	/* phy address, should be 0 */
437 #define	CAS_MIF_FRAME_OP	0x30000000	/* operation - write/read */
438 #define	CAS_MIF_FRAME_START	0xc0000000	/* START bits */
439 
440 #define	CAS_MIF_FRAME_READ	0x60020000
441 #define	CAS_MIF_FRAME_WRITE	0x50020000
442 
443 #define	CAS_MIF_REG_SHIFT	18
444 #define	CAS_MIF_PHY_SHIFT	23
445 
446 /* CAS_MIF_CONFIG register bits */
447 #define	CAS_MIF_CONFIG_PHY_SEL	0x00000001	/* PHY select, 0=MDIO0 */
448 #define	CAS_MIF_CONFIG_POLL_ENA	0x00000002	/* poll enable */
449 #define	CAS_MIF_CONFIG_BB_ENA	0x00000004	/* bit bang enable */
450 #define	CAS_MIF_CONFIG_REG_ADR	0x000000f8	/* poll register address */
451 #define	CAS_MIF_CONFIG_MDI0	0x00000100	/* MDIO_0 Data/MDIO_0 attached */
452 #define	CAS_MIF_CONFIG_MDI1	0x00000200	/* MDIO_1 Data/MDIO_1 attached */
453 #define	CAS_MIF_CONFIG_PHY_ADR	0x00007c00	/* poll PHY address */
454 /* MDI0 is onboard transceiver MID1 is external, PHYAD for both is 0 */
455 
456 /* CAS_MIF_BASIC_STATUS and CAS_MIF_INTERRUPT_MASK bits */
457 #define	CAS_MIF_STATUS		0x0000ffff
458 #define	CAS_MIF_BASIC		0xffff0000
459 /*
460  * The Basic part is the last value read in the POLL field of the config
461  * register.
462  *
463  * The status part indicates the bits that have changed.
464  */
465 
466 /* Cassini PCS/Serial link registers */
467 #define	CAS_MII_CONTROL		0x9000
468 #define	CAS_MII_STATUS		0x9004
469 #define	CAS_MII_ANAR		0x9008		/* MII advertisement reg */
470 #define	CAS_MII_ANLPAR		0x900c		/* Link Partner Ability Reg */
471 #define	CAS_MII_CONFIG		0x9010
472 #define	CAS_MII_STATE_MACHINE	0x9014
473 #define	CAS_MII_INTERRUP_STATUS	0x9018		/* PCS interrupt state */
474 #define	CAS_MII_DATAPATH_MODE	0x9050
475 #define	CAS_MII_SLINK_CONTROL	0x9054		/* Serial link control */
476 #define	CAS_MII_OUTPUT_SELECT	0x9058
477 #define	CAS_MII_SLINK_STATUS	0x905c		/* serial link status */
478 #define	CAS_MII_PACKET_COUNT	0x9060
479 
480 /* CAS_MII_CONTROL bits */
481 #define	CAS_MII_CONTROL_RESET	0x00008000
482 #define	CAS_MII_CONTROL_LOOPBK	0x00004000	/* 10-bit i/f loopback */
483 #define	CAS_MII_CONTROL_1000M	0x00002000	/* speed select, always 0 */
484 #define	CAS_MII_CONTROL_AUTONEG	0x00001000	/* auto negotiation enabled */
485 #define	CAS_MII_CONTROL_POWERDN	0x00000800
486 #define	CAS_MII_CONTROL_ISOLATE	0x00000400	/* isolate phy from mii */
487 #define	CAS_MII_CONTROL_RAN	0x00000200	/* restart auto negotiation */
488 #define	CAS_MII_CONTROL_FDUPLEX	0x00000100	/* full duplex, always 0 */
489 #define	CAS_MII_CONTROL_COL_TST	0x00000080	/* collision test */
490 
491 /* CAS_MII_STATUS reg - PCS "BMSR" (Basic Mode Status Reg) */
492 #define	CAS_MII_STATUS_GB_FDX	0x00000400	/* can perform GBit FDX */
493 #define	CAS_MII_STATUS_GB_HDX	0x00000200	/* can perform GBit HDX */
494 #define	CAS_MII_STATUS_UNK	0x00000100
495 #define	CAS_MII_STATUS_ANEG_CPT	0x00000020	/* auto negotiate compete */
496 #define	CAS_MII_STATUS_REM_FLT	0x00000010	/* remote fault detected */
497 #define	CAS_MII_STATUS_ACFG	0x00000008	/* can auto negotiate */
498 #define	CAS_MII_STATUS_LINK_STS	0x00000004	/* link status */
499 #define	CAS_MII_STATUS_JABBER	0x00000002	/* jabber condition detected */
500 #define	CAS_MII_STATUS_EXTCAP	0x00000001	/* extended register capability */
501 
502 /* CAS_MII_ANAR and CAS_MII_ANLPAR reg bits */
503 #define	CAS_MII_ANEG_NP		0x00008000	/* next page bit */
504 #define	CAS_MII_ANEG_ACK	0x00004000	/* ack reception of */
505 						/* Link Partner Capability */
506 #define	CAS_MII_ANEG_RF		0x00003000	/* advertise remote fault cap */
507 #define	CAS_MII_ANEG_ASYM_PAUSE	0x00000100	/* asymmetric pause */
508 #define	CAS_MII_ANEG_SYM_PAUSE	0x00000080	/* symmetric pause */
509 #define	CAS_MII_ANEG_HLF_DUPLX	0x00000040
510 #define	CAS_MII_ANEG_FUL_DUPLX	0x00000020
511 
512 /* CAS_MII_CONFIG reg */
513 #define	CAS_MII_CONFIG_TIMER	0x0000000e	/* link monitor timer values */
514 #define	CAS_MII_CONFIG_ANTO	0x00000020	/* 10ms ANEG timer override */
515 #define	CAS_MII_CONFIG_JS	0x00000018	/* Jitter Study, 0 normal
516 						 * 1 high freq, 2 low freq */
517 #define	CAS_MII_CONFIG_SDL	0x00000004	/* Signal Detect active low */
518 #define	CAS_MII_CONFIG_SDO	0x00000002	/* Signal Detect Override */
519 #define	CAS_MII_CONFIG_ENABLE	0x00000001	/* Enable PCS */
520 
521 /*
522  * CAS_MII_STATE_MACHINE
523  * XXX These are best guesses from observed behavior.
524  */
525 #define	CAS_MII_FSM_STOP	0x00000000	/* stopped */
526 #define	CAS_MII_FSM_RUN		0x00000001	/* running */
527 #define	CAS_MII_FSM_UNKWN	0x00000100	/* unknown */
528 #define	CAS_MII_FSM_DONE	0x00000101	/* complete */
529 
530 /*
531  * CAS_MII_INTERRUP_STATUS reg
532  * No mask register; mask with the global interrupt mask register.
533  */
534 #define	CAS_MII_INTERRUP_LINK	0x00000002	/* PCS link status change */
535 
536 /* CAS_MII_DATAPATH_MODE reg */
537 #define	CAS_MII_DATAPATH_SERIAL	0x00000001	/* Serial link */
538 #define	CAS_MII_DATAPATH_SERDES	0x00000002	/* Use PCS via 10bit interface */
539 #define	CAS_MII_DATAPATH_MII	0x00000004	/* Use {G}MII, not PCS */
540 #define	CAS_MII_DATAPATH_MIIOUT	0x00000008	/* enable serial output on GMII */
541 
542 /* CAS_MII_SLINK_CONTROL reg */
543 #define	CAS_MII_SLINK_LOOPBACK	0x00000001	/* enable loopback at sl, logic
544 						 * reversed for SERDES */
545 #define	CAS_MII_SLINK_EN_SYNC_D	0x00000002	/* enable sync detection */
546 #define	CAS_MII_SLINK_LOCK_REF	0x00000004	/* lock reference clock */
547 #define	CAS_MII_SLINK_EMPHASIS	0x00000008	/* enable emphasis */
548 #define	CAS_MII_SLINK_SELFTEST	0x000001c0
549 #define	CAS_MII_SLINK_POWER_OFF	0x00000200	/* Power down serial link */
550 
551 /* CAS_MII_SLINK_STATUS reg */
552 #define	CAS_MII_SLINK_TEST	0x00000000	/* undergoing test */
553 #define	CAS_MII_SLINK_LOCKED	0x00000001	/* waiting 500us lockrefn */
554 #define	CAS_MII_SLINK_COMMA	0x00000002	/* waiting for comma detect */
555 #define	CAS_MII_SLINK_SYNC	0x00000003	/* recv data synchronized */
556 
557 /* Wired PHY addresses */
558 #define	CAS_PHYAD_INTERNAL	1
559 #define	CAS_PHYAD_EXTERNAL	0
560 
561 /*
562  * Cassini ring structures.
563  */
564 
565 /* Descriptor rings */
566 struct cas_desc {
567 	uint64_t	cd_flags;
568 	uint64_t	cd_addr;
569 };
570 
571 /* Transmit flags */
572 #define	CAS_TD_BUFSIZE		0x0000000000007fffLL
573 #define	CAS_TD_CXSUM_START	0x00000000001f8000LL	/* Cxsum start offset */
574 #define	CAS_TD_CXSUM_STARTSHFT  15
575 #define	CAS_TD_CXSUM_STUFF	0x000000001fe00000LL	/* Cxsum stuff offset */
576 #define	CAS_TD_CXSUM_STUFFSHFT  21
577 #define	CAS_TD_CXSUM_ENABLE	0x0000000020000000LL	/* Cxsum generation enable */
578 #define	CAS_TD_END_OF_PACKET	0x0000000040000000LL
579 #define	CAS_TD_START_OF_PACKET	0x0000000080000000LL
580 #define	CAS_TD_INTERRUPT_ME	0x0000000100000000LL	/* Interrupt me now */
581 #define	CAS_TD_NO_CRC		0x0000000200000000LL	/* do not insert crc */
582 /*
583  * Only need to set CAS_TD_CXSUM_ENABLE, CAS_TD_CXSUM_STUFF,
584  * CAS_TD_CXSUM_START, and CAS_TD_INTERRUPT_ME in 1st descriptor of a group.
585  */
586 
587 /* Completion ring */
588 struct cas_comp {
589 	uint64_t	cc_word[4];
590 };
591 
592 #define	CAS_RC0_TYPE		0xc000000000000000ULL
593 #define	CAS_RC0_RELEASE_HDR	0x2000000000000000ULL
594 #define	CAS_RC0_RELEASE_DATA	0x1000000000000000ULL
595 #define	CAS_RC0_SPLIT		0x0400000000000000ULL
596 #define	CAS_RC0_SKIP_MASK	0x0180000000000000ULL
597 #define	CAS_RC0_SKIP_SHIFT	55
598 #define CAS_RC0_DATA_IDX_MASK	0x007ffe0000000000ULL
599 #define CAS_RC0_DATA_IDX_SHIFT	41
600 #define CAS_RC0_DATA_OFF_MASK	0x000001fff8000000ULL
601 #define CAS_RC0_DATA_OFF_SHIFT	27
602 #define CAS_RC0_DATA_LEN_MASK	0x0000000007ffe000ULL
603 #define CAS_RC0_DATA_LEN_SHIFT	13
604 
605 #define CAS_RC0_SKIP(w) \
606 	(((w) & CAS_RC0_SKIP_MASK) >> CAS_RC0_SKIP_SHIFT)
607 #define CAS_RC0_DATA_IDX(w) \
608 	(((w) & CAS_RC0_DATA_IDX_MASK) >> CAS_RC0_DATA_IDX_SHIFT)
609 #define CAS_RC0_DATA_OFF(w) \
610 	(((w) & CAS_RC0_DATA_OFF_MASK) >> CAS_RC0_DATA_OFF_SHIFT)
611 #define CAS_RC0_DATA_LEN(w) \
612 	(((w) & CAS_RC0_DATA_LEN_MASK) >> CAS_RC0_DATA_LEN_SHIFT)
613 
614 #define CAS_RC1_HDR_IDX_MASK	0xfffc000000000000ULL
615 #define CAS_RC1_HDR_IDX_SHIFT	50
616 #define CAS_RC1_HDR_OFF_MASK	0x0003f00000000000ULL
617 #define CAS_RC1_HDR_OFF_SHIFT	44
618 #define CAS_RC1_HDR_LEN_MASK	0x00000ff800000000ULL
619 #define CAS_RC1_HDR_LEN_SHIFT	35
620 
621 #define CAS_RC1_HDR_IDX(w) \
622 	(((w) & CAS_RC1_HDR_IDX_MASK) >> CAS_RC1_HDR_IDX_SHIFT)
623 #define CAS_RC1_HDR_OFF(w) \
624 	(((w) & CAS_RC1_HDR_OFF_MASK) >> CAS_RC1_HDR_OFF_SHIFT)
625 #define CAS_RC1_HDR_LEN(w) \
626 	(((w) & CAS_RC1_HDR_LEN_MASK) >> CAS_RC1_HDR_LEN_SHIFT)
627 
628 #define	CAS_RC3_OWN		0x0000080000000000ULL /* Owned by hardware */
629 
630 #endif /* _IF_CASREG_H */
631