xref: /freebsd/sys/dev/rtwn/rtl8821a/r21a_priv.h (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1 /*-
2  * Copyright (c) 2016 Andriy Voskoboinyk <avos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 #ifndef R21A_PRIV_H
30 #define R21A_PRIV_H
31 
32 /*
33  * MAC initialization values.
34  */
35 static const struct rtwn_mac_prog rtl8821au_mac[] = {
36 	{ 0x421, 0x0f }, { 0x428, 0x0a }, { 0x429, 0x10 }, { 0x430, 0x00 },
37 	{ 0x431, 0x00 }, { 0x432, 0x00 }, { 0x433, 0x01 }, { 0x434, 0x04 },
38 	{ 0x435, 0x05 }, { 0x436, 0x07 }, { 0x437, 0x08 }, { 0x43c, 0x04 },
39 	{ 0x43d, 0x05 }, { 0x43e, 0x07 }, { 0x43f, 0x08 }, { 0x440, 0x5d },
40 	{ 0x441, 0x01 }, { 0x442, 0x00 }, { 0x444, 0x10 }, { 0x445, 0x00 },
41 	{ 0x446, 0x00 }, { 0x447, 0x00 }, { 0x448, 0x00 }, { 0x449, 0xf0 },
42 	{ 0x44a, 0x0f }, { 0x44b, 0x3e }, { 0x44c, 0x10 }, { 0x44d, 0x00 },
43 	{ 0x44e, 0x00 }, { 0x44f, 0x00 }, { 0x450, 0x00 }, { 0x451, 0xf0 },
44 	{ 0x452, 0x0f }, { 0x453, 0x00 }, { 0x456, 0x5e }, { 0x460, 0x66 },
45 	{ 0x461, 0x66 }, { 0x4c8, 0x3f }, { 0x4c9, 0xff }, { 0x4cc, 0xff },
46 	{ 0x4cd, 0xff }, { 0x4ce, 0x01 }, { 0x500, 0x26 }, { 0x501, 0xa2 },
47 	{ 0x502, 0x2f }, { 0x503, 0x00 }, { 0x504, 0x28 }, { 0x505, 0xa3 },
48 	{ 0x506, 0x5e }, { 0x507, 0x00 }, { 0x508, 0x2b }, { 0x509, 0xa4 },
49 	{ 0x50a, 0x5e }, { 0x50b, 0x00 }, { 0x50c, 0x4f }, { 0x50d, 0xa4 },
50 	{ 0x50e, 0x00 }, { 0x50f, 0x00 }, { 0x512, 0x1c }, { 0x514, 0x0a },
51 	{ 0x516, 0x0a }, { 0x525, 0x4f }, { 0x550, 0x10 }, { 0x551, 0x10 },
52 	{ 0x559, 0x02 }, { 0x55c, 0x50 }, { 0x55d, 0xff }, { 0x605, 0x30 },
53 	{ 0x607, 0x07 }, { 0x608, 0x0e }, { 0x609, 0x2a }, { 0x620, 0xff },
54 	{ 0x621, 0xff }, { 0x622, 0xff }, { 0x623, 0xff }, { 0x624, 0xff },
55 	{ 0x625, 0xff }, { 0x626, 0xff }, { 0x627, 0xff }, { 0x638, 0x50 },
56 	{ 0x63c, 0x0a }, { 0x63d, 0x0a }, { 0x63e, 0x0e }, { 0x63f, 0x0e },
57 	{ 0x640, 0x40 }, { 0x642, 0x40 }, { 0x643, 0x00 }, { 0x652, 0xc8 },
58 	{ 0x66e, 0x05 }, { 0x700, 0x21 }, { 0x701, 0x43 }, { 0x702, 0x65 },
59 	{ 0x703, 0x87 }, { 0x708, 0x21 }, { 0x709, 0x43 }, { 0x70a, 0x65 },
60 	{ 0x70b, 0x87 }, { 0x718, 0x40 }
61 };
62 
63 /*
64  * Baseband initialization values.
65  */
66 #define R21A_COND_EXT_PA_5G	0x01
67 #define R21A_COND_EXT_LNA_5G	0x02
68 #define R21A_COND_BOARD_DEF	0x04
69 #define R21A_COND_BT		0x08
70 
71 static const uint16_t rtl8821au_bb_regs[] = {
72 	0x800, 0x804, 0x808, 0x80c, 0x810, 0x814, 0x818, 0x820, 0x824,
73 	0x828, 0x82c, 0x830, 0x834, 0x838, 0x83c, 0x840, 0x844, 0x848,
74 	0x84c, 0x850, 0x854, 0x858, 0x85c, 0x860, 0x864, 0x868, 0x86c,
75 	0x870, 0x874, 0x878, 0x87c, 0x8a0, 0x8a4, 0x8a8, 0x8ac, 0x8b4,
76 	0x8b8, 0x8bc, 0x8c0, 0x8c4, 0x8c8, 0x8cc, 0x8d4, 0x8d8, 0x8f8,
77 	0x8fc, 0x900, 0x90c, 0x910, 0x914, 0x918, 0x91c, 0x920, 0x924,
78 	0x928, 0x92c, 0x930, 0x934, 0x960, 0x964, 0x968, 0x96c, 0x970,
79 	0x974, 0x978, 0x97c, 0x980, 0x984, 0x988, 0x990, 0x994, 0x998,
80 	0x99c, 0x9a0, 0x9a4, 0x9a8, 0x9ac, 0x9b0, 0x9b4, 0x9b8, 0x9bc,
81 	0x9d0, 0x9d4, 0x9d8, 0x9dc, 0x9e0, 0x9e4, 0x9e8, 0xa00, 0xa04,
82 	0xa08, 0xa0c, 0xa10, 0xa14, 0xa18, 0xa1c, 0xa20, 0xa24, 0xa28,
83 	0xa2c, 0xa70, 0xa74, 0xa78, 0xa7c, 0xa80, 0xa84, 0xb00, 0xb04,
84 	0xb08, 0xb0c, 0xb10, 0xb14, 0xb18, 0xb1c, 0xb20, 0xb24, 0xb28,
85 	0xb2c, 0xb30, 0xb34, 0xb38, 0xb3c, 0xb40, 0xb44, 0xb48, 0xb4c,
86 	0xb50, 0xb54, 0xb58, 0xb5c, 0xc00, 0xc04, 0xc08, 0xc0c, 0xc10,
87 	0xc14, 0xc1c, 0xc20, 0xc24, 0xc28, 0xc2c, 0xc30, 0xc34, 0xc38,
88 	0xc3c, 0xc40, 0xc44, 0xc48, 0xc4c, 0xc50, 0xc54, 0xc58, 0xc5c,
89 	0xc60, 0xc64, 0xc68, 0xc6c, 0xc70, 0xc74, 0xc78, 0xc7c, 0xc80,
90 	0xc84, 0xc94, 0xc98, 0xc9c, 0xca0, 0xca4, 0xca8, 0xcb0, 0xcb4,
91 	0xcb8
92 };
93 
94 static const uint32_t rtl8821au_bb_vals[] = {
95 	0x0020d090, 0x080112e0, 0x0e028211, 0x92131111, 0x20101261,
96 	0x020c3d10, 0x03a00385, 0x00000000, 0x00030fe0, 0x00000000,
97 	0x002081dd, 0x2aaaeec8, 0x0037a706, 0x06489b44, 0x0000095b,
98 	0xc0000001, 0x40003cde, 0x62103f8b, 0x6cfdffb8, 0x28874706,
99 	0x0001520c, 0x8060e000, 0x74210168, 0x6929c321, 0x79727432,
100 	0x8ca7a314, 0x888c2878, 0x08888888, 0x31612c2e, 0x00000152,
101 	0x000fd000, 0x00000013, 0x7f7f7f7f, 0xa2000338, 0x0ff0fa0a,
102 	0x000fc080, 0x6c10d7ff, 0x0ca52090, 0x1bf00020, 0x00000000,
103 	0x00013169, 0x08248492, 0x940008a0, 0x290b5612, 0x400002c0,
104 	0x00000000, 0x00000700, 0x00000000, 0x0000fc00, 0x00000404,
105 	0x1c1028c0, 0x64b11a1c, 0xe0767233, 0x055aa500, 0x00000004,
106 	0xfffe0000, 0xfffffffe, 0x001fffff, 0x00000000, 0x00000000,
107 	0x00000000, 0x00000000, 0x801fffff, 0x000003ff, 0x00000000,
108 	0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x27100000,
109 	0xffff0100, 0xffffff5c, 0xffffffff, 0x000000ff, 0x00480080,
110 	0x00000000, 0x00000000, 0x81081008, 0x01081008, 0x01081008,
111 	0x01081008, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
112 	0x00005d00, 0x00000003, 0x00000001, 0x00d047c8, 0x01ff800c,
113 	0x8c8a8300, 0x2e68000f, 0x9500bb78, 0x11144028, 0x00881117,
114 	0x89140f00, 0x1a1b0000, 0x090e1317, 0x00000204, 0x00900000,
115 	0x101fff00, 0x00000008, 0x00000900, 0x225b0606, 0x21805490,
116 	0x001f0000, 0x03100040, 0x0000b000, 0xae0201eb, 0x01003207,
117 	0x00009807, 0x01000000, 0x00000002, 0x00000002, 0x0000001f,
118 	0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c, 0x13121110,
119 	0x17161514, 0x0000003a, 0x00000000, 0x00000000, 0x13000032,
120 	0x48080000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
121 	0x00000007, 0x00042020, 0x80410231, 0x00000000, 0x00000100,
122 	0x01000000, 0x40000003, 0x2c2c2c2c, 0x30303030, 0x30303030,
123 	0x2c2c2c2c, 0x2c2c2c2c, 0x2c2c2c2c, 0x2c2c2c2c, 0x2a2a2a2a,
124 	0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x2a2a2a2a, 0x00000020,
125 	0x001c1208, 0x30000c1c, 0x00000058, 0x34344443, 0x07003333,
126 	0x19791979, 0x19791979, 0x19791979, 0x19791979, 0x19791979,
127 	0x19791979, 0x19791979, 0x19791979, 0x0100005c, 0x00000000,
128 	0x00000000, 0x00000029, 0x08040201, 0x80402010, 0x77775747,
129 	0x10000077, 0x00508240
130 };
131 
132 static const struct rtwn_bb_prog rtl8821au_bb[] = {
133 	{
134 		nitems(rtl8821au_bb_regs),
135 		rtl8821au_bb_regs,
136 		rtl8821au_bb_vals,
137 		{ 0 },
138 		NULL
139 	}
140 };
141 
142 static const uint32_t rtl8821au_agc_vals0[] = {
143 	0xbf000001, 0xbf020001, 0xbf040001, 0xbf060001, 0xbe080001,
144 	0xbd0a0001, 0xbc0c0001, 0xba0e0001, 0xb9100001, 0xb8120001,
145 	0xb7140001, 0xb6160001, 0xb5180001, 0xb41a0001, 0xb31c0001,
146 	0xb21e0001, 0xb1200001, 0xb0220001, 0xaf240001, 0xae260001,
147 	0xad280001, 0xac2a0001, 0xab2c0001, 0xaa2e0001, 0xa9300001,
148 	0xa8320001, 0xa7340001, 0xa6360001, 0xa5380001, 0xa43a0001,
149 	0x683c0001, 0x673e0001, 0x66400001, 0x65420001, 0x64440001,
150 	0x63460001, 0x62480001, 0x614a0001, 0x474c0001, 0x464e0001,
151 	0x45500001, 0x44520001, 0x43540001, 0x42560001, 0x41580001,
152 	0x285a0001, 0x275c0001, 0x265e0001, 0x25600001, 0x24620001,
153 	0x0a640001, 0x09660001, 0x08680001, 0x076a0001, 0x066c0001,
154 	0x056e0001, 0x04700001, 0x03720001, 0x02740001, 0x01760001,
155 	0x01780001, 0x017a0001, 0x017c0001, 0x017e0001
156 }, rtl8821au_agc_vals1_pa_lna_5g[] = {
157 	0xfb000101, 0xfa020101, 0xf9040101, 0xf8060101, 0xf7080101,
158 	0xf60a0101, 0xf50c0101, 0xf40e0101, 0xf3100101, 0xf2120101,
159 	0xf1140101, 0xf0160101, 0xef180101, 0xee1a0101, 0xed1c0101,
160 	0xec1e0101, 0xeb200101, 0xea220101, 0xe9240101, 0xe8260101,
161 	0xe7280101, 0xe62a0101, 0xe52c0101, 0xe42e0101, 0xe3300101,
162 	0xa5320101, 0xa4340101, 0xa3360101, 0x87380101, 0x863a0101,
163 	0x853c0101, 0x843e0101, 0x69400101, 0x68420101, 0x67440101,
164 	0x66460101, 0x49480101, 0x484a0101, 0x474c0101, 0x2a4e0101,
165 	0x29500101, 0x28520101, 0x27540101, 0x26560101, 0x25580101,
166 	0x245a0101, 0x235c0101, 0x055e0101, 0x04600101, 0x03620101,
167 	0x02640101, 0x01660101, 0x01680101, 0x016a0101, 0x016c0101,
168 	0x016e0101, 0x01700101, 0x01720101
169 }, rtl8821au_agc_vals1[] = {
170 	0xff000101, 0xff020101, 0xfe040101, 0xfd060101, 0xfc080101,
171 	0xfd0a0101, 0xfc0c0101, 0xfb0e0101, 0xfa100101, 0xf9120101,
172 	0xf8140101, 0xf7160101, 0xf6180101, 0xf51a0101, 0xf41c0101,
173 	0xf31e0101, 0xf2200101, 0xf1220101, 0xf0240101, 0xef260101,
174 	0xee280101, 0xed2a0101, 0xec2c0101, 0xeb2e0101, 0xea300101,
175 	0xe9320101, 0xe8340101, 0xe7360101, 0xe6380101, 0xe53a0101,
176 	0xe43c0101, 0xe33e0101, 0xa5400101, 0xa4420101, 0xa3440101,
177 	0x87460101, 0x86480101, 0x854a0101, 0x844c0101, 0x694e0101,
178 	0x68500101, 0x67520101, 0x66540101, 0x49560101, 0x48580101,
179 	0x475a0101, 0x2a5c0101, 0x295e0101, 0x28600101, 0x27620101,
180 	0x26640101, 0x25660101, 0x24680101, 0x236a0101, 0x056c0101,
181 	0x046e0101, 0x03700101, 0x02720101
182 }, rtl8821au_agc_vals2[] = {
183 	0x01740101, 0x01760101, 0x01780101, 0x017a0101, 0x017c0101,
184 	0x017e0101
185 };
186 
187 static const struct rtwn_agc_prog rtl8821au_agc[] = {
188 	{
189 		nitems(rtl8821au_agc_vals0),
190 		rtl8821au_agc_vals0,
191 		{ 0 },
192 		NULL
193 	},
194 	/*
195 	 * For devices with external 5GHz PA / LNA.
196 	 */
197 	{
198 		nitems(rtl8821au_agc_vals1_pa_lna_5g),
199 		rtl8821au_agc_vals1_pa_lna_5g,
200 		{ R21A_COND_EXT_PA_5G | R21A_COND_EXT_LNA_5G, 0 },
201 		/*
202 		 * Others.
203 		 */
204 		&(const struct rtwn_agc_prog){
205 			nitems(rtl8821au_agc_vals1),
206 			rtl8821au_agc_vals1,
207 			{ 0 },
208 			NULL
209 		}
210 	},
211 	{
212 		nitems(rtl8821au_agc_vals2),
213 		rtl8821au_agc_vals2,
214 		{ 0 },
215 		NULL
216 	}
217 };
218 
219 /*
220  * RF initialization values.
221  */
222 static const uint8_t rtl8821au_rf_regs0[] = {
223 	0x18, 0x56, 0x66, 0x00, 0x1e, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
224 	0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0xef, 0x3e, 0x3f,
225 	0x3e, 0x3f, 0x3e, 0x3f, 0x3e, 0x3f, 0xef, 0x18, 0x89, 0x8b, 0xef,
226 	0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b,
227 	0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a,
228 	0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c,
229 	0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b,
230 	0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a,
231 	0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0x3a, 0x3b, 0x3c, 0xef, 0xef
232 }, rtl8821au_rf_regs1[] = {
233 	0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
234 	0x34, 0x34
235 }, rtl8821au_rf_regs2[] = {
236 	0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
237 	0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0xef, 0x18,
238 	0xef
239 }, rtl8821au_rf_regs3[] = {
240 	0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0xef, 0x18,
241 	0xef, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
242 	0x36, 0x36, 0xef, 0xef, 0x3c, 0x3c
243 }, rtl8821au_rf_regs4[] = {
244 	0x3c, 0xef, 0x18, 0xef, 0x08, 0xef, 0xdf, 0x1f, 0x58, 0x59, 0x61,
245 	0x62, 0x63, 0x64, 0x65
246 }, rtl8821au_rf_regs5[] = {
247 	0x18, 0xef, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
248 	0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0xef, 0xef, 0x34, 0x34,
249 	0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0xef, 0xed,
250 	0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
251 	0xed, 0xed, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xed,
252 	0xef, 0xdf, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x36, 0xef, 0x51,
253 	0x52, 0x53, 0x54, 0x56, 0x51, 0x52, 0x53, 0x70, 0x71, 0x72, 0x74,
254 	0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x36, 0xed, 0x45, 0x45, 0x45,
255 	0x46, 0x46, 0x46, 0x46, 0xdf, 0xb3, 0xb4, 0xb7, 0x1c, 0xc4, 0x18,
256 	0xfe, 0xfe, 0x18,
257 };
258 
259 static const uint32_t rtl8821au_rf_vals0[] = {
260 	0x1712a, 0x51cf2, 0x40000, 0x10000, 0x80000, 0x00830, 0x21800,
261 	0x28000, 0x48000, 0x94838, 0x44980, 0x48000, 0x0d480, 0x42240,
262 	0xf0380, 0x90000, 0x22852, 0x65540, 0x88001, 0x20000, 0x00380,
263 	0x90018, 0x20380, 0xa0018, 0x40308, 0xa0018, 0x60018, 0xa0018,
264 	0x00000, 0x1712a, 0x00080, 0x80180, 0x01000, 0x00244, 0x38027,
265 	0x82000, 0x00244, 0x30113, 0x82000, 0x0014c, 0x28027, 0x82000,
266 	0x000cc, 0x27027, 0x42000, 0x0014c, 0x1f913, 0x42000, 0x0010c,
267 	0x17f10, 0x12000, 0x000d0, 0x08027, 0xca000, 0x00244, 0x78027,
268 	0x82000, 0x00244, 0x70113, 0x82000, 0x0014c, 0x68027, 0x82000,
269 	0x000cc, 0x67027, 0x42000, 0x0014c, 0x5f913, 0x42000, 0x0010c,
270 	0x57f10, 0x12000, 0x000d0, 0x48027, 0xca000, 0x00244, 0xb8027,
271 	0x82000, 0x00244, 0xb0113, 0x82000, 0x0014c, 0xa8027, 0x82000,
272 	0x000cc, 0xa7027, 0x42000, 0x0014c, 0x9f913, 0x42000, 0x0010c,
273 	0x97f10, 0x12000, 0x000d0, 0x88027, 0xca000, 0x00000, 0x01100
274 }, rtl8821au_rf_vals1_def_or_bt[] = {
275 	0x4adf5, 0x49df2, 0x48def, 0x47dec, 0x46de9, 0x45ccb, 0x4488d,
276 	0x4348d, 0x4248a, 0x4108d, 0x4008a, 0x2adf4, 0x29df1
277 }, rtl8821au_rf_vals1_ext_5g[] = {
278 	0x4a0f3, 0x490b1, 0x480ae, 0x470ab, 0x4608b, 0x45069, 0x44048,
279 	0x43045, 0x42026, 0x41023, 0x40002, 0x2a0f3, 0x290f0
280 }, rtl8821au_rf_vals1[] = {
281 	0x4adf7, 0x49df3, 0x48def, 0x47dec, 0x46de9, 0x45ccb, 0x4488d,
282 	0x4348d, 0x4248a, 0x4108d, 0x4008a, 0x2adf7, 0x29df2
283 }, rtl8821au_rf_vals2_ext_5g[] = {
284 	0x280af, 0x270ac, 0x2608b, 0x25069, 0x24048, 0x23045, 0x22026,
285 	0x21023, 0x20002, 0x0a0d7, 0x090d3, 0x080b1, 0x070ae, 0x0608d,
286 	0x0506b, 0x0404a, 0x03047, 0x02044, 0x01025, 0x00004, 0x00000,
287 	0x1712a, 0x00040
288 }, rtl8821au_rf_vals2[] = {
289 	0x28dee, 0x27deb, 0x26ccd, 0x25cca, 0x2488c, 0x2384c, 0x22849,
290 	0x21449, 0x2004d, 0x0adf7, 0x09df4, 0x08df1, 0x07dee, 0x06dcd,
291 	0x05ccd, 0x04cca, 0x0388c, 0x02888, 0x01488, 0x00486, 0x00000,
292 	0x1712a, 0x00040
293 }, rtl8821au_rf_vals3_def_or_bt[] = {
294 	0x00128, 0x08128, 0x10128, 0x201c8, 0x281c8, 0x301c8, 0x401c8,
295 	0x481c8, 0x501c8, 0x00000, 0x1712a, 0x00010, 0x063b5, 0x0e3b5,
296 	0x163b5, 0x1e3b5, 0x263b5, 0x2e3b5, 0x363b5, 0x3e3b5, 0x463b5,
297 	0x4e3b5, 0x563b5, 0x5e3b5, 0x00000, 0x00008, 0x001b6, 0x00492
298 }, rtl8821au_rf_vals3[] = {
299 	0x00145, 0x08145, 0x10145, 0x20196, 0x28196, 0x30196, 0x401c7,
300 	0x481c7, 0x501c7, 0x00000, 0x1712a, 0x00010, 0x056b3, 0x0d6b3,
301 	0x156b3, 0x1d6b3, 0x26634, 0x2e634, 0x36634, 0x3e634, 0x467b4,
302 	0x4e7b4, 0x567b4, 0x5e7b4, 0x00000, 0x00008, 0x0022a, 0x00594
303 }, rtl8821au_rf_vals4_def_or_bt[] = {
304 	0x00800, 0x00000, 0x1712a, 0x00002, 0x02000, 0x00000, 0x000c0,
305 	0x00064, 0x81184, 0x6016c, 0xefd83, 0x93fcc, 0x110eb, 0x1c27c,
306 	0x93016
307 }, rtl8821au_rf_vals4_ext_5g[] = {
308 	0x00820, 0x00000, 0x1712a, 0x00002, 0x02000, 0x00000, 0x000c0,
309 	0x00064, 0x81184, 0x6016c, 0xead53, 0x93bc4, 0x110e9, 0x1c67c,
310 	0x93015
311 }, rtl8821au_rf_vals4[] = {
312 	0x00900, 0x00000, 0x1712a, 0x00002, 0x02000, 0x00000, 0x000c0,
313 	0x00064, 0x81184, 0x6016c, 0xead53, 0x93bc4, 0x714e9, 0x1c67c,
314 	0x91016
315 }, rtl8821au_rf_vals5[] = {
316 	0x00006, 0x02000, 0x3824b, 0x3024b, 0x2844b, 0x20f4b, 0x18f4b,
317 	0x104b2, 0x08049, 0x00148, 0x7824b, 0x7024b, 0x6824b, 0x60f4b,
318 	0x58f4b, 0x504b2, 0x48049, 0x40148, 0x00000, 0x00100, 0x0adf3,
319 	0x09df0, 0x08d70, 0x07d6d, 0x06cee, 0x05ccc, 0x044ec, 0x034ac,
320 	0x0246d, 0x0106f, 0x0006c, 0x00000, 0x00010, 0x0adf2, 0x09def,
321 	0x08dec, 0x07de9, 0x06cec, 0x05ce9, 0x044ec, 0x034e9, 0x0246c,
322 	0x01469, 0x0006c, 0x00000, 0x00001, 0x38da7, 0x300c2, 0x288e2,
323 	0x200b8, 0x188a5, 0x10fbc, 0x08f71, 0x00240, 0x00000, 0x020a2,
324 	0x00080, 0x00120, 0x08120, 0x10120, 0x00085, 0x08085, 0x10085,
325 	0x18085, 0x00000, 0x00c31, 0x00622, 0xfc70b, 0x0017e, 0x51df3,
326 	0x00c01, 0x006d6, 0xfc649, 0x49661, 0x7843e, 0x00382, 0x51400,
327 	0x00160, 0x08160, 0x10160, 0x00124, 0x08124, 0x10124, 0x18124,
328 	0x0000c, 0x00140, 0x08140, 0x10140, 0x00124, 0x08124, 0x10124,
329 	0x18124, 0x00088, 0xf0e18, 0x1214c, 0x3000c, 0x539d2, 0xafe00,
330 	0x1f12a, 0x0c350, 0x0c350, 0x1712a,
331 };
332 
333 static const struct rtwn_rf_prog rtl8821au_rf[] = {
334 	/* RF chain 0. */
335 	{
336 		nitems(rtl8821au_rf_regs0),
337 		rtl8821au_rf_regs0,
338 		rtl8821au_rf_vals0,
339 		{ 0 },
340 		NULL
341 	},
342 	/*
343 	 * No external PA/LNA; with or without BT.
344 	 */
345 	{
346 		nitems(rtl8821au_rf_regs1),
347 		rtl8821au_rf_regs1,
348 		rtl8821au_rf_vals1_def_or_bt,
349 		{ R21A_COND_BOARD_DEF, R21A_COND_BT, 0 },
350 		/*
351 		 * With external 5GHz PA and LNA.
352 		 */
353 		&(const struct rtwn_rf_prog){
354 			nitems(rtl8821au_rf_regs1),
355 			rtl8821au_rf_regs1,
356 			rtl8821au_rf_vals1_ext_5g,
357 			{ R21A_COND_EXT_PA_5G | R21A_COND_EXT_LNA_5G, 0 },
358 			/*
359 			 * Others.
360 			 */
361 			&(const struct rtwn_rf_prog){
362 				nitems(rtl8821au_rf_regs1),
363 				rtl8821au_rf_regs1,
364 				rtl8821au_rf_vals1,
365 				{ 0 },
366 				NULL
367 			}
368 		}
369 	},
370 	/*
371 	 * With external 5GHz PA and LNA.
372 	 */
373 	{
374 		nitems(rtl8821au_rf_regs2),
375 		rtl8821au_rf_regs2,
376 		rtl8821au_rf_vals2_ext_5g,
377 		{ R21A_COND_EXT_PA_5G | R21A_COND_EXT_LNA_5G, 0 },
378 		/*
379 		 * Others.
380 		 */
381 		&(const struct rtwn_rf_prog){
382 			nitems(rtl8821au_rf_regs2),
383 			rtl8821au_rf_regs2,
384 			rtl8821au_rf_vals2,
385 			{ 0 },
386 			NULL
387 		}
388 	},
389 	/*
390 	 * No external PA/LNA; with or without BT.
391 	 */
392 	{
393 		nitems(rtl8821au_rf_regs3),
394 		rtl8821au_rf_regs3,
395 		rtl8821au_rf_vals3_def_or_bt,
396 		{ R21A_COND_BOARD_DEF, R21A_COND_BT, 0 },
397 		/*
398 		 * Others.
399 		 */
400 		&(const struct rtwn_rf_prog){
401 			nitems(rtl8821au_rf_regs3),
402 			rtl8821au_rf_regs3,
403 			rtl8821au_rf_vals3,
404 			{ 0 },
405 			NULL
406 		}
407 	},
408 	/*
409 	 * No external PA/LNA; with or without BT.
410 	 */
411 	{
412 		nitems(rtl8821au_rf_regs4),
413 		rtl8821au_rf_regs4,
414 		rtl8821au_rf_vals4_def_or_bt,
415 		{ R21A_COND_BOARD_DEF, R21A_COND_BT, 0 },
416 		/*
417 		 * With external 5GHz PA and LNA.
418 		 */
419 		&(const struct rtwn_rf_prog){
420 			nitems(rtl8821au_rf_regs4),
421 			rtl8821au_rf_regs4,
422 			rtl8821au_rf_vals4_ext_5g,
423 			{ R21A_COND_EXT_PA_5G | R21A_COND_EXT_LNA_5G, 0 },
424 			/*
425 			 * Others.
426 			 */
427 			&(const struct rtwn_rf_prog){
428 				nitems(rtl8821au_rf_regs4),
429 				rtl8821au_rf_regs4,
430 				rtl8821au_rf_vals4,
431 				{ 0 },
432 				NULL
433 			}
434 		}
435 	},
436 	{
437 		nitems(rtl8821au_rf_regs5),
438 		rtl8821au_rf_regs5,
439 		rtl8821au_rf_vals5,
440 		{ 0 },
441 		NULL
442 	},
443 	{ 0, NULL, NULL, { 0 }, NULL }
444 };
445 
446 /*
447  * Registers to save before IQ calibration.
448  */
449 static const uint16_t r21a_iq_bb_regs[] = {
450 	0x520, 0x550, 0x808, 0xa04, 0x90c, 0xc00, 0x838, 0x82c
451 };
452 
453 static const uint16_t r21a_iq_afe_regs[] = {
454 	0xc5c, 0xc60, 0xc64, 0xc68
455 };
456 
457 static const uint8_t r21a_iq_rf_regs[] = {
458 	0x65, 0x8f, 0x0
459 };
460 
461 #endif	/* R21A_PRIV_H */
462