xref: /onnv-gate/usr/src/uts/common/io/rwd/rt2661_reg.h (revision 9983:660985e98e06)
1*9983SFei.Feng@Sun.COM /*
2*9983SFei.Feng@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3*9983SFei.Feng@Sun.COM  * Use is subject to license terms.
4*9983SFei.Feng@Sun.COM  */
5*9983SFei.Feng@Sun.COM 
6*9983SFei.Feng@Sun.COM /*
7*9983SFei.Feng@Sun.COM  * Copyright (c) 2006
8*9983SFei.Feng@Sun.COM  *	Damien Bergamini <damien.bergamini@free.fr>
9*9983SFei.Feng@Sun.COM  *
10*9983SFei.Feng@Sun.COM  * Permission to use, copy, modify, and distribute this software for any
11*9983SFei.Feng@Sun.COM  * purpose with or without fee is hereby granted, provided that the above
12*9983SFei.Feng@Sun.COM  * copyright notice and this permission notice appear in all copies.
13*9983SFei.Feng@Sun.COM  *
14*9983SFei.Feng@Sun.COM  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15*9983SFei.Feng@Sun.COM  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16*9983SFei.Feng@Sun.COM  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17*9983SFei.Feng@Sun.COM  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18*9983SFei.Feng@Sun.COM  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19*9983SFei.Feng@Sun.COM  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20*9983SFei.Feng@Sun.COM  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21*9983SFei.Feng@Sun.COM  */
22*9983SFei.Feng@Sun.COM 
23*9983SFei.Feng@Sun.COM #ifndef _RT2661_REG_H
24*9983SFei.Feng@Sun.COM #define	_RT2661_REG_H
25*9983SFei.Feng@Sun.COM 
26*9983SFei.Feng@Sun.COM #ifdef __cplusplus
27*9983SFei.Feng@Sun.COM extern "C" {
28*9983SFei.Feng@Sun.COM #endif
29*9983SFei.Feng@Sun.COM 
30*9983SFei.Feng@Sun.COM #define	RT2661_NOISE_FLOOR	-95
31*9983SFei.Feng@Sun.COM 
32*9983SFei.Feng@Sun.COM #define	RT2661_TX_RING_COUNT	32
33*9983SFei.Feng@Sun.COM #define	RT2661_MGT_RING_COUNT	32
34*9983SFei.Feng@Sun.COM #define	RT2661_RX_RING_COUNT	64
35*9983SFei.Feng@Sun.COM 
36*9983SFei.Feng@Sun.COM #define	RT2661_TX_DESC_SIZE	(sizeof (struct rt2661_tx_desc))
37*9983SFei.Feng@Sun.COM #define	RT2661_TX_DESC_WSIZE	(RT2661_TX_DESC_SIZE / 4)
38*9983SFei.Feng@Sun.COM #define	RT2661_RX_DESC_SIZE	(sizeof (struct rt2661_rx_desc))
39*9983SFei.Feng@Sun.COM #define	RT2661_RX_DESC_WSIZE	(RT2661_RX_DESC_SIZE / 4)
40*9983SFei.Feng@Sun.COM 
41*9983SFei.Feng@Sun.COM #define	RT2661_MAX_SCATTER	5
42*9983SFei.Feng@Sun.COM 
43*9983SFei.Feng@Sun.COM /*
44*9983SFei.Feng@Sun.COM  * Control and status registers.
45*9983SFei.Feng@Sun.COM  */
46*9983SFei.Feng@Sun.COM #define	RT2661_HOST_CMD_CSR		0x0008
47*9983SFei.Feng@Sun.COM #define	RT2661_MCU_CNTL_CSR		0x000c
48*9983SFei.Feng@Sun.COM #define	RT2661_SOFT_RESET_CSR		0x0010
49*9983SFei.Feng@Sun.COM #define	RT2661_MCU_INT_SOURCE_CSR	0x0014
50*9983SFei.Feng@Sun.COM #define	RT2661_MCU_INT_MASK_CSR		0x0018
51*9983SFei.Feng@Sun.COM #define	RT2661_PCI_USEC_CSR		0x001c
52*9983SFei.Feng@Sun.COM #define	RT2661_H2M_MAILBOX_CSR		0x2100
53*9983SFei.Feng@Sun.COM #define	RT2661_M2H_CMD_DONE_CSR		0x2104
54*9983SFei.Feng@Sun.COM #define	RT2661_HW_BEACON_BASE0		0x2c00
55*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR0			0x3000
56*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR1			0x3004
57*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR2			0x3008
58*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR3			0x300c
59*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR4			0x3010
60*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR5			0x3014
61*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR6			0x3018
62*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR7			0x301c
63*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR8			0x3020
64*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR9			0x3024
65*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR10		0x3028
66*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR11		0x302c
67*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR12		0x3030
68*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR13		0x3034
69*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR14		0x3038
70*9983SFei.Feng@Sun.COM #define	RT2661_MAC_CSR15		0x303c
71*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR0		0x3040
72*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR1		0x3044
73*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR2		0x3048
74*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR3		0x304c
75*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR4		0x3050
76*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR5		0x3054
77*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR6		0x3058
78*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR7		0x305c
79*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR8		0x3060
80*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR9		0x3064
81*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR10		0x3068
82*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR11		0x306c
83*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR12		0x3070
84*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR13		0x3074
85*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR14		0x3078
86*9983SFei.Feng@Sun.COM #define	RT2661_TXRX_CSR15		0x307c
87*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR0			0x3080
88*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR1			0x3084
89*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR2			0x3088
90*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR3			0x308c
91*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR4			0x3090
92*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR5			0x3094
93*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR6			0x3098
94*9983SFei.Feng@Sun.COM #define	RT2661_PHY_CSR7			0x309c
95*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR0			0x30a0
96*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR1			0x30a4
97*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR2			0x30a8
98*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR3			0x30ac
99*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR4			0x30b0
100*9983SFei.Feng@Sun.COM #define	RT2661_SEC_CSR5			0x30b4
101*9983SFei.Feng@Sun.COM #define	RT2661_STA_CSR0			0x30c0
102*9983SFei.Feng@Sun.COM #define	RT2661_STA_CSR1			0x30c4
103*9983SFei.Feng@Sun.COM #define	RT2661_STA_CSR2			0x30c8
104*9983SFei.Feng@Sun.COM #define	RT2661_STA_CSR3			0x30cc
105*9983SFei.Feng@Sun.COM #define	RT2661_STA_CSR4			0x30d0
106*9983SFei.Feng@Sun.COM #define	RT2661_AC0_BASE_CSR		0x3400
107*9983SFei.Feng@Sun.COM #define	RT2661_AC1_BASE_CSR		0x3404
108*9983SFei.Feng@Sun.COM #define	RT2661_AC2_BASE_CSR		0x3408
109*9983SFei.Feng@Sun.COM #define	RT2661_AC3_BASE_CSR		0x340c
110*9983SFei.Feng@Sun.COM #define	RT2661_MGT_BASE_CSR		0x3410
111*9983SFei.Feng@Sun.COM #define	RT2661_TX_RING_CSR0		0x3418
112*9983SFei.Feng@Sun.COM #define	RT2661_TX_RING_CSR1		0x341c
113*9983SFei.Feng@Sun.COM #define	RT2661_AIFSN_CSR		0x3420
114*9983SFei.Feng@Sun.COM #define	RT2661_CWMIN_CSR		0x3424
115*9983SFei.Feng@Sun.COM #define	RT2661_CWMAX_CSR		0x3428
116*9983SFei.Feng@Sun.COM #define	RT2661_TX_DMA_DST_CSR		0x342c
117*9983SFei.Feng@Sun.COM #define	RT2661_TX_CNTL_CSR		0x3430
118*9983SFei.Feng@Sun.COM #define	RT2661_LOAD_TX_RING_CSR		0x3434
119*9983SFei.Feng@Sun.COM #define	RT2661_RX_BASE_CSR		0x3450
120*9983SFei.Feng@Sun.COM #define	RT2661_RX_RING_CSR		0x3454
121*9983SFei.Feng@Sun.COM #define	RT2661_RX_CNTL_CSR		0x3458
122*9983SFei.Feng@Sun.COM #define	RT2661_PCI_CFG_CSR		0x3460
123*9983SFei.Feng@Sun.COM #define	RT2661_INT_SOURCE_CSR		0x3468
124*9983SFei.Feng@Sun.COM #define	RT2661_INT_MASK_CSR		0x346c
125*9983SFei.Feng@Sun.COM #define	RT2661_E2PROM_CSR		0x3470
126*9983SFei.Feng@Sun.COM #define	RT2661_AC_TXOP_CSR0		0x3474
127*9983SFei.Feng@Sun.COM #define	RT2661_AC_TXOP_CSR1		0x3478
128*9983SFei.Feng@Sun.COM #define	RT2661_TEST_MODE_CSR		0x3484
129*9983SFei.Feng@Sun.COM #define	RT2661_IO_CNTL_CSR		0x3498
130*9983SFei.Feng@Sun.COM #define	RT2661_MCU_CODE_BASE		0x4000
131*9983SFei.Feng@Sun.COM 
132*9983SFei.Feng@Sun.COM /* possible flags for register HOST_CMD_CSR */
133*9983SFei.Feng@Sun.COM #define	RT2661_KICK_CMD		(1 << 7)
134*9983SFei.Feng@Sun.COM /* Host to MCU (8051) command identifiers */
135*9983SFei.Feng@Sun.COM #define	RT2661_MCU_CMD_SLEEP	0x30
136*9983SFei.Feng@Sun.COM #define	RT2661_MCU_CMD_WAKEUP	0x31
137*9983SFei.Feng@Sun.COM #define	RT2661_MCU_SET_LED	0x50
138*9983SFei.Feng@Sun.COM #define	RT2661_MCU_SET_RSSI_LED	0x52
139*9983SFei.Feng@Sun.COM 
140*9983SFei.Feng@Sun.COM /* possible flags for register MCU_CNTL_CSR */
141*9983SFei.Feng@Sun.COM #define	RT2661_MCU_SEL		(1 << 0)
142*9983SFei.Feng@Sun.COM #define	RT2661_MCU_RESET	(1 << 1)
143*9983SFei.Feng@Sun.COM #define	RT2661_MCU_READY	(1 << 2)
144*9983SFei.Feng@Sun.COM 
145*9983SFei.Feng@Sun.COM /* possible flags for register MCU_INT_SOURCE_CSR */
146*9983SFei.Feng@Sun.COM #define	RT2661_MCU_CMD_DONE		0xff
147*9983SFei.Feng@Sun.COM #define	RT2661_MCU_WAKEUP		(1 << 8)
148*9983SFei.Feng@Sun.COM #define	RT2661_MCU_BEACON_EXPIRE	(1 << 9)
149*9983SFei.Feng@Sun.COM 
150*9983SFei.Feng@Sun.COM /* possible flags for register H2M_MAILBOX_CSR */
151*9983SFei.Feng@Sun.COM #define	RT2661_H2M_BUSY		(1 << 24)
152*9983SFei.Feng@Sun.COM #define	RT2661_TOKEN_NO_INTR	0xff
153*9983SFei.Feng@Sun.COM 
154*9983SFei.Feng@Sun.COM /* possible flags for register MAC_CSR5 */
155*9983SFei.Feng@Sun.COM #define	RT2661_ONE_BSSID	3
156*9983SFei.Feng@Sun.COM 
157*9983SFei.Feng@Sun.COM /* possible flags for register TXRX_CSR0 */
158*9983SFei.Feng@Sun.COM /* Tx filter flags are in the low 16 bits */
159*9983SFei.Feng@Sun.COM #define	RT2661_AUTO_TX_SEQ	(1 << 15)
160*9983SFei.Feng@Sun.COM /* Rx filter flags are in the high 16 bits */
161*9983SFei.Feng@Sun.COM #define	RT2661_DISABLE_RX	(1 << 16)
162*9983SFei.Feng@Sun.COM #define	RT2661_DROP_CRC_ERROR	(1 << 17)
163*9983SFei.Feng@Sun.COM #define	RT2661_DROP_PHY_ERROR	(1 << 18)
164*9983SFei.Feng@Sun.COM #define	RT2661_DROP_CTL		(1 << 19)
165*9983SFei.Feng@Sun.COM #define	RT2661_DROP_NOT_TO_ME	(1 << 20)
166*9983SFei.Feng@Sun.COM #define	RT2661_DROP_TODS	(1 << 21)
167*9983SFei.Feng@Sun.COM #define	RT2661_DROP_VER_ERROR	(1 << 22)
168*9983SFei.Feng@Sun.COM #define	RT2661_DROP_MULTICAST	(1 << 23)
169*9983SFei.Feng@Sun.COM #define	RT2661_DROP_BROADCAST	(1 << 24)
170*9983SFei.Feng@Sun.COM #define	RT2661_DROP_ACKCTS	(1 << 25)
171*9983SFei.Feng@Sun.COM 
172*9983SFei.Feng@Sun.COM /* possible flags for register TXRX_CSR4 */
173*9983SFei.Feng@Sun.COM #define	RT2661_SHORT_PREAMBLE	(1 << 19)
174*9983SFei.Feng@Sun.COM #define	RT2661_MRR_ENABLED	(1 << 20)
175*9983SFei.Feng@Sun.COM #define	RT2661_MRR_CCK_FALLBACK	(1 << 23)
176*9983SFei.Feng@Sun.COM 
177*9983SFei.Feng@Sun.COM /* possible flags for register TXRX_CSR9 */
178*9983SFei.Feng@Sun.COM #define	RT2661_TSF_TICKING	(1 << 16)
179*9983SFei.Feng@Sun.COM #define	RT2661_TSF_MODE(x)	(((x) & 0x3) << 17)
180*9983SFei.Feng@Sun.COM /* TBTT stands for Target Beacon Transmission Time */
181*9983SFei.Feng@Sun.COM #define	RT2661_ENABLE_TBTT	(1 << 19)
182*9983SFei.Feng@Sun.COM #define	RT2661_GENERATE_BEACON	(1 << 20)
183*9983SFei.Feng@Sun.COM 
184*9983SFei.Feng@Sun.COM /* possible flags for register PHY_CSR0 */
185*9983SFei.Feng@Sun.COM #define	RT2661_PA_PE_2GHZ	(1 << 16)
186*9983SFei.Feng@Sun.COM #define	RT2661_PA_PE_5GHZ	(1 << 17)
187*9983SFei.Feng@Sun.COM 
188*9983SFei.Feng@Sun.COM /* possible flags for register PHY_CSR3 */
189*9983SFei.Feng@Sun.COM #define	RT2661_BBP_READ	(1 << 15)
190*9983SFei.Feng@Sun.COM #define	RT2661_BBP_BUSY	(1 << 16)
191*9983SFei.Feng@Sun.COM 
192*9983SFei.Feng@Sun.COM /* possible flags for register PHY_CSR4 */
193*9983SFei.Feng@Sun.COM #define	RT2661_RF_21BIT	(21 << 24)
194*9983SFei.Feng@Sun.COM #define	RT2661_RF_BUSY	((uint32_t)1 << 31)
195*9983SFei.Feng@Sun.COM 
196*9983SFei.Feng@Sun.COM /* possible values for register STA_CSR4 */
197*9983SFei.Feng@Sun.COM #define	RT2661_TX_STAT_VALID	(1 << 0)
198*9983SFei.Feng@Sun.COM #define	RT2661_TX_RESULT(v)	(((v) >> 1) & 0x7)
199*9983SFei.Feng@Sun.COM #define	RT2661_TX_RETRYCNT(v)	(((v) >> 4) & 0xf)
200*9983SFei.Feng@Sun.COM #define	RT2661_TX_QID(v)	(((v) >> 8) & 0xf)
201*9983SFei.Feng@Sun.COM #define	RT2661_TX_SUCCESS	0
202*9983SFei.Feng@Sun.COM #define	RT2661_TX_RETRY_FAIL	6
203*9983SFei.Feng@Sun.COM 
204*9983SFei.Feng@Sun.COM /* possible flags for register TX_CNTL_CSR */
205*9983SFei.Feng@Sun.COM #define	RT2661_KICK_MGT	(1 << 4)
206*9983SFei.Feng@Sun.COM 
207*9983SFei.Feng@Sun.COM /* possible flags for register INT_SOURCE_CSR */
208*9983SFei.Feng@Sun.COM #define	RT2661_TX_DONE		(1 << 0)
209*9983SFei.Feng@Sun.COM #define	RT2661_RX_DONE		(1 << 1)
210*9983SFei.Feng@Sun.COM #define	RT2661_TX0_DMA_DONE	(1 << 16)
211*9983SFei.Feng@Sun.COM #define	RT2661_TX1_DMA_DONE	(1 << 17)
212*9983SFei.Feng@Sun.COM #define	RT2661_TX2_DMA_DONE	(1 << 18)
213*9983SFei.Feng@Sun.COM #define	RT2661_TX3_DMA_DONE	(1 << 19)
214*9983SFei.Feng@Sun.COM #define	RT2661_MGT_DONE		(1 << 20)
215*9983SFei.Feng@Sun.COM 
216*9983SFei.Feng@Sun.COM /* possible flags for register E2PROM_CSR */
217*9983SFei.Feng@Sun.COM #define	RT2661_C	(1 << 1)
218*9983SFei.Feng@Sun.COM #define	RT2661_S	(1 << 2)
219*9983SFei.Feng@Sun.COM #define	RT2661_D	(1 << 3)
220*9983SFei.Feng@Sun.COM #define	RT2661_Q	(1 << 4)
221*9983SFei.Feng@Sun.COM #define	RT2661_93C46	(1 << 5)
222*9983SFei.Feng@Sun.COM 
223*9983SFei.Feng@Sun.COM #pragma pack(1)
224*9983SFei.Feng@Sun.COM /* Tx descriptor */
225*9983SFei.Feng@Sun.COM struct rt2661_tx_desc {
226*9983SFei.Feng@Sun.COM 	uint32_t	flags;
227*9983SFei.Feng@Sun.COM #define	RT2661_TX_BUSY		(1 << 0)
228*9983SFei.Feng@Sun.COM #define	RT2661_TX_VALID		(1 << 1)
229*9983SFei.Feng@Sun.COM #define	RT2661_TX_MORE_FRAG	(1 << 2)
230*9983SFei.Feng@Sun.COM #define	RT2661_TX_NEED_ACK	(1 << 3)
231*9983SFei.Feng@Sun.COM #define	RT2661_TX_TIMESTAMP	(1 << 4)
232*9983SFei.Feng@Sun.COM #define	RT2661_TX_OFDM		(1 << 5)
233*9983SFei.Feng@Sun.COM #define	RT2661_TX_IFS		(1 << 6)
234*9983SFei.Feng@Sun.COM #define	RT2661_TX_LONG_RETRY	(1 << 7)
235*9983SFei.Feng@Sun.COM #define	RT2661_TX_BURST		(1 << 28)
236*9983SFei.Feng@Sun.COM 
237*9983SFei.Feng@Sun.COM 	uint16_t	wme;
238*9983SFei.Feng@Sun.COM #define	RT2661_QID(v)		(v)
239*9983SFei.Feng@Sun.COM #define	RT2661_AIFSN(v)		((v) << 4)
240*9983SFei.Feng@Sun.COM #define	RT2661_LOGCWMIN(v)	((v) << 8)
241*9983SFei.Feng@Sun.COM #define	RT2661_LOGCWMAX(v)	((v) << 12)
242*9983SFei.Feng@Sun.COM 
243*9983SFei.Feng@Sun.COM 	uint16_t	xflags;
244*9983SFei.Feng@Sun.COM #define	RT2661_TX_HWSEQ		(1 << 12)
245*9983SFei.Feng@Sun.COM 
246*9983SFei.Feng@Sun.COM 	uint8_t		plcp_signal;
247*9983SFei.Feng@Sun.COM 	uint8_t		plcp_service;
248*9983SFei.Feng@Sun.COM #define	RT2661_PLCP_LENGEXT	0x80
249*9983SFei.Feng@Sun.COM 
250*9983SFei.Feng@Sun.COM 	uint8_t		plcp_length_lo;
251*9983SFei.Feng@Sun.COM 	uint8_t		plcp_length_hi;
252*9983SFei.Feng@Sun.COM 
253*9983SFei.Feng@Sun.COM 	uint32_t	iv;
254*9983SFei.Feng@Sun.COM 	uint32_t	eiv;
255*9983SFei.Feng@Sun.COM 
256*9983SFei.Feng@Sun.COM 	uint8_t		offset;
257*9983SFei.Feng@Sun.COM 	uint8_t		qid;
258*9983SFei.Feng@Sun.COM #define	RT2661_QID_MGT	13
259*9983SFei.Feng@Sun.COM 
260*9983SFei.Feng@Sun.COM 	uint8_t		txpower;
261*9983SFei.Feng@Sun.COM #define	RT2661_DEFAULT_TXPOWER	0
262*9983SFei.Feng@Sun.COM 
263*9983SFei.Feng@Sun.COM 	uint8_t		reserved1;
264*9983SFei.Feng@Sun.COM 
265*9983SFei.Feng@Sun.COM 	uint32_t	addr[RT2661_MAX_SCATTER];
266*9983SFei.Feng@Sun.COM 	uint16_t	len[RT2661_MAX_SCATTER];
267*9983SFei.Feng@Sun.COM 
268*9983SFei.Feng@Sun.COM 	uint16_t	reserved2;
269*9983SFei.Feng@Sun.COM };
270*9983SFei.Feng@Sun.COM #pragma pack()
271*9983SFei.Feng@Sun.COM 
272*9983SFei.Feng@Sun.COM #pragma pack(1)
273*9983SFei.Feng@Sun.COM /* Rx descriptor */
274*9983SFei.Feng@Sun.COM struct rt2661_rx_desc {
275*9983SFei.Feng@Sun.COM 	uint32_t	flags;
276*9983SFei.Feng@Sun.COM #define	RT2661_RX_BUSY		(1 << 0)
277*9983SFei.Feng@Sun.COM #define	RT2661_RX_DROP		(1 << 1)
278*9983SFei.Feng@Sun.COM #define	RT2661_RX_CRC_ERROR	(1 << 6)
279*9983SFei.Feng@Sun.COM #define	RT2661_RX_OFDM		(1 << 7)
280*9983SFei.Feng@Sun.COM #define	RT2661_RX_PHY_ERROR	(1 << 8)
281*9983SFei.Feng@Sun.COM #define	RT2661_RX_CIPHER_MASK	0x00000600
282*9983SFei.Feng@Sun.COM 
283*9983SFei.Feng@Sun.COM 	uint8_t		rate;
284*9983SFei.Feng@Sun.COM 	uint8_t		rssi;
285*9983SFei.Feng@Sun.COM 	uint8_t		reserved1;
286*9983SFei.Feng@Sun.COM 	uint8_t		offset;
287*9983SFei.Feng@Sun.COM 	uint32_t	iv;
288*9983SFei.Feng@Sun.COM 	uint32_t	eiv;
289*9983SFei.Feng@Sun.COM 	uint32_t	reserved2;
290*9983SFei.Feng@Sun.COM 	uint32_t	physaddr;
291*9983SFei.Feng@Sun.COM 	uint32_t	reserved3[10];
292*9983SFei.Feng@Sun.COM };
293*9983SFei.Feng@Sun.COM #pragma pack()
294*9983SFei.Feng@Sun.COM 
295*9983SFei.Feng@Sun.COM #define	RT2661_RF1	0
296*9983SFei.Feng@Sun.COM #define	RT2661_RF2	2
297*9983SFei.Feng@Sun.COM #define	RT2661_RF3	1
298*9983SFei.Feng@Sun.COM #define	RT2661_RF4	3
299*9983SFei.Feng@Sun.COM 
300*9983SFei.Feng@Sun.COM /* dual-band RF */
301*9983SFei.Feng@Sun.COM #define	RT2661_RF_5225	1
302*9983SFei.Feng@Sun.COM #define	RT2661_RF_5325	2
303*9983SFei.Feng@Sun.COM /* single-band RF */
304*9983SFei.Feng@Sun.COM #define	RT2661_RF_2527	3
305*9983SFei.Feng@Sun.COM #define	RT2661_RF_2529	4
306*9983SFei.Feng@Sun.COM 
307*9983SFei.Feng@Sun.COM #define	RT2661_RX_DESC_BACK	4
308*9983SFei.Feng@Sun.COM 
309*9983SFei.Feng@Sun.COM #define	RT2661_SMART_MODE	(1 << 0)
310*9983SFei.Feng@Sun.COM 
311*9983SFei.Feng@Sun.COM #define	RT2661_BBPR94_DEFAULT	6
312*9983SFei.Feng@Sun.COM 
313*9983SFei.Feng@Sun.COM #define	RT2661_SHIFT_D	3
314*9983SFei.Feng@Sun.COM #define	RT2661_SHIFT_Q	4
315*9983SFei.Feng@Sun.COM 
316*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_MAC01		0x02
317*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_MAC23		0x03
318*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_MAC45		0x04
319*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_ANTENNA		0x10
320*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_CONFIG2		0x11
321*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_BBP_BASE		0x13
322*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_TXPOWER		0x23
323*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_FREQ_OFFSET	0x2f
324*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_RSSI_2GHZ_OFFSET	0x4d
325*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_RSSI_5GHZ_OFFSET	0x4e
326*9983SFei.Feng@Sun.COM 
327*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_DELAY	1	/* minimum hold time (microsecond) */
328*9983SFei.Feng@Sun.COM 
329*9983SFei.Feng@Sun.COM /*
330*9983SFei.Feng@Sun.COM  * control and status registers access macros
331*9983SFei.Feng@Sun.COM  */
332*9983SFei.Feng@Sun.COM #define	RT2661_READ(sc, reg)						\
333*9983SFei.Feng@Sun.COM 	ddi_get32((sc)->sc_io_handle,					\
334*9983SFei.Feng@Sun.COM 	    (uint32_t *)((uintptr_t)(sc)->sc_io_base + (reg)))
335*9983SFei.Feng@Sun.COM 
336*9983SFei.Feng@Sun.COM #define	RT2661_WRITE(sc, reg, val)					\
337*9983SFei.Feng@Sun.COM 	ddi_put32((sc)->sc_io_handle,					\
338*9983SFei.Feng@Sun.COM 	    (uint32_t *)((uintptr_t)(sc)->sc_io_base + (reg)), (val))
339*9983SFei.Feng@Sun.COM 
340*9983SFei.Feng@Sun.COM #define	RT2661_MEM_WRITE1(sc, reg, val)					\
341*9983SFei.Feng@Sun.COM 	ddi_put8((sc)->sc_io_handle,					\
342*9983SFei.Feng@Sun.COM 	    (uint8_t *)((sc)->sc_io_base + (reg)), (val))
343*9983SFei.Feng@Sun.COM 
344*9983SFei.Feng@Sun.COM #define	RT2661_MEM_READ1(sc, reg)					\
345*9983SFei.Feng@Sun.COM 	ddi_get8((sc)->sc_io_handle,					\
346*9983SFei.Feng@Sun.COM 	    (uint8_t *)((sc)->sc_io_base + (reg)))
347*9983SFei.Feng@Sun.COM 
348*9983SFei.Feng@Sun.COM /*
349*9983SFei.Feng@Sun.COM  * EEPROM access macro
350*9983SFei.Feng@Sun.COM  */
351*9983SFei.Feng@Sun.COM #define	RT2661_EEPROM_CTL(sc, val) do {					\
352*9983SFei.Feng@Sun.COM 	RT2661_WRITE((sc), RT2661_E2PROM_CSR, (val));			\
353*9983SFei.Feng@Sun.COM 	DELAY(RT2661_EEPROM_DELAY);					\
354*9983SFei.Feng@Sun.COM 	_NOTE(CONSTCOND)						\
355*9983SFei.Feng@Sun.COM } while (0)
356*9983SFei.Feng@Sun.COM 
357*9983SFei.Feng@Sun.COM /*
358*9983SFei.Feng@Sun.COM  * Default values for MAC registers; values taken from the reference driver.
359*9983SFei.Feng@Sun.COM  */
360*9983SFei.Feng@Sun.COM #define	RT2661_DEF_MAC					\
361*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR0,	0x0000b032 },	\
362*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR1,	0x9eb39eb3 },	\
363*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR2,	0x8a8b8c8d },	\
364*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR3,	0x00858687 },	\
365*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR7,	0x2e31353b },	\
366*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR8,	0x2a2a2a2c },	\
367*9983SFei.Feng@Sun.COM 	{ RT2661_TXRX_CSR15,	0x0000000f },	\
368*9983SFei.Feng@Sun.COM 	{ RT2661_MAC_CSR6,	0x00000fff },	\
369*9983SFei.Feng@Sun.COM 	{ RT2661_MAC_CSR8,	0x016c030a },	\
370*9983SFei.Feng@Sun.COM 	{ RT2661_MAC_CSR10,	0x00000718 },	\
371*9983SFei.Feng@Sun.COM 	{ RT2661_MAC_CSR12,	0x00000004 },	\
372*9983SFei.Feng@Sun.COM 	{ RT2661_MAC_CSR13,	0x0000e000 },	\
373*9983SFei.Feng@Sun.COM 	{ RT2661_SEC_CSR0,	0x00000000 },	\
374*9983SFei.Feng@Sun.COM 	{ RT2661_SEC_CSR1,	0x00000000 },	\
375*9983SFei.Feng@Sun.COM 	{ RT2661_SEC_CSR5,	0x00000000 },	\
376*9983SFei.Feng@Sun.COM 	{ RT2661_PHY_CSR1,	0x000023b0 },	\
377*9983SFei.Feng@Sun.COM 	{ RT2661_PHY_CSR5,	0x060a100c },	\
378*9983SFei.Feng@Sun.COM 	{ RT2661_PHY_CSR6,	0x00080606 },	\
379*9983SFei.Feng@Sun.COM 	{ RT2661_PHY_CSR7,	0x00000a08 },	\
380*9983SFei.Feng@Sun.COM 	{ RT2661_PCI_CFG_CSR,	0x3cca4808 },	\
381*9983SFei.Feng@Sun.COM 	{ RT2661_AIFSN_CSR,	0x00002273 },	\
382*9983SFei.Feng@Sun.COM 	{ RT2661_CWMIN_CSR,	0x00002344 },	\
383*9983SFei.Feng@Sun.COM 	{ RT2661_CWMAX_CSR,	0x000034aa },	\
384*9983SFei.Feng@Sun.COM 	{ RT2661_TEST_MODE_CSR,	0x00000200 },	\
385*9983SFei.Feng@Sun.COM 	{ RT2661_M2H_CMD_DONE_CSR,	0xffffffff }
386*9983SFei.Feng@Sun.COM 
387*9983SFei.Feng@Sun.COM /*
388*9983SFei.Feng@Sun.COM  * Default values for BBP registers; values taken from the reference driver.
389*9983SFei.Feng@Sun.COM  */
390*9983SFei.Feng@Sun.COM #define	RT2661_DEF_BBP	\
391*9983SFei.Feng@Sun.COM 	{   3, 0x00 },	\
392*9983SFei.Feng@Sun.COM 	{  15, 0x30 },	\
393*9983SFei.Feng@Sun.COM 	{  17, 0x20 },	\
394*9983SFei.Feng@Sun.COM 	{  21, 0xc8 },	\
395*9983SFei.Feng@Sun.COM 	{  22, 0x38 },	\
396*9983SFei.Feng@Sun.COM 	{  23, 0x06 },	\
397*9983SFei.Feng@Sun.COM 	{  24, 0xfe },	\
398*9983SFei.Feng@Sun.COM 	{  25, 0x0a },	\
399*9983SFei.Feng@Sun.COM 	{  26, 0x0d },	\
400*9983SFei.Feng@Sun.COM 	{  34, 0x12 },	\
401*9983SFei.Feng@Sun.COM 	{  37, 0x07 },	\
402*9983SFei.Feng@Sun.COM 	{  39, 0xf8 },	\
403*9983SFei.Feng@Sun.COM 	{  41, 0x60 },	\
404*9983SFei.Feng@Sun.COM 	{  53, 0x10 },	\
405*9983SFei.Feng@Sun.COM 	{  54, 0x18 },	\
406*9983SFei.Feng@Sun.COM 	{  60, 0x10 },	\
407*9983SFei.Feng@Sun.COM 	{  61, 0x04 },	\
408*9983SFei.Feng@Sun.COM 	{  62, 0x04 },	\
409*9983SFei.Feng@Sun.COM 	{  75, 0xfe },	\
410*9983SFei.Feng@Sun.COM 	{  86, 0xfe },	\
411*9983SFei.Feng@Sun.COM 	{  88, 0xfe },	\
412*9983SFei.Feng@Sun.COM 	{  90, 0x0f },	\
413*9983SFei.Feng@Sun.COM 	{  99, 0x00 },	\
414*9983SFei.Feng@Sun.COM 	{ 102, 0x16 },	\
415*9983SFei.Feng@Sun.COM 	{ 107, 0x04 }
416*9983SFei.Feng@Sun.COM 
417*9983SFei.Feng@Sun.COM /*
418*9983SFei.Feng@Sun.COM  * Default settings for RF registers; values taken from the reference driver.
419*9983SFei.Feng@Sun.COM  */
420*9983SFei.Feng@Sun.COM #define	RT2661_RF5225_1					\
421*9983SFei.Feng@Sun.COM 	{   1, 0x00b33, 0x011e1, 0x1a014, 0x30282 },	\
422*9983SFei.Feng@Sun.COM 	{   2, 0x00b33, 0x011e1, 0x1a014, 0x30287 },	\
423*9983SFei.Feng@Sun.COM 	{   3, 0x00b33, 0x011e2, 0x1a014, 0x30282 },	\
424*9983SFei.Feng@Sun.COM 	{   4, 0x00b33, 0x011e2, 0x1a014, 0x30287 },	\
425*9983SFei.Feng@Sun.COM 	{   5, 0x00b33, 0x011e3, 0x1a014, 0x30282 },	\
426*9983SFei.Feng@Sun.COM 	{   6, 0x00b33, 0x011e3, 0x1a014, 0x30287 },	\
427*9983SFei.Feng@Sun.COM 	{   7, 0x00b33, 0x011e4, 0x1a014, 0x30282 },	\
428*9983SFei.Feng@Sun.COM 	{   8, 0x00b33, 0x011e4, 0x1a014, 0x30287 },	\
429*9983SFei.Feng@Sun.COM 	{   9, 0x00b33, 0x011e5, 0x1a014, 0x30282 },	\
430*9983SFei.Feng@Sun.COM 	{  10, 0x00b33, 0x011e5, 0x1a014, 0x30287 },	\
431*9983SFei.Feng@Sun.COM 	{  11, 0x00b33, 0x011e6, 0x1a014, 0x30282 },	\
432*9983SFei.Feng@Sun.COM 	{  12, 0x00b33, 0x011e6, 0x1a014, 0x30287 },	\
433*9983SFei.Feng@Sun.COM 	{  13, 0x00b33, 0x011e7, 0x1a014, 0x30282 },	\
434*9983SFei.Feng@Sun.COM 	{  14, 0x00b33, 0x011e8, 0x1a014, 0x30284 },	\
435*9983SFei.Feng@Sun.COM 							\
436*9983SFei.Feng@Sun.COM 	{  36, 0x00b33, 0x01266, 0x26014, 0x30288 },	\
437*9983SFei.Feng@Sun.COM 	{  40, 0x00b33, 0x01268, 0x26014, 0x30280 },	\
438*9983SFei.Feng@Sun.COM 	{  44, 0x00b33, 0x01269, 0x26014, 0x30282 },	\
439*9983SFei.Feng@Sun.COM 	{  48, 0x00b33, 0x0126a, 0x26014, 0x30284 },	\
440*9983SFei.Feng@Sun.COM 	{  52, 0x00b33, 0x0126b, 0x26014, 0x30286 },	\
441*9983SFei.Feng@Sun.COM 	{  56, 0x00b33, 0x0126c, 0x26014, 0x30288 },	\
442*9983SFei.Feng@Sun.COM 	{  60, 0x00b33, 0x0126e, 0x26014, 0x30280 },	\
443*9983SFei.Feng@Sun.COM 	{  64, 0x00b33, 0x0126f, 0x26014, 0x30282 },	\
444*9983SFei.Feng@Sun.COM 							\
445*9983SFei.Feng@Sun.COM 	{ 100, 0x00b33, 0x0128a, 0x2e014, 0x30280 },	\
446*9983SFei.Feng@Sun.COM 	{ 104, 0x00b33, 0x0128b, 0x2e014, 0x30282 },	\
447*9983SFei.Feng@Sun.COM 	{ 108, 0x00b33, 0x0128c, 0x2e014, 0x30284 },	\
448*9983SFei.Feng@Sun.COM 	{ 112, 0x00b33, 0x0128d, 0x2e014, 0x30286 },	\
449*9983SFei.Feng@Sun.COM 	{ 116, 0x00b33, 0x0128e, 0x2e014, 0x30288 },	\
450*9983SFei.Feng@Sun.COM 	{ 120, 0x00b33, 0x012a0, 0x2e014, 0x30280 },	\
451*9983SFei.Feng@Sun.COM 	{ 124, 0x00b33, 0x012a1, 0x2e014, 0x30282 },	\
452*9983SFei.Feng@Sun.COM 	{ 128, 0x00b33, 0x012a2, 0x2e014, 0x30284 },	\
453*9983SFei.Feng@Sun.COM 	{ 132, 0x00b33, 0x012a3, 0x2e014, 0x30286 },	\
454*9983SFei.Feng@Sun.COM 	{ 136, 0x00b33, 0x012a4, 0x2e014, 0x30288 },	\
455*9983SFei.Feng@Sun.COM 	{ 140, 0x00b33, 0x012a6, 0x2e014, 0x30280 },	\
456*9983SFei.Feng@Sun.COM 							\
457*9983SFei.Feng@Sun.COM 	{ 149, 0x00b33, 0x012a8, 0x2e014, 0x30287 },	\
458*9983SFei.Feng@Sun.COM 	{ 153, 0x00b33, 0x012a9, 0x2e014, 0x30289 },	\
459*9983SFei.Feng@Sun.COM 	{ 157, 0x00b33, 0x012ab, 0x2e014, 0x30281 },	\
460*9983SFei.Feng@Sun.COM 	{ 161, 0x00b33, 0x012ac, 0x2e014, 0x30283 },	\
461*9983SFei.Feng@Sun.COM 	{ 165, 0x00b33, 0x012ad, 0x2e014, 0x30285 }
462*9983SFei.Feng@Sun.COM 
463*9983SFei.Feng@Sun.COM #define	RT2661_RF5225_2					\
464*9983SFei.Feng@Sun.COM 	{   1, 0x00b33, 0x011e1, 0x1a014, 0x30282 },	\
465*9983SFei.Feng@Sun.COM 	{   2, 0x00b33, 0x011e1, 0x1a014, 0x30287 },	\
466*9983SFei.Feng@Sun.COM 	{   3, 0x00b33, 0x011e2, 0x1a014, 0x30282 },	\
467*9983SFei.Feng@Sun.COM 	{   4, 0x00b33, 0x011e2, 0x1a014, 0x30287 },	\
468*9983SFei.Feng@Sun.COM 	{   5, 0x00b33, 0x011e3, 0x1a014, 0x30282 },	\
469*9983SFei.Feng@Sun.COM 	{   6, 0x00b33, 0x011e3, 0x1a014, 0x30287 },	\
470*9983SFei.Feng@Sun.COM 	{   7, 0x00b33, 0x011e4, 0x1a014, 0x30282 },	\
471*9983SFei.Feng@Sun.COM 	{   8, 0x00b33, 0x011e4, 0x1a014, 0x30287 },	\
472*9983SFei.Feng@Sun.COM 	{   9, 0x00b33, 0x011e5, 0x1a014, 0x30282 },	\
473*9983SFei.Feng@Sun.COM 	{  10, 0x00b33, 0x011e5, 0x1a014, 0x30287 },	\
474*9983SFei.Feng@Sun.COM 	{  11, 0x00b33, 0x011e6, 0x1a014, 0x30282 },	\
475*9983SFei.Feng@Sun.COM 	{  12, 0x00b33, 0x011e6, 0x1a014, 0x30287 },	\
476*9983SFei.Feng@Sun.COM 	{  13, 0x00b33, 0x011e7, 0x1a014, 0x30282 },	\
477*9983SFei.Feng@Sun.COM 	{  14, 0x00b33, 0x011e8, 0x1a014, 0x30284 },	\
478*9983SFei.Feng@Sun.COM 							\
479*9983SFei.Feng@Sun.COM 	{  36, 0x00b35, 0x11206, 0x26014, 0x30280 },	\
480*9983SFei.Feng@Sun.COM 	{  40, 0x00b34, 0x111a0, 0x26014, 0x30280 },	\
481*9983SFei.Feng@Sun.COM 	{  44, 0x00b34, 0x111a1, 0x26014, 0x30286 },	\
482*9983SFei.Feng@Sun.COM 	{  48, 0x00b34, 0x111a3, 0x26014, 0x30282 },	\
483*9983SFei.Feng@Sun.COM 	{  52, 0x00b34, 0x111a4, 0x26014, 0x30288 },	\
484*9983SFei.Feng@Sun.COM 	{  56, 0x00b34, 0x111a6, 0x26014, 0x30284 },	\
485*9983SFei.Feng@Sun.COM 	{  60, 0x00b34, 0x111a8, 0x26014, 0x30280 },	\
486*9983SFei.Feng@Sun.COM 	{  64, 0x00b34, 0x111a9, 0x26014, 0x30286 },	\
487*9983SFei.Feng@Sun.COM 							\
488*9983SFei.Feng@Sun.COM 	{ 100, 0x00b35, 0x11226, 0x2e014, 0x30280 },	\
489*9983SFei.Feng@Sun.COM 	{ 104, 0x00b35, 0x11228, 0x2e014, 0x30280 },	\
490*9983SFei.Feng@Sun.COM 	{ 108, 0x00b35, 0x1122a, 0x2e014, 0x30280 },	\
491*9983SFei.Feng@Sun.COM 	{ 112, 0x00b35, 0x1122c, 0x2e014, 0x30280 },	\
492*9983SFei.Feng@Sun.COM 	{ 116, 0x00b35, 0x1122e, 0x2e014, 0x30280 },	\
493*9983SFei.Feng@Sun.COM 	{ 120, 0x00b34, 0x111c0, 0x2e014, 0x30280 },	\
494*9983SFei.Feng@Sun.COM 	{ 124, 0x00b34, 0x111c1, 0x2e014, 0x30286 },	\
495*9983SFei.Feng@Sun.COM 	{ 128, 0x00b34, 0x111c3, 0x2e014, 0x30282 },	\
496*9983SFei.Feng@Sun.COM 	{ 132, 0x00b34, 0x111c4, 0x2e014, 0x30288 },	\
497*9983SFei.Feng@Sun.COM 	{ 136, 0x00b34, 0x111c6, 0x2e014, 0x30284 },	\
498*9983SFei.Feng@Sun.COM 	{ 140, 0x00b34, 0x111c8, 0x2e014, 0x30280 },	\
499*9983SFei.Feng@Sun.COM 							\
500*9983SFei.Feng@Sun.COM 	{ 149, 0x00b34, 0x111cb, 0x2e014, 0x30286 },	\
501*9983SFei.Feng@Sun.COM 	{ 153, 0x00b34, 0x111cd, 0x2e014, 0x30282 },	\
502*9983SFei.Feng@Sun.COM 	{ 157, 0x00b35, 0x11242, 0x2e014, 0x30285 },	\
503*9983SFei.Feng@Sun.COM 	{ 161, 0x00b35, 0x11244, 0x2e014, 0x30285 },	\
504*9983SFei.Feng@Sun.COM 	{ 165, 0x00b35, 0x11246, 0x2e014, 0x30285 }
505*9983SFei.Feng@Sun.COM 
506*9983SFei.Feng@Sun.COM #ifdef __cplusplus
507*9983SFei.Feng@Sun.COM }
508*9983SFei.Feng@Sun.COM #endif
509*9983SFei.Feng@Sun.COM 
510*9983SFei.Feng@Sun.COM #endif /* _RT2661_REG_H */
511