xref: /freebsd/sys/dev/vr/if_vrreg.h (revision 141ae166569bd7263050c14ec84a80d72665b77c)
1726ff6a1SBill Paul /*
2726ff6a1SBill Paul  * Copyright (c) 1997, 1998
3726ff6a1SBill Paul  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
4726ff6a1SBill Paul  *
5726ff6a1SBill Paul  * Redistribution and use in source and binary forms, with or without
6726ff6a1SBill Paul  * modification, are permitted provided that the following conditions
7726ff6a1SBill Paul  * are met:
8726ff6a1SBill Paul  * 1. Redistributions of source code must retain the above copyright
9726ff6a1SBill Paul  *    notice, this list of conditions and the following disclaimer.
10726ff6a1SBill Paul  * 2. Redistributions in binary form must reproduce the above copyright
11726ff6a1SBill Paul  *    notice, this list of conditions and the following disclaimer in the
12726ff6a1SBill Paul  *    documentation and/or other materials provided with the distribution.
13726ff6a1SBill Paul  * 3. All advertising materials mentioning features or use of this software
14726ff6a1SBill Paul  *    must display the following acknowledgement:
15726ff6a1SBill Paul  *	This product includes software developed by Bill Paul.
16726ff6a1SBill Paul  * 4. Neither the name of the author nor the names of any co-contributors
17726ff6a1SBill Paul  *    may be used to endorse or promote products derived from this software
18726ff6a1SBill Paul  *    without specific prior written permission.
19726ff6a1SBill Paul  *
20726ff6a1SBill Paul  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21726ff6a1SBill Paul  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22726ff6a1SBill Paul  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23726ff6a1SBill Paul  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24726ff6a1SBill Paul  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25726ff6a1SBill Paul  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26726ff6a1SBill Paul  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27726ff6a1SBill Paul  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28726ff6a1SBill Paul  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29726ff6a1SBill Paul  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30726ff6a1SBill Paul  * THE POSSIBILITY OF SUCH DAMAGE.
31726ff6a1SBill Paul  *
32141ae166SBill Paul  *	$Id: if_vrreg.h,v 1.10 1999/02/23 06:47:52 wpaul Exp $
33726ff6a1SBill Paul  */
34726ff6a1SBill Paul 
35726ff6a1SBill Paul /*
36726ff6a1SBill Paul  * Rhine register definitions.
37726ff6a1SBill Paul  */
38726ff6a1SBill Paul 
39726ff6a1SBill Paul #define VR_PAR0			0x00	/* node address 0 to 4 */
40726ff6a1SBill Paul #define VR_PAR1			0x04	/* node address 2 to 6 */
41726ff6a1SBill Paul #define VR_RXCFG		0x06	/* receiver config register */
42726ff6a1SBill Paul #define VR_TXCFG		0x07	/* transmit config register */
43726ff6a1SBill Paul #define VR_COMMAND		0x08	/* command register */
44726ff6a1SBill Paul #define VR_ISR			0x0C	/* interrupt/status register */
45726ff6a1SBill Paul #define VR_IMR			0x0E	/* interrupt mask register */
46726ff6a1SBill Paul #define VR_MAR0			0x10	/* multicast hash 0 */
47726ff6a1SBill Paul #define VR_MAR1			0x14	/* multicast hash 1 */
48726ff6a1SBill Paul #define VR_RXADDR		0x18	/* rx descriptor list start addr */
49726ff6a1SBill Paul #define VR_TXADDR		0x1C	/* tx descriptor list start addr */
50726ff6a1SBill Paul #define VR_CURRXDESC0		0x20
51726ff6a1SBill Paul #define VR_CURRXDESC1		0x24
52726ff6a1SBill Paul #define VR_CURRXDESC2		0x28
53726ff6a1SBill Paul #define VR_CURRXDESC3		0x2C
54726ff6a1SBill Paul #define VR_NEXTRXDESC0		0x30
55726ff6a1SBill Paul #define VR_NEXTRXDESC1		0x34
56726ff6a1SBill Paul #define VR_NEXTRXDESC2		0x38
57726ff6a1SBill Paul #define VR_NEXTRXDESC3		0x3C
58726ff6a1SBill Paul #define VR_CURTXDESC0		0x40
59726ff6a1SBill Paul #define VR_CURTXDESC1		0x44
60726ff6a1SBill Paul #define VR_CURTXDESC2		0x48
61726ff6a1SBill Paul #define VR_CURTXDESC3		0x4C
62726ff6a1SBill Paul #define VR_NEXTTXDESC0		0x50
63726ff6a1SBill Paul #define VR_NEXTTXDESC1		0x54
64726ff6a1SBill Paul #define VR_NEXTTXDESC2		0x58
65726ff6a1SBill Paul #define VR_NEXTTXDESC3		0x5C
66726ff6a1SBill Paul #define VR_CURRXDMA		0x60	/* current RX DMA address */
67726ff6a1SBill Paul #define VR_CURTXDMA		0x64	/* current TX DMA address */
68726ff6a1SBill Paul #define VR_TALLYCNT		0x68	/* tally counter test register */
69726ff6a1SBill Paul #define VR_PHYADDR		0x6C
70726ff6a1SBill Paul #define VR_MIISTAT		0x6D
71726ff6a1SBill Paul #define VR_BCR0			0x6E
72726ff6a1SBill Paul #define VR_BCR1			0x6F
73726ff6a1SBill Paul #define VR_MIICMD		0x70
74726ff6a1SBill Paul #define VR_MIIADDR		0x71
75726ff6a1SBill Paul #define VR_MIIDATA		0x72
76726ff6a1SBill Paul #define VR_EECSR		0x74
77726ff6a1SBill Paul #define VR_TEST			0x75
78726ff6a1SBill Paul #define VR_GPIO			0x76
79726ff6a1SBill Paul #define VR_CONFIG		0x78
80726ff6a1SBill Paul #define VR_MPA_CNT		0x7C
81726ff6a1SBill Paul #define VR_CRC_CNT		0x7E
82726ff6a1SBill Paul 
83726ff6a1SBill Paul /*
84726ff6a1SBill Paul  * RX config bits.
85726ff6a1SBill Paul  */
86726ff6a1SBill Paul #define VR_RXCFG_RX_ERRPKTS	0x01
87726ff6a1SBill Paul #define VR_RXCFG_RX_RUNT	0x02
88726ff6a1SBill Paul #define VR_RXCFG_RX_MULTI	0x04
89726ff6a1SBill Paul #define VR_RXCFG_RX_BROAD	0x08
90726ff6a1SBill Paul #define VR_RXCFG_RX_PROMISC	0x10
91726ff6a1SBill Paul #define VR_RXCFG_RX_THRESH	0xE0
92726ff6a1SBill Paul 
93726ff6a1SBill Paul #define VR_RXTHRESH_32BYTES	0x00
94726ff6a1SBill Paul #define VR_RXTHRESH_64BYTES	0x20
95726ff6a1SBill Paul #define VR_RXTHRESH_128BYTES	0x40
96726ff6a1SBill Paul #define VR_RXTHRESH_256BYTES	0x60
97726ff6a1SBill Paul #define VR_RXTHRESH_512BYTES	0x80
98726ff6a1SBill Paul #define VR_RXTHRESH_768BYTES	0xA0
99726ff6a1SBill Paul #define VR_RXTHRESH_1024BYTES	0xC0
100726ff6a1SBill Paul #define VR_RXTHRESH_STORENFWD	0xE0
101726ff6a1SBill Paul 
102726ff6a1SBill Paul /*
103726ff6a1SBill Paul  * TX config bits.
104726ff6a1SBill Paul  */
105726ff6a1SBill Paul #define VR_TXCFG_RSVD0		0x01
106726ff6a1SBill Paul #define VR_TXCFG_LOOPBKMODE	0x06
107726ff6a1SBill Paul #define VR_TXCFG_BACKOFF	0x08
108726ff6a1SBill Paul #define VR_TXCFG_RSVD1		0x10
109726ff6a1SBill Paul #define VR_TXCFG_TX_THRESH	0xE0
110726ff6a1SBill Paul 
111726ff6a1SBill Paul #define VR_TXTHRESH_32BYTES	0x00
112726ff6a1SBill Paul #define VR_TXTHRESH_64BYTES	0x20
113726ff6a1SBill Paul #define VR_TXTHRESH_128BYTES	0x40
114726ff6a1SBill Paul #define VR_TXTHRESH_256BYTES	0x60
115726ff6a1SBill Paul #define VR_TXTHRESH_512BYTES	0x80
116726ff6a1SBill Paul #define VR_TXTHRESH_768BYTES	0xA0
117726ff6a1SBill Paul #define VR_TXTHRESH_1024BYTES	0xC0
118726ff6a1SBill Paul #define VR_TXTHRESH_STORENFWD	0xE0
119726ff6a1SBill Paul 
120726ff6a1SBill Paul /*
121726ff6a1SBill Paul  * Command register bits.
122726ff6a1SBill Paul  */
123726ff6a1SBill Paul #define VR_CMD_INIT		0x0001
124726ff6a1SBill Paul #define VR_CMD_START		0x0002
125726ff6a1SBill Paul #define VR_CMD_STOP		0x0004
126726ff6a1SBill Paul #define VR_CMD_RX_ON		0x0008
127726ff6a1SBill Paul #define VR_CMD_TX_ON		0x0010
128726ff6a1SBill Paul #define	VR_CMD_TX_GO		0x0020
129726ff6a1SBill Paul #define VR_CMD_RX_GO		0x0040
130726ff6a1SBill Paul #define VR_CMD_RSVD		0x0080
131726ff6a1SBill Paul #define VR_CMD_RX_EARLY		0x0100
132726ff6a1SBill Paul #define VR_CMD_TX_EARLY		0x0200
133726ff6a1SBill Paul #define VR_CMD_FULLDUPLEX	0x0400
134726ff6a1SBill Paul #define VR_CMD_TX_NOPOLL	0x0800
135726ff6a1SBill Paul 
136726ff6a1SBill Paul #define VR_CMD_RESET		0x8000
137726ff6a1SBill Paul 
138726ff6a1SBill Paul /*
139726ff6a1SBill Paul  * Interrupt status bits.
140726ff6a1SBill Paul  */
141726ff6a1SBill Paul #define VR_ISR_RX_OK		0x0001	/* packet rx ok */
142726ff6a1SBill Paul #define VR_ISR_TX_OK		0x0002	/* packet tx ok */
143726ff6a1SBill Paul #define VR_ISR_RX_ERR		0x0004	/* packet rx with err */
144726ff6a1SBill Paul #define VR_ISR_TX_ABRT		0x0008	/* tx aborted due to excess colls */
145726ff6a1SBill Paul #define VR_ISR_TX_UNDERRUN	0x0010	/* tx buffer underflow */
146726ff6a1SBill Paul #define VR_ISR_RX_NOBUF		0x0020	/* no rx buffer available */
147726ff6a1SBill Paul #define VR_ISR_BUSERR		0x0040	/* PCI bus error */
148726ff6a1SBill Paul #define VR_ISR_STATSOFLOW	0x0080	/* stats counter oflow */
149726ff6a1SBill Paul #define VR_ISR_RX_EARLY		0x0100	/* rx early */
150726ff6a1SBill Paul #define VR_ISR_LINKSTAT		0x0200	/* MII status change */
151726ff6a1SBill Paul #define VR_ISR_RX_OFLOW		0x0400	/* rx FIFO overflow */
152726ff6a1SBill Paul #define VR_ISR_RX_DROPPED	0x0800
153726ff6a1SBill Paul #define VR_ISR_RX_NOBUF2	0x1000
154726ff6a1SBill Paul #define VR_ISR_TX_ABRT2		0x2000
155726ff6a1SBill Paul #define VR_ISR_LINKSTAT2	0x4000
156726ff6a1SBill Paul #define VR_ISR_MAGICPACKET	0x8000
157726ff6a1SBill Paul 
158726ff6a1SBill Paul /*
159726ff6a1SBill Paul  * Interrupt mask bits.
160726ff6a1SBill Paul  */
161726ff6a1SBill Paul #define VR_IMR_RX_OK		0x0001	/* packet rx ok */
162726ff6a1SBill Paul #define VR_IMR_TX_OK		0x0002	/* packet tx ok */
163726ff6a1SBill Paul #define VR_IMR_RX_ERR		0x0004	/* packet rx with err */
164726ff6a1SBill Paul #define VR_IMR_TX_ABRT		0x0008	/* tx aborted due to excess colls */
165726ff6a1SBill Paul #define VR_IMR_TX_UNDERRUN	0x0010	/* tx buffer underflow */
166726ff6a1SBill Paul #define VR_IMR_RX_NOBUF		0x0020	/* no rx buffer available */
167726ff6a1SBill Paul #define VR_IMR_BUSERR		0x0040	/* PCI bus error */
168726ff6a1SBill Paul #define VR_IMR_STATSOFLOW	0x0080	/* stats counter oflow */
169726ff6a1SBill Paul #define VR_IMR_RX_EARLY		0x0100	/* rx early */
170726ff6a1SBill Paul #define VR_IMR_LINKSTAT		0x0200	/* MII status change */
171726ff6a1SBill Paul #define VR_IMR_RX_OFLOW		0x0400	/* rx FIFO overflow */
172726ff6a1SBill Paul #define VR_IMR_RX_DROPPED	0x0800
173726ff6a1SBill Paul #define VR_IMR_RX_NOBUF2	0x1000
174726ff6a1SBill Paul #define VR_IMR_TX_ABRT2		0x2000
175726ff6a1SBill Paul #define VR_IMR_LINKSTAT2	0x4000
176726ff6a1SBill Paul #define VR_IMR_MAGICPACKET	0x8000
177726ff6a1SBill Paul 
178726ff6a1SBill Paul #define VR_INTRS							\
179726ff6a1SBill Paul 	(VR_IMR_RX_OK|VR_IMR_TX_OK|VR_IMR_RX_NOBUF|			\
180726ff6a1SBill Paul 	VR_IMR_TX_ABRT|VR_IMR_TX_UNDERRUN|VR_IMR_BUSERR|		\
181726ff6a1SBill Paul 	VR_IMR_RX_ERR|VR_ISR_RX_DROPPED)
182726ff6a1SBill Paul 
183726ff6a1SBill Paul /*
184726ff6a1SBill Paul  * MII status register.
185726ff6a1SBill Paul  */
186726ff6a1SBill Paul 
187726ff6a1SBill Paul #define VR_MIISTAT_SPEED	0x01
188726ff6a1SBill Paul #define VR_MIISTAT_LINKFAULT	0x02
189726ff6a1SBill Paul #define VR_MIISTAT_MGTREADERR	0x04
190726ff6a1SBill Paul #define VR_MIISTAT_MIIERR	0x08
191726ff6a1SBill Paul #define VR_MIISTAT_PHYOPT	0x10
192726ff6a1SBill Paul #define VR_MIISTAT_MDC_SPEED	0x20
193726ff6a1SBill Paul #define VR_MIISTAT_RSVD		0x40
194726ff6a1SBill Paul #define VR_MIISTAT_GPIO1POLL	0x80
195726ff6a1SBill Paul 
196726ff6a1SBill Paul /*
197726ff6a1SBill Paul  * MII command register bits.
198726ff6a1SBill Paul  */
199726ff6a1SBill Paul #define VR_MIICMD_CLK		0x01
200726ff6a1SBill Paul #define VR_MIICMD_DATAOUT	0x02
201726ff6a1SBill Paul #define VR_MIICMD_DATAIN	0x04
202726ff6a1SBill Paul #define VR_MIICMD_DIR		0x08
203726ff6a1SBill Paul #define VR_MIICMD_DIRECTPGM	0x10
204726ff6a1SBill Paul #define VR_MIICMD_WRITE_ENB	0x20
205726ff6a1SBill Paul #define VR_MIICMD_READ_ENB	0x40
206726ff6a1SBill Paul #define VR_MIICMD_AUTOPOLL	0x80
207726ff6a1SBill Paul 
208726ff6a1SBill Paul /*
209726ff6a1SBill Paul  * EEPROM control bits.
210726ff6a1SBill Paul  */
211726ff6a1SBill Paul #define VR_EECSR_DATAIN		0x01	/* data out */
212726ff6a1SBill Paul #define VR_EECSR_DATAOUT	0x02	/* data in */
213726ff6a1SBill Paul #define VR_EECSR_CLK		0x04	/* clock */
214726ff6a1SBill Paul #define VR_EECSR_CS		0x08	/* chip select */
215726ff6a1SBill Paul #define VR_EECSR_DPM		0x10
216726ff6a1SBill Paul #define VR_EECSR_LOAD		0x20
217726ff6a1SBill Paul #define VR_EECSR_EMBP		0x40
218726ff6a1SBill Paul #define VR_EECSR_EEPR		0x80
219726ff6a1SBill Paul 
220726ff6a1SBill Paul #define VR_EECMD_WRITE		0x140
221726ff6a1SBill Paul #define VR_EECMD_READ		0x180
222726ff6a1SBill Paul #define VR_EECMD_ERASE		0x1c0
223726ff6a1SBill Paul 
224726ff6a1SBill Paul /*
225726ff6a1SBill Paul  * Test register bits.
226726ff6a1SBill Paul  */
227726ff6a1SBill Paul #define VR_TEST_TEST0		0x01
228726ff6a1SBill Paul #define VR_TEST_TEST1		0x02
229726ff6a1SBill Paul #define VR_TEST_TEST2		0x04
230726ff6a1SBill Paul #define VR_TEST_TSTUD		0x08
231726ff6a1SBill Paul #define VR_TEST_TSTOV		0x10
232726ff6a1SBill Paul #define VR_TEST_BKOFF		0x20
233726ff6a1SBill Paul #define VR_TEST_FCOL		0x40
234726ff6a1SBill Paul #define VR_TEST_HBDES		0x80
235726ff6a1SBill Paul 
236726ff6a1SBill Paul /*
237726ff6a1SBill Paul  * Config register bits.
238726ff6a1SBill Paul  */
239726ff6a1SBill Paul #define VR_CFG_GPIO2OUTENB	0x00000001
240726ff6a1SBill Paul #define VR_CFG_GPIO2OUT		0x00000002	/* gen. purp. pin */
241726ff6a1SBill Paul #define VR_CFG_GPIO2IN		0x00000004	/* gen. purp. pin */
242726ff6a1SBill Paul #define VR_CFG_AUTOOPT		0x00000008	/* enable rx/tx autopoll */
243726ff6a1SBill Paul #define VR_CFG_MIIOPT		0x00000010
244726ff6a1SBill Paul #define VR_CFG_MMIENB		0x00000020	/* memory mapped mode enb */
245726ff6a1SBill Paul #define VR_CFG_JUMPER		0x00000040	/* PHY and oper. mode select */
246726ff6a1SBill Paul #define VR_CFG_EELOAD		0x00000080	/* enable EEPROM programming */
247726ff6a1SBill Paul #define VR_CFG_LATMENB		0x00000100	/* larency timer effect enb. */
248726ff6a1SBill Paul #define VR_CFG_MRREADWAIT	0x00000200
249726ff6a1SBill Paul #define VR_CFG_MRWRITEWAIT	0x00000400
250726ff6a1SBill Paul #define VR_CFG_RX_ARB		0x00000800
251726ff6a1SBill Paul #define VR_CFG_TX_ARB		0x00001000
252726ff6a1SBill Paul #define VR_CFG_READMULTI	0x00002000
253726ff6a1SBill Paul #define VR_CFG_TX_PACE		0x00004000
254726ff6a1SBill Paul #define VR_CFG_TX_QDIS		0x00008000
255726ff6a1SBill Paul #define VR_CFG_ROMSEL0		0x00010000
256726ff6a1SBill Paul #define VR_CFG_ROMSEL1		0x00020000
257726ff6a1SBill Paul #define VR_CFG_ROMSEL2		0x00040000
258726ff6a1SBill Paul #define VR_CFG_ROMTIMESEL	0x00080000
259726ff6a1SBill Paul #define VR_CFG_RSVD0		0x00100000
260726ff6a1SBill Paul #define VR_CFG_ROMDLY		0x00200000
261726ff6a1SBill Paul #define VR_CFG_ROMOPT		0x00400000
262726ff6a1SBill Paul #define VR_CFG_RSVD1		0x00800000
263726ff6a1SBill Paul #define VR_CFG_BACKOFFOPT	0x01000000
264726ff6a1SBill Paul #define VR_CFG_BACKOFFMOD	0x02000000
265726ff6a1SBill Paul #define VR_CFG_CAPEFFECT	0x04000000
266726ff6a1SBill Paul #define VR_CFG_BACKOFFRAND	0x08000000
267726ff6a1SBill Paul #define VR_CFG_MAGICKPACKET	0x10000000
268726ff6a1SBill Paul #define VR_CFG_PCIREADLINE	0x20000000
269726ff6a1SBill Paul #define VR_CFG_DIAG		0x40000000
270726ff6a1SBill Paul #define VR_CFG_GPIOEN		0x80000000
271726ff6a1SBill Paul 
272726ff6a1SBill Paul /*
273726ff6a1SBill Paul  * Rhine TX/RX list structure.
274726ff6a1SBill Paul  */
275726ff6a1SBill Paul 
276726ff6a1SBill Paul struct vr_desc {
277726ff6a1SBill Paul 	u_int32_t		vr_status;
278726ff6a1SBill Paul 	u_int32_t		vr_ctl;
279726ff6a1SBill Paul 	u_int32_t		vr_ptr1;
280726ff6a1SBill Paul 	u_int32_t		vr_ptr2;
281726ff6a1SBill Paul };
282726ff6a1SBill Paul 
283726ff6a1SBill Paul #define vr_data		vr_ptr1
284726ff6a1SBill Paul #define vr_next		vr_ptr2
285726ff6a1SBill Paul 
286726ff6a1SBill Paul 
287726ff6a1SBill Paul #define VR_RXSTAT_RXERR		0x00000001
288726ff6a1SBill Paul #define VR_RXSTAT_CRCERR	0x00000002
289726ff6a1SBill Paul #define VR_RXSTAT_FRAMEALIGNERR	0x00000004
290726ff6a1SBill Paul #define VR_RXSTAT_FIFOOFLOW	0x00000008
291726ff6a1SBill Paul #define VR_RXSTAT_GIANT		0x00000010
292726ff6a1SBill Paul #define VR_RXSTAT_RUNT		0x00000020
293726ff6a1SBill Paul #define VR_RXSTAT_BUSERR	0x00000040
294726ff6a1SBill Paul #define VR_RXSTAT_BUFFERR	0x00000080
295726ff6a1SBill Paul #define VR_RXSTAT_LASTFRAG	0x00000100
296726ff6a1SBill Paul #define VR_RXSTAT_FIRSTFRAG	0x00000200
297726ff6a1SBill Paul #define VR_RXSTAT_RLINK		0x00000400
298726ff6a1SBill Paul #define VR_RXSTAT_RX_PHYS	0x00000800
299726ff6a1SBill Paul #define VR_RXSTAT_RX_BROAD	0x00001000
300726ff6a1SBill Paul #define VR_RXSTAT_RX_MULTI	0x00002000
301726ff6a1SBill Paul #define VR_RXSTAT_RX_OK		0x00004000
302726ff6a1SBill Paul #define VR_RXSTAT_RXLEN		0x07FF0000
303726ff6a1SBill Paul #define VR_RXSTAT_RXLEN_EXT	0x78000000
304726ff6a1SBill Paul #define VR_RXSTAT_OWN		0x80000000
305726ff6a1SBill Paul 
306726ff6a1SBill Paul #define VR_RXBYTES(x)		((x & VR_RXSTAT_RXLEN) >> 16)
307726ff6a1SBill Paul #define VR_RXSTAT (VR_RXSTAT_FIRSTFRAG|VR_RXSTAT_LASTFRAG|VR_RXSTAT_OWN)
308726ff6a1SBill Paul 
309726ff6a1SBill Paul #define VR_RXCTL_BUFLEN		0x000007FF
310726ff6a1SBill Paul #define VR_RXCTL_BUFLEN_EXT	0x00007800
311726ff6a1SBill Paul #define VR_RXCTL_CHAIN		0x00008000
312726ff6a1SBill Paul #define VR_RXCTL_RX_INTR	0x00800000
313726ff6a1SBill Paul 
3146c70e5b4SBill Paul #define VR_RXCTL (VR_RXCTL_CHAIN|VR_RXCTL_RX_INTR)
315726ff6a1SBill Paul 
316726ff6a1SBill Paul #define VR_TXSTAT_DEFER		0x00000001
317726ff6a1SBill Paul #define VR_TXSTAT_UNDERRUN	0x00000002
318726ff6a1SBill Paul #define VR_TXSTAT_COLLCNT	0x00000078
319726ff6a1SBill Paul #define VR_TXSTAT_SQE		0x00000080
320726ff6a1SBill Paul #define VR_TXSTAT_ABRT		0x00000100
321726ff6a1SBill Paul #define VR_TXSTAT_LATECOLL	0x00000200
322726ff6a1SBill Paul #define VR_TXSTAT_CARRLOST	0x00000400
323726ff6a1SBill Paul #define VR_TXSTAT_BUSERR	0x00002000
324726ff6a1SBill Paul #define VR_TXSTAT_JABTIMEO	0x00004000
325726ff6a1SBill Paul #define VR_TXSTAT_ERRSUM	0x00008000
326726ff6a1SBill Paul #define VR_TXSTAT_OWN		0x80000000
327726ff6a1SBill Paul 
328726ff6a1SBill Paul #define VR_TXCTL_BUFLEN		0x000007FF
329726ff6a1SBill Paul #define VR_TXCTL_BUFLEN_EXT	0x00007800
330726ff6a1SBill Paul #define VR_TXCTL_TLINK		0x00008000
331726ff6a1SBill Paul #define VR_TXCTL_FIRSTFRAG	0x00200000
332726ff6a1SBill Paul #define VR_TXCTL_LASTFRAG	0x00400000
333726ff6a1SBill Paul #define VR_TXCTL_FINT		0x00800000
334726ff6a1SBill Paul 
335726ff6a1SBill Paul 
336726ff6a1SBill Paul #define VR_MAXFRAGS		16
337726ff6a1SBill Paul #define VR_RX_LIST_CNT		64
338726ff6a1SBill Paul #define VR_TX_LIST_CNT		64
339726ff6a1SBill Paul #define VR_MIN_FRAMELEN		60
340726ff6a1SBill Paul #define VR_FRAMELEN		1536
3416c70e5b4SBill Paul #define VR_RXLEN		1520
342726ff6a1SBill Paul 
343726ff6a1SBill Paul #define VR_TXOWN(x)		x->vr_ptr->vr_status
344726ff6a1SBill Paul 
345726ff6a1SBill Paul struct vr_list_data {
346726ff6a1SBill Paul 	struct vr_desc		vr_rx_list[VR_RX_LIST_CNT];
347726ff6a1SBill Paul 	struct vr_desc		vr_tx_list[VR_TX_LIST_CNT];
348726ff6a1SBill Paul };
349726ff6a1SBill Paul 
350726ff6a1SBill Paul struct vr_chain {
351726ff6a1SBill Paul 	struct vr_desc		*vr_ptr;
352726ff6a1SBill Paul 	struct mbuf		*vr_mbuf;
353726ff6a1SBill Paul 	struct vr_chain		*vr_nextdesc;
354726ff6a1SBill Paul };
355726ff6a1SBill Paul 
356726ff6a1SBill Paul struct vr_chain_onefrag {
357726ff6a1SBill Paul 	struct vr_desc		*vr_ptr;
358726ff6a1SBill Paul 	struct mbuf		*vr_mbuf;
359726ff6a1SBill Paul 	struct vr_chain_onefrag	*vr_nextdesc;
360726ff6a1SBill Paul };
361726ff6a1SBill Paul 
362726ff6a1SBill Paul struct vr_chain_data {
363726ff6a1SBill Paul 	struct vr_chain_onefrag	vr_rx_chain[VR_RX_LIST_CNT];
364726ff6a1SBill Paul 	struct vr_chain		vr_tx_chain[VR_TX_LIST_CNT];
365726ff6a1SBill Paul 
366726ff6a1SBill Paul 	struct vr_chain_onefrag	*vr_rx_head;
367726ff6a1SBill Paul 
368726ff6a1SBill Paul 	struct vr_chain		*vr_tx_head;
369726ff6a1SBill Paul 	struct vr_chain		*vr_tx_tail;
370726ff6a1SBill Paul 	struct vr_chain		*vr_tx_free;
371726ff6a1SBill Paul };
372726ff6a1SBill Paul 
373726ff6a1SBill Paul struct vr_type {
374726ff6a1SBill Paul 	u_int16_t		vr_vid;
375726ff6a1SBill Paul 	u_int16_t		vr_did;
376726ff6a1SBill Paul 	char			*vr_name;
377726ff6a1SBill Paul };
378726ff6a1SBill Paul 
379726ff6a1SBill Paul struct vr_mii_frame {
380726ff6a1SBill Paul 	u_int8_t		mii_stdelim;
381726ff6a1SBill Paul 	u_int8_t		mii_opcode;
382726ff6a1SBill Paul 	u_int8_t		mii_phyaddr;
383726ff6a1SBill Paul 	u_int8_t		mii_regaddr;
384726ff6a1SBill Paul 	u_int8_t		mii_turnaround;
385726ff6a1SBill Paul 	u_int16_t		mii_data;
386726ff6a1SBill Paul };
387726ff6a1SBill Paul 
388726ff6a1SBill Paul /*
389726ff6a1SBill Paul  * MII constants
390726ff6a1SBill Paul  */
391726ff6a1SBill Paul #define VR_MII_STARTDELIM	0x01
392726ff6a1SBill Paul #define VR_MII_READOP		0x02
393726ff6a1SBill Paul #define VR_MII_WRITEOP		0x01
394726ff6a1SBill Paul #define VR_MII_TURNAROUND	0x02
395726ff6a1SBill Paul 
396726ff6a1SBill Paul #define VR_FLAG_FORCEDELAY	1
397726ff6a1SBill Paul #define VR_FLAG_SCHEDDELAY	2
398726ff6a1SBill Paul #define VR_FLAG_DELAYTIMEO	3
399726ff6a1SBill Paul 
400726ff6a1SBill Paul struct vr_softc {
401726ff6a1SBill Paul 	struct arpcom		arpcom;		/* interface info */
402726ff6a1SBill Paul 	struct ifmedia		ifmedia;	/* media info */
403726ff6a1SBill Paul 	bus_space_handle_t	vr_bhandle;	/* bus space handle */
404726ff6a1SBill Paul 	bus_space_tag_t		vr_btag;	/* bus space tag */
405726ff6a1SBill Paul 	struct vr_type		*vr_info;	/* Rhine adapter info */
406726ff6a1SBill Paul 	struct vr_type		*vr_pinfo;	/* phy info */
407726ff6a1SBill Paul 	u_int8_t		vr_unit;	/* interface number */
408726ff6a1SBill Paul 	u_int8_t		vr_type;
409726ff6a1SBill Paul 	u_int8_t		vr_phy_addr;	/* PHY address */
410726ff6a1SBill Paul 	u_int8_t		vr_tx_pend;	/* TX pending */
411726ff6a1SBill Paul 	u_int8_t		vr_want_auto;
412726ff6a1SBill Paul 	u_int8_t		vr_autoneg;
413726ff6a1SBill Paul 	caddr_t			vr_ldata_ptr;
414726ff6a1SBill Paul 	struct vr_list_data	*vr_ldata;
415726ff6a1SBill Paul 	struct vr_chain_data	vr_cdata;
416726ff6a1SBill Paul };
417726ff6a1SBill Paul 
418726ff6a1SBill Paul /*
419726ff6a1SBill Paul  * register space access macros
420726ff6a1SBill Paul  */
421726ff6a1SBill Paul #define CSR_WRITE_4(sc, reg, val)	\
422726ff6a1SBill Paul 	bus_space_write_4(sc->vr_btag, sc->vr_bhandle, reg, val)
423726ff6a1SBill Paul #define CSR_WRITE_2(sc, reg, val)	\
424726ff6a1SBill Paul 	bus_space_write_2(sc->vr_btag, sc->vr_bhandle, reg, val)
425726ff6a1SBill Paul #define CSR_WRITE_1(sc, reg, val)	\
426726ff6a1SBill Paul 	bus_space_write_1(sc->vr_btag, sc->vr_bhandle, reg, val)
427726ff6a1SBill Paul 
428726ff6a1SBill Paul #define CSR_READ_4(sc, reg)		\
429726ff6a1SBill Paul 	bus_space_read_4(sc->vr_btag, sc->vr_bhandle, reg)
430726ff6a1SBill Paul #define CSR_READ_2(sc, reg)		\
431726ff6a1SBill Paul 	bus_space_read_2(sc->vr_btag, sc->vr_bhandle, reg)
432726ff6a1SBill Paul #define CSR_READ_1(sc, reg)		\
433726ff6a1SBill Paul 	bus_space_read_1(sc->vr_btag, sc->vr_bhandle, reg)
434726ff6a1SBill Paul 
435726ff6a1SBill Paul #define VR_TIMEOUT		1000
436726ff6a1SBill Paul 
437726ff6a1SBill Paul /*
438726ff6a1SBill Paul  * General constants that are fun to know.
439726ff6a1SBill Paul  *
440726ff6a1SBill Paul  * VIA vendor ID
441726ff6a1SBill Paul  */
442726ff6a1SBill Paul #define	VIA_VENDORID			0x1106
443726ff6a1SBill Paul 
444726ff6a1SBill Paul /*
445726ff6a1SBill Paul  * VIA Rhine device IDs.
446726ff6a1SBill Paul  */
447726ff6a1SBill Paul #define	VIA_DEVICEID_RHINE		0x3043
448726ff6a1SBill Paul #define VIA_DEVICEID_RHINE_II		0x6100
449726ff6a1SBill Paul 
450141ae166SBill Paul /*
451141ae166SBill Paul  * Delta Electronics device ID.
452141ae166SBill Paul  */
453141ae166SBill Paul #define DELTA_VENDORID			0x1500
454141ae166SBill Paul 
455141ae166SBill Paul /*
456141ae166SBill Paul  * Delta device IDs.
457141ae166SBill Paul  */
458141ae166SBill Paul #define DELTA_DEVICEID_RHINE_II		0x1320
459141ae166SBill Paul 
460141ae166SBill Paul /*
461141ae166SBill Paul  * Addtron vendor ID.
462141ae166SBill Paul  */
463141ae166SBill Paul #define ADDTRON_VENDORID		0x4033
464141ae166SBill Paul 
465141ae166SBill Paul /*
466141ae166SBill Paul  * Addtron device IDs.
467141ae166SBill Paul  */
468141ae166SBill Paul #define ADDTRON_DEVICEID_RHINE_II	0x1320
469141ae166SBill Paul 
470726ff6a1SBill Paul 
471726ff6a1SBill Paul /*
472726ff6a1SBill Paul  * Texas Instruments PHY identifiers
473726ff6a1SBill Paul  */
474726ff6a1SBill Paul #define TI_PHY_VENDORID		0x4000
475726ff6a1SBill Paul #define TI_PHY_10BT		0x501F
476726ff6a1SBill Paul #define TI_PHY_100VGPMI		0x502F
477726ff6a1SBill Paul 
478726ff6a1SBill Paul /*
479726ff6a1SBill Paul  * These ID values are for the NS DP83840A 10/100 PHY
480726ff6a1SBill Paul  */
481726ff6a1SBill Paul #define NS_PHY_VENDORID		0x2000
482726ff6a1SBill Paul #define NS_PHY_83840A		0x5C0F
483726ff6a1SBill Paul 
484726ff6a1SBill Paul /*
485726ff6a1SBill Paul  * Level 1 10/100 PHY
486726ff6a1SBill Paul  */
487726ff6a1SBill Paul #define LEVEL1_PHY_VENDORID	0x7810
488726ff6a1SBill Paul #define LEVEL1_PHY_LXT970	0x000F
489726ff6a1SBill Paul 
490726ff6a1SBill Paul /*
491726ff6a1SBill Paul  * Intel 82555 10/100 PHY
492726ff6a1SBill Paul  */
493726ff6a1SBill Paul #define INTEL_PHY_VENDORID	0x0A28
494726ff6a1SBill Paul #define INTEL_PHY_82555		0x015F
495726ff6a1SBill Paul 
496726ff6a1SBill Paul /*
497726ff6a1SBill Paul  * SEEQ 80220 10/100 PHY
498726ff6a1SBill Paul  */
499726ff6a1SBill Paul #define SEEQ_PHY_VENDORID	0x0016
500726ff6a1SBill Paul #define SEEQ_PHY_80220		0xF83F
501726ff6a1SBill Paul 
502726ff6a1SBill Paul 
503726ff6a1SBill Paul /*
504726ff6a1SBill Paul  * PCI low memory base and low I/O base register, and
505726ff6a1SBill Paul  * other PCI registers.
506726ff6a1SBill Paul  */
507726ff6a1SBill Paul 
508726ff6a1SBill Paul #define VR_PCI_VENDOR_ID	0x00
509726ff6a1SBill Paul #define VR_PCI_DEVICE_ID	0x02
510726ff6a1SBill Paul #define VR_PCI_COMMAND		0x04
511726ff6a1SBill Paul #define VR_PCI_STATUS		0x06
512726ff6a1SBill Paul #define VR_PCI_CLASSCODE	0x09
513726ff6a1SBill Paul #define VR_PCI_LATENCY_TIMER	0x0D
514726ff6a1SBill Paul #define VR_PCI_HEADER_TYPE	0x0E
515726ff6a1SBill Paul #define VR_PCI_LOIO		0x10
516726ff6a1SBill Paul #define VR_PCI_LOMEM		0x14
517726ff6a1SBill Paul #define VR_PCI_BIOSROM		0x30
518726ff6a1SBill Paul #define VR_PCI_INTLINE		0x3C
519726ff6a1SBill Paul #define VR_PCI_INTPIN		0x3D
520726ff6a1SBill Paul #define VR_PCI_MINGNT		0x3E
521726ff6a1SBill Paul #define VR_PCI_MINLAT		0x0F
522726ff6a1SBill Paul #define VR_PCI_RESETOPT		0x48
523726ff6a1SBill Paul #define VR_PCI_EEPROM_DATA	0x4C
524726ff6a1SBill Paul 
525726ff6a1SBill Paul /* power management registers */
526726ff6a1SBill Paul #define VR_PCI_CAPID		0xDC /* 8 bits */
527726ff6a1SBill Paul #define VR_PCI_NEXTPTR		0xDD /* 8 bits */
528726ff6a1SBill Paul #define VR_PCI_PWRMGMTCAP	0xDE /* 16 bits */
529726ff6a1SBill Paul #define VR_PCI_PWRMGMTCTRL	0xE0 /* 16 bits */
530726ff6a1SBill Paul 
531726ff6a1SBill Paul #define VR_PSTATE_MASK		0x0003
532726ff6a1SBill Paul #define VR_PSTATE_D0		0x0000
533726ff6a1SBill Paul #define VR_PSTATE_D1		0x0002
534726ff6a1SBill Paul #define VR_PSTATE_D2		0x0002
535726ff6a1SBill Paul #define VR_PSTATE_D3		0x0003
536726ff6a1SBill Paul #define VR_PME_EN		0x0010
537726ff6a1SBill Paul #define VR_PME_STATUS		0x8000
538726ff6a1SBill Paul 
539726ff6a1SBill Paul #define PHY_UNKNOWN		6
540726ff6a1SBill Paul 
541726ff6a1SBill Paul #define VR_PHYADDR_MIN		0x00
542726ff6a1SBill Paul #define VR_PHYADDR_MAX		0x1F
543726ff6a1SBill Paul 
544726ff6a1SBill Paul #define PHY_BMCR		0x00
545726ff6a1SBill Paul #define PHY_BMSR		0x01
546726ff6a1SBill Paul #define PHY_VENID		0x02
547726ff6a1SBill Paul #define PHY_DEVID		0x03
548726ff6a1SBill Paul #define PHY_ANAR		0x04
549726ff6a1SBill Paul #define PHY_LPAR		0x05
550726ff6a1SBill Paul #define PHY_ANEXP		0x06
551726ff6a1SBill Paul 
552726ff6a1SBill Paul #define PHY_ANAR_NEXTPAGE	0x8000
553726ff6a1SBill Paul #define PHY_ANAR_RSVD0		0x4000
554726ff6a1SBill Paul #define PHY_ANAR_TLRFLT		0x2000
555726ff6a1SBill Paul #define PHY_ANAR_RSVD1		0x1000
556726ff6a1SBill Paul #define PHY_ANAR_RSVD2		0x0800
557726ff6a1SBill Paul #define PHY_ANAR_RSVD3		0x0400
558726ff6a1SBill Paul #define PHY_ANAR_100BT4		0x0200
559726ff6a1SBill Paul #define PHY_ANAR_100BTXFULL	0x0100
560726ff6a1SBill Paul #define PHY_ANAR_100BTXHALF	0x0080
561726ff6a1SBill Paul #define PHY_ANAR_10BTFULL	0x0040
562726ff6a1SBill Paul #define PHY_ANAR_10BTHALF	0x0020
563726ff6a1SBill Paul #define PHY_ANAR_PROTO4		0x0010
564726ff6a1SBill Paul #define PHY_ANAR_PROTO3		0x0008
565726ff6a1SBill Paul #define PHY_ANAR_PROTO2		0x0004
566726ff6a1SBill Paul #define PHY_ANAR_PROTO1		0x0002
567726ff6a1SBill Paul #define PHY_ANAR_PROTO0		0x0001
568726ff6a1SBill Paul 
569726ff6a1SBill Paul /*
570726ff6a1SBill Paul  * These are the register definitions for the PHY (physical layer
571726ff6a1SBill Paul  * interface chip).
572726ff6a1SBill Paul  */
573726ff6a1SBill Paul /*
574726ff6a1SBill Paul  * PHY BMCR Basic Mode Control Register
575726ff6a1SBill Paul  */
576726ff6a1SBill Paul #define PHY_BMCR_RESET			0x8000
577726ff6a1SBill Paul #define PHY_BMCR_LOOPBK			0x4000
578726ff6a1SBill Paul #define PHY_BMCR_SPEEDSEL		0x2000
579726ff6a1SBill Paul #define PHY_BMCR_AUTONEGENBL		0x1000
580726ff6a1SBill Paul #define PHY_BMCR_RSVD0			0x0800	/* write as zero */
581726ff6a1SBill Paul #define PHY_BMCR_ISOLATE		0x0400
582726ff6a1SBill Paul #define PHY_BMCR_AUTONEGRSTR		0x0200
583726ff6a1SBill Paul #define PHY_BMCR_DUPLEX			0x0100
584726ff6a1SBill Paul #define PHY_BMCR_COLLTEST		0x0080
585726ff6a1SBill Paul #define PHY_BMCR_RSVD1			0x0040	/* write as zero, don't care */
586726ff6a1SBill Paul #define PHY_BMCR_RSVD2			0x0020	/* write as zero, don't care */
587726ff6a1SBill Paul #define PHY_BMCR_RSVD3			0x0010	/* write as zero, don't care */
588726ff6a1SBill Paul #define PHY_BMCR_RSVD4			0x0008	/* write as zero, don't care */
589726ff6a1SBill Paul #define PHY_BMCR_RSVD5			0x0004	/* write as zero, don't care */
590726ff6a1SBill Paul #define PHY_BMCR_RSVD6			0x0002	/* write as zero, don't care */
591726ff6a1SBill Paul #define PHY_BMCR_RSVD7			0x0001	/* write as zero, don't care */
592726ff6a1SBill Paul /*
593726ff6a1SBill Paul  * RESET: 1 == software reset, 0 == normal operation
594726ff6a1SBill Paul  * Resets status and control registers to default values.
595726ff6a1SBill Paul  * Relatches all hardware config values.
596726ff6a1SBill Paul  *
597726ff6a1SBill Paul  * LOOPBK: 1 == loopback operation enabled, 0 == normal operation
598726ff6a1SBill Paul  *
599726ff6a1SBill Paul  * SPEEDSEL: 1 == 100Mb/s, 0 == 10Mb/s
600726ff6a1SBill Paul  * Link speed is selected byt his bit or if auto-negotiation if bit
601726ff6a1SBill Paul  * 12 (AUTONEGENBL) is set (in which case the value of this register
602726ff6a1SBill Paul  * is ignored).
603726ff6a1SBill Paul  *
604726ff6a1SBill Paul  * AUTONEGENBL: 1 == Autonegotiation enabled, 0 == Autonegotiation disabled
605726ff6a1SBill Paul  * Bits 8 and 13 are ignored when autoneg is set, otherwise bits 8 and 13
606726ff6a1SBill Paul  * determine speed and mode. Should be cleared and then set if PHY configured
607726ff6a1SBill Paul  * for no autoneg on startup.
608726ff6a1SBill Paul  *
609726ff6a1SBill Paul  * ISOLATE: 1 == isolate PHY from MII, 0 == normal operation
610726ff6a1SBill Paul  *
611726ff6a1SBill Paul  * AUTONEGRSTR: 1 == restart autonegotiation, 0 = normal operation
612726ff6a1SBill Paul  *
613726ff6a1SBill Paul  * DUPLEX: 1 == full duplex mode, 0 == half duplex mode
614726ff6a1SBill Paul  *
615726ff6a1SBill Paul  * COLLTEST: 1 == collision test enabled, 0 == normal operation
616726ff6a1SBill Paul  */
617726ff6a1SBill Paul 
618726ff6a1SBill Paul /*
619726ff6a1SBill Paul  * PHY, BMSR Basic Mode Status Register
620726ff6a1SBill Paul  */
621726ff6a1SBill Paul #define PHY_BMSR_100BT4			0x8000
622726ff6a1SBill Paul #define PHY_BMSR_100BTXFULL		0x4000
623726ff6a1SBill Paul #define PHY_BMSR_100BTXHALF		0x2000
624726ff6a1SBill Paul #define PHY_BMSR_10BTFULL		0x1000
625726ff6a1SBill Paul #define PHY_BMSR_10BTHALF		0x0800
626726ff6a1SBill Paul #define PHY_BMSR_RSVD1			0x0400	/* write as zero, don't care */
627726ff6a1SBill Paul #define PHY_BMSR_RSVD2			0x0200	/* write as zero, don't care */
628726ff6a1SBill Paul #define PHY_BMSR_RSVD3			0x0100	/* write as zero, don't care */
629726ff6a1SBill Paul #define PHY_BMSR_RSVD4			0x0080	/* write as zero, don't care */
630726ff6a1SBill Paul #define PHY_BMSR_MFPRESUP		0x0040
631726ff6a1SBill Paul #define PHY_BMSR_AUTONEGCOMP		0x0020
632726ff6a1SBill Paul #define PHY_BMSR_REMFAULT		0x0010
633726ff6a1SBill Paul #define PHY_BMSR_CANAUTONEG		0x0008
634726ff6a1SBill Paul #define PHY_BMSR_LINKSTAT		0x0004
635726ff6a1SBill Paul #define PHY_BMSR_JABBER			0x0002
636726ff6a1SBill Paul #define PHY_BMSR_EXTENDED		0x0001
637