xref: /freebsd/sys/dev/usb/wlan/if_runreg.h (revision 9f44a47fd07924afc035991af15d84e6585dea4f)
1 /*	$OpenBSD: rt2860reg.h,v 1.19 2009/05/18 19:25:07 damien Exp $	*/
2 
3 /*-
4  * Copyright (c) 2007
5  *	Damien Bergamini <damien.bergamini@free.fr>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  *
19  * $FreeBSD$
20  */
21 
22 #ifndef _IF_RUNREG_H_
23 #define	_IF_RUNREG_H_
24 
25 #define	RT2860_CONFIG_NO		1
26 #define	RT2860_IFACE_INDEX		0
27 
28 #define	RT3070_OPT_14			0x0114
29 
30 /* SCH/DMA registers */
31 #define	RT2860_INT_STATUS		0x0200
32 #define	RT2860_INT_MASK			0x0204
33 #define	RT2860_WPDMA_GLO_CFG		0x0208
34 #define	RT2860_WPDMA_RST_IDX		0x020c
35 #define	RT2860_DELAY_INT_CFG		0x0210
36 #define	RT2860_WMM_AIFSN_CFG		0x0214
37 #define	RT2860_WMM_CWMIN_CFG		0x0218
38 #define	RT2860_WMM_CWMAX_CFG		0x021c
39 #define	RT2860_WMM_TXOP0_CFG		0x0220
40 #define	RT2860_WMM_TXOP1_CFG		0x0224
41 #define	RT2860_GPIO_CTRL		0x0228
42 #define	RT2860_MCU_CMD_REG		0x022c
43 #define	RT2860_TX_BASE_PTR(qid)		(0x0230 + (qid) * 16)
44 #define	RT2860_TX_MAX_CNT(qid)		(0x0234 + (qid) * 16)
45 #define	RT2860_TX_CTX_IDX(qid)		(0x0238 + (qid) * 16)
46 #define	RT2860_TX_DTX_IDX(qid)		(0x023c + (qid) * 16)
47 #define	RT2860_RX_BASE_PTR		0x0290
48 #define	RT2860_RX_MAX_CNT		0x0294
49 #define	RT2860_RX_CALC_IDX		0x0298
50 #define	RT2860_FS_DRX_IDX		0x029c
51 #define	RT2860_USB_DMA_CFG		0x02a0	/* RT2870 only */
52 #define	RT2860_US_CYC_CNT		0x02a4
53 
54 /* PBF registers */
55 #define	RT2860_SYS_CTRL			0x0400
56 #define	RT2860_HOST_CMD			0x0404
57 #define	RT2860_PBF_CFG			0x0408
58 #define	RT2860_MAX_PCNT			0x040c
59 #define	RT2860_BUF_CTRL			0x0410
60 #define	RT2860_MCU_INT_STA		0x0414
61 #define	RT2860_MCU_INT_ENA		0x0418
62 #define	RT2860_TXQ_IO(qid)		(0x041c + (qid) * 4)
63 #define	RT2860_RX0Q_IO			0x0424
64 #define	RT2860_BCN_OFFSET0		0x042c
65 #define	RT2860_BCN_OFFSET1		0x0430
66 #define	RT2860_TXRXQ_STA		0x0434
67 #define	RT2860_TXRXQ_PCNT		0x0438
68 #define	RT2860_PBF_DBG			0x043c
69 #define	RT2860_CAP_CTRL			0x0440
70 
71 /* RT3070 registers */
72 #define	RT3070_RF_CSR_CFG		0x0500
73 #define	RT3070_EFUSE_CTRL		0x0580
74 #define	RT3070_EFUSE_DATA0		0x0590
75 #define	RT3070_EFUSE_DATA1		0x0594
76 #define	RT3070_EFUSE_DATA2		0x0598
77 #define	RT3070_EFUSE_DATA3		0x059c
78 #define	RT3070_LDO_CFG0			0x05d4
79 #define	RT3070_GPIO_SWITCH		0x05dc
80 
81 /* RT5592 registers */
82 #define	RT5592_DEBUG_INDEX		0x05e8
83 
84 /* MAC registers */
85 #define	RT2860_ASIC_VER_ID		0x1000
86 #define	RT2860_MAC_SYS_CTRL		0x1004
87 #define	RT2860_MAC_ADDR_DW0		0x1008
88 #define	RT2860_MAC_ADDR_DW1		0x100c
89 #define	RT2860_MAC_BSSID_DW0		0x1010
90 #define	RT2860_MAC_BSSID_DW1		0x1014
91 #define	RT2860_MAX_LEN_CFG		0x1018
92 #define	RT2860_BBP_CSR_CFG		0x101c
93 #define	RT2860_RF_CSR_CFG0		0x1020
94 #define	RT2860_RF_CSR_CFG1		0x1024
95 #define	RT2860_RF_CSR_CFG2		0x1028
96 #define	RT2860_LED_CFG			0x102c
97 
98 /* undocumented registers */
99 #define	RT2860_DEBUG			0x10f4
100 
101 /* MAC Timing control registers */
102 #define	RT2860_XIFS_TIME_CFG		0x1100
103 #define	RT2860_BKOFF_SLOT_CFG		0x1104
104 #define	RT2860_NAV_TIME_CFG		0x1108
105 #define	RT2860_CH_TIME_CFG		0x110c
106 #define	RT2860_PBF_LIFE_TIMER		0x1110
107 #define	RT2860_BCN_TIME_CFG		0x1114
108 #define	RT2860_TBTT_SYNC_CFG		0x1118
109 #define	RT2860_TSF_TIMER_DW0		0x111c
110 #define	RT2860_TSF_TIMER_DW1		0x1120
111 #define	RT2860_TBTT_TIMER		0x1124
112 #define	RT2860_INT_TIMER_CFG		0x1128
113 #define	RT2860_INT_TIMER_EN		0x112c
114 #define	RT2860_CH_IDLE_TIME		0x1130
115 
116 /* MAC Power Save configuration registers */
117 #define	RT2860_MAC_STATUS_REG		0x1200
118 #define	RT2860_PWR_PIN_CFG		0x1204
119 #define	RT2860_AUTO_WAKEUP_CFG		0x1208
120 
121 /* MAC TX configuration registers */
122 #define	RT2860_EDCA_AC_CFG(aci)		(0x1300 + (aci) * 4)
123 #define	RT2860_EDCA_TID_AC_MAP		0x1310
124 #define	RT2860_TX_PWR_CFG(ridx)		(0x1314 + (ridx) * 4)
125 #define	RT2860_TX_PIN_CFG		0x1328
126 #define	RT2860_TX_BAND_CFG		0x132c
127 #define	RT2860_TX_SW_CFG0		0x1330
128 #define	RT2860_TX_SW_CFG1		0x1334
129 #define	RT2860_TX_SW_CFG2		0x1338
130 #define	RT2860_TXOP_THRES_CFG		0x133c
131 #define	RT2860_TXOP_CTRL_CFG		0x1340
132 #define	RT2860_TX_RTS_CFG		0x1344
133 #define	RT2860_TX_TIMEOUT_CFG		0x1348
134 #define	RT2860_TX_RTY_CFG		0x134c
135 #define	RT2860_TX_LINK_CFG		0x1350
136 #define	RT2860_HT_FBK_CFG0		0x1354
137 #define	RT2860_HT_FBK_CFG1		0x1358
138 #define	RT2860_LG_FBK_CFG0		0x135c
139 #define	RT2860_LG_FBK_CFG1		0x1360
140 #define	RT2860_CCK_PROT_CFG		0x1364
141 #define	RT2860_OFDM_PROT_CFG		0x1368
142 #define	RT2860_MM20_PROT_CFG		0x136c
143 #define	RT2860_MM40_PROT_CFG		0x1370
144 #define	RT2860_GF20_PROT_CFG		0x1374
145 #define	RT2860_GF40_PROT_CFG		0x1378
146 #define	RT2860_EXP_CTS_TIME		0x137c
147 #define	RT2860_EXP_ACK_TIME		0x1380
148 
149 /* MAC RX configuration registers */
150 #define	RT2860_RX_FILTR_CFG		0x1400
151 #define	RT2860_AUTO_RSP_CFG		0x1404
152 #define	RT2860_LEGACY_BASIC_RATE	0x1408
153 #define	RT2860_HT_BASIC_RATE		0x140c
154 #define	RT2860_HT_CTRL_CFG		0x1410
155 #define	RT2860_SIFS_COST_CFG		0x1414
156 #define	RT2860_RX_PARSER_CFG		0x1418
157 
158 /* MAC Security configuration registers */
159 #define	RT2860_TX_SEC_CNT0		0x1500
160 #define	RT2860_RX_SEC_CNT0		0x1504
161 #define	RT2860_CCMP_FC_MUTE		0x1508
162 
163 /* MAC HCCA/PSMP configuration registers */
164 #define	RT2860_TXOP_HLDR_ADDR0		0x1600
165 #define	RT2860_TXOP_HLDR_ADDR1		0x1604
166 #define	RT2860_TXOP_HLDR_ET		0x1608
167 #define	RT2860_QOS_CFPOLL_RA_DW0	0x160c
168 #define	RT2860_QOS_CFPOLL_A1_DW1	0x1610
169 #define	RT2860_QOS_CFPOLL_QC		0x1614
170 
171 /* MAC Statistics Counters */
172 #define	RT2860_RX_STA_CNT0		0x1700
173 #define	RT2860_RX_STA_CNT1		0x1704
174 #define	RT2860_RX_STA_CNT2		0x1708
175 #define	RT2860_TX_STA_CNT0		0x170c
176 #define	RT2860_TX_STA_CNT1		0x1710
177 #define	RT2860_TX_STA_CNT2		0x1714
178 #define	RT2860_TX_STAT_FIFO		0x1718
179 
180 /* RX WCID search table */
181 #define	RT2860_WCID_ENTRY(wcid)		(0x1800 + (wcid) * 8)
182 
183 #define	RT2860_FW_BASE			0x2000
184 #define	RT2870_FW_BASE			0x3000
185 
186 /* Pair-wise key table */
187 #define	RT2860_PKEY(wcid)		(0x4000 + (wcid) * 32)
188 
189 /* IV/EIV table */
190 #define	RT2860_IVEIV(wcid)		(0x6000 + (wcid) * 8)
191 
192 /* WCID attribute table */
193 #define	RT2860_WCID_ATTR(wcid)		(0x6800 + (wcid) * 4)
194 
195 /* Shared Key Table */
196 #define	RT2860_SKEY(vap, kidx)		(0x6c00 + (vap) * 128 + (kidx) * 32)
197 
198 /* Shared Key Mode */
199 #define	RT2860_SKEY_MODE_0_7		0x7000
200 #define	RT2860_SKEY_MODE_8_15		0x7004
201 #define	RT2860_SKEY_MODE_16_23		0x7008
202 #define	RT2860_SKEY_MODE_24_31		0x700c
203 
204 /* Shared Memory between MCU and host */
205 #define	RT2860_H2M_MAILBOX		0x7010
206 #define	RT2860_H2M_MAILBOX_CID		0x7014
207 #define	RT2860_H2M_MAILBOX_STATUS	0x701c
208 #define	RT2860_H2M_INTSRC		0x7024
209 #define	RT2860_H2M_BBPAGENT		0x7028
210 #define	RT2860_BCN_BASE(vap)		(0x7800 + (vap) * 512)
211 
212 /* possible flags for register RT2860_PCI_EECTRL */
213 #define	RT2860_C	(1 << 0)
214 #define	RT2860_S	(1 << 1)
215 #define	RT2860_D	(1 << 2)
216 #define	RT2860_SHIFT_D	2
217 #define	RT2860_Q	(1 << 3)
218 #define	RT2860_SHIFT_Q	3
219 
220 /* possible flags for registers INT_STATUS/INT_MASK */
221 #define	RT2860_TX_COHERENT	(1 << 17)
222 #define	RT2860_RX_COHERENT	(1 << 16)
223 #define	RT2860_MAC_INT_4	(1 << 15)
224 #define	RT2860_MAC_INT_3	(1 << 14)
225 #define	RT2860_MAC_INT_2	(1 << 13)
226 #define	RT2860_MAC_INT_1	(1 << 12)
227 #define	RT2860_MAC_INT_0	(1 << 11)
228 #define	RT2860_TX_RX_COHERENT	(1 << 10)
229 #define	RT2860_MCU_CMD_INT	(1 <<  9)
230 #define	RT2860_TX_DONE_INT5	(1 <<  8)
231 #define	RT2860_TX_DONE_INT4	(1 <<  7)
232 #define	RT2860_TX_DONE_INT3	(1 <<  6)
233 #define	RT2860_TX_DONE_INT2	(1 <<  5)
234 #define	RT2860_TX_DONE_INT1	(1 <<  4)
235 #define	RT2860_TX_DONE_INT0	(1 <<  3)
236 #define	RT2860_RX_DONE_INT	(1 <<  2)
237 #define	RT2860_TX_DLY_INT	(1 <<  1)
238 #define	RT2860_RX_DLY_INT	(1 <<  0)
239 
240 /* possible flags for register WPDMA_GLO_CFG */
241 #define	RT2860_HDR_SEG_LEN_SHIFT	8
242 #define	RT2860_BIG_ENDIAN		(1 << 7)
243 #define	RT2860_TX_WB_DDONE		(1 << 6)
244 #define	RT2860_WPDMA_BT_SIZE_SHIFT	4
245 #define	RT2860_WPDMA_BT_SIZE16		0
246 #define	RT2860_WPDMA_BT_SIZE32		1
247 #define	RT2860_WPDMA_BT_SIZE64		2
248 #define	RT2860_WPDMA_BT_SIZE128		3
249 #define	RT2860_RX_DMA_BUSY		(1 << 3)
250 #define	RT2860_RX_DMA_EN		(1 << 2)
251 #define	RT2860_TX_DMA_BUSY		(1 << 1)
252 #define	RT2860_TX_DMA_EN		(1 << 0)
253 
254 /* possible flags for register DELAY_INT_CFG */
255 #define	RT2860_TXDLY_INT_EN		(1U << 31)
256 #define	RT2860_TXMAX_PINT_SHIFT		24
257 #define	RT2860_TXMAX_PTIME_SHIFT	16
258 #define	RT2860_RXDLY_INT_EN		(1 << 15)
259 #define	RT2860_RXMAX_PINT_SHIFT		8
260 #define	RT2860_RXMAX_PTIME_SHIFT	0
261 
262 /* possible flags for register GPIO_CTRL */
263 #define	RT2860_GPIO_D_SHIFT	8
264 #define	RT2860_GPIO_O_SHIFT	0
265 
266 /* possible flags for register USB_DMA_CFG */
267 #define	RT2860_USB_TX_BUSY		(1U << 31)
268 #define	RT2860_USB_RX_BUSY		(1 << 30)
269 #define	RT2860_USB_EPOUT_VLD_SHIFT	24
270 #define	RT2860_USB_TX_EN		(1 << 23)
271 #define	RT2860_USB_RX_EN		(1 << 22)
272 #define	RT2860_USB_RX_AGG_EN		(1 << 21)
273 #define	RT2860_USB_TXOP_HALT		(1 << 20)
274 #define	RT2860_USB_TX_CLEAR		(1 << 19)
275 #define	RT2860_USB_PHY_WD_EN		(1 << 16)
276 #define	RT2860_USB_RX_AGG_LMT(x)	((x) << 8)	/* in unit of 1KB */
277 #define	RT2860_USB_RX_AGG_TO(x)		((x) & 0xff)	/* in unit of 33ns */
278 
279 /* possible flags for register US_CYC_CNT */
280 #define	RT2860_TEST_EN		(1 << 24)
281 #define	RT2860_TEST_SEL_SHIFT	16
282 #define	RT2860_BT_MODE_EN	(1 <<  8)
283 #define	RT2860_US_CYC_CNT_SHIFT	0
284 
285 /* possible flags for register SYS_CTRL */
286 #define	RT2860_HST_PM_SEL	(1 << 16)
287 #define	RT2860_CAP_MODE		(1 << 14)
288 #define	RT2860_PME_OEN		(1 << 13)
289 #define	RT2860_CLKSELECT	(1 << 12)
290 #define	RT2860_PBF_CLK_EN	(1 << 11)
291 #define	RT2860_MAC_CLK_EN	(1 << 10)
292 #define	RT2860_DMA_CLK_EN	(1 <<  9)
293 #define	RT2860_MCU_READY	(1 <<  7)
294 #define	RT2860_ASY_RESET	(1 <<  4)
295 #define	RT2860_PBF_RESET	(1 <<  3)
296 #define	RT2860_MAC_RESET	(1 <<  2)
297 #define	RT2860_DMA_RESET	(1 <<  1)
298 #define	RT2860_MCU_RESET	(1 <<  0)
299 
300 /* possible values for register HOST_CMD */
301 #define	RT2860_MCU_CMD_SLEEP	0x30
302 #define	RT2860_MCU_CMD_WAKEUP	0x31
303 #define	RT2860_MCU_CMD_LEDS	0x50
304 #define	RT2860_MCU_CMD_LED_RSSI	0x51
305 #define	RT2860_MCU_CMD_LED1	0x52
306 #define	RT2860_MCU_CMD_LED2	0x53
307 #define	RT2860_MCU_CMD_LED3	0x54
308 #define	RT2860_MCU_CMD_RFRESET	0x72
309 #define	RT2860_MCU_CMD_ANTSEL	0x73
310 #define	RT2860_MCU_CMD_BBP	0x80
311 #define	RT2860_MCU_CMD_PSLEVEL	0x83
312 
313 /* possible flags for register PBF_CFG */
314 #define	RT2860_TX1Q_NUM_SHIFT	21
315 #define	RT2860_TX2Q_NUM_SHIFT	16
316 #define	RT2860_NULL0_MODE	(1 << 15)
317 #define	RT2860_NULL1_MODE	(1 << 14)
318 #define	RT2860_RX_DROP_MODE	(1 << 13)
319 #define	RT2860_TX0Q_MANUAL	(1 << 12)
320 #define	RT2860_TX1Q_MANUAL	(1 << 11)
321 #define	RT2860_TX2Q_MANUAL	(1 << 10)
322 #define	RT2860_RX0Q_MANUAL	(1 <<  9)
323 #define	RT2860_HCCA_EN		(1 <<  8)
324 #define	RT2860_TX0Q_EN		(1 <<  4)
325 #define	RT2860_TX1Q_EN		(1 <<  3)
326 #define	RT2860_TX2Q_EN		(1 <<  2)
327 #define	RT2860_RX0Q_EN		(1 <<  1)
328 
329 /* possible flags for register BUF_CTRL */
330 #define	RT2860_WRITE_TXQ(qid)	(1 << (11 - (qid)))
331 #define	RT2860_NULL0_KICK	(1 << 7)
332 #define	RT2860_NULL1_KICK	(1 << 6)
333 #define	RT2860_BUF_RESET	(1 << 5)
334 #define	RT2860_READ_TXQ(qid)	(1 << (3 - (qid))
335 #define	RT2860_READ_RX0Q	(1 << 0)
336 
337 /* possible flags for registers MCU_INT_STA/MCU_INT_ENA */
338 #define	RT2860_MCU_MAC_INT_8	(1 << 24)
339 #define	RT2860_MCU_MAC_INT_7	(1 << 23)
340 #define	RT2860_MCU_MAC_INT_6	(1 << 22)
341 #define	RT2860_MCU_MAC_INT_4	(1 << 20)
342 #define	RT2860_MCU_MAC_INT_3	(1 << 19)
343 #define	RT2860_MCU_MAC_INT_2	(1 << 18)
344 #define	RT2860_MCU_MAC_INT_1	(1 << 17)
345 #define	RT2860_MCU_MAC_INT_0	(1 << 16)
346 #define	RT2860_DTX0_INT		(1 << 11)
347 #define	RT2860_DTX1_INT		(1 << 10)
348 #define	RT2860_DTX2_INT		(1 <<  9)
349 #define	RT2860_DRX0_INT		(1 <<  8)
350 #define	RT2860_HCMD_INT		(1 <<  7)
351 #define	RT2860_N0TX_INT		(1 <<  6)
352 #define	RT2860_N1TX_INT		(1 <<  5)
353 #define	RT2860_BCNTX_INT	(1 <<  4)
354 #define	RT2860_MTX0_INT		(1 <<  3)
355 #define	RT2860_MTX1_INT		(1 <<  2)
356 #define	RT2860_MTX2_INT		(1 <<  1)
357 #define	RT2860_MRX0_INT		(1 <<  0)
358 
359 /* possible flags for register TXRXQ_PCNT */
360 #define	RT2860_RX0Q_PCNT_MASK	0xff000000
361 #define	RT2860_TX2Q_PCNT_MASK	0x00ff0000
362 #define	RT2860_TX1Q_PCNT_MASK	0x0000ff00
363 #define	RT2860_TX0Q_PCNT_MASK	0x000000ff
364 
365 /* possible flags for register CAP_CTRL */
366 #define	RT2860_CAP_ADC_FEQ		(1U << 31)
367 #define	RT2860_CAP_START		(1 << 30)
368 #define	RT2860_MAN_TRIG			(1 << 29)
369 #define	RT2860_TRIG_OFFSET_SHIFT	16
370 #define	RT2860_START_ADDR_SHIFT		0
371 
372 /* possible flags for register RF_CSR_CFG */
373 #define	RT3070_RF_KICK		(1 << 17)
374 #define	RT3070_RF_WRITE		(1 << 16)
375 
376 /* possible flags for register EFUSE_CTRL */
377 #define	RT3070_SEL_EFUSE	(1U << 31)
378 #define	RT3070_EFSROM_KICK	(1 << 30)
379 #define	RT3070_EFSROM_AIN_MASK	0x03ff0000
380 #define	RT3070_EFSROM_AIN_SHIFT	16
381 #define	RT3070_EFSROM_MODE_MASK	0x000000c0
382 #define	RT3070_EFUSE_AOUT_MASK	0x0000003f
383 
384 /* possible flag for register DEBUG_INDEX */
385 #define	RT5592_SEL_XTAL		(1U << 31)
386 
387 /* possible flags for register MAC_SYS_CTRL */
388 #define	RT2860_RX_TS_EN		(1 << 7)
389 #define	RT2860_WLAN_HALT_EN	(1 << 6)
390 #define	RT2860_PBF_LOOP_EN	(1 << 5)
391 #define	RT2860_CONT_TX_TEST	(1 << 4)
392 #define	RT2860_MAC_RX_EN	(1 << 3)
393 #define	RT2860_MAC_TX_EN	(1 << 2)
394 #define	RT2860_BBP_HRST		(1 << 1)
395 #define	RT2860_MAC_SRST		(1 << 0)
396 
397 /* possible flags for register MAC_BSSID_DW1 */
398 #define	RT2860_MULTI_BCN_NUM_SHIFT	18
399 #define	RT2860_MULTI_BSSID_MODE_SHIFT	16
400 
401 /* possible flags for register MAX_LEN_CFG */
402 #define	RT2860_MIN_MPDU_LEN_SHIFT	16
403 #define	RT2860_MAX_PSDU_LEN_SHIFT	12
404 #define	RT2860_MAX_PSDU_LEN8K		0
405 #define	RT2860_MAX_PSDU_LEN16K		1
406 #define	RT2860_MAX_PSDU_LEN32K		2
407 #define	RT2860_MAX_PSDU_LEN64K		3
408 #define	RT2860_MAX_MPDU_LEN_SHIFT	0
409 
410 /* possible flags for registers BBP_CSR_CFG/H2M_BBPAGENT */
411 #define	RT2860_BBP_RW_PARALLEL		(1 << 19)
412 #define	RT2860_BBP_PAR_DUR_112_5	(1 << 18)
413 #define	RT2860_BBP_CSR_KICK		(1 << 17)
414 #define	RT2860_BBP_CSR_READ		(1 << 16)
415 #define	RT2860_BBP_ADDR_SHIFT		8
416 #define	RT2860_BBP_DATA_SHIFT		0
417 
418 /* possible flags for register RF_CSR_CFG0 */
419 #define	RT2860_RF_REG_CTRL		(1U << 31)
420 #define	RT2860_RF_LE_SEL1		(1 << 30)
421 #define	RT2860_RF_LE_STBY		(1 << 29)
422 #define	RT2860_RF_REG_WIDTH_SHIFT	24
423 #define	RT2860_RF_REG_0_SHIFT		0
424 
425 /* possible flags for register RF_CSR_CFG1 */
426 #define	RT2860_RF_DUR_5		(1 << 24)
427 #define	RT2860_RF_REG_1_SHIFT	0
428 
429 /* possible flags for register LED_CFG */
430 #define	RT2860_LED_POL			(1 << 30)
431 #define	RT2860_Y_LED_MODE_SHIFT		28
432 #define	RT2860_G_LED_MODE_SHIFT		26
433 #define	RT2860_R_LED_MODE_SHIFT		24
434 #define	RT2860_LED_MODE_OFF		0
435 #define	RT2860_LED_MODE_BLINK_TX	1
436 #define	RT2860_LED_MODE_SLOW_BLINK	2
437 #define	RT2860_LED_MODE_ON		3
438 #define	RT2860_SLOW_BLK_TIME_SHIFT	16
439 #define	RT2860_LED_OFF_TIME_SHIFT	8
440 #define	RT2860_LED_ON_TIME_SHIFT	0
441 
442 /* possible flags for register XIFS_TIME_CFG */
443 #define	RT2860_BB_RXEND_EN		(1 << 29)
444 #define	RT2860_EIFS_TIME_SHIFT		20
445 #define	RT2860_OFDM_XIFS_TIME_SHIFT	16
446 #define	RT2860_OFDM_SIFS_TIME_SHIFT	8
447 #define	RT2860_CCK_SIFS_TIME_SHIFT	0
448 
449 /* possible flags for register BKOFF_SLOT_CFG */
450 #define	RT2860_CC_DELAY_TIME_SHIFT	8
451 #define	RT2860_SLOT_TIME		0
452 
453 /* possible flags for register NAV_TIME_CFG */
454 #define	RT2860_NAV_UPD			(1U << 31)
455 #define	RT2860_NAV_UPD_VAL_SHIFT	16
456 #define	RT2860_NAV_CLR_EN		(1 << 15)
457 #define	RT2860_NAV_TIMER_SHIFT		0
458 
459 /* possible flags for register CH_TIME_CFG */
460 #define	RT2860_EIFS_AS_CH_BUSY	(1 << 4)
461 #define	RT2860_NAV_AS_CH_BUSY	(1 << 3)
462 #define	RT2860_RX_AS_CH_BUSY	(1 << 2)
463 #define	RT2860_TX_AS_CH_BUSY	(1 << 1)
464 #define	RT2860_CH_STA_TIMER_EN	(1 << 0)
465 
466 /* possible values for register BCN_TIME_CFG */
467 #define	RT2860_TSF_INS_COMP_SHIFT	24
468 #define	RT2860_BCN_TX_EN		(1 << 20)
469 #define	RT2860_TBTT_TIMER_EN		(1 << 19)
470 #define	RT2860_TSF_SYNC_MODE_SHIFT	17
471 #define	RT2860_TSF_SYNC_MODE_DIS	0
472 #define	RT2860_TSF_SYNC_MODE_STA	1
473 #define	RT2860_TSF_SYNC_MODE_IBSS	2
474 #define	RT2860_TSF_SYNC_MODE_HOSTAP	3
475 #define	RT2860_TSF_TIMER_EN		(1 << 16)
476 #define	RT2860_BCN_INTVAL_SHIFT		0
477 
478 /* possible flags for register TBTT_SYNC_CFG */
479 #define	RT2860_BCN_CWMIN_SHIFT		20
480 #define	RT2860_BCN_AIFSN_SHIFT		16
481 #define	RT2860_BCN_EXP_WIN_SHIFT	8
482 #define	RT2860_TBTT_ADJUST_SHIFT	0
483 
484 /* possible flags for register INT_TIMER_CFG */
485 #define	RT2860_GP_TIMER_SHIFT		16
486 #define	RT2860_PRE_TBTT_TIMER_SHIFT	0
487 
488 /* possible flags for register INT_TIMER_EN */
489 #define	RT2860_GP_TIMER_EN	(1 << 1)
490 #define	RT2860_PRE_TBTT_INT_EN	(1 << 0)
491 
492 /* possible flags for register MAC_STATUS_REG */
493 #define	RT2860_RX_STATUS_BUSY	(1 << 1)
494 #define	RT2860_TX_STATUS_BUSY	(1 << 0)
495 
496 /* possible flags for register PWR_PIN_CFG */
497 #define	RT2860_IO_ADDA_PD	(1 << 3)
498 #define	RT2860_IO_PLL_PD	(1 << 2)
499 #define	RT2860_IO_RA_PE		(1 << 1)
500 #define	RT2860_IO_RF_PE		(1 << 0)
501 
502 /* possible flags for register AUTO_WAKEUP_CFG */
503 #define	RT2860_AUTO_WAKEUP_EN		(1 << 15)
504 #define	RT2860_SLEEP_TBTT_NUM_SHIFT	8
505 #define	RT2860_WAKEUP_LEAD_TIME_SHIFT	0
506 
507 /* possible flags for register TX_PIN_CFG */
508 #define	RT2860_TRSW_POL		(1 << 19)
509 #define	RT2860_TRSW_EN		(1 << 18)
510 #define	RT2860_RFTR_POL		(1 << 17)
511 #define	RT2860_RFTR_EN		(1 << 16)
512 #define	RT2860_LNA_PE_G1_POL	(1 << 15)
513 #define	RT2860_LNA_PE_A1_POL	(1 << 14)
514 #define	RT2860_LNA_PE_G0_POL	(1 << 13)
515 #define	RT2860_LNA_PE_A0_POL	(1 << 12)
516 #define	RT2860_LNA_PE_G1_EN	(1 << 11)
517 #define	RT2860_LNA_PE_A1_EN	(1 << 10)
518 #define	RT2860_LNA_PE1_EN	(RT2860_LNA_PE_A1_EN | RT2860_LNA_PE_G1_EN)
519 #define	RT2860_LNA_PE_G0_EN	(1 <<  9)
520 #define	RT2860_LNA_PE_A0_EN	(1 <<  8)
521 #define	RT2860_LNA_PE0_EN	(RT2860_LNA_PE_A0_EN | RT2860_LNA_PE_G0_EN)
522 #define	RT2860_PA_PE_G1_POL	(1 <<  7)
523 #define	RT2860_PA_PE_A1_POL	(1 <<  6)
524 #define	RT2860_PA_PE_G0_POL	(1 <<  5)
525 #define	RT2860_PA_PE_A0_POL	(1 <<  4)
526 #define	RT2860_PA_PE_G1_EN	(1 <<  3)
527 #define	RT2860_PA_PE_A1_EN	(1 <<  2)
528 #define	RT2860_PA_PE_G0_EN	(1 <<  1)
529 #define	RT2860_PA_PE_A0_EN	(1 <<  0)
530 
531 /* possible flags for register TX_BAND_CFG */
532 #define	RT2860_5G_BAND_SEL_N	(1 << 2)
533 #define	RT2860_5G_BAND_SEL_P	(1 << 1)
534 #define	RT2860_TX_BAND_SEL	(1 << 0)
535 
536 /* possible flags for register TX_SW_CFG0 */
537 #define	RT2860_DLY_RFTR_EN_SHIFT	24
538 #define	RT2860_DLY_TRSW_EN_SHIFT	16
539 #define	RT2860_DLY_PAPE_EN_SHIFT	8
540 #define	RT2860_DLY_TXPE_EN_SHIFT	0
541 
542 /* possible flags for register TX_SW_CFG1 */
543 #define	RT2860_DLY_RFTR_DIS_SHIFT	16
544 #define	RT2860_DLY_TRSW_DIS_SHIFT	8
545 #define	RT2860_DLY_PAPE_DIS SHIFT	0
546 
547 /* possible flags for register TX_SW_CFG2 */
548 #define	RT2860_DLY_LNA_EN_SHIFT		24
549 #define	RT2860_DLY_LNA_DIS_SHIFT	16
550 #define	RT2860_DLY_DAC_EN_SHIFT		8
551 #define	RT2860_DLY_DAC_DIS_SHIFT	0
552 
553 /* possible flags for register TXOP_THRES_CFG */
554 #define	RT2860_TXOP_REM_THRES_SHIFT	24
555 #define	RT2860_CF_END_THRES_SHIFT	16
556 #define	RT2860_RDG_IN_THRES		8
557 #define	RT2860_RDG_OUT_THRES		0
558 
559 /* possible flags for register TXOP_CTRL_CFG */
560 #define	RT2860_EXT_CW_MIN_SHIFT		16
561 #define	RT2860_EXT_CCA_DLY_SHIFT	8
562 #define	RT2860_EXT_CCA_EN		(1 << 7)
563 #define	RT2860_LSIG_TXOP_EN		(1 << 6)
564 #define	RT2860_TXOP_TRUN_EN_MIMOPS	(1 << 4)
565 #define	RT2860_TXOP_TRUN_EN_TXOP	(1 << 3)
566 #define	RT2860_TXOP_TRUN_EN_RATE	(1 << 2)
567 #define	RT2860_TXOP_TRUN_EN_AC		(1 << 1)
568 #define	RT2860_TXOP_TRUN_EN_TIMEOUT	(1 << 0)
569 
570 /* possible flags for register TX_RTS_CFG */
571 #define	RT2860_RTS_FBK_EN		(1 << 24)
572 #define	RT2860_RTS_THRES_SHIFT		8
573 #define	RT2860_RTS_RTY_LIMIT_SHIFT	0
574 
575 /* possible flags for register TX_TIMEOUT_CFG */
576 #define	RT2860_TXOP_TIMEOUT_SHIFT	16
577 #define	RT2860_RX_ACK_TIMEOUT_SHIFT	8
578 #define	RT2860_MPDU_LIFE_TIME_SHIFT	4
579 
580 /* possible flags for register TX_RTY_CFG */
581 #define	RT2860_TX_AUTOFB_EN		(1 << 30)
582 #define	RT2860_AGG_RTY_MODE_TIMER	(1 << 29)
583 #define	RT2860_NAG_RTY_MODE_TIMER	(1 << 28)
584 #define	RT2860_LONG_RTY_THRES_SHIFT	16
585 #define	RT2860_LONG_RTY_LIMIT_SHIFT	8
586 #define	RT2860_SHORT_RTY_LIMIT_SHIFT	0
587 
588 /* possible flags for register TX_LINK_CFG */
589 #define	RT2860_REMOTE_MFS_SHIFT		24
590 #define	RT2860_REMOTE_MFB_SHIFT		16
591 #define	RT2860_TX_CFACK_EN		(1 << 12)
592 #define	RT2860_TX_RDG_EN		(1 << 11)
593 #define	RT2860_TX_MRQ_EN		(1 << 10)
594 #define	RT2860_REMOTE_UMFS_EN		(1 <<  9)
595 #define	RT2860_TX_MFB_EN		(1 <<  8)
596 #define	RT2860_REMOTE_MFB_LT_SHIFT	0
597 
598 /* possible flags for registers *_PROT_CFG */
599 #define	RT2860_RTSTH_EN			(1 << 26)
600 #define	RT2860_TXOP_ALLOW_GF40		(1 << 25)
601 #define	RT2860_TXOP_ALLOW_GF20		(1 << 24)
602 #define	RT2860_TXOP_ALLOW_MM40		(1 << 23)
603 #define	RT2860_TXOP_ALLOW_MM20		(1 << 22)
604 #define	RT2860_TXOP_ALLOW_OFDM		(1 << 21)
605 #define	RT2860_TXOP_ALLOW_CCK		(1 << 20)
606 #define	RT2860_TXOP_ALLOW_ALL		(0x3f << 20)
607 #define	RT2860_PROT_NAV_SHORT		(1 << 18)
608 #define	RT2860_PROT_NAV_LONG		(2 << 18)
609 #define	RT2860_PROT_CTRL_RTS_CTS	(1 << 16)
610 #define	RT2860_PROT_CTRL_CTS		(2 << 16)
611 
612 /* possible flags for registers EXP_{CTS,ACK}_TIME */
613 #define	RT2860_EXP_OFDM_TIME_SHIFT	16
614 #define	RT2860_EXP_CCK_TIME_SHIFT	0
615 
616 /* possible flags for register RX_FILTR_CFG */
617 #define	RT2860_DROP_CTRL_RSV	(1 << 16)
618 #define	RT2860_DROP_BAR		(1 << 15)
619 #define	RT2860_DROP_BA		(1 << 14)
620 #define	RT2860_DROP_PSPOLL	(1 << 13)
621 #define	RT2860_DROP_RTS		(1 << 12)
622 #define	RT2860_DROP_CTS		(1 << 11)
623 #define	RT2860_DROP_ACK		(1 << 10)
624 #define	RT2860_DROP_CFEND	(1 <<  9)
625 #define	RT2860_DROP_CFACK	(1 <<  8)
626 #define	RT2860_DROP_DUPL	(1 <<  7)
627 #define	RT2860_DROP_BC		(1 <<  6)
628 #define	RT2860_DROP_MC		(1 <<  5)
629 #define	RT2860_DROP_VER_ERR	(1 <<  4)
630 #define	RT2860_DROP_NOT_MYBSS	(1 <<  3)
631 #define	RT2860_DROP_UC_NOME	(1 <<  2)
632 #define	RT2860_DROP_PHY_ERR	(1 <<  1)
633 #define	RT2860_DROP_CRC_ERR	(1 <<  0)
634 
635 /* possible flags for register AUTO_RSP_CFG */
636 #define	RT2860_CTRL_PWR_BIT	(1 << 7)
637 #define	RT2860_BAC_ACK_POLICY	(1 << 6)
638 #define	RT2860_CCK_SHORT_EN	(1 << 4)
639 #define	RT2860_CTS_40M_REF_EN	(1 << 3)
640 #define	RT2860_CTS_40M_MODE_EN	(1 << 2)
641 #define	RT2860_BAC_ACKPOLICY_EN	(1 << 1)
642 #define	RT2860_AUTO_RSP_EN	(1 << 0)
643 
644 /* possible flags for register SIFS_COST_CFG */
645 #define	RT2860_OFDM_SIFS_COST_SHIFT	8
646 #define	RT2860_CCK_SIFS_COST_SHIFT	0
647 
648 /* possible flags for register TXOP_HLDR_ET */
649 #define	RT2860_TXOP_ETM1_EN		(1 << 25)
650 #define	RT2860_TXOP_ETM0_EN		(1 << 24)
651 #define	RT2860_TXOP_ETM_THRES_SHIFT	16
652 #define	RT2860_TXOP_ETO_EN		(1 <<  8)
653 #define	RT2860_TXOP_ETO_THRES_SHIFT	1
654 #define	RT2860_PER_RX_RST_EN		(1 <<  0)
655 
656 /* possible flags for register TX_STAT_FIFO */
657 #define	RT2860_TXQ_MCS_SHIFT	16
658 #define	RT2860_TXQ_WCID_SHIFT	8
659 #define	RT2860_TXQ_ACKREQ	(1 << 7)
660 #define	RT2860_TXQ_AGG		(1 << 6)
661 #define	RT2860_TXQ_OK		(1 << 5)
662 #define	RT2860_TXQ_PID_SHIFT	1
663 #define	RT2860_TXQ_VLD		(1 << 0)
664 
665 /* possible flags for register WCID_ATTR */
666 #define	RT2860_MODE_NOSEC	0
667 #define	RT2860_MODE_WEP40	1
668 #define	RT2860_MODE_WEP104	2
669 #define	RT2860_MODE_TKIP	3
670 #define	RT2860_MODE_AES_CCMP	4
671 #define	RT2860_MODE_CKIP40	5
672 #define	RT2860_MODE_CKIP104	6
673 #define	RT2860_MODE_CKIP128	7
674 #define	RT2860_RX_PKEY_EN	(1 << 0)
675 
676 /* possible flags for register H2M_MAILBOX */
677 #define	RT2860_H2M_BUSY		(1 << 24)
678 #define	RT2860_TOKEN_NO_INTR	0xff
679 
680 /* possible flags for MCU command RT2860_MCU_CMD_LEDS */
681 #define	RT2860_LED_RADIO	(1 << 13)
682 #define	RT2860_LED_LINK_2GHZ	(1 << 14)
683 #define	RT2860_LED_LINK_5GHZ	(1 << 15)
684 
685 /* possible flags for RT3020 RF register 1 */
686 #define	RT3070_RF_BLOCK	(1 << 0)
687 #define	RT3070_PLL_PD	(1 << 1)
688 #define	RT3070_RX0_PD	(1 << 2)
689 #define	RT3070_TX0_PD	(1 << 3)
690 #define	RT3070_RX1_PD	(1 << 4)
691 #define	RT3070_TX1_PD	(1 << 5)
692 #define	RT3070_RX2_PD	(1 << 6)
693 #define	RT3070_TX2_PD	(1 << 7)
694 
695 /* possible flags for RT3020 RF register 15 */
696 #define	RT3070_TX_LO2	(1 << 3)
697 
698 /* possible flags for RT3020 RF register 17 */
699 #define	RT3070_TX_LO1	(1 << 3)
700 
701 /* possible flags for RT3020 RF register 20 */
702 #define	RT3070_RX_LO1	(1 << 3)
703 
704 /* possible flags for RT3020 RF register 21 */
705 #define	RT3070_RX_LO2	(1 << 3)
706 
707 /* possible flags for RT3053 RF register 18 */
708 #define	RT3593_AUTOTUNE_BYPASS	(1 << 6)
709 
710 /* possible flags for RT3053 RF register 50 */
711 #define	RT3593_TX_LO2	(1 << 4)
712 
713 /* possible flags for RT3053 RF register 51 */
714 #define	RT3593_TX_LO1	(1 << 4)
715 
716 /* Possible flags for RT5390 RF register 2. */
717 #define	RT5390_RESCAL	(1 << 7)
718 
719 /* Possible flags for RT5390 RF register 3. */
720 #define	RT5390_VCOCAL	(1 << 7)
721 
722 /* Possible flags for RT5390 RF register 38. */
723 #define	RT5390_RX_LO1	(1 << 5)
724 
725 /* Possible flags for RT5390 RF register 39. */
726 #define	RT5390_RX_LO2	(1 << 7)
727 
728 /* Possible flags for RT5390 BBP register 4. */
729 #define	RT5390_MAC_IF_CTRL	(1 << 6)
730 
731 /* Possible flags for RT5390 BBP register 105. */
732 #define	RT5390_MLD			(1 << 2)
733 #define	RT5390_EN_SIG_MODULATION	(1 << 3)
734 
735 /* RT2860 TX descriptor */
736 struct rt2860_txd {
737 	uint32_t	sdp0;		/* Segment Data Pointer 0 */
738 	uint16_t	sdl1;		/* Segment Data Length 1 */
739 #define	RT2860_TX_BURST	(1 << 15)
740 #define	RT2860_TX_LS1	(1 << 14)	/* SDP1 is the last segment */
741 
742 	uint16_t	sdl0;		/* Segment Data Length 0 */
743 #define	RT2860_TX_DDONE	(1 << 15)
744 #define	RT2860_TX_LS0	(1 << 14)	/* SDP0 is the last segment */
745 
746 	uint32_t	sdp1;		/* Segment Data Pointer 1 */
747 	uint8_t		reserved[3];
748 	uint8_t		flags;
749 #define	RT2860_TX_QSEL_SHIFT	1
750 #define	RT2860_TX_QSEL_MGMT	(0 << 1)
751 #define	RT2860_TX_QSEL_HCCA	(1 << 1)
752 #define	RT2860_TX_QSEL_EDCA	(2 << 1)
753 #define	RT2860_TX_WIV		(1 << 0)
754 } __packed;
755 
756 /* RT2870 TX descriptor */
757 struct rt2870_txd {
758 	uint16_t	len;
759 	uint8_t		pad;
760 	uint8_t		flags;
761 } __packed;
762 
763 /* TX Wireless Information */
764 struct rt2860_txwi {
765 	uint8_t		flags;
766 #define	RT2860_TX_MPDU_DSITY_SHIFT	5
767 #define	RT2860_TX_AMPDU			(1 << 4)
768 #define	RT2860_TX_TS			(1 << 3)
769 #define	RT2860_TX_CFACK			(1 << 2)
770 #define	RT2860_TX_MMPS			(1 << 1)
771 #define	RT2860_TX_FRAG			(1 << 0)
772 
773 	uint8_t		txop;
774 #define	RT2860_TX_TXOP_HT	0
775 #define	RT2860_TX_TXOP_PIFS	1
776 #define	RT2860_TX_TXOP_SIFS	2
777 #define	RT2860_TX_TXOP_BACKOFF	3
778 
779 	uint16_t	phy;
780 #define	RT2860_PHY_MODE		0xc000
781 #define	RT2860_PHY_CCK		(0 << 14)
782 #define	RT2860_PHY_OFDM		(1 << 14)
783 #define	RT2860_PHY_HT_MIX	(2 << 14)
784 #define	RT2860_PHY_HT_GF	(3 << 14)
785 #define	RT2860_PHY_SGI		(1 << 8)
786 #define	RT2860_PHY_BW40		(1 << 7)
787 #define	RT2860_PHY_MCS		0x7f
788 #define	RT2860_PHY_SHPRE	(1 << 3)
789 
790 	uint8_t		xflags;
791 #define	RT2860_TX_BAWINSIZE_SHIFT	2
792 #define	RT2860_TX_NSEQ			(1 << 1)
793 #define	RT2860_TX_ACK			(1 << 0)
794 
795 	uint8_t		wcid;	/* Wireless Client ID */
796 	uint16_t	len;
797 #define	RT2860_TX_PID_SHIFT	12
798 
799 	uint32_t	iv;
800 	uint32_t	eiv;
801 } __packed;
802 
803 /* RT2860 RX descriptor */
804 struct rt2860_rxd {
805 	uint32_t	sdp0;
806 	uint16_t	sdl1;	/* unused */
807 	uint16_t	sdl0;
808 #define	RT2860_RX_DDONE	(1 << 15)
809 #define	RT2860_RX_LS0	(1 << 14)
810 
811 	uint32_t	sdp1;	/* unused */
812 	uint32_t	flags;
813 #define	RT2860_RX_DEC		(1 << 16)
814 #define	RT2860_RX_AMPDU		(1 << 15)
815 #define	RT2860_RX_L2PAD		(1 << 14)
816 #define	RT2860_RX_RSSI		(1 << 13)
817 #define	RT2860_RX_HTC		(1 << 12)
818 #define	RT2860_RX_AMSDU		(1 << 11)
819 #define	RT2860_RX_MICERR	(1 << 10)
820 #define	RT2860_RX_ICVERR	(1 <<  9)
821 #define	RT2860_RX_CRCERR	(1 <<  8)
822 #define	RT2860_RX_MYBSS		(1 <<  7)
823 #define	RT2860_RX_BC		(1 <<  6)
824 #define	RT2860_RX_MC		(1 <<  5)
825 #define	RT2860_RX_UC2ME		(1 <<  4)
826 #define	RT2860_RX_FRAG		(1 <<  3)
827 #define	RT2860_RX_NULL		(1 <<  2)
828 #define	RT2860_RX_DATA		(1 <<  1)
829 #define	RT2860_RX_BA		(1 <<  0)
830 } __packed;
831 
832 /* RT2870 RX descriptor */
833 struct rt2870_rxd {
834 	/* single 32-bit field */
835 	uint32_t	flags;
836 } __packed;
837 
838 /* RX Wireless Information */
839 struct rt2860_rxwi {
840 	uint8_t		wcid;
841 	uint8_t		keyidx;
842 #define	RT2860_RX_UDF_SHIFT	5
843 #define	RT2860_RX_BSS_IDX_SHIFT	2
844 
845 	uint16_t	len;
846 #define	RT2860_RX_TID_SHIFT	12
847 
848 	uint16_t	seq;
849 	uint16_t	phy;
850 	uint8_t		rssi[3];
851 	uint8_t		reserved1;
852 	uint8_t		snr[2];
853 	uint16_t	reserved2;
854 } __packed;
855 
856 #define	RT2860_RF_2820	0x0001	/* 2T3R */
857 #define	RT2860_RF_2850	0x0002	/* dual-band 2T3R */
858 #define	RT2860_RF_2720	0x0003	/* 1T2R */
859 #define	RT2860_RF_2750	0x0004	/* dual-band 1T2R */
860 #define	RT3070_RF_3020	0x0005	/* 1T1R */
861 #define	RT3070_RF_2020	0x0006	/* b/g */
862 #define	RT3070_RF_3021	0x0007	/* 1T2R */
863 #define	RT3070_RF_3022	0x0008	/* 2T2R */
864 #define	RT3070_RF_3052	0x0009	/* dual-band 2T2R */
865 #define	RT3593_RF_3053	0x000d	/* dual-band 3T3R */
866 #define	RT5592_RF_5592	0x000f	/* dual-band 2T2R */
867 #define	RT5390_RF_5370	0x5370	/* 1T1R */
868 #define	RT5390_RF_5372	0x5372	/* 2T2R */
869 
870 /* USB commands for RT2870 only */
871 #define	RT2870_RESET		1
872 #define	RT2870_WRITE_2		2
873 #define	RT2870_WRITE_REGION_1	6
874 #define	RT2870_READ_REGION_1	7
875 #define	RT2870_EEPROM_READ	9
876 
877 #define	RT2860_EEPROM_DELAY	1	/* minimum hold time (microsecond) */
878 
879 #define	RT2860_EEPROM_VERSION		0x01
880 #define	RT2860_EEPROM_MAC01		0x02
881 #define	RT2860_EEPROM_MAC23		0x03
882 #define	RT2860_EEPROM_MAC45		0x04
883 #define	RT2860_EEPROM_PCIE_PSLEVEL	0x11
884 #define	RT2860_EEPROM_REV		0x12
885 #define	RT2860_EEPROM_ANTENNA		0x1a
886 #define	RT2860_EEPROM_CONFIG		0x1b
887 #define	RT2860_EEPROM_COUNTRY		0x1c
888 #define	RT2860_EEPROM_FREQ_LEDS		0x1d
889 #define	RT2860_EEPROM_LED1		0x1e
890 #define	RT2860_EEPROM_LED2		0x1f
891 #define	RT2860_EEPROM_LED3		0x20
892 #define	RT2860_EEPROM_LNA		0x22
893 #define	RT2860_EEPROM_RSSI1_2GHZ	0x23
894 #define	RT2860_EEPROM_RSSI2_2GHZ	0x24
895 #define	RT2860_EEPROM_RSSI1_5GHZ	0x25
896 #define	RT2860_EEPROM_RSSI2_5GHZ	0x26
897 #define	RT2860_EEPROM_DELTAPWR		0x28
898 #define	RT2860_EEPROM_PWR2GHZ_BASE1	0x29
899 #define	RT2860_EEPROM_PWR2GHZ_BASE2	0x30
900 #define	RT2860_EEPROM_TSSI1_2GHZ	0x37
901 #define	RT2860_EEPROM_TSSI2_2GHZ	0x38
902 #define	RT2860_EEPROM_TSSI3_2GHZ	0x39
903 #define	RT2860_EEPROM_TSSI4_2GHZ	0x3a
904 #define	RT2860_EEPROM_TSSI5_2GHZ	0x3b
905 #define	RT2860_EEPROM_PWR5GHZ_BASE1	0x3c
906 #define	RT2860_EEPROM_PWR5GHZ_BASE2	0x53
907 #define	RT2860_EEPROM_TSSI1_5GHZ	0x6a
908 #define	RT2860_EEPROM_TSSI2_5GHZ	0x6b
909 #define	RT2860_EEPROM_TSSI3_5GHZ	0x6c
910 #define	RT2860_EEPROM_TSSI4_5GHZ	0x6d
911 #define	RT2860_EEPROM_TSSI5_5GHZ	0x6e
912 #define	RT2860_EEPROM_RPWR		0x6f
913 #define	RT2860_EEPROM_BBP_BASE		0x78
914 #define	RT3071_EEPROM_RF_BASE		0x82
915 
916 /* EEPROM registers for RT3593. */
917 #define	RT3593_EEPROM_FREQ_LEDS		0x21
918 #define	RT3593_EEPROM_FREQ		0x22
919 #define	RT3593_EEPROM_LED1		0x22
920 #define	RT3593_EEPROM_LED2		0x23
921 #define	RT3593_EEPROM_LED3		0x24
922 #define	RT3593_EEPROM_LNA		0x26
923 #define	RT3593_EEPROM_LNA_5GHZ		0x27
924 #define	RT3593_EEPROM_RSSI1_2GHZ	0x28
925 #define	RT3593_EEPROM_RSSI2_2GHZ	0x29
926 #define	RT3593_EEPROM_RSSI1_5GHZ	0x2a
927 #define	RT3593_EEPROM_RSSI2_5GHZ	0x2b
928 #define	RT3593_EEPROM_PWR2GHZ_BASE1	0x30
929 #define	RT3593_EEPROM_PWR2GHZ_BASE2	0x37
930 #define	RT3593_EEPROM_PWR2GHZ_BASE3	0x3e
931 #define	RT3593_EEPROM_PWR5GHZ_BASE1	0x4b
932 #define	RT3593_EEPROM_PWR5GHZ_BASE2	0x65
933 #define	RT3593_EEPROM_PWR5GHZ_BASE3	0x7f
934 
935 /*
936  * EEPROM IQ calibration.
937  */
938 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX0_2GHZ			0x130
939 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX0_2GHZ			0x131
940 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX1_2GHZ			0x133
941 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX1_2GHZ			0x134
942 #define	RT5390_EEPROM_RF_IQ_COMPENSATION_CTL			0x13c
943 #define	RT5390_EEPROM_RF_IQ_IMBALANCE_COMPENSATION_CTL		0x13d
944 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH36_TO_CH64_5GHZ		0x144
945 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH36_TO_CH64_5GHZ	0x145
946 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH100_TO_CH138_5GHZ	0x146
947 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH100_TO_CH138_5GHZ	0x147
948 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH140_TO_CH165_5GHZ	0x148
949 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH140_TO_CH165_5GHZ	0x149
950 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH36_TO_CH64_5GHZ		0x14a
951 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH36_TO_CH64_5GHZ	0x14b
952 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH100_TO_CH138_5GHZ	0x14c
953 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH100_TO_CH138_5GHZ	0x14d
954 #define	RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH140_TO_CH165_5GHZ	0x14e
955 #define	RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH140_TO_CH165_5GHZ	0x14f
956 
957 /*
958  * EEPROM access macro.
959  */
960 #define RT2860_EEPROM_CTL(sc, val) do {					\
961 	RAL_WRITE((sc), RT2860_PCI_EECTRL, (val));			\
962 	RAL_BARRIER_READ_WRITE((sc));					\
963 	DELAY(RT2860_EEPROM_DELAY);					\
964 } while (/* CONSTCOND */0)
965 
966 /*
967  * Default values for MAC registers; values taken from the reference driver.
968  */
969 #define	RT2870_DEF_MAC					\
970 	{ RT2860_BCN_OFFSET0,		0xf8f0e8e0 },	\
971 	{ RT2860_BCN_OFFSET1,		0x6f77d0c8 },	\
972 	{ RT2860_LEGACY_BASIC_RATE,	0x0000013f },	\
973 	{ RT2860_HT_BASIC_RATE,		0x00008003 },	\
974 	{ RT2860_MAC_SYS_CTRL,		0x00000000 },	\
975 	{ RT2860_BKOFF_SLOT_CFG,	0x00000209 },	\
976 	{ RT2860_TX_SW_CFG0,		0x00000000 },	\
977 	{ RT2860_TX_SW_CFG1,		0x00080606 },	\
978 	{ RT2860_TX_LINK_CFG,		0x00001020 },	\
979 	{ RT2860_TX_TIMEOUT_CFG,	0x000a2090 },	\
980 	{ RT2860_MAX_LEN_CFG,		0x00001f00 },	\
981 	{ RT2860_LED_CFG,		0x7f031e46 },	\
982 	{ RT2860_WMM_AIFSN_CFG,		0x00002273 },	\
983 	{ RT2860_WMM_CWMIN_CFG,		0x00002344 },	\
984 	{ RT2860_WMM_CWMAX_CFG,		0x000034aa },	\
985 	{ RT2860_MAX_PCNT,		0x1f3fbf9f },	\
986 	{ RT2860_TX_RTY_CFG,		0x47d01f0f },	\
987 	{ RT2860_AUTO_RSP_CFG,		0x00000013 },	\
988 	{ RT2860_CCK_PROT_CFG,		0x05740003 },	\
989 	{ RT2860_OFDM_PROT_CFG,		0x05740003 },	\
990 	{ RT2860_PBF_CFG,		0x00f40006 },	\
991 	{ RT2860_WPDMA_GLO_CFG,		0x00000030 },	\
992 	{ RT2860_GF20_PROT_CFG,		0x01744004 },	\
993 	{ RT2860_GF40_PROT_CFG,		0x03f44084 },	\
994 	{ RT2860_MM20_PROT_CFG,		0x01744004 },	\
995 	{ RT2860_MM40_PROT_CFG,		0x03f44084 },	\
996 	{ RT2860_TXOP_CTRL_CFG,		0x0000583f },	\
997 	{ RT2860_TXOP_HLDR_ET,		0x00000002 },	\
998 	{ RT2860_TX_RTS_CFG,		0x00092b20 },	\
999 	{ RT2860_EXP_ACK_TIME,		0x002400ca },	\
1000 	{ RT2860_XIFS_TIME_CFG,		0x33a41010 },	\
1001 	{ RT2860_PWR_PIN_CFG,		0x00000003 }
1002 
1003 /*
1004  * Default values for BBP registers; values taken from the reference driver.
1005  */
1006 #define	RT2860_DEF_BBP	\
1007 	{  65, 0x2c },	\
1008 	{  66, 0x38 },	\
1009 	{  68, 0x0b },	\
1010 	{  69, 0x12 },	\
1011 	{  70, 0x0a },	\
1012 	{  73, 0x10 },	\
1013 	{  81, 0x37 },	\
1014 	{  82, 0x62 },	\
1015 	{  83, 0x6a },	\
1016 	{  84, 0x99 },	\
1017 	{  86, 0x00 },	\
1018 	{  91, 0x04 },	\
1019 	{  92, 0x00 },	\
1020 	{ 103, 0x00 },	\
1021 	{ 105, 0x05 },	\
1022 	{ 106, 0x35 }
1023 
1024 #define	RT5390_DEF_BBP	\
1025 	{  31, 0x08 },	\
1026 	{  65, 0x2c },	\
1027 	{  66, 0x38 },	\
1028 	{  68, 0x0b },	\
1029 	{  69, 0x0d },	\
1030 	{  70, 0x06 },	\
1031 	{  73, 0x13 },	\
1032 	{  75, 0x46 },	\
1033 	{  76, 0x28 },	\
1034 	{  77, 0x59 },	\
1035 	{  81, 0x37 },	\
1036 	{  82, 0x62 },	\
1037 	{  83, 0x7a },	\
1038 	{  84, 0x9a },	\
1039 	{  86, 0x38 },	\
1040 	{  91, 0x04 },	\
1041 	{  92, 0x02 },	\
1042 	{ 103, 0xc0 },	\
1043 	{ 104, 0x92 },	\
1044 	{ 105, 0x3c },	\
1045 	{ 106, 0x03 },	\
1046 	{ 128, 0x12 }
1047 
1048 #define	RT5592_DEF_BBP	\
1049 	{  20, 0x06 },	\
1050 	{  31, 0x08 },	\
1051 	{  65, 0x2c },	\
1052 	{  66, 0x38 },	\
1053 	{  68, 0xdd },	\
1054 	{  69, 0x1a },	\
1055 	{  70, 0x05 },	\
1056 	{  73, 0x13 },	\
1057 	{  74, 0x0f },	\
1058 	{  75, 0x4f },	\
1059 	{  76, 0x28 },	\
1060 	{  77, 0x59 },	\
1061 	{  81, 0x37 },	\
1062 	{  82, 0x62 },	\
1063 	{  83, 0x6a },	\
1064 	{  84, 0x9a },	\
1065 	{  86, 0x38 },	\
1066 	{  88, 0x90 },	\
1067 	{  91, 0x04 },	\
1068 	{  92, 0x02 },	\
1069 	{  95, 0x9a },	\
1070 	{  98, 0x12 },	\
1071 	{ 103, 0xc0 },	\
1072 	{ 104, 0x92 },	\
1073 	{ 105, 0x3c },	\
1074 	{ 106, 0x35 },	\
1075 	{ 128, 0x12 },	\
1076 	{ 134, 0xd0 },	\
1077 	{ 135, 0xf6 },	\
1078 	{ 137, 0x0f }
1079 
1080 /*
1081  * Channel map for run(4) driver; taken from the table below.
1082  */
1083 static const uint8_t run_chan_5ghz[] =
1084 	{ 36, 38, 40, 44, 46, 48, 52, 54, 56, 60, 62, 64, 100, 102, 104,
1085 	  108, 110, 112, 116, 118, 120, 124, 126, 128, 132, 134, 136, 140,
1086 	  149, 151, 153, 157, 159, 161, 165, 167, 169, 171, 173,
1087 	  184, 188, 192, 196, 208, 212, 216 };
1088 
1089 /*
1090  * Default settings for RF registers; values derived from the reference driver.
1091  */
1092 #define	RT2860_RF2850							\
1093 	{   1, 0x98402ecc, 0x984c0786, 0x9816b455, 0x9800510b },	\
1094 	{   2, 0x98402ecc, 0x984c0786, 0x98168a55, 0x9800519f },	\
1095 	{   3, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800518b },	\
1096 	{   4, 0x98402ecc, 0x984c078a, 0x98168a55, 0x9800519f },	\
1097 	{   5, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800518b },	\
1098 	{   6, 0x98402ecc, 0x984c078e, 0x98168a55, 0x9800519f },	\
1099 	{   7, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800518b },	\
1100 	{   8, 0x98402ecc, 0x984c0792, 0x98168a55, 0x9800519f },	\
1101 	{   9, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800518b },	\
1102 	{  10, 0x98402ecc, 0x984c0796, 0x98168a55, 0x9800519f },	\
1103 	{  11, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800518b },	\
1104 	{  12, 0x98402ecc, 0x984c079a, 0x98168a55, 0x9800519f },	\
1105 	{  13, 0x98402ecc, 0x984c079e, 0x98168a55, 0x9800518b },	\
1106 	{  14, 0x98402ecc, 0x984c07a2, 0x98168a55, 0x98005193 },	\
1107 	{  36, 0x98402ecc, 0x984c099a, 0x98158a55, 0x980ed1a3 },	\
1108 	{  38, 0x98402ecc, 0x984c099e, 0x98158a55, 0x980ed193 },	\
1109 	{  40, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed183 },	\
1110 	{  44, 0x98402ec8, 0x984c0682, 0x98158a55, 0x980ed1a3 },	\
1111 	{  46, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed18b },	\
1112 	{  48, 0x98402ec8, 0x984c0686, 0x98158a55, 0x980ed19b },	\
1113 	{  52, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed193 },	\
1114 	{  54, 0x98402ec8, 0x984c068a, 0x98158a55, 0x980ed1a3 },	\
1115 	{  56, 0x98402ec8, 0x984c068e, 0x98158a55, 0x980ed18b },	\
1116 	{  60, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed183 },	\
1117 	{  62, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed193 },	\
1118 	{  64, 0x98402ec8, 0x984c0692, 0x98158a55, 0x980ed1a3 },	\
1119 	{ 100, 0x98402ec8, 0x984c06b2, 0x98178a55, 0x980ed783 },	\
1120 	{ 102, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed793 },	\
1121 	{ 104, 0x98402ec8, 0x985c06b2, 0x98578a55, 0x980ed1a3 },	\
1122 	{ 108, 0x98402ecc, 0x985c0a32, 0x98578a55, 0x980ed193 },	\
1123 	{ 110, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed183 },	\
1124 	{ 112, 0x98402ecc, 0x984c0a36, 0x98178a55, 0x980ed19b },	\
1125 	{ 116, 0x98402ecc, 0x984c0a3a, 0x98178a55, 0x980ed1a3 },	\
1126 	{ 118, 0x98402ecc, 0x984c0a3e, 0x98178a55, 0x980ed193 },	\
1127 	{ 120, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed183 },	\
1128 	{ 124, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed193 },	\
1129 	{ 126, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed15b },	\
1130 	{ 128, 0x98402ec4, 0x984c0382, 0x98178a55, 0x980ed1a3 },	\
1131 	{ 132, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed18b },	\
1132 	{ 134, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed193 },	\
1133 	{ 136, 0x98402ec4, 0x984c0386, 0x98178a55, 0x980ed19b },	\
1134 	{ 140, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed183 },	\
1135 	{ 149, 0x98402ec4, 0x984c038a, 0x98178a55, 0x980ed1a7 },	\
1136 	{ 151, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed187 },	\
1137 	{ 153, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed18f },	\
1138 	{ 157, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed19f },	\
1139 	{ 159, 0x98402ec4, 0x984c038e, 0x98178a55, 0x980ed1a7 },	\
1140 	{ 161, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed187 },	\
1141 	{ 165, 0x98402ec4, 0x984c0392, 0x98178a55, 0x980ed197 },	\
1142 	{ 167, 0x98402ec4, 0x984c03d2, 0x98179855, 0x9815531f },	\
1143 	{ 169, 0x98402ec4, 0x984c03d2, 0x98179855, 0x98155327 },	\
1144 	{ 171, 0x98402ec4, 0x984c03d6, 0x98179855, 0x98155307 },	\
1145 	{ 173, 0x98402ec4, 0x984c03d6, 0x98179855, 0x9815530f },	\
1146 	{ 184, 0x95002ccc, 0x9500491e, 0x9509be55, 0x950c0a0b },	\
1147 	{ 188, 0x95002ccc, 0x95004922, 0x9509be55, 0x950c0a13 },	\
1148 	{ 192, 0x95002ccc, 0x95004926, 0x9509be55, 0x950c0a1b },	\
1149 	{ 196, 0x95002ccc, 0x9500492a, 0x9509be55, 0x950c0a23 },	\
1150 	{ 208, 0x95002ccc, 0x9500493a, 0x9509be55, 0x950c0a13 },	\
1151 	{ 212, 0x95002ccc, 0x9500493e, 0x9509be55, 0x950c0a1b },	\
1152 	{ 216, 0x95002ccc, 0x95004982, 0x9509be55, 0x950c0a23 }
1153 
1154 #define	RT3070_RF3052		\
1155 	{ 0xf1, 2,  2 },	\
1156 	{ 0xf1, 2,  7 },	\
1157 	{ 0xf2, 2,  2 },	\
1158 	{ 0xf2, 2,  7 },	\
1159 	{ 0xf3, 2,  2 },	\
1160 	{ 0xf3, 2,  7 },	\
1161 	{ 0xf4, 2,  2 },	\
1162 	{ 0xf4, 2,  7 },	\
1163 	{ 0xf5, 2,  2 },	\
1164 	{ 0xf5, 2,  7 },	\
1165 	{ 0xf6, 2,  2 },	\
1166 	{ 0xf6, 2,  7 },	\
1167 	{ 0xf7, 2,  2 },	\
1168 	{ 0xf8, 2,  4 },	\
1169 	{ 0x56, 0,  4 },	\
1170 	{ 0x56, 0,  6 },	\
1171 	{ 0x56, 0,  8 },	\
1172 	{ 0x57, 0,  0 },	\
1173 	{ 0x57, 0,  2 },	\
1174 	{ 0x57, 0,  4 },	\
1175 	{ 0x57, 0,  8 },	\
1176 	{ 0x57, 0, 10 },	\
1177 	{ 0x58, 0,  0 },	\
1178 	{ 0x58, 0,  4 },	\
1179 	{ 0x58, 0,  6 },	\
1180 	{ 0x58, 0,  8 },	\
1181 	{ 0x5b, 0,  8 },	\
1182 	{ 0x5b, 0, 10 },	\
1183 	{ 0x5c, 0,  0 },	\
1184 	{ 0x5c, 0,  4 },	\
1185 	{ 0x5c, 0,  6 },	\
1186 	{ 0x5c, 0,  8 },	\
1187 	{ 0x5d, 0,  0 },	\
1188 	{ 0x5d, 0,  2 },	\
1189 	{ 0x5d, 0,  4 },	\
1190 	{ 0x5d, 0,  8 },	\
1191 	{ 0x5d, 0, 10 },	\
1192 	{ 0x5e, 0,  0 },	\
1193 	{ 0x5e, 0,  4 },	\
1194 	{ 0x5e, 0,  6 },	\
1195 	{ 0x5e, 0,  8 },	\
1196 	{ 0x5f, 0,  0 },	\
1197 	{ 0x5f, 0,  9 },	\
1198 	{ 0x5f, 0, 11 },	\
1199 	{ 0x60, 0,  1 },	\
1200 	{ 0x60, 0,  5 },	\
1201 	{ 0x60, 0,  7 },	\
1202 	{ 0x60, 0,  9 },	\
1203 	{ 0x61, 0,  1 },	\
1204 	{ 0x61, 0,  3 },	\
1205 	{ 0x61, 0,  5 },	\
1206 	{ 0x61, 0,  7 },	\
1207 	{ 0x61, 0,  9 }
1208 
1209 #define	RT5592_RF5592_20MHZ	\
1210 	{ 0x1e2,  4, 10, 3 },	\
1211 	{ 0x1e3,  4, 10, 3 },	\
1212 	{ 0x1e4,  4, 10, 3 },	\
1213 	{ 0x1e5,  4, 10, 3 },	\
1214 	{ 0x1e6,  4, 10, 3 },	\
1215 	{ 0x1e7,  4, 10, 3 },	\
1216 	{ 0x1e8,  4, 10, 3 },	\
1217 	{ 0x1e9,  4, 10, 3 },	\
1218 	{ 0x1ea,  4, 10, 3 },	\
1219 	{ 0x1eb,  4, 10, 3 },	\
1220 	{ 0x1ec,  4, 10, 3 },	\
1221 	{ 0x1ed,  4, 10, 3 },	\
1222 	{ 0x1ee,  4, 10, 3 },	\
1223 	{ 0x1f0,  8, 10, 3 },	\
1224 	{  0xac,  8, 12, 1 },	\
1225 	{  0xad,  0, 12, 1 },	\
1226 	{  0xad,  4, 12, 1 },	\
1227 	{  0xae,  0, 12, 1 },	\
1228 	{  0xae,  4, 12, 1 },	\
1229 	{  0xae,  8, 12, 1 },	\
1230 	{  0xaf,  4, 12, 1 },	\
1231 	{  0xaf,  8, 12, 1 },	\
1232 	{  0xb0,  0, 12, 1 },	\
1233 	{  0xb0,  8, 12, 1 },	\
1234 	{  0xb1,  0, 12, 1 },	\
1235 	{  0xb1,  4, 12, 1 },	\
1236 	{  0xb7,  4, 12, 1 },	\
1237 	{  0xb7,  8, 12, 1 },	\
1238 	{  0xb8,  0, 12, 1 },	\
1239 	{  0xb8,  8, 12, 1 },	\
1240 	{  0xb9,  0, 12, 1 },	\
1241 	{  0xb9,  4, 12, 1 },	\
1242 	{  0xba,  0, 12, 1 },	\
1243 	{  0xba,  4, 12, 1 },	\
1244 	{  0xba,  8, 12, 1 },	\
1245 	{  0xbb,  4, 12, 1 },	\
1246 	{  0xbb,  8, 12, 1 },	\
1247 	{  0xbc,  0, 12, 1 },	\
1248 	{  0xbc,  8, 12, 1 },	\
1249 	{  0xbd,  0, 12, 1 },	\
1250 	{  0xbd,  4, 12, 1 },	\
1251 	{  0xbe,  0, 12, 1 },	\
1252 	{  0xbf,  6, 12, 1 },	\
1253 	{  0xbf, 10, 12, 1 },	\
1254 	{  0xc0,  2, 12, 1 },	\
1255 	{  0xc0, 10, 12, 1 },	\
1256 	{  0xc1,  2, 12, 1 },	\
1257 	{  0xc1,  6, 12, 1 },	\
1258 	{  0xc2,  2, 12, 1 },	\
1259 	{  0xa4,  0, 12, 1 },	\
1260 	{  0xa4,  4, 12, 1 },	\
1261 	{  0xa5,  8, 12, 1 },	\
1262 	{  0xa6,  0, 12, 1 }
1263 
1264 #define	RT5592_RF5592_40MHZ	\
1265 	{ 0xf1,  2, 10, 3 },	\
1266 	{ 0xf1,  7, 10, 3 },	\
1267 	{ 0xf2,  2, 10, 3 },	\
1268 	{ 0xf2,  7, 10, 3 },	\
1269 	{ 0xf3,  2, 10, 3 },	\
1270 	{ 0xf3,  7, 10, 3 },	\
1271 	{ 0xf4,  2, 10, 3 },	\
1272 	{ 0xf4,  7, 10, 3 },	\
1273 	{ 0xf5,  2, 10, 3 },	\
1274 	{ 0xf5,  7, 10, 3 },	\
1275 	{ 0xf6,  2, 10, 3 },	\
1276 	{ 0xf6,  7, 10, 3 },	\
1277 	{ 0xf7,  2, 10, 3 },	\
1278 	{ 0xf8,  4, 10, 3 },	\
1279 	{ 0x56,  4, 12, 1 },	\
1280 	{ 0x56,  6, 12, 1 },	\
1281 	{ 0x56,  8, 12, 1 },	\
1282 	{ 0x57,  0, 12, 1 },	\
1283 	{ 0x57,  2, 12, 1 },	\
1284 	{ 0x57,  4, 12, 1 },	\
1285 	{ 0x57,  8, 12, 1 },	\
1286 	{ 0x57, 10, 12, 1 },	\
1287 	{ 0x58,  0, 12, 1 },	\
1288 	{ 0x58,  4, 12, 1 },	\
1289 	{ 0x58,  6, 12, 1 },	\
1290 	{ 0x58,  8, 12, 1 },	\
1291 	{ 0x5b,  8, 12, 1 },	\
1292 	{ 0x5b, 10, 12, 1 },	\
1293 	{ 0x5c,  0, 12, 1 },	\
1294 	{ 0x5c,  4, 12, 1 },	\
1295 	{ 0x5c,  6, 12, 1 },	\
1296 	{ 0x5c,  8, 12, 1 },	\
1297 	{ 0x5d,  0, 12, 1 },	\
1298 	{ 0x5d,  2, 12, 1 },	\
1299 	{ 0x5d,  4, 12, 1 },	\
1300 	{ 0x5d,  8, 12, 1 },	\
1301 	{ 0x5d, 10, 12, 1 },	\
1302 	{ 0x5e,  0, 12, 1 },	\
1303 	{ 0x5e,  4, 12, 1 },	\
1304 	{ 0x5e,  6, 12, 1 },	\
1305 	{ 0x5e,  8, 12, 1 },	\
1306 	{ 0x5f,  0, 12, 1 },	\
1307 	{ 0x5f,  9, 12, 1 },	\
1308 	{ 0x5f, 11, 12, 1 },	\
1309 	{ 0x60,  1, 12, 1 },	\
1310 	{ 0x60,  5, 12, 1 },	\
1311 	{ 0x60,  7, 12, 1 },	\
1312 	{ 0x60,  9, 12, 1 },	\
1313 	{ 0x61,  1, 12, 1 },	\
1314 	{ 0x52,  0, 12, 1 },	\
1315 	{ 0x52,  4, 12, 1 },	\
1316 	{ 0x52,  8, 12, 1 },	\
1317 	{ 0x53,  0, 12, 1 }
1318 
1319 #define	RT3070_DEF_RF	\
1320 	{  4, 0x40 },	\
1321 	{  5, 0x03 },	\
1322 	{  6, 0x02 },	\
1323 	{  7, 0x60 },	\
1324 	{  9, 0x0f },	\
1325 	{ 10, 0x41 },	\
1326 	{ 11, 0x21 },	\
1327 	{ 12, 0x7b },	\
1328 	{ 14, 0x90 },	\
1329 	{ 15, 0x58 },	\
1330 	{ 16, 0xb3 },	\
1331 	{ 17, 0x92 },	\
1332 	{ 18, 0x2c },	\
1333 	{ 19, 0x02 },	\
1334 	{ 20, 0xba },	\
1335 	{ 21, 0xdb },	\
1336 	{ 24, 0x16 },	\
1337 	{ 25, 0x03 },	\
1338 	{ 29, 0x1f }
1339 
1340 #define	RT3572_DEF_RF	\
1341 	{  0, 0x70 },	\
1342 	{  1, 0x81 },	\
1343 	{  2, 0xf1 },	\
1344 	{  3, 0x02 },	\
1345 	{  4, 0x4c },	\
1346 	{  5, 0x05 },	\
1347 	{  6, 0x4a },	\
1348 	{  7, 0xd8 },	\
1349 	{  9, 0xc3 },	\
1350 	{ 10, 0xf1 },	\
1351 	{ 11, 0xb9 },	\
1352 	{ 12, 0x70 },	\
1353 	{ 13, 0x65 },	\
1354 	{ 14, 0xa0 },	\
1355 	{ 15, 0x53 },	\
1356 	{ 16, 0x4c },	\
1357 	{ 17, 0x23 },	\
1358 	{ 18, 0xac },	\
1359 	{ 19, 0x93 },	\
1360 	{ 20, 0xb3 },	\
1361 	{ 21, 0xd0 },	\
1362 	{ 22, 0x00 },  	\
1363 	{ 23, 0x3c },	\
1364 	{ 24, 0x16 },	\
1365 	{ 25, 0x15 },	\
1366 	{ 26, 0x85 },	\
1367 	{ 27, 0x00 },	\
1368 	{ 28, 0x00 },	\
1369 	{ 29, 0x9b },	\
1370 	{ 30, 0x09 },	\
1371 	{ 31, 0x10 }
1372 
1373 #define	RT3593_DEF_RF	\
1374 	{  1, 0x03 },	\
1375 	{  3, 0x80 },	\
1376 	{  5, 0x00 },	\
1377 	{  6, 0x40 },	\
1378 	{  8, 0xf1 },	\
1379 	{  9, 0x02 },	\
1380 	{ 10, 0xd3 },	\
1381 	{ 11, 0x40 },	\
1382 	{ 12, 0x4e },	\
1383 	{ 13, 0x12 },	\
1384 	{ 18, 0x40 },	\
1385 	{ 22, 0x20 },	\
1386 	{ 30, 0x10 },	\
1387 	{ 31, 0x80 },	\
1388 	{ 32, 0x78 },	\
1389 	{ 33, 0x3b },	\
1390 	{ 34, 0x3c },	\
1391 	{ 35, 0xe0 },	\
1392 	{ 38, 0x86 },	\
1393 	{ 39, 0x23 },	\
1394 	{ 44, 0xd3 },	\
1395 	{ 45, 0xbb },	\
1396 	{ 46, 0x60 },	\
1397 	{ 49, 0x81 },	\
1398 	{ 50, 0x86 },	\
1399 	{ 51, 0x75 },	\
1400 	{ 52, 0x45 },	\
1401 	{ 53, 0x18 },	\
1402 	{ 54, 0x18 },	\
1403 	{ 55, 0x18 },	\
1404 	{ 56, 0xdb },	\
1405 	{ 57, 0x6e }
1406 
1407 #define	RT5390_DEF_RF	\
1408 	{  1, 0x0f },	\
1409 	{  2, 0x80 },	\
1410 	{  3, 0x88 },	\
1411 	{  5, 0x10 },	\
1412 	{  6, 0xa0 },	\
1413 	{  7, 0x00 },	\
1414 	{ 10, 0x53 },	\
1415 	{ 11, 0x4a },	\
1416 	{ 12, 0x46 },	\
1417 	{ 13, 0x9f },	\
1418 	{ 14, 0x00 },	\
1419 	{ 15, 0x00 },	\
1420 	{ 16, 0x00 },	\
1421 	{ 18, 0x03 },	\
1422 	{ 19, 0x00 },	\
1423 	{ 20, 0x00 },	\
1424 	{ 21, 0x00 },	\
1425 	{ 22, 0x20 },  	\
1426 	{ 23, 0x00 },	\
1427 	{ 24, 0x00 },	\
1428 	{ 25, 0xc0 },	\
1429 	{ 26, 0x00 },	\
1430 	{ 27, 0x09 },	\
1431 	{ 28, 0x00 },	\
1432 	{ 29, 0x10 },	\
1433 	{ 30, 0x10 },	\
1434 	{ 31, 0x80 },	\
1435 	{ 32, 0x80 },	\
1436 	{ 33, 0x00 },	\
1437 	{ 34, 0x07 },	\
1438 	{ 35, 0x12 },	\
1439 	{ 36, 0x00 },	\
1440 	{ 37, 0x08 },	\
1441 	{ 38, 0x85 },	\
1442 	{ 39, 0x1b },	\
1443 	{ 40, 0x0b },	\
1444 	{ 41, 0xbb },	\
1445 	{ 42, 0xd2 },	\
1446 	{ 43, 0x9a },	\
1447 	{ 44, 0x0e },	\
1448 	{ 45, 0xa2 },	\
1449 	{ 46, 0x7b },	\
1450 	{ 47, 0x00 },	\
1451 	{ 48, 0x10 },	\
1452 	{ 49, 0x94 },	\
1453 	{ 52, 0x38 },	\
1454 	{ 53, 0x84 },	\
1455 	{ 54, 0x78 },	\
1456 	{ 55, 0x44 },	\
1457 	{ 56, 0x22 },	\
1458 	{ 57, 0x80 },	\
1459 	{ 58, 0x7f },	\
1460 	{ 59, 0x8f },	\
1461 	{ 60, 0x45 },	\
1462 	{ 61, 0xdd },	\
1463 	{ 62, 0x00 },	\
1464 	{ 63, 0x00 }
1465 
1466 #define	RT5392_DEF_RF	\
1467 	{  1, 0x17 },	\
1468 	{  3, 0x88 },	\
1469 	{  5, 0x10 },	\
1470 	{  6, 0xe0 },	\
1471 	{  7, 0x00 },	\
1472 	{ 10, 0x53 },	\
1473 	{ 11, 0x4a },	\
1474 	{ 12, 0x46 },	\
1475 	{ 13, 0x9f },	\
1476 	{ 14, 0x00 },	\
1477 	{ 15, 0x00 },	\
1478 	{ 16, 0x00 },	\
1479 	{ 18, 0x03 },	\
1480 	{ 19, 0x4d },	\
1481 	{ 20, 0x00 },	\
1482 	{ 21, 0x8d },	\
1483 	{ 22, 0x20 },  	\
1484 	{ 23, 0x0b },	\
1485 	{ 24, 0x44 },	\
1486 	{ 25, 0x80 },	\
1487 	{ 26, 0x82 },	\
1488 	{ 27, 0x09 },	\
1489 	{ 28, 0x00 },	\
1490 	{ 29, 0x10 },	\
1491 	{ 30, 0x10 },	\
1492 	{ 31, 0x80 },	\
1493 	{ 32, 0x20 },	\
1494 	{ 33, 0xc0 },	\
1495 	{ 34, 0x07 },	\
1496 	{ 35, 0x12 },	\
1497 	{ 36, 0x00 },	\
1498 	{ 37, 0x08 },	\
1499 	{ 38, 0x89 },	\
1500 	{ 39, 0x1b },	\
1501 	{ 40, 0x0f },	\
1502 	{ 41, 0xbb },	\
1503 	{ 42, 0xd5 },	\
1504 	{ 43, 0x9b },	\
1505 	{ 44, 0x0e },	\
1506 	{ 45, 0xa2 },	\
1507 	{ 46, 0x73 },	\
1508 	{ 47, 0x0c },	\
1509 	{ 48, 0x10 },	\
1510 	{ 49, 0x94 },	\
1511 	{ 50, 0x94 },	\
1512 	{ 51, 0x3a },	\
1513 	{ 52, 0x48 },	\
1514 	{ 53, 0x44 },	\
1515 	{ 54, 0x38 },	\
1516 	{ 55, 0x43 },	\
1517 	{ 56, 0xa1 },	\
1518 	{ 57, 0x00 },	\
1519 	{ 58, 0x39 },	\
1520 	{ 59, 0x07 },	\
1521 	{ 60, 0x45 },	\
1522 	{ 61, 0x91 },	\
1523 	{ 62, 0x39 },	\
1524 	{ 63, 0x07 }
1525 
1526 #define	RT5592_DEF_RF	\
1527 	{  1, 0x3f },	\
1528 	{  3, 0x08 },	\
1529 	{  5, 0x10 },	\
1530 	{  6, 0xe4 },	\
1531 	{  7, 0x00 },	\
1532 	{ 14, 0x00 },	\
1533 	{ 15, 0x00 },	\
1534 	{ 16, 0x00 },	\
1535 	{ 18, 0x03 },	\
1536 	{ 19, 0x4d },	\
1537 	{ 20, 0x10 },	\
1538 	{ 21, 0x8d },	\
1539 	{ 26, 0x82 },	\
1540 	{ 28, 0x00 },	\
1541 	{ 29, 0x10 },	\
1542 	{ 33, 0xc0 },	\
1543 	{ 34, 0x07 },	\
1544 	{ 35, 0x12 },	\
1545 	{ 47, 0x0c },	\
1546 	{ 53, 0x22 },	\
1547 	{ 63, 0x07 }
1548 
1549 #define	RT5592_2GHZ_DEF_RF	\
1550 	{ 10, 0x90 },		\
1551 	{ 11, 0x4a },		\
1552 	{ 12, 0x52 },		\
1553 	{ 13, 0x42 },		\
1554 	{ 22, 0x40 },		\
1555 	{ 24, 0x4a },		\
1556 	{ 25, 0x80 },		\
1557 	{ 27, 0x42 },		\
1558 	{ 36, 0x80 },		\
1559 	{ 37, 0x08 },		\
1560 	{ 38, 0x89 },		\
1561 	{ 39, 0x1b },		\
1562 	{ 40, 0x0d },		\
1563 	{ 41, 0x9b },		\
1564 	{ 42, 0xd5 },		\
1565 	{ 43, 0x72 },		\
1566 	{ 44, 0x0e },		\
1567 	{ 45, 0xa2 },		\
1568 	{ 46, 0x6b },		\
1569 	{ 48, 0x10 },		\
1570 	{ 51, 0x3e },		\
1571 	{ 52, 0x48 },		\
1572 	{ 54, 0x38 },		\
1573 	{ 56, 0xa1 },		\
1574 	{ 57, 0x00 },		\
1575 	{ 58, 0x39 },		\
1576 	{ 60, 0x45 },		\
1577 	{ 61, 0x91 },		\
1578 	{ 62, 0x39 }
1579 
1580 #define	RT5592_5GHZ_DEF_RF	\
1581 	{ 10, 0x97 },		\
1582 	{ 11, 0x40 },		\
1583 	{ 25, 0xbf },		\
1584 	{ 27, 0x42 },		\
1585 	{ 36, 0x00 },		\
1586 	{ 37, 0x04 },		\
1587 	{ 38, 0x85 },		\
1588 	{ 40, 0x42 },		\
1589 	{ 41, 0xbb },		\
1590 	{ 42, 0xd7 },		\
1591 	{ 45, 0x41 },		\
1592 	{ 48, 0x00 },		\
1593 	{ 57, 0x77 },		\
1594 	{ 60, 0x05 },		\
1595 	{ 61, 0x01 }
1596 
1597 #define	RT5592_CHAN_5GHZ	\
1598 	{  36,  64, 12, 0x2e },	\
1599 	{ 100, 165, 12, 0x0e },	\
1600 	{  36,  64, 13, 0x22 },	\
1601 	{ 100, 165, 13, 0x42 },	\
1602 	{  36,  64, 22, 0x60 },	\
1603 	{ 100, 165, 22, 0x40 },	\
1604 	{  36,  64, 23, 0x7f },	\
1605 	{ 100, 153, 23, 0x3c },	\
1606 	{ 155, 165, 23, 0x38 },	\
1607 	{  36,  50, 24, 0x09 },	\
1608 	{  52,  64, 24, 0x07 },	\
1609 	{ 100, 153, 24, 0x06 },	\
1610 	{ 155, 165, 24, 0x05 },	\
1611 	{  36,  64, 39, 0x1c },	\
1612 	{ 100, 138, 39, 0x1a },	\
1613 	{ 140, 165, 39, 0x18 },	\
1614 	{  36,  64, 43, 0x5b },	\
1615 	{ 100, 138, 43, 0x3b },	\
1616 	{ 140, 165, 43, 0x1b },	\
1617 	{  36,  64, 44, 0x40 },	\
1618 	{ 100, 138, 44, 0x20 },	\
1619 	{ 140, 165, 44, 0x10 },	\
1620 	{  36,  64, 46, 0x00 },	\
1621 	{ 100, 138, 46, 0x18 },	\
1622 	{ 140, 165, 46, 0x08 },	\
1623 	{  36,  64, 51, 0xfe },	\
1624 	{ 100, 124, 51, 0xfc },	\
1625 	{ 126, 165, 51, 0xec },	\
1626 	{  36,  64, 52, 0x0c },	\
1627 	{ 100, 138, 52, 0x06 },	\
1628 	{ 140, 165, 52, 0x06 },	\
1629 	{  36,  64, 54, 0xf8 },	\
1630 	{ 100, 165, 54, 0xeb },	\
1631 	{ 36,   50, 55, 0x06 },	\
1632 	{ 52,   64, 55, 0x04 },	\
1633 	{ 100, 138, 55, 0x01 },	\
1634 	{ 140, 165, 55, 0x00 },	\
1635 	{  36,  50, 56, 0xd3 },	\
1636 	{  52, 128, 56, 0xbb },	\
1637 	{ 130, 165, 56, 0xab },	\
1638 	{  36,  64, 58, 0x15 },	\
1639 	{ 100, 116, 58, 0x1d },	\
1640 	{ 118, 165, 58, 0x15 },	\
1641 	{  36,  64, 59, 0x7f },	\
1642 	{ 100, 138, 59, 0x3f },	\
1643 	{ 140, 165, 59, 0x7c },	\
1644 	{  36,  64, 62, 0x15 },	\
1645 	{ 100, 116, 62, 0x1d },	\
1646 	{ 118, 165, 62, 0x15 }
1647 
1648 union run_stats {
1649 	uint32_t	raw;
1650 	struct {
1651 		uint16_t	fail;
1652 		uint16_t	pad;
1653 	} error;
1654 	struct {
1655 		uint16_t	success;
1656 		uint16_t	retry;
1657 	} tx;
1658 } __aligned(4);
1659 
1660 #endif	/* _IF_RUNREG_H_ */
1661