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