xref: /linux/drivers/net/wireless/broadcom/b43/radio_2059.c (revision 1517d90cfafe0f95fd7863d04e1596f7beb7dfa8)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 
4   Broadcom B43 wireless driver
5   IEEE 802.11n 2059 radio device data tables
6 
7   Copyright (c) 2011 Rafał Miłecki <zajec5@gmail.com>
8 
9 
10 */
11 
12 #include "b43.h"
13 #include "radio_2059.h"
14 
15 /* Extracted from MMIO dump of 6.30.223.141 */
16 static u16 r2059_phy_rev1_init[][2] = {
17 	{ 0x051, 0x70 }, { 0x05a, 0x03 }, { 0x079, 0x01 }, { 0x082, 0x70 },
18 	{ 0x083, 0x00 }, { 0x084, 0x70 }, { 0x09a, 0x7f }, { 0x0b6, 0x10 },
19 	{ 0x188, 0x05 },
20 };
21 
22 #define RADIOREGS(r00, r01, r02, r03, r04, r05, r06, r07, r08, r09, \
23 		  r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, \
24 		  r20) \
25 	.radio_syn16			= r00,	\
26 	.radio_syn17			= r01,	\
27 	.radio_syn22			= r02,	\
28 	.radio_syn25			= r03,	\
29 	.radio_syn27			= r04,	\
30 	.radio_syn28			= r05,	\
31 	.radio_syn29			= r06,	\
32 	.radio_syn2c			= r07,	\
33 	.radio_syn2d			= r08,	\
34 	.radio_syn37			= r09,	\
35 	.radio_syn41			= r10,	\
36 	.radio_syn43			= r11,	\
37 	.radio_syn47			= r12,	\
38 	.radio_rxtx4a			= r13,	\
39 	.radio_rxtx58			= r14,	\
40 	.radio_rxtx5a			= r15,	\
41 	.radio_rxtx6a			= r16,	\
42 	.radio_rxtx6d			= r17,	\
43 	.radio_rxtx6e			= r18,	\
44 	.radio_rxtx92			= r19,	\
45 	.radio_rxtx98			= r20
46 
47 #define PHYREGS(r0, r1, r2, r3, r4, r5)	\
48 	.phy_regs.bw1	= r0,	\
49 	.phy_regs.bw2	= r1,	\
50 	.phy_regs.bw3	= r2,	\
51 	.phy_regs.bw4	= r3,	\
52 	.phy_regs.bw5	= r4,	\
53 	.phy_regs.bw6	= r5
54 
55 /* Extracted from MMIO dump of 6.30.223.141
56  * TODO: Values for channels 12 & 13 are outdated (from some old 5.x driver)!
57  */
58 static const struct b43_phy_ht_channeltab_e_radio2059 b43_phy_ht_channeltab_radio2059[] = {
59 	{
60 		.freq			= 2412,
61 		RADIOREGS(0x48, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x6c,
62 			  0x09, 0x0f, 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73,
63 			  0x00, 0x00, 0x00, 0xd0, 0x00),
64 		PHYREGS(0x03c9, 0x03c5, 0x03c1, 0x043a, 0x043f, 0x0443),
65 	},
66 	{
67 		.freq			= 2417,
68 		RADIOREGS(0x4b, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x71,
69 			  0x09, 0x0f, 0x0a, 0x00, 0x0a, 0x00, 0x61, 0x73,
70 			  0x00, 0x00, 0x00, 0xd0, 0x00),
71 		PHYREGS(0x03cb, 0x03c7, 0x03c3, 0x0438, 0x043d, 0x0441),
72 	},
73 	{
74 		.freq			= 2422,
75 		RADIOREGS(0x4e, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x76,
76 			  0x09, 0x0f, 0x09, 0x00, 0x09, 0x00, 0x61, 0x73,
77 			  0x00, 0x00, 0x00, 0xd0, 0x00),
78 		PHYREGS(0x03cd, 0x03c9, 0x03c5, 0x0436, 0x043a, 0x043f),
79 	},
80 	{
81 		.freq			= 2427,
82 		RADIOREGS(0x52, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x7b,
83 			  0x09, 0x0f, 0x09, 0x00, 0x09, 0x00, 0x61, 0x73,
84 			  0x00, 0x00, 0x00, 0xa0, 0x00),
85 		PHYREGS(0x03cf, 0x03cb, 0x03c7, 0x0434, 0x0438, 0x043d),
86 	},
87 	{
88 		.freq			= 2432,
89 		RADIOREGS(0x55, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x80,
90 			  0x09, 0x0f, 0x08, 0x00, 0x08, 0x00, 0x61, 0x73,
91 			  0x00, 0x00, 0x00, 0xa0, 0x00),
92 		PHYREGS(0x03d1, 0x03cd, 0x03c9, 0x0431, 0x0436, 0x043a),
93 	},
94 	{
95 		.freq			= 2437,
96 		RADIOREGS(0x58, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x85,
97 			  0x09, 0x0f, 0x08, 0x00, 0x08, 0x00, 0x61, 0x73,
98 			  0x00, 0x00, 0x00, 0xa0, 0x00),
99 		PHYREGS(0x03d3, 0x03cf, 0x03cb, 0x042f, 0x0434, 0x0438),
100 	},
101 	{
102 		.freq			= 2442,
103 		RADIOREGS(0x5c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8a,
104 			  0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x73,
105 			  0x00, 0x00, 0x00, 0x80, 0x00),
106 		PHYREGS(0x03d5, 0x03d1, 0x03cd, 0x042d, 0x0431, 0x0436),
107 	},
108 	{
109 		.freq			= 2447,
110 		RADIOREGS(0x5f, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x8f,
111 			  0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x73,
112 			  0x00, 0x00, 0x00, 0x80, 0x00),
113 		PHYREGS(0x03d7, 0x03d3, 0x03cf, 0x042b, 0x042f, 0x0434),
114 	},
115 	{
116 		.freq			= 2452,
117 		RADIOREGS(0x62, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x94,
118 			  0x09, 0x0f, 0x07, 0x00, 0x07, 0x00, 0x61, 0x73,
119 			  0x00, 0x00, 0x00, 0x80, 0x00),
120 		PHYREGS(0x03d9, 0x03d5, 0x03d1, 0x0429, 0x042d, 0x0431),
121 	},
122 	{
123 		.freq			= 2457,
124 		RADIOREGS(0x66, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x99,
125 			  0x09, 0x0f, 0x06, 0x00, 0x06, 0x00, 0x61, 0x73,
126 			  0x00, 0x00, 0x00, 0x60, 0x00),
127 		PHYREGS(0x03db, 0x03d7, 0x03d3, 0x0427, 0x042b, 0x042f),
128 	},
129 	{
130 		.freq			= 2462,
131 		RADIOREGS(0x69, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0x9e,
132 			  0x09, 0x0f, 0x06, 0x00, 0x06, 0x00, 0x61, 0x73,
133 			  0x00, 0x00, 0x00, 0x60, 0x00),
134 		PHYREGS(0x03dd, 0x03d9, 0x03d5, 0x0424, 0x0429, 0x042d),
135 	},
136   {	.freq			= 2467,
137 	RADIOREGS(0x6c, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa3,
138 		  0x09, 0x0f, 0x05, 0x00, 0x05, 0x00, 0x61, 0x03,
139 		  0x00, 0x00, 0x00, 0xf0, 0x00),
140 	PHYREGS(0x03df, 0x03db, 0x03d7, 0x0422, 0x0427, 0x042b),
141   },
142   {	.freq			= 2472,
143 	RADIOREGS(0x70, 0x16, 0x30, 0x1b, 0x0a, 0x0a, 0x30, 0xa8,
144 		  0x09, 0x0f, 0x05, 0x00, 0x05, 0x00, 0x61, 0x03,
145 		  0x00, 0x00, 0x00, 0xf0, 0x00),
146 	PHYREGS(0x03e1, 0x03dd, 0x03d9, 0x0420, 0x0424, 0x0429),
147   },
148 	{
149 		.freq			= 5180,
150 		RADIOREGS(0xbe, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x06,
151 			  0x02, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00,
152 			  0x0f, 0x4f, 0xa3, 0x00, 0xfc),
153 		PHYREGS(0x081c, 0x0818, 0x0814, 0x01f9, 0x01fa, 0x01fb),
154 	},
155 	{
156 		.freq			= 5200,
157 		RADIOREGS(0xc5, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x08,
158 			  0x02, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00,
159 			  0x0f, 0x4f, 0x93, 0x00, 0xfb),
160 		PHYREGS(0x0824, 0x0820, 0x081c, 0x01f7, 0x01f8, 0x01f9),
161 	},
162 	{
163 		.freq			= 5220,
164 		RADIOREGS(0xcc, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x0a,
165 			  0x02, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00,
166 			  0x0f, 0x4f, 0x93, 0x00, 0xea),
167 		PHYREGS(0x082c, 0x0828, 0x0824, 0x01f5, 0x01f6, 0x01f7),
168 	},
169 	{
170 		.freq			= 5240,
171 		RADIOREGS(0xd2, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x0c,
172 			  0x02, 0x0c, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x00,
173 			  0x0f, 0x4f, 0x93, 0x00, 0xda),
174 		PHYREGS(0x0834, 0x0830, 0x082c, 0x01f3, 0x01f4, 0x01f5),
175 	},
176 	{
177 		.freq			= 5260,
178 		RADIOREGS(0xd9, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x0e,
179 			  0x02, 0x0b, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x00,
180 			  0x0f, 0x4f, 0x93, 0x00, 0xca),
181 		PHYREGS(0x083c, 0x0838, 0x0834, 0x01f1, 0x01f2, 0x01f3),
182 	},
183 	{
184 		.freq			= 5280,
185 		RADIOREGS(0xe0, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x10,
186 			  0x02, 0x0b, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x00,
187 			  0x0f, 0x4f, 0x93, 0x00, 0xb9),
188 		PHYREGS(0x0844, 0x0840, 0x083c, 0x01f0, 0x01f0, 0x01f1),
189 	},
190 	{
191 		.freq			= 5300,
192 		RADIOREGS(0xe6, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x12,
193 			  0x02, 0x0b, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x00,
194 			  0x0f, 0x4c, 0x83, 0x00, 0xb8),
195 		PHYREGS(0x084c, 0x0848, 0x0844, 0x01ee, 0x01ef, 0x01f0),
196 	},
197 	{
198 		.freq			= 5320,
199 		RADIOREGS(0xed, 0x16, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x14,
200 			  0x02, 0x0b, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x00,
201 			  0x0f, 0x4c, 0x83, 0x00, 0xa8),
202 		PHYREGS(0x0854, 0x0850, 0x084c, 0x01ec, 0x01ed, 0x01ee),
203 	},
204 	{
205 		.freq			= 5500,
206 		RADIOREGS(0x29, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x26,
207 			  0x02, 0x09, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00,
208 			  0x0a, 0x46, 0x43, 0x00, 0x75),
209 		PHYREGS(0x089c, 0x0898, 0x0894, 0x01dc, 0x01dd, 0x01dd),
210 	},
211 	{
212 		.freq			= 5520,
213 		RADIOREGS(0x30, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x28,
214 			  0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
215 			  0x0a, 0x46, 0x43, 0x00, 0x75),
216 		PHYREGS(0x08a4, 0x08a0, 0x089c, 0x01da, 0x01db, 0x01dc),
217 	},
218 	{
219 		.freq			= 5540,
220 		RADIOREGS(0x36, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x2a,
221 			  0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
222 			  0x0a, 0x46, 0x43, 0x00, 0x75),
223 		PHYREGS(0x08ac, 0x08a8, 0x08a4, 0x01d8, 0x01d9, 0x01da),
224 	},
225 	{
226 		.freq			= 5560,
227 		RADIOREGS(0x3d, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x2c,
228 			  0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
229 			  0x0a, 0x46, 0x43, 0x00, 0x75),
230 		PHYREGS(0x08b4, 0x08b0, 0x08ac, 0x01d7, 0x01d7, 0x01d8),
231 	},
232 	{
233 		.freq			= 5580,
234 		RADIOREGS(0x44, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x2e,
235 			  0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
236 			  0x0a, 0x46, 0x43, 0x00, 0x74),
237 		PHYREGS(0x08bc, 0x08b8, 0x08b4, 0x01d5, 0x01d6, 0x01d7),
238 	},
239 	{
240 		.freq			= 5600,
241 		RADIOREGS(0x4a, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x30,
242 			  0x02, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00,
243 			  0x09, 0x44, 0x23, 0x00, 0x54),
244 		PHYREGS(0x08c4, 0x08c0, 0x08bc, 0x01d3, 0x01d4, 0x01d5),
245 	},
246 	{
247 		.freq			= 5620,
248 		RADIOREGS(0x51, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x32,
249 			  0x02, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
250 			  0x09, 0x44, 0x23, 0x00, 0x54),
251 		PHYREGS(0x08cc, 0x08c8, 0x08c4, 0x01d2, 0x01d2, 0x01d3),
252 	},
253 	{
254 		.freq			= 5640,
255 		RADIOREGS(0x58, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x34,
256 			  0x02, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
257 			  0x09, 0x44, 0x23, 0x00, 0x43),
258 		PHYREGS(0x08d4, 0x08d0, 0x08cc, 0x01d0, 0x01d1, 0x01d2),
259 	},
260 	{
261 		.freq			= 5660,
262 		RADIOREGS(0x5e, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x36,
263 			  0x02, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
264 			  0x09, 0x43, 0x23, 0x00, 0x43),
265 		PHYREGS(0x08dc, 0x08d8, 0x08d4, 0x01ce, 0x01cf, 0x01d0),
266 	},
267 	{
268 		.freq			= 5680,
269 		RADIOREGS(0x65, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x38,
270 			  0x02, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
271 			  0x09, 0x42, 0x23, 0x00, 0x43),
272 		PHYREGS(0x08e4, 0x08e0, 0x08dc, 0x01cd, 0x01ce, 0x01ce),
273 	},
274 	{
275 		.freq			= 5700,
276 		RADIOREGS(0x6c, 0x17, 0x10, 0x1f, 0x08, 0x08, 0x3f, 0x3a,
277 			  0x02, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
278 			  0x08, 0x42, 0x13, 0x00, 0x32),
279 		PHYREGS(0x08ec, 0x08e8, 0x08e4, 0x01cb, 0x01cc, 0x01cd),
280 	},
281 	{
282 		.freq			= 5745,
283 		RADIOREGS(0x7b, 0x17, 0x20, 0x1f, 0x08, 0x08, 0x3f, 0x7d,
284 			  0x04, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
285 			  0x08, 0x42, 0x13, 0x00, 0x21),
286 		PHYREGS(0x08fe, 0x08fa, 0x08f6, 0x01c8, 0x01c8, 0x01c9),
287 	},
288 	{
289 		.freq			= 5765,
290 		RADIOREGS(0x81, 0x17, 0x20, 0x1f, 0x08, 0x08, 0x3f, 0x81,
291 			  0x04, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00,
292 			  0x08, 0x42, 0x13, 0x00, 0x11),
293 		PHYREGS(0x0906, 0x0902, 0x08fe, 0x01c6, 0x01c7, 0x01c8),
294 	},
295 	{
296 		.freq			= 5785,
297 		RADIOREGS(0x88, 0x17, 0x20, 0x1f, 0x08, 0x08, 0x3f, 0x85,
298 			  0x04, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00,
299 			  0x08, 0x42, 0x13, 0x00, 0x00),
300 		PHYREGS(0x090e, 0x090a, 0x0906, 0x01c4, 0x01c5, 0x01c6),
301 	},
302 	{
303 		.freq			= 5805,
304 		RADIOREGS(0x8f, 0x17, 0x20, 0x1f, 0x08, 0x08, 0x3f, 0x89,
305 			  0x04, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00,
306 			  0x06, 0x41, 0x03, 0x00, 0x00),
307 		PHYREGS(0x0916, 0x0912, 0x090e, 0x01c3, 0x01c4, 0x01c4),
308 	},
309 	{
310 		.freq			= 5825,
311 		RADIOREGS(0x95, 0x17, 0x20, 0x1f, 0x08, 0x08, 0x3f, 0x8d,
312 			  0x04, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00,
313 			  0x06, 0x41, 0x03, 0x00, 0x00),
314 		PHYREGS(0x091e, 0x091a, 0x0916, 0x01c1, 0x01c2, 0x01c3),
315 	},
316 };
317 
318 void r2059_upload_inittabs(struct b43_wldev *dev)
319 {
320 	struct b43_phy *phy = &dev->phy;
321 	u16 *table = NULL;
322 	u16 size, i;
323 
324 	switch (phy->rev) {
325 	case 1:
326 		table = r2059_phy_rev1_init[0];
327 		size = ARRAY_SIZE(r2059_phy_rev1_init);
328 		break;
329 	default:
330 		B43_WARN_ON(1);
331 		return;
332 	}
333 
334 	for (i = 0; i < size; i++, table += 2)
335 		b43_radio_write(dev, R2059_ALL | table[0], table[1]);
336 }
337 
338 const struct b43_phy_ht_channeltab_e_radio2059
339 *b43_phy_ht_get_channeltab_e_r2059(struct b43_wldev *dev, u16 freq)
340 {
341 	const struct b43_phy_ht_channeltab_e_radio2059 *e;
342 	unsigned int i;
343 
344 	e = b43_phy_ht_channeltab_radio2059;
345 	for (i = 0; i < ARRAY_SIZE(b43_phy_ht_channeltab_radio2059); i++, e++) {
346 		if (e->freq == freq)
347 			return e;
348 	}
349 
350 	return NULL;
351 }
352