if_ruereg.h revision 184610
1184610Salfred/*-
2184610Salfred * Copyright (c) 2001-2003, Shunsuke Akiyama <akiyama@FreeBSD.org>.
3184610Salfred * All rights reserved.
4184610Salfred *
5184610Salfred * Redistribution and use in source and binary forms, with or without
6184610Salfred * modification, are permitted provided that the following conditions
7184610Salfred * are met:
8184610Salfred * 1. Redistributions of source code must retain the above copyright
9184610Salfred *    notice, this list of conditions and the following disclaimer.
10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright
11184610Salfred *    notice, this list of conditions and the following disclaimer in the
12184610Salfred *    documentation and/or other materials provided with the distribution.
13184610Salfred *
14184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17184610Salfred * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22184610Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24184610Salfred * SUCH DAMAGE.
25184610Salfred *
26184610Salfred * $FreeBSD: head/sys/dev/usb2/ethernet/if_rue2_reg.h 184610 2008-11-04 02:31:03Z alfred $
27184610Salfred */
28184610Salfred
29184610Salfred#define	RUE_CONFIG_IDX		0	/* config number 1 */
30184610Salfred#define	RUE_IFACE_IDX		0
31184610Salfred
32184610Salfred#define	RUE_ENDPT_MAX		6
33184610Salfred
34184610Salfred#define	RUE_INTR_PKTLEN		0x8
35184610Salfred
36184610Salfred#define	RUE_TIMEOUT		50
37184610Salfred#define	RUE_MIN_FRAMELEN	60
38184610Salfred
39184610Salfred/* Registers. */
40184610Salfred#define	RUE_IDR0		0x0120
41184610Salfred#define	RUE_IDR1		0x0121
42184610Salfred#define	RUE_IDR2		0x0122
43184610Salfred#define	RUE_IDR3		0x0123
44184610Salfred#define	RUE_IDR4		0x0124
45184610Salfred#define	RUE_IDR5		0x0125
46184610Salfred
47184610Salfred#define	RUE_MAR0		0x0126
48184610Salfred#define	RUE_MAR1		0x0127
49184610Salfred#define	RUE_MAR2		0x0128
50184610Salfred#define	RUE_MAR3		0x0129
51184610Salfred#define	RUE_MAR4		0x012A
52184610Salfred#define	RUE_MAR5		0x012B
53184610Salfred#define	RUE_MAR6		0x012C
54184610Salfred#define	RUE_MAR7		0x012D
55184610Salfred
56184610Salfred#define	RUE_CR			0x012E	/* B, R/W */
57184610Salfred#define	RUE_CR_SOFT_RST		0x10
58184610Salfred#define	RUE_CR_RE		0x08
59184610Salfred#define	RUE_CR_TE		0x04
60184610Salfred#define	RUE_CR_EP3CLREN		0x02
61184610Salfred
62184610Salfred#define	RUE_TCR			0x012F	/* B, R/W */
63184610Salfred#define	RUE_TCR_TXRR1		0x80
64184610Salfred#define	RUE_TCR_TXRR0		0x40
65184610Salfred#define	RUE_TCR_IFG1		0x10
66184610Salfred#define	RUE_TCR_IFG0		0x08
67184610Salfred#define	RUE_TCR_NOCRC		0x01
68184610Salfred#define	RUE_TCR_CONFIG		(RUE_TCR_TXRR1 | RUE_TCR_TXRR0 | 	\
69184610Salfred				    RUE_TCR_IFG1 | RUE_TCR_IFG0)
70184610Salfred
71184610Salfred#define	RUE_RCR			0x0130	/* W, R/W */
72184610Salfred#define	RUE_RCR_TAIL		0x80
73184610Salfred#define	RUE_RCR_AER		0x40
74184610Salfred#define	RUE_RCR_AR		0x20
75184610Salfred#define	RUE_RCR_AM		0x10
76184610Salfred#define	RUE_RCR_AB		0x08
77184610Salfred#define	RUE_RCR_AD		0x04
78184610Salfred#define	RUE_RCR_AAM		0x02
79184610Salfred#define	RUE_RCR_AAP		0x01
80184610Salfred#define	RUE_RCR_CONFIG		(RUE_RCR_TAIL | RUE_RCR_AD)
81184610Salfred
82184610Salfred#define	RUE_TSR			0x0132
83184610Salfred#define	RUE_RSR			0x0133
84184610Salfred#define	RUE_CON0		0x0135
85184610Salfred#define	RUE_CON1		0x0136
86184610Salfred#define	RUE_MSR			0x0137
87184610Salfred#define	RUE_PHYADD		0x0138
88184610Salfred#define	RUE_PHYDAT		0x0139
89184610Salfred
90184610Salfred#define	RUE_PHYCNT		0x013B	/* B, R/W */
91184610Salfred#define	RUE_PHYCNT_PHYOWN	0x40
92184610Salfred#define	RUE_PHYCNT_RWCR		0x20
93184610Salfred
94184610Salfred#define	RUE_GPPC		0x013D
95184610Salfred#define	RUE_WAKECNT		0x013E
96184610Salfred
97184610Salfred#define	RUE_BMCR		0x0140
98184610Salfred#define	RUE_BMCR_SPD_SET	0x2000
99184610Salfred#define	RUE_BMCR_DUPLEX		0x0100
100184610Salfred
101184610Salfred#define	RUE_BMSR		0x0142
102184610Salfred
103184610Salfred#define	RUE_ANAR		0x0144	/* W, R/W */
104184610Salfred#define	RUE_ANAR_PAUSE		0x0400
105184610Salfred
106184610Salfred#define	RUE_ANLP		0x0146	/* W, R/O */
107184610Salfred#define	RUE_ANLP_PAUSE		0x0400
108184610Salfred
109184610Salfred#define	RUE_AER			0x0148
110184610Salfred
111184610Salfred#define	RUE_NWAYT		0x014A
112184610Salfred#define	RUE_CSCR		0x014C
113184610Salfred
114184610Salfred#define	RUE_CRC0		0x014E
115184610Salfred#define	RUE_CRC1		0x0150
116184610Salfred#define	RUE_CRC2		0x0152
117184610Salfred#define	RUE_CRC3		0x0154
118184610Salfred#define	RUE_CRC4		0x0156
119184610Salfred
120184610Salfred#define	RUE_BYTEMASK0		0x0158
121184610Salfred#define	RUE_BYTEMASK1		0x0160
122184610Salfred#define	RUE_BYTEMASK2		0x0168
123184610Salfred#define	RUE_BYTEMASK3		0x0170
124184610Salfred#define	RUE_BYTEMASK4		0x0178
125184610Salfred
126184610Salfred#define	RUE_PHY1		0x0180
127184610Salfred#define	RUE_PHY2		0x0184
128184610Salfred
129184610Salfred#define	RUE_TW1			0x0186
130184610Salfred
131184610Salfred#define	RUE_REG_MIN		0x0120
132184610Salfred#define	RUE_REG_MAX		0x0189
133184610Salfred
134184610Salfred/* EEPROM address declarations. */
135184610Salfred#define	RUE_EEPROM_BASE		0x1200
136184610Salfred#define	RUE_EEPROM_IDR0		(RUE_EEPROM_BASE + 0x02)
137184610Salfred#define	RUE_EEPROM_IDR1		(RUE_EEPROM_BASE + 0x03)
138184610Salfred#define	RUE_EEPROM_IDR2		(RUE_EEPROM_BASE + 0x03)
139184610Salfred#define	RUE_EEPROM_IDR3		(RUE_EEPROM_BASE + 0x03)
140184610Salfred#define	RUE_EEPROM_IDR4		(RUE_EEPROM_BASE + 0x03)
141184610Salfred#define	RUE_EEPROM_IDR5		(RUE_EEPROM_BASE + 0x03)
142184610Salfred#define	RUE_EEPROM_INTERVAL	(RUE_EEPROM_BASE + 0x17)
143184610Salfred
144184610Salfred#define	RUE_RXSTAT_VALID	(0x01 << 12)
145184610Salfred#define	RUE_RXSTAT_RUNT		(0x02 << 12)
146184610Salfred#define	RUE_RXSTAT_PMATCH	(0x04 << 12)
147184610Salfred#define	RUE_RXSTAT_MCAST	(0x08 << 12)
148184610Salfred
149184610Salfred#define	GET_MII(sc)	((sc)->sc_miibus ?				\
150184610Salfred			    device_get_softc((sc)->sc_miibus) : NULL)
151184610Salfred
152184610Salfredstruct rue_intrpkt {
153184610Salfred	uint8_t	rue_tsr;
154184610Salfred	uint8_t	rue_rsr;
155184610Salfred	uint8_t	rue_gep_msr;
156184610Salfred	uint8_t	rue_waksr;
157184610Salfred	uint8_t	rue_txok_cnt;
158184610Salfred	uint8_t	rue_rxlost_cnt;
159184610Salfred	uint8_t	rue_crcerr_cnt;
160184610Salfred	uint8_t	rue_col_cnt;
161184610Salfred} __packed;
162184610Salfred
163184610Salfredstruct rue_type {
164184610Salfred	uint16_t rue_vid;
165184610Salfred	uint16_t rue_did;
166184610Salfred};
167184610Salfred
168184610Salfredstruct rue_softc {
169184610Salfred	void   *sc_evilhack;		/* XXX this pointer must be first */
170184610Salfred
171184610Salfred	struct usb2_config_td sc_config_td;
172184610Salfred	struct usb2_callout sc_watchdog;
173184610Salfred	struct mtx sc_mtx;
174184610Salfred
175184610Salfred	struct ifnet *sc_ifp;
176184610Salfred	struct usb2_device *sc_udev;
177184610Salfred	struct usb2_xfer *sc_xfer[RUE_ENDPT_MAX];
178184610Salfred	device_t sc_miibus;
179184610Salfred	device_t sc_dev;
180184610Salfred
181184610Salfred	uint32_t sc_unit;
182184610Salfred	uint32_t sc_media_active;
183184610Salfred	uint32_t sc_media_status;
184184610Salfred
185184610Salfred	uint16_t sc_flags;
186184610Salfred#define	RUE_FLAG_WAIT_LINK	0x0001
187184610Salfred#define	RUE_FLAG_INTR_STALL	0x0002
188184610Salfred#define	RUE_FLAG_READ_STALL	0x0004
189184610Salfred#define	RUE_FLAG_WRITE_STALL	0x0008
190184610Salfred#define	RUE_FLAG_LL_READY	0x0010
191184610Salfred#define	RUE_FLAG_HL_READY	0x0020
192184610Salfred
193184610Salfred	uint8_t	sc_name[16];
194184610Salfred};
195