1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <asm/unaligned.h>
18#include "hw.h"
19#include "ar9003_phy.h"
20#include "ar9003_eeprom.h"
21#include "ar9003_mci.h"
22
23#define COMP_HDR_LEN 4
24#define COMP_CKSUM_LEN 2
25
26#define LE16(x) cpu_to_le16(x)
27#define LE32(x) cpu_to_le32(x)
28
29
30#define EXT_ADDITIVE (0x8000)
31#define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
32#define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
33#define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
34
35#define SUB_NUM_CTL_MODES_AT_5G_40 2
36#define SUB_NUM_CTL_MODES_AT_2G_40 3
37
38#define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
39
40#define EEPROM_DATA_LEN_9485 1088
41
42static int ar9003_hw_power_interpolate(int32_t x,
43 int32_t *px, int32_t *py, u_int16_t np);
44
45static const struct ar9300_eeprom ar9300_default = {
46 .eepromVersion = 2,
47 .templateVersion = 2,
48 .macAddr = {0, 2, 3, 4, 5, 6},
49 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
51 .baseEepHeader = {
52 .regDmn = { LE16(0), LE16(0x1f) },
53 .txrxMask = 0x77,
54 .opCapFlags = {
55 .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
56 .eepMisc = 0,
57 },
58 .rfSilent = 0,
59 .blueToothOptions = 0,
60 .deviceCap = 0,
61 .deviceType = 5,
62 .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
63 .params_for_tuning_caps = {0, 0},
64 .featureEnable = 0x0c,
65
66
67
68
69
70
71
72
73 .miscConfiguration = 0,
74 .eepromWriteEnableGpio = 3,
75 .wlanDisableGpio = 0,
76 .wlanLedGpio = 8,
77 .rxBandSelectGpio = 0xff,
78 .txrxgain = 0,
79 .swreg = 0,
80 },
81 .modalHeader2G = {
82
83
84 .antCtrlCommon = LE32(0x110),
85
86 .antCtrlCommon2 = LE32(0x22222),
87
88
89
90
91
92 .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
93
94
95
96
97
98 .xatten1DB = {0, 0, 0},
99
100
101
102
103
104 .xatten1Margin = {0, 0, 0},
105 .tempSlope = 36,
106 .voltSlope = 0,
107
108
109
110
111
112 .spurChans = {0, 0, 0, 0, 0},
113
114
115
116
117
118 .noiseFloorThreshCh = {-1, 0, 0},
119 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
120 .quick_drop = 0,
121 .xpaBiasLvl = 0,
122 .txFrameToDataStart = 0x0e,
123 .txFrameToPaOn = 0x0e,
124 .txClip = 3,
125 .antennaGain = 0,
126 .switchSettling = 0x2c,
127 .adcDesiredSize = -30,
128 .txEndToXpaOff = 0,
129 .txEndToRxOn = 0x2,
130 .txFrameToXpaOn = 0xe,
131 .thresh62 = 28,
132 .papdRateMaskHt20 = LE32(0x0cf0e0e0),
133 .papdRateMaskHt40 = LE32(0x6cf0e0e0),
134 .switchcomspdt = 0,
135 .xlna_bias_strength = 0,
136 .futureModal = {
137 0, 0, 0, 0, 0, 0, 0,
138 },
139 },
140 .base_ext1 = {
141 .ant_div_control = 0,
142 .future = {0, 0},
143 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
144 },
145 .calFreqPier2G = {
146 FREQ2FBIN(2412, 1),
147 FREQ2FBIN(2437, 1),
148 FREQ2FBIN(2472, 1),
149 },
150
151 .calPierData2G = {
152 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
153 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
154 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
155 },
156 .calTarget_freqbin_Cck = {
157 FREQ2FBIN(2412, 1),
158 FREQ2FBIN(2484, 1),
159 },
160 .calTarget_freqbin_2G = {
161 FREQ2FBIN(2412, 1),
162 FREQ2FBIN(2437, 1),
163 FREQ2FBIN(2472, 1)
164 },
165 .calTarget_freqbin_2GHT20 = {
166 FREQ2FBIN(2412, 1),
167 FREQ2FBIN(2437, 1),
168 FREQ2FBIN(2472, 1)
169 },
170 .calTarget_freqbin_2GHT40 = {
171 FREQ2FBIN(2412, 1),
172 FREQ2FBIN(2437, 1),
173 FREQ2FBIN(2472, 1)
174 },
175 .calTargetPowerCck = {
176
177 { {36, 36, 36, 36} },
178 { {36, 36, 36, 36} },
179 },
180 .calTargetPower2G = {
181
182 { {32, 32, 28, 24} },
183 { {32, 32, 28, 24} },
184 { {32, 32, 28, 24} },
185 },
186 .calTargetPower2GHT20 = {
187 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
188 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
189 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
190 },
191 .calTargetPower2GHT40 = {
192 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
193 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
194 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
195 },
196 .ctlIndex_2G = {
197 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
198 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
199 },
200 .ctl_freqbin_2G = {
201 {
202 FREQ2FBIN(2412, 1),
203 FREQ2FBIN(2417, 1),
204 FREQ2FBIN(2457, 1),
205 FREQ2FBIN(2462, 1)
206 },
207 {
208 FREQ2FBIN(2412, 1),
209 FREQ2FBIN(2417, 1),
210 FREQ2FBIN(2462, 1),
211 0xFF,
212 },
213
214 {
215 FREQ2FBIN(2412, 1),
216 FREQ2FBIN(2417, 1),
217 FREQ2FBIN(2462, 1),
218 0xFF,
219 },
220 {
221 FREQ2FBIN(2422, 1),
222 FREQ2FBIN(2427, 1),
223 FREQ2FBIN(2447, 1),
224 FREQ2FBIN(2452, 1)
225 },
226
227 {
228 FREQ2FBIN(2412, 1),
229 FREQ2FBIN(2417, 1),
230 FREQ2FBIN(2472, 1),
231 FREQ2FBIN(2484, 1),
232 },
233
234 {
235 FREQ2FBIN(2412, 1),
236 FREQ2FBIN(2417, 1),
237 FREQ2FBIN(2472, 1),
238 0,
239 },
240
241 {
242 FREQ2FBIN(2412, 1),
243 FREQ2FBIN(2417, 1),
244 FREQ2FBIN(2472, 1),
245 0,
246 },
247
248 {
249 FREQ2FBIN(2422, 1),
250 FREQ2FBIN(2427, 1),
251 FREQ2FBIN(2447, 1),
252 FREQ2FBIN(2462, 1),
253 },
254
255 {
256 FREQ2FBIN(2412, 1),
257 FREQ2FBIN(2417, 1),
258 FREQ2FBIN(2472, 1),
259 },
260
261 {
262 FREQ2FBIN(2412, 1),
263 FREQ2FBIN(2417, 1),
264 FREQ2FBIN(2472, 1),
265 0
266 },
267
268 {
269 FREQ2FBIN(2412, 1),
270 FREQ2FBIN(2417, 1),
271 FREQ2FBIN(2472, 1),
272 0
273 },
274
275 {
276 FREQ2FBIN(2422, 1),
277 FREQ2FBIN(2427, 1),
278 FREQ2FBIN(2447, 1),
279 FREQ2FBIN(2462, 1),
280 }
281 },
282 .ctlPowerData_2G = {
283 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
284 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
285 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
286
287 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
288 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
289 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
290
291 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
292 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
293 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
294
295 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
296 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
297 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
298 },
299 .modalHeader5G = {
300
301 .antCtrlCommon = LE32(0x110),
302
303 .antCtrlCommon2 = LE32(0x22222),
304
305 .antCtrlChain = {
306 LE16(0x000), LE16(0x000), LE16(0x000),
307 },
308
309 .xatten1DB = {0, 0, 0},
310
311
312
313
314
315 .xatten1Margin = {0, 0, 0},
316 .tempSlope = 68,
317 .voltSlope = 0,
318
319 .spurChans = {0, 0, 0, 0, 0},
320
321 .noiseFloorThreshCh = {-1, 0, 0},
322 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
323 .quick_drop = 0,
324 .xpaBiasLvl = 0,
325 .txFrameToDataStart = 0x0e,
326 .txFrameToPaOn = 0x0e,
327 .txClip = 3,
328 .antennaGain = 0,
329 .switchSettling = 0x2d,
330 .adcDesiredSize = -30,
331 .txEndToXpaOff = 0,
332 .txEndToRxOn = 0x2,
333 .txFrameToXpaOn = 0xe,
334 .thresh62 = 28,
335 .papdRateMaskHt20 = LE32(0x0c80c080),
336 .papdRateMaskHt40 = LE32(0x0080c080),
337 .switchcomspdt = 0,
338 .xlna_bias_strength = 0,
339 .futureModal = {
340 0, 0, 0, 0, 0, 0, 0,
341 },
342 },
343 .base_ext2 = {
344 .tempSlopeLow = 0,
345 .tempSlopeHigh = 0,
346 .xatten1DBLow = {0, 0, 0},
347 .xatten1MarginLow = {0, 0, 0},
348 .xatten1DBHigh = {0, 0, 0},
349 .xatten1MarginHigh = {0, 0, 0}
350 },
351 .calFreqPier5G = {
352 FREQ2FBIN(5180, 0),
353 FREQ2FBIN(5220, 0),
354 FREQ2FBIN(5320, 0),
355 FREQ2FBIN(5400, 0),
356 FREQ2FBIN(5500, 0),
357 FREQ2FBIN(5600, 0),
358 FREQ2FBIN(5725, 0),
359 FREQ2FBIN(5825, 0)
360 },
361 .calPierData5G = {
362 {
363 {0, 0, 0, 0, 0},
364 {0, 0, 0, 0, 0},
365 {0, 0, 0, 0, 0},
366 {0, 0, 0, 0, 0},
367 {0, 0, 0, 0, 0},
368 {0, 0, 0, 0, 0},
369 {0, 0, 0, 0, 0},
370 {0, 0, 0, 0, 0},
371 },
372 {
373 {0, 0, 0, 0, 0},
374 {0, 0, 0, 0, 0},
375 {0, 0, 0, 0, 0},
376 {0, 0, 0, 0, 0},
377 {0, 0, 0, 0, 0},
378 {0, 0, 0, 0, 0},
379 {0, 0, 0, 0, 0},
380 {0, 0, 0, 0, 0},
381 },
382 {
383 {0, 0, 0, 0, 0},
384 {0, 0, 0, 0, 0},
385 {0, 0, 0, 0, 0},
386 {0, 0, 0, 0, 0},
387 {0, 0, 0, 0, 0},
388 {0, 0, 0, 0, 0},
389 {0, 0, 0, 0, 0},
390 {0, 0, 0, 0, 0},
391 },
392
393 },
394 .calTarget_freqbin_5G = {
395 FREQ2FBIN(5180, 0),
396 FREQ2FBIN(5220, 0),
397 FREQ2FBIN(5320, 0),
398 FREQ2FBIN(5400, 0),
399 FREQ2FBIN(5500, 0),
400 FREQ2FBIN(5600, 0),
401 FREQ2FBIN(5725, 0),
402 FREQ2FBIN(5825, 0)
403 },
404 .calTarget_freqbin_5GHT20 = {
405 FREQ2FBIN(5180, 0),
406 FREQ2FBIN(5240, 0),
407 FREQ2FBIN(5320, 0),
408 FREQ2FBIN(5500, 0),
409 FREQ2FBIN(5700, 0),
410 FREQ2FBIN(5745, 0),
411 FREQ2FBIN(5725, 0),
412 FREQ2FBIN(5825, 0)
413 },
414 .calTarget_freqbin_5GHT40 = {
415 FREQ2FBIN(5180, 0),
416 FREQ2FBIN(5240, 0),
417 FREQ2FBIN(5320, 0),
418 FREQ2FBIN(5500, 0),
419 FREQ2FBIN(5700, 0),
420 FREQ2FBIN(5745, 0),
421 FREQ2FBIN(5725, 0),
422 FREQ2FBIN(5825, 0)
423 },
424 .calTargetPower5G = {
425
426 { {20, 20, 20, 10} },
427 { {20, 20, 20, 10} },
428 { {20, 20, 20, 10} },
429 { {20, 20, 20, 10} },
430 { {20, 20, 20, 10} },
431 { {20, 20, 20, 10} },
432 { {20, 20, 20, 10} },
433 { {20, 20, 20, 10} },
434 },
435 .calTargetPower5GHT20 = {
436
437
438
439
440 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
441 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
442 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
443 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
444 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
445 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
446 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
447 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
448 },
449 .calTargetPower5GHT40 = {
450
451
452
453
454 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
455 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
456 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
457 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
458 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
459 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
460 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
461 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
462 },
463 .ctlIndex_5G = {
464 0x10, 0x16, 0x18, 0x40, 0x46,
465 0x48, 0x30, 0x36, 0x38
466 },
467 .ctl_freqbin_5G = {
468 {
469 FREQ2FBIN(5180, 0),
470 FREQ2FBIN(5260, 0),
471 FREQ2FBIN(5280, 0),
472 FREQ2FBIN(5500, 0),
473 FREQ2FBIN(5600, 0),
474 FREQ2FBIN(5700, 0),
475 FREQ2FBIN(5745, 0),
476 FREQ2FBIN(5825, 0)
477 },
478 {
479 FREQ2FBIN(5180, 0),
480 FREQ2FBIN(5260, 0),
481 FREQ2FBIN(5280, 0),
482 FREQ2FBIN(5500, 0),
483 FREQ2FBIN(5520, 0),
484 FREQ2FBIN(5700, 0),
485 FREQ2FBIN(5745, 0),
486 FREQ2FBIN(5825, 0)
487 },
488
489 {
490 FREQ2FBIN(5190, 0),
491 FREQ2FBIN(5230, 0),
492 FREQ2FBIN(5270, 0),
493 FREQ2FBIN(5310, 0),
494 FREQ2FBIN(5510, 0),
495 FREQ2FBIN(5550, 0),
496 FREQ2FBIN(5670, 0),
497 FREQ2FBIN(5755, 0)
498 },
499
500 {
501 FREQ2FBIN(5180, 0),
502 FREQ2FBIN(5200, 0),
503 FREQ2FBIN(5260, 0),
504 FREQ2FBIN(5320, 0),
505 FREQ2FBIN(5500, 0),
506 FREQ2FBIN(5700, 0),
507 0xFF,
508 0xFF,
509 },
510
511 {
512 FREQ2FBIN(5180, 0),
513 FREQ2FBIN(5260, 0),
514 FREQ2FBIN(5500, 0),
515 FREQ2FBIN(5700, 0),
516 0xFF,
517 0xFF,
518 0xFF,
519 0xFF,
520 },
521
522 {
523 FREQ2FBIN(5190, 0),
524 FREQ2FBIN(5270, 0),
525 FREQ2FBIN(5310, 0),
526 FREQ2FBIN(5510, 0),
527 FREQ2FBIN(5590, 0),
528 FREQ2FBIN(5670, 0),
529 0xFF,
530 0xFF
531 },
532
533 {
534 FREQ2FBIN(5180, 0),
535 FREQ2FBIN(5200, 0),
536 FREQ2FBIN(5220, 0),
537 FREQ2FBIN(5260, 0),
538 FREQ2FBIN(5500, 0),
539 FREQ2FBIN(5600, 0),
540 FREQ2FBIN(5700, 0),
541 FREQ2FBIN(5745, 0)
542 },
543
544 {
545 FREQ2FBIN(5180, 0),
546 FREQ2FBIN(5260, 0),
547 FREQ2FBIN(5320, 0),
548 FREQ2FBIN(5500, 0),
549 FREQ2FBIN(5560, 0),
550 FREQ2FBIN(5700, 0),
551 FREQ2FBIN(5745, 0),
552 FREQ2FBIN(5825, 0)
553 },
554
555 {
556 FREQ2FBIN(5190, 0),
557 FREQ2FBIN(5230, 0),
558 FREQ2FBIN(5270, 0),
559 FREQ2FBIN(5510, 0),
560 FREQ2FBIN(5550, 0),
561 FREQ2FBIN(5670, 0),
562 FREQ2FBIN(5755, 0),
563 FREQ2FBIN(5795, 0)
564 }
565 },
566 .ctlPowerData_5G = {
567 {
568 {
569 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
570 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
571 }
572 },
573 {
574 {
575 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
576 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
577 }
578 },
579 {
580 {
581 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
582 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
583 }
584 },
585 {
586 {
587 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
588 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
589 }
590 },
591 {
592 {
593 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
594 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
595 }
596 },
597 {
598 {
599 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
600 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
601 }
602 },
603 {
604 {
605 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
606 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
607 }
608 },
609 {
610 {
611 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
612 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
613 }
614 },
615 {
616 {
617 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
618 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
619 }
620 },
621 }
622};
623
624static const struct ar9300_eeprom ar9300_x113 = {
625 .eepromVersion = 2,
626 .templateVersion = 6,
627 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
628 .custData = {"x113-023-f0000"},
629 .baseEepHeader = {
630 .regDmn = { LE16(0), LE16(0x1f) },
631 .txrxMask = 0x77,
632 .opCapFlags = {
633 .opFlags = AR5416_OPFLAGS_11A,
634 .eepMisc = 0,
635 },
636 .rfSilent = 0,
637 .blueToothOptions = 0,
638 .deviceCap = 0,
639 .deviceType = 5,
640 .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
641 .params_for_tuning_caps = {0, 0},
642 .featureEnable = 0x0d,
643
644
645
646
647
648
649
650
651 .miscConfiguration = 0,
652 .eepromWriteEnableGpio = 6,
653 .wlanDisableGpio = 0,
654 .wlanLedGpio = 8,
655 .rxBandSelectGpio = 0xff,
656 .txrxgain = 0x21,
657 .swreg = 0,
658 },
659 .modalHeader2G = {
660
661
662 .antCtrlCommon = LE32(0x110),
663
664 .antCtrlCommon2 = LE32(0x44444),
665
666
667
668
669
670 .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
671
672
673
674
675
676 .xatten1DB = {0, 0, 0},
677
678
679
680
681
682 .xatten1Margin = {0, 0, 0},
683 .tempSlope = 25,
684 .voltSlope = 0,
685
686
687
688
689
690 .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
691
692
693
694
695
696 .noiseFloorThreshCh = {-1, 0, 0},
697 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
698 .quick_drop = 0,
699 .xpaBiasLvl = 0,
700 .txFrameToDataStart = 0x0e,
701 .txFrameToPaOn = 0x0e,
702 .txClip = 3,
703 .antennaGain = 0,
704 .switchSettling = 0x2c,
705 .adcDesiredSize = -30,
706 .txEndToXpaOff = 0,
707 .txEndToRxOn = 0x2,
708 .txFrameToXpaOn = 0xe,
709 .thresh62 = 28,
710 .papdRateMaskHt20 = LE32(0x0c80c080),
711 .papdRateMaskHt40 = LE32(0x0080c080),
712 .switchcomspdt = 0,
713 .xlna_bias_strength = 0,
714 .futureModal = {
715 0, 0, 0, 0, 0, 0, 0,
716 },
717 },
718 .base_ext1 = {
719 .ant_div_control = 0,
720 .future = {0, 0},
721 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
722 },
723 .calFreqPier2G = {
724 FREQ2FBIN(2412, 1),
725 FREQ2FBIN(2437, 1),
726 FREQ2FBIN(2472, 1),
727 },
728
729 .calPierData2G = {
730 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
731 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
732 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
733 },
734 .calTarget_freqbin_Cck = {
735 FREQ2FBIN(2412, 1),
736 FREQ2FBIN(2472, 1),
737 },
738 .calTarget_freqbin_2G = {
739 FREQ2FBIN(2412, 1),
740 FREQ2FBIN(2437, 1),
741 FREQ2FBIN(2472, 1)
742 },
743 .calTarget_freqbin_2GHT20 = {
744 FREQ2FBIN(2412, 1),
745 FREQ2FBIN(2437, 1),
746 FREQ2FBIN(2472, 1)
747 },
748 .calTarget_freqbin_2GHT40 = {
749 FREQ2FBIN(2412, 1),
750 FREQ2FBIN(2437, 1),
751 FREQ2FBIN(2472, 1)
752 },
753 .calTargetPowerCck = {
754
755 { {34, 34, 34, 34} },
756 { {34, 34, 34, 34} },
757 },
758 .calTargetPower2G = {
759
760 { {34, 34, 32, 32} },
761 { {34, 34, 32, 32} },
762 { {34, 34, 32, 32} },
763 },
764 .calTargetPower2GHT20 = {
765 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
766 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
767 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
768 },
769 .calTargetPower2GHT40 = {
770 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
771 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
772 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
773 },
774 .ctlIndex_2G = {
775 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
776 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
777 },
778 .ctl_freqbin_2G = {
779 {
780 FREQ2FBIN(2412, 1),
781 FREQ2FBIN(2417, 1),
782 FREQ2FBIN(2457, 1),
783 FREQ2FBIN(2462, 1)
784 },
785 {
786 FREQ2FBIN(2412, 1),
787 FREQ2FBIN(2417, 1),
788 FREQ2FBIN(2462, 1),
789 0xFF,
790 },
791
792 {
793 FREQ2FBIN(2412, 1),
794 FREQ2FBIN(2417, 1),
795 FREQ2FBIN(2462, 1),
796 0xFF,
797 },
798 {
799 FREQ2FBIN(2422, 1),
800 FREQ2FBIN(2427, 1),
801 FREQ2FBIN(2447, 1),
802 FREQ2FBIN(2452, 1)
803 },
804
805 {
806 FREQ2FBIN(2412, 1),
807 FREQ2FBIN(2417, 1),
808 FREQ2FBIN(2472, 1),
809 FREQ2FBIN(2484, 1),
810 },
811
812 {
813 FREQ2FBIN(2412, 1),
814 FREQ2FBIN(2417, 1),
815 FREQ2FBIN(2472, 1),
816 0,
817 },
818
819 {
820 FREQ2FBIN(2412, 1),
821 FREQ2FBIN(2417, 1),
822 FREQ2FBIN(2472, 1),
823 0,
824 },
825
826 {
827 FREQ2FBIN(2422, 1),
828 FREQ2FBIN(2427, 1),
829 FREQ2FBIN(2447, 1),
830 FREQ2FBIN(2462, 1),
831 },
832
833 {
834 FREQ2FBIN(2412, 1),
835 FREQ2FBIN(2417, 1),
836 FREQ2FBIN(2472, 1),
837 },
838
839 {
840 FREQ2FBIN(2412, 1),
841 FREQ2FBIN(2417, 1),
842 FREQ2FBIN(2472, 1),
843 0
844 },
845
846 {
847 FREQ2FBIN(2412, 1),
848 FREQ2FBIN(2417, 1),
849 FREQ2FBIN(2472, 1),
850 0
851 },
852
853 {
854 FREQ2FBIN(2422, 1),
855 FREQ2FBIN(2427, 1),
856 FREQ2FBIN(2447, 1),
857 FREQ2FBIN(2462, 1),
858 }
859 },
860 .ctlPowerData_2G = {
861 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
862 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
863 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
864
865 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
866 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
867 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
868
869 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
870 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
871 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
872
873 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
874 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
875 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
876 },
877 .modalHeader5G = {
878
879 .antCtrlCommon = LE32(0x220),
880
881 .antCtrlCommon2 = LE32(0x11111),
882
883 .antCtrlChain = {
884 LE16(0x150), LE16(0x150), LE16(0x150),
885 },
886
887 .xatten1DB = {0, 0, 0},
888
889
890
891
892
893 .xatten1Margin = {0, 0, 0},
894 .tempSlope = 68,
895 .voltSlope = 0,
896
897 .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0},
898
899 .noiseFloorThreshCh = {-1, 0, 0},
900 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
901 .quick_drop = 0,
902 .xpaBiasLvl = 0xf,
903 .txFrameToDataStart = 0x0e,
904 .txFrameToPaOn = 0x0e,
905 .txClip = 3,
906 .antennaGain = 0,
907 .switchSettling = 0x2d,
908 .adcDesiredSize = -30,
909 .txEndToXpaOff = 0,
910 .txEndToRxOn = 0x2,
911 .txFrameToXpaOn = 0xe,
912 .thresh62 = 28,
913 .papdRateMaskHt20 = LE32(0x0cf0e0e0),
914 .papdRateMaskHt40 = LE32(0x6cf0e0e0),
915 .switchcomspdt = 0,
916 .xlna_bias_strength = 0,
917 .futureModal = {
918 0, 0, 0, 0, 0, 0, 0,
919 },
920 },
921 .base_ext2 = {
922 .tempSlopeLow = 72,
923 .tempSlopeHigh = 105,
924 .xatten1DBLow = {0, 0, 0},
925 .xatten1MarginLow = {0, 0, 0},
926 .xatten1DBHigh = {0, 0, 0},
927 .xatten1MarginHigh = {0, 0, 0}
928 },
929 .calFreqPier5G = {
930 FREQ2FBIN(5180, 0),
931 FREQ2FBIN(5240, 0),
932 FREQ2FBIN(5320, 0),
933 FREQ2FBIN(5400, 0),
934 FREQ2FBIN(5500, 0),
935 FREQ2FBIN(5600, 0),
936 FREQ2FBIN(5745, 0),
937 FREQ2FBIN(5785, 0)
938 },
939 .calPierData5G = {
940 {
941 {0, 0, 0, 0, 0},
942 {0, 0, 0, 0, 0},
943 {0, 0, 0, 0, 0},
944 {0, 0, 0, 0, 0},
945 {0, 0, 0, 0, 0},
946 {0, 0, 0, 0, 0},
947 {0, 0, 0, 0, 0},
948 {0, 0, 0, 0, 0},
949 },
950 {
951 {0, 0, 0, 0, 0},
952 {0, 0, 0, 0, 0},
953 {0, 0, 0, 0, 0},
954 {0, 0, 0, 0, 0},
955 {0, 0, 0, 0, 0},
956 {0, 0, 0, 0, 0},
957 {0, 0, 0, 0, 0},
958 {0, 0, 0, 0, 0},
959 },
960 {
961 {0, 0, 0, 0, 0},
962 {0, 0, 0, 0, 0},
963 {0, 0, 0, 0, 0},
964 {0, 0, 0, 0, 0},
965 {0, 0, 0, 0, 0},
966 {0, 0, 0, 0, 0},
967 {0, 0, 0, 0, 0},
968 {0, 0, 0, 0, 0},
969 },
970
971 },
972 .calTarget_freqbin_5G = {
973 FREQ2FBIN(5180, 0),
974 FREQ2FBIN(5220, 0),
975 FREQ2FBIN(5320, 0),
976 FREQ2FBIN(5400, 0),
977 FREQ2FBIN(5500, 0),
978 FREQ2FBIN(5600, 0),
979 FREQ2FBIN(5745, 0),
980 FREQ2FBIN(5785, 0)
981 },
982 .calTarget_freqbin_5GHT20 = {
983 FREQ2FBIN(5180, 0),
984 FREQ2FBIN(5240, 0),
985 FREQ2FBIN(5320, 0),
986 FREQ2FBIN(5400, 0),
987 FREQ2FBIN(5500, 0),
988 FREQ2FBIN(5700, 0),
989 FREQ2FBIN(5745, 0),
990 FREQ2FBIN(5825, 0)
991 },
992 .calTarget_freqbin_5GHT40 = {
993 FREQ2FBIN(5190, 0),
994 FREQ2FBIN(5230, 0),
995 FREQ2FBIN(5320, 0),
996 FREQ2FBIN(5410, 0),
997 FREQ2FBIN(5510, 0),
998 FREQ2FBIN(5670, 0),
999 FREQ2FBIN(5755, 0),
1000 FREQ2FBIN(5825, 0)
1001 },
1002 .calTargetPower5G = {
1003
1004 { {42, 40, 40, 34} },
1005 { {42, 40, 40, 34} },
1006 { {42, 40, 40, 34} },
1007 { {42, 40, 40, 34} },
1008 { {42, 40, 40, 34} },
1009 { {42, 40, 40, 34} },
1010 { {42, 40, 40, 34} },
1011 { {42, 40, 40, 34} },
1012 },
1013 .calTargetPower5GHT20 = {
1014
1015
1016
1017
1018 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1019 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1020 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1021 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1022 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1023 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1024 { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} },
1025 { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} },
1026 },
1027 .calTargetPower5GHT40 = {
1028
1029
1030
1031
1032 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1033 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1034 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1035 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1036 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1037 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1038 { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} },
1039 { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} },
1040 },
1041 .ctlIndex_5G = {
1042 0x10, 0x16, 0x18, 0x40, 0x46,
1043 0x48, 0x30, 0x36, 0x38
1044 },
1045 .ctl_freqbin_5G = {
1046 {
1047 FREQ2FBIN(5180, 0),
1048 FREQ2FBIN(5260, 0),
1049 FREQ2FBIN(5280, 0),
1050 FREQ2FBIN(5500, 0),
1051 FREQ2FBIN(5600, 0),
1052 FREQ2FBIN(5700, 0),
1053 FREQ2FBIN(5745, 0),
1054 FREQ2FBIN(5825, 0)
1055 },
1056 {
1057 FREQ2FBIN(5180, 0),
1058 FREQ2FBIN(5260, 0),
1059 FREQ2FBIN(5280, 0),
1060 FREQ2FBIN(5500, 0),
1061 FREQ2FBIN(5520, 0),
1062 FREQ2FBIN(5700, 0),
1063 FREQ2FBIN(5745, 0),
1064 FREQ2FBIN(5825, 0)
1065 },
1066
1067 {
1068 FREQ2FBIN(5190, 0),
1069 FREQ2FBIN(5230, 0),
1070 FREQ2FBIN(5270, 0),
1071 FREQ2FBIN(5310, 0),
1072 FREQ2FBIN(5510, 0),
1073 FREQ2FBIN(5550, 0),
1074 FREQ2FBIN(5670, 0),
1075 FREQ2FBIN(5755, 0)
1076 },
1077
1078 {
1079 FREQ2FBIN(5180, 0),
1080 FREQ2FBIN(5200, 0),
1081 FREQ2FBIN(5260, 0),
1082 FREQ2FBIN(5320, 0),
1083 FREQ2FBIN(5500, 0),
1084 FREQ2FBIN(5700, 0),
1085 0xFF,
1086 0xFF,
1087 },
1088
1089 {
1090 FREQ2FBIN(5180, 0),
1091 FREQ2FBIN(5260, 0),
1092 FREQ2FBIN(5500, 0),
1093 FREQ2FBIN(5700, 0),
1094 0xFF,
1095 0xFF,
1096 0xFF,
1097 0xFF,
1098 },
1099
1100 {
1101 FREQ2FBIN(5190, 0),
1102 FREQ2FBIN(5270, 0),
1103 FREQ2FBIN(5310, 0),
1104 FREQ2FBIN(5510, 0),
1105 FREQ2FBIN(5590, 0),
1106 FREQ2FBIN(5670, 0),
1107 0xFF,
1108 0xFF
1109 },
1110
1111 {
1112 FREQ2FBIN(5180, 0),
1113 FREQ2FBIN(5200, 0),
1114 FREQ2FBIN(5220, 0),
1115 FREQ2FBIN(5260, 0),
1116 FREQ2FBIN(5500, 0),
1117 FREQ2FBIN(5600, 0),
1118 FREQ2FBIN(5700, 0),
1119 FREQ2FBIN(5745, 0)
1120 },
1121
1122 {
1123 FREQ2FBIN(5180, 0),
1124 FREQ2FBIN(5260, 0),
1125 FREQ2FBIN(5320, 0),
1126 FREQ2FBIN(5500, 0),
1127 FREQ2FBIN(5560, 0),
1128 FREQ2FBIN(5700, 0),
1129 FREQ2FBIN(5745, 0),
1130 FREQ2FBIN(5825, 0)
1131 },
1132
1133 {
1134 FREQ2FBIN(5190, 0),
1135 FREQ2FBIN(5230, 0),
1136 FREQ2FBIN(5270, 0),
1137 FREQ2FBIN(5510, 0),
1138 FREQ2FBIN(5550, 0),
1139 FREQ2FBIN(5670, 0),
1140 FREQ2FBIN(5755, 0),
1141 FREQ2FBIN(5795, 0)
1142 }
1143 },
1144 .ctlPowerData_5G = {
1145 {
1146 {
1147 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1148 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1149 }
1150 },
1151 {
1152 {
1153 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1154 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1155 }
1156 },
1157 {
1158 {
1159 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1160 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1161 }
1162 },
1163 {
1164 {
1165 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1166 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1167 }
1168 },
1169 {
1170 {
1171 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1172 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1173 }
1174 },
1175 {
1176 {
1177 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1178 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1179 }
1180 },
1181 {
1182 {
1183 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1184 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1185 }
1186 },
1187 {
1188 {
1189 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1190 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1191 }
1192 },
1193 {
1194 {
1195 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
1196 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1197 }
1198 },
1199 }
1200};
1201
1202
1203static const struct ar9300_eeprom ar9300_h112 = {
1204 .eepromVersion = 2,
1205 .templateVersion = 3,
1206 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
1207 .custData = {"h112-241-f0000"},
1208 .baseEepHeader = {
1209 .regDmn = { LE16(0), LE16(0x1f) },
1210 .txrxMask = 0x77,
1211 .opCapFlags = {
1212 .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
1213 .eepMisc = 0,
1214 },
1215 .rfSilent = 0,
1216 .blueToothOptions = 0,
1217 .deviceCap = 0,
1218 .deviceType = 5,
1219 .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
1220 .params_for_tuning_caps = {0, 0},
1221 .featureEnable = 0x0d,
1222
1223
1224
1225
1226
1227
1228
1229
1230 .miscConfiguration = 0,
1231 .eepromWriteEnableGpio = 6,
1232 .wlanDisableGpio = 0,
1233 .wlanLedGpio = 8,
1234 .rxBandSelectGpio = 0xff,
1235 .txrxgain = 0x10,
1236 .swreg = 0,
1237 },
1238 .modalHeader2G = {
1239
1240
1241 .antCtrlCommon = LE32(0x110),
1242
1243 .antCtrlCommon2 = LE32(0x44444),
1244
1245
1246
1247
1248
1249 .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
1250
1251
1252
1253
1254
1255 .xatten1DB = {0, 0, 0},
1256
1257
1258
1259
1260
1261 .xatten1Margin = {0, 0, 0},
1262 .tempSlope = 25,
1263 .voltSlope = 0,
1264
1265
1266
1267
1268
1269 .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
1270
1271
1272
1273
1274
1275 .noiseFloorThreshCh = {-1, 0, 0},
1276 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1277 .quick_drop = 0,
1278 .xpaBiasLvl = 0,
1279 .txFrameToDataStart = 0x0e,
1280 .txFrameToPaOn = 0x0e,
1281 .txClip = 3,
1282 .antennaGain = 0,
1283 .switchSettling = 0x2c,
1284 .adcDesiredSize = -30,
1285 .txEndToXpaOff = 0,
1286 .txEndToRxOn = 0x2,
1287 .txFrameToXpaOn = 0xe,
1288 .thresh62 = 28,
1289 .papdRateMaskHt20 = LE32(0x0c80c080),
1290 .papdRateMaskHt40 = LE32(0x0080c080),
1291 .switchcomspdt = 0,
1292 .xlna_bias_strength = 0,
1293 .futureModal = {
1294 0, 0, 0, 0, 0, 0, 0,
1295 },
1296 },
1297 .base_ext1 = {
1298 .ant_div_control = 0,
1299 .future = {0, 0},
1300 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
1301 },
1302 .calFreqPier2G = {
1303 FREQ2FBIN(2412, 1),
1304 FREQ2FBIN(2437, 1),
1305 FREQ2FBIN(2462, 1),
1306 },
1307
1308 .calPierData2G = {
1309 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1310 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1311 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1312 },
1313 .calTarget_freqbin_Cck = {
1314 FREQ2FBIN(2412, 1),
1315 FREQ2FBIN(2472, 1),
1316 },
1317 .calTarget_freqbin_2G = {
1318 FREQ2FBIN(2412, 1),
1319 FREQ2FBIN(2437, 1),
1320 FREQ2FBIN(2472, 1)
1321 },
1322 .calTarget_freqbin_2GHT20 = {
1323 FREQ2FBIN(2412, 1),
1324 FREQ2FBIN(2437, 1),
1325 FREQ2FBIN(2472, 1)
1326 },
1327 .calTarget_freqbin_2GHT40 = {
1328 FREQ2FBIN(2412, 1),
1329 FREQ2FBIN(2437, 1),
1330 FREQ2FBIN(2472, 1)
1331 },
1332 .calTargetPowerCck = {
1333
1334 { {34, 34, 34, 34} },
1335 { {34, 34, 34, 34} },
1336 },
1337 .calTargetPower2G = {
1338
1339 { {34, 34, 32, 32} },
1340 { {34, 34, 32, 32} },
1341 { {34, 34, 32, 32} },
1342 },
1343 .calTargetPower2GHT20 = {
1344 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1345 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1346 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1347 },
1348 .calTargetPower2GHT40 = {
1349 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1350 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1351 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1352 },
1353 .ctlIndex_2G = {
1354 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
1355 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
1356 },
1357 .ctl_freqbin_2G = {
1358 {
1359 FREQ2FBIN(2412, 1),
1360 FREQ2FBIN(2417, 1),
1361 FREQ2FBIN(2457, 1),
1362 FREQ2FBIN(2462, 1)
1363 },
1364 {
1365 FREQ2FBIN(2412, 1),
1366 FREQ2FBIN(2417, 1),
1367 FREQ2FBIN(2462, 1),
1368 0xFF,
1369 },
1370
1371 {
1372 FREQ2FBIN(2412, 1),
1373 FREQ2FBIN(2417, 1),
1374 FREQ2FBIN(2462, 1),
1375 0xFF,
1376 },
1377 {
1378 FREQ2FBIN(2422, 1),
1379 FREQ2FBIN(2427, 1),
1380 FREQ2FBIN(2447, 1),
1381 FREQ2FBIN(2452, 1)
1382 },
1383
1384 {
1385 FREQ2FBIN(2412, 1),
1386 FREQ2FBIN(2417, 1),
1387 FREQ2FBIN(2472, 1),
1388 FREQ2FBIN(2484, 1),
1389 },
1390
1391 {
1392 FREQ2FBIN(2412, 1),
1393 FREQ2FBIN(2417, 1),
1394 FREQ2FBIN(2472, 1),
1395 0,
1396 },
1397
1398 {
1399 FREQ2FBIN(2412, 1),
1400 FREQ2FBIN(2417, 1),
1401 FREQ2FBIN(2472, 1),
1402 0,
1403 },
1404
1405 {
1406 FREQ2FBIN(2422, 1),
1407 FREQ2FBIN(2427, 1),
1408 FREQ2FBIN(2447, 1),
1409 FREQ2FBIN(2462, 1),
1410 },
1411
1412 {
1413 FREQ2FBIN(2412, 1),
1414 FREQ2FBIN(2417, 1),
1415 FREQ2FBIN(2472, 1),
1416 },
1417
1418 {
1419 FREQ2FBIN(2412, 1),
1420 FREQ2FBIN(2417, 1),
1421 FREQ2FBIN(2472, 1),
1422 0
1423 },
1424
1425 {
1426 FREQ2FBIN(2412, 1),
1427 FREQ2FBIN(2417, 1),
1428 FREQ2FBIN(2472, 1),
1429 0
1430 },
1431
1432 {
1433 FREQ2FBIN(2422, 1),
1434 FREQ2FBIN(2427, 1),
1435 FREQ2FBIN(2447, 1),
1436 FREQ2FBIN(2462, 1),
1437 }
1438 },
1439 .ctlPowerData_2G = {
1440 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1441 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1442 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
1443
1444 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
1445 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1446 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1447
1448 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
1449 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1450 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1451
1452 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
1453 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
1454 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
1455 },
1456 .modalHeader5G = {
1457
1458 .antCtrlCommon = LE32(0x220),
1459
1460 .antCtrlCommon2 = LE32(0x44444),
1461
1462 .antCtrlChain = {
1463 LE16(0x150), LE16(0x150), LE16(0x150),
1464 },
1465
1466 .xatten1DB = {0, 0, 0},
1467
1468
1469
1470
1471
1472 .xatten1Margin = {0, 0, 0},
1473 .tempSlope = 45,
1474 .voltSlope = 0,
1475
1476 .spurChans = {0, 0, 0, 0, 0},
1477
1478 .noiseFloorThreshCh = {-1, 0, 0},
1479 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1480 .quick_drop = 0,
1481 .xpaBiasLvl = 0,
1482 .txFrameToDataStart = 0x0e,
1483 .txFrameToPaOn = 0x0e,
1484 .txClip = 3,
1485 .antennaGain = 0,
1486 .switchSettling = 0x2d,
1487 .adcDesiredSize = -30,
1488 .txEndToXpaOff = 0,
1489 .txEndToRxOn = 0x2,
1490 .txFrameToXpaOn = 0xe,
1491 .thresh62 = 28,
1492 .papdRateMaskHt20 = LE32(0x0cf0e0e0),
1493 .papdRateMaskHt40 = LE32(0x6cf0e0e0),
1494 .switchcomspdt = 0,
1495 .xlna_bias_strength = 0,
1496 .futureModal = {
1497 0, 0, 0, 0, 0, 0, 0,
1498 },
1499 },
1500 .base_ext2 = {
1501 .tempSlopeLow = 40,
1502 .tempSlopeHigh = 50,
1503 .xatten1DBLow = {0, 0, 0},
1504 .xatten1MarginLow = {0, 0, 0},
1505 .xatten1DBHigh = {0, 0, 0},
1506 .xatten1MarginHigh = {0, 0, 0}
1507 },
1508 .calFreqPier5G = {
1509 FREQ2FBIN(5180, 0),
1510 FREQ2FBIN(5220, 0),
1511 FREQ2FBIN(5320, 0),
1512 FREQ2FBIN(5400, 0),
1513 FREQ2FBIN(5500, 0),
1514 FREQ2FBIN(5600, 0),
1515 FREQ2FBIN(5700, 0),
1516 FREQ2FBIN(5785, 0)
1517 },
1518 .calPierData5G = {
1519 {
1520 {0, 0, 0, 0, 0},
1521 {0, 0, 0, 0, 0},
1522 {0, 0, 0, 0, 0},
1523 {0, 0, 0, 0, 0},
1524 {0, 0, 0, 0, 0},
1525 {0, 0, 0, 0, 0},
1526 {0, 0, 0, 0, 0},
1527 {0, 0, 0, 0, 0},
1528 },
1529 {
1530 {0, 0, 0, 0, 0},
1531 {0, 0, 0, 0, 0},
1532 {0, 0, 0, 0, 0},
1533 {0, 0, 0, 0, 0},
1534 {0, 0, 0, 0, 0},
1535 {0, 0, 0, 0, 0},
1536 {0, 0, 0, 0, 0},
1537 {0, 0, 0, 0, 0},
1538 },
1539 {
1540 {0, 0, 0, 0, 0},
1541 {0, 0, 0, 0, 0},
1542 {0, 0, 0, 0, 0},
1543 {0, 0, 0, 0, 0},
1544 {0, 0, 0, 0, 0},
1545 {0, 0, 0, 0, 0},
1546 {0, 0, 0, 0, 0},
1547 {0, 0, 0, 0, 0},
1548 },
1549
1550 },
1551 .calTarget_freqbin_5G = {
1552 FREQ2FBIN(5180, 0),
1553 FREQ2FBIN(5240, 0),
1554 FREQ2FBIN(5320, 0),
1555 FREQ2FBIN(5400, 0),
1556 FREQ2FBIN(5500, 0),
1557 FREQ2FBIN(5600, 0),
1558 FREQ2FBIN(5700, 0),
1559 FREQ2FBIN(5825, 0)
1560 },
1561 .calTarget_freqbin_5GHT20 = {
1562 FREQ2FBIN(5180, 0),
1563 FREQ2FBIN(5240, 0),
1564 FREQ2FBIN(5320, 0),
1565 FREQ2FBIN(5400, 0),
1566 FREQ2FBIN(5500, 0),
1567 FREQ2FBIN(5700, 0),
1568 FREQ2FBIN(5745, 0),
1569 FREQ2FBIN(5825, 0)
1570 },
1571 .calTarget_freqbin_5GHT40 = {
1572 FREQ2FBIN(5180, 0),
1573 FREQ2FBIN(5240, 0),
1574 FREQ2FBIN(5320, 0),
1575 FREQ2FBIN(5400, 0),
1576 FREQ2FBIN(5500, 0),
1577 FREQ2FBIN(5700, 0),
1578 FREQ2FBIN(5745, 0),
1579 FREQ2FBIN(5825, 0)
1580 },
1581 .calTargetPower5G = {
1582
1583 { {30, 30, 28, 24} },
1584 { {30, 30, 28, 24} },
1585 { {30, 30, 28, 24} },
1586 { {30, 30, 28, 24} },
1587 { {30, 30, 28, 24} },
1588 { {30, 30, 28, 24} },
1589 { {30, 30, 28, 24} },
1590 { {30, 30, 28, 24} },
1591 },
1592 .calTargetPower5GHT20 = {
1593
1594
1595
1596
1597 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
1598 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
1599 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
1600 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
1601 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
1602 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
1603 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
1604 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
1605 },
1606 .calTargetPower5GHT40 = {
1607
1608
1609
1610
1611 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
1612 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
1613 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
1614 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
1615 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
1616 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
1617 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
1618 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
1619 },
1620 .ctlIndex_5G = {
1621 0x10, 0x16, 0x18, 0x40, 0x46,
1622 0x48, 0x30, 0x36, 0x38
1623 },
1624 .ctl_freqbin_5G = {
1625 {
1626 FREQ2FBIN(5180, 0),
1627 FREQ2FBIN(5260, 0),
1628 FREQ2FBIN(5280, 0),
1629 FREQ2FBIN(5500, 0),
1630 FREQ2FBIN(5600, 0),
1631 FREQ2FBIN(5700, 0),
1632 FREQ2FBIN(5745, 0),
1633 FREQ2FBIN(5825, 0)
1634 },
1635 {
1636 FREQ2FBIN(5180, 0),
1637 FREQ2FBIN(5260, 0),
1638 FREQ2FBIN(5280, 0),
1639 FREQ2FBIN(5500, 0),
1640 FREQ2FBIN(5520, 0),
1641 FREQ2FBIN(5700, 0),
1642 FREQ2FBIN(5745, 0),
1643 FREQ2FBIN(5825, 0)
1644 },
1645
1646 {
1647 FREQ2FBIN(5190, 0),
1648 FREQ2FBIN(5230, 0),
1649 FREQ2FBIN(5270, 0),
1650 FREQ2FBIN(5310, 0),
1651 FREQ2FBIN(5510, 0),
1652 FREQ2FBIN(5550, 0),
1653 FREQ2FBIN(5670, 0),
1654 FREQ2FBIN(5755, 0)
1655 },
1656
1657 {
1658 FREQ2FBIN(5180, 0),
1659 FREQ2FBIN(5200, 0),
1660 FREQ2FBIN(5260, 0),
1661 FREQ2FBIN(5320, 0),
1662 FREQ2FBIN(5500, 0),
1663 FREQ2FBIN(5700, 0),
1664 0xFF,
1665 0xFF,
1666 },
1667
1668 {
1669 FREQ2FBIN(5180, 0),
1670 FREQ2FBIN(5260, 0),
1671 FREQ2FBIN(5500, 0),
1672 FREQ2FBIN(5700, 0),
1673 0xFF,
1674 0xFF,
1675 0xFF,
1676 0xFF,
1677 },
1678
1679 {
1680 FREQ2FBIN(5190, 0),
1681 FREQ2FBIN(5270, 0),
1682 FREQ2FBIN(5310, 0),
1683 FREQ2FBIN(5510, 0),
1684 FREQ2FBIN(5590, 0),
1685 FREQ2FBIN(5670, 0),
1686 0xFF,
1687 0xFF
1688 },
1689
1690 {
1691 FREQ2FBIN(5180, 0),
1692 FREQ2FBIN(5200, 0),
1693 FREQ2FBIN(5220, 0),
1694 FREQ2FBIN(5260, 0),
1695 FREQ2FBIN(5500, 0),
1696 FREQ2FBIN(5600, 0),
1697 FREQ2FBIN(5700, 0),
1698 FREQ2FBIN(5745, 0)
1699 },
1700
1701 {
1702 FREQ2FBIN(5180, 0),
1703 FREQ2FBIN(5260, 0),
1704 FREQ2FBIN(5320, 0),
1705 FREQ2FBIN(5500, 0),
1706 FREQ2FBIN(5560, 0),
1707 FREQ2FBIN(5700, 0),
1708 FREQ2FBIN(5745, 0),
1709 FREQ2FBIN(5825, 0)
1710 },
1711
1712 {
1713 FREQ2FBIN(5190, 0),
1714 FREQ2FBIN(5230, 0),
1715 FREQ2FBIN(5270, 0),
1716 FREQ2FBIN(5510, 0),
1717 FREQ2FBIN(5550, 0),
1718 FREQ2FBIN(5670, 0),
1719 FREQ2FBIN(5755, 0),
1720 FREQ2FBIN(5795, 0)
1721 }
1722 },
1723 .ctlPowerData_5G = {
1724 {
1725 {
1726 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1727 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1728 }
1729 },
1730 {
1731 {
1732 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1733 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1734 }
1735 },
1736 {
1737 {
1738 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1739 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1740 }
1741 },
1742 {
1743 {
1744 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1745 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1746 }
1747 },
1748 {
1749 {
1750 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1751 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1752 }
1753 },
1754 {
1755 {
1756 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1757 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
1758 }
1759 },
1760 {
1761 {
1762 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1763 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
1764 }
1765 },
1766 {
1767 {
1768 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1769 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
1770 }
1771 },
1772 {
1773 {
1774 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
1775 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
1776 }
1777 },
1778 }
1779};
1780
1781
1782static const struct ar9300_eeprom ar9300_x112 = {
1783 .eepromVersion = 2,
1784 .templateVersion = 5,
1785 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
1786 .custData = {"x112-041-f0000"},
1787 .baseEepHeader = {
1788 .regDmn = { LE16(0), LE16(0x1f) },
1789 .txrxMask = 0x77,
1790 .opCapFlags = {
1791 .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
1792 .eepMisc = 0,
1793 },
1794 .rfSilent = 0,
1795 .blueToothOptions = 0,
1796 .deviceCap = 0,
1797 .deviceType = 5,
1798 .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
1799 .params_for_tuning_caps = {0, 0},
1800 .featureEnable = 0x0d,
1801
1802
1803
1804
1805
1806
1807
1808
1809 .miscConfiguration = 0,
1810 .eepromWriteEnableGpio = 6,
1811 .wlanDisableGpio = 0,
1812 .wlanLedGpio = 8,
1813 .rxBandSelectGpio = 0xff,
1814 .txrxgain = 0x0,
1815 .swreg = 0,
1816 },
1817 .modalHeader2G = {
1818
1819
1820 .antCtrlCommon = LE32(0x110),
1821
1822 .antCtrlCommon2 = LE32(0x22222),
1823
1824
1825
1826
1827
1828 .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
1829
1830
1831
1832
1833
1834 .xatten1DB = {0x1b, 0x1b, 0x1b},
1835
1836
1837
1838
1839
1840 .xatten1Margin = {0x15, 0x15, 0x15},
1841 .tempSlope = 50,
1842 .voltSlope = 0,
1843
1844
1845
1846
1847
1848 .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
1849
1850
1851
1852
1853
1854 .noiseFloorThreshCh = {-1, 0, 0},
1855 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1856 .quick_drop = 0,
1857 .xpaBiasLvl = 0,
1858 .txFrameToDataStart = 0x0e,
1859 .txFrameToPaOn = 0x0e,
1860 .txClip = 3,
1861 .antennaGain = 0,
1862 .switchSettling = 0x2c,
1863 .adcDesiredSize = -30,
1864 .txEndToXpaOff = 0,
1865 .txEndToRxOn = 0x2,
1866 .txFrameToXpaOn = 0xe,
1867 .thresh62 = 28,
1868 .papdRateMaskHt20 = LE32(0x0c80c080),
1869 .papdRateMaskHt40 = LE32(0x0080c080),
1870 .switchcomspdt = 0,
1871 .xlna_bias_strength = 0,
1872 .futureModal = {
1873 0, 0, 0, 0, 0, 0, 0,
1874 },
1875 },
1876 .base_ext1 = {
1877 .ant_div_control = 0,
1878 .future = {0, 0},
1879 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
1880 },
1881 .calFreqPier2G = {
1882 FREQ2FBIN(2412, 1),
1883 FREQ2FBIN(2437, 1),
1884 FREQ2FBIN(2472, 1),
1885 },
1886
1887 .calPierData2G = {
1888 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1889 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1890 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1891 },
1892 .calTarget_freqbin_Cck = {
1893 FREQ2FBIN(2412, 1),
1894 FREQ2FBIN(2472, 1),
1895 },
1896 .calTarget_freqbin_2G = {
1897 FREQ2FBIN(2412, 1),
1898 FREQ2FBIN(2437, 1),
1899 FREQ2FBIN(2472, 1)
1900 },
1901 .calTarget_freqbin_2GHT20 = {
1902 FREQ2FBIN(2412, 1),
1903 FREQ2FBIN(2437, 1),
1904 FREQ2FBIN(2472, 1)
1905 },
1906 .calTarget_freqbin_2GHT40 = {
1907 FREQ2FBIN(2412, 1),
1908 FREQ2FBIN(2437, 1),
1909 FREQ2FBIN(2472, 1)
1910 },
1911 .calTargetPowerCck = {
1912
1913 { {38, 38, 38, 38} },
1914 { {38, 38, 38, 38} },
1915 },
1916 .calTargetPower2G = {
1917
1918 { {38, 38, 36, 34} },
1919 { {38, 38, 36, 34} },
1920 { {38, 38, 34, 32} },
1921 },
1922 .calTargetPower2GHT20 = {
1923 { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
1924 { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} },
1925 { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
1926 },
1927 .calTargetPower2GHT40 = {
1928 { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
1929 { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} },
1930 { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
1931 },
1932 .ctlIndex_2G = {
1933 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
1934 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
1935 },
1936 .ctl_freqbin_2G = {
1937 {
1938 FREQ2FBIN(2412, 1),
1939 FREQ2FBIN(2417, 1),
1940 FREQ2FBIN(2457, 1),
1941 FREQ2FBIN(2462, 1)
1942 },
1943 {
1944 FREQ2FBIN(2412, 1),
1945 FREQ2FBIN(2417, 1),
1946 FREQ2FBIN(2462, 1),
1947 0xFF,
1948 },
1949
1950 {
1951 FREQ2FBIN(2412, 1),
1952 FREQ2FBIN(2417, 1),
1953 FREQ2FBIN(2462, 1),
1954 0xFF,
1955 },
1956 {
1957 FREQ2FBIN(2422, 1),
1958 FREQ2FBIN(2427, 1),
1959 FREQ2FBIN(2447, 1),
1960 FREQ2FBIN(2452, 1)
1961 },
1962
1963 {
1964 FREQ2FBIN(2412, 1),
1965 FREQ2FBIN(2417, 1),
1966 FREQ2FBIN(2472, 1),
1967 FREQ2FBIN(2484, 1),
1968 },
1969
1970 {
1971 FREQ2FBIN(2412, 1),
1972 FREQ2FBIN(2417, 1),
1973 FREQ2FBIN(2472, 1),
1974 0,
1975 },
1976
1977 {
1978 FREQ2FBIN(2412, 1),
1979 FREQ2FBIN(2417, 1),
1980 FREQ2FBIN(2472, 1),
1981 0,
1982 },
1983
1984 {
1985 FREQ2FBIN(2422, 1),
1986 FREQ2FBIN(2427, 1),
1987 FREQ2FBIN(2447, 1),
1988 FREQ2FBIN(2462, 1),
1989 },
1990
1991 {
1992 FREQ2FBIN(2412, 1),
1993 FREQ2FBIN(2417, 1),
1994 FREQ2FBIN(2472, 1),
1995 },
1996
1997 {
1998 FREQ2FBIN(2412, 1),
1999 FREQ2FBIN(2417, 1),
2000 FREQ2FBIN(2472, 1),
2001 0
2002 },
2003
2004 {
2005 FREQ2FBIN(2412, 1),
2006 FREQ2FBIN(2417, 1),
2007 FREQ2FBIN(2472, 1),
2008 0
2009 },
2010
2011 {
2012 FREQ2FBIN(2422, 1),
2013 FREQ2FBIN(2427, 1),
2014 FREQ2FBIN(2447, 1),
2015 FREQ2FBIN(2462, 1),
2016 }
2017 },
2018 .ctlPowerData_2G = {
2019 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2020 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2021 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
2022
2023 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
2024 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2025 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2026
2027 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
2028 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2029 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2030
2031 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2032 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
2033 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
2034 },
2035 .modalHeader5G = {
2036
2037 .antCtrlCommon = LE32(0x110),
2038
2039 .antCtrlCommon2 = LE32(0x22222),
2040
2041 .antCtrlChain = {
2042 LE16(0x0), LE16(0x0), LE16(0x0),
2043 },
2044
2045 .xatten1DB = {0x13, 0x19, 0x17},
2046
2047
2048
2049
2050
2051 .xatten1Margin = {0x19, 0x19, 0x19},
2052 .tempSlope = 70,
2053 .voltSlope = 15,
2054
2055 .spurChans = {0, 0, 0, 0, 0},
2056
2057 .noiseFloorThreshCh = {-1, 0, 0},
2058 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2059 .quick_drop = 0,
2060 .xpaBiasLvl = 0,
2061 .txFrameToDataStart = 0x0e,
2062 .txFrameToPaOn = 0x0e,
2063 .txClip = 3,
2064 .antennaGain = 0,
2065 .switchSettling = 0x2d,
2066 .adcDesiredSize = -30,
2067 .txEndToXpaOff = 0,
2068 .txEndToRxOn = 0x2,
2069 .txFrameToXpaOn = 0xe,
2070 .thresh62 = 28,
2071 .papdRateMaskHt20 = LE32(0x0cf0e0e0),
2072 .papdRateMaskHt40 = LE32(0x6cf0e0e0),
2073 .switchcomspdt = 0,
2074 .xlna_bias_strength = 0,
2075 .futureModal = {
2076 0, 0, 0, 0, 0, 0, 0,
2077 },
2078 },
2079 .base_ext2 = {
2080 .tempSlopeLow = 72,
2081 .tempSlopeHigh = 105,
2082 .xatten1DBLow = {0x10, 0x14, 0x10},
2083 .xatten1MarginLow = {0x19, 0x19 , 0x19},
2084 .xatten1DBHigh = {0x1d, 0x20, 0x24},
2085 .xatten1MarginHigh = {0x10, 0x10, 0x10}
2086 },
2087 .calFreqPier5G = {
2088 FREQ2FBIN(5180, 0),
2089 FREQ2FBIN(5220, 0),
2090 FREQ2FBIN(5320, 0),
2091 FREQ2FBIN(5400, 0),
2092 FREQ2FBIN(5500, 0),
2093 FREQ2FBIN(5600, 0),
2094 FREQ2FBIN(5700, 0),
2095 FREQ2FBIN(5785, 0)
2096 },
2097 .calPierData5G = {
2098 {
2099 {0, 0, 0, 0, 0},
2100 {0, 0, 0, 0, 0},
2101 {0, 0, 0, 0, 0},
2102 {0, 0, 0, 0, 0},
2103 {0, 0, 0, 0, 0},
2104 {0, 0, 0, 0, 0},
2105 {0, 0, 0, 0, 0},
2106 {0, 0, 0, 0, 0},
2107 },
2108 {
2109 {0, 0, 0, 0, 0},
2110 {0, 0, 0, 0, 0},
2111 {0, 0, 0, 0, 0},
2112 {0, 0, 0, 0, 0},
2113 {0, 0, 0, 0, 0},
2114 {0, 0, 0, 0, 0},
2115 {0, 0, 0, 0, 0},
2116 {0, 0, 0, 0, 0},
2117 },
2118 {
2119 {0, 0, 0, 0, 0},
2120 {0, 0, 0, 0, 0},
2121 {0, 0, 0, 0, 0},
2122 {0, 0, 0, 0, 0},
2123 {0, 0, 0, 0, 0},
2124 {0, 0, 0, 0, 0},
2125 {0, 0, 0, 0, 0},
2126 {0, 0, 0, 0, 0},
2127 },
2128
2129 },
2130 .calTarget_freqbin_5G = {
2131 FREQ2FBIN(5180, 0),
2132 FREQ2FBIN(5220, 0),
2133 FREQ2FBIN(5320, 0),
2134 FREQ2FBIN(5400, 0),
2135 FREQ2FBIN(5500, 0),
2136 FREQ2FBIN(5600, 0),
2137 FREQ2FBIN(5725, 0),
2138 FREQ2FBIN(5825, 0)
2139 },
2140 .calTarget_freqbin_5GHT20 = {
2141 FREQ2FBIN(5180, 0),
2142 FREQ2FBIN(5220, 0),
2143 FREQ2FBIN(5320, 0),
2144 FREQ2FBIN(5400, 0),
2145 FREQ2FBIN(5500, 0),
2146 FREQ2FBIN(5600, 0),
2147 FREQ2FBIN(5725, 0),
2148 FREQ2FBIN(5825, 0)
2149 },
2150 .calTarget_freqbin_5GHT40 = {
2151 FREQ2FBIN(5180, 0),
2152 FREQ2FBIN(5220, 0),
2153 FREQ2FBIN(5320, 0),
2154 FREQ2FBIN(5400, 0),
2155 FREQ2FBIN(5500, 0),
2156 FREQ2FBIN(5600, 0),
2157 FREQ2FBIN(5725, 0),
2158 FREQ2FBIN(5825, 0)
2159 },
2160 .calTargetPower5G = {
2161
2162 { {32, 32, 28, 26} },
2163 { {32, 32, 28, 26} },
2164 { {32, 32, 28, 26} },
2165 { {32, 32, 26, 24} },
2166 { {32, 32, 26, 24} },
2167 { {32, 32, 24, 22} },
2168 { {30, 30, 24, 22} },
2169 { {30, 30, 24, 22} },
2170 },
2171 .calTargetPower5GHT20 = {
2172
2173
2174
2175
2176 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2177 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2178 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2179 { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} },
2180 { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} },
2181 { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} },
2182 { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
2183 { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
2184 },
2185 .calTargetPower5GHT40 = {
2186
2187
2188
2189
2190 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2191 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2192 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2193 { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} },
2194 { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} },
2195 { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2196 { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2197 { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2198 },
2199 .ctlIndex_5G = {
2200 0x10, 0x16, 0x18, 0x40, 0x46,
2201 0x48, 0x30, 0x36, 0x38
2202 },
2203 .ctl_freqbin_5G = {
2204 {
2205 FREQ2FBIN(5180, 0),
2206 FREQ2FBIN(5260, 0),
2207 FREQ2FBIN(5280, 0),
2208 FREQ2FBIN(5500, 0),
2209 FREQ2FBIN(5600, 0),
2210 FREQ2FBIN(5700, 0),
2211 FREQ2FBIN(5745, 0),
2212 FREQ2FBIN(5825, 0)
2213 },
2214 {
2215 FREQ2FBIN(5180, 0),
2216 FREQ2FBIN(5260, 0),
2217 FREQ2FBIN(5280, 0),
2218 FREQ2FBIN(5500, 0),
2219 FREQ2FBIN(5520, 0),
2220 FREQ2FBIN(5700, 0),
2221 FREQ2FBIN(5745, 0),
2222 FREQ2FBIN(5825, 0)
2223 },
2224
2225 {
2226 FREQ2FBIN(5190, 0),
2227 FREQ2FBIN(5230, 0),
2228 FREQ2FBIN(5270, 0),
2229 FREQ2FBIN(5310, 0),
2230 FREQ2FBIN(5510, 0),
2231 FREQ2FBIN(5550, 0),
2232 FREQ2FBIN(5670, 0),
2233 FREQ2FBIN(5755, 0)
2234 },
2235
2236 {
2237 FREQ2FBIN(5180, 0),
2238 FREQ2FBIN(5200, 0),
2239 FREQ2FBIN(5260, 0),
2240 FREQ2FBIN(5320, 0),
2241 FREQ2FBIN(5500, 0),
2242 FREQ2FBIN(5700, 0),
2243 0xFF,
2244 0xFF,
2245 },
2246
2247 {
2248 FREQ2FBIN(5180, 0),
2249 FREQ2FBIN(5260, 0),
2250 FREQ2FBIN(5500, 0),
2251 FREQ2FBIN(5700, 0),
2252 0xFF,
2253 0xFF,
2254 0xFF,
2255 0xFF,
2256 },
2257
2258 {
2259 FREQ2FBIN(5190, 0),
2260 FREQ2FBIN(5270, 0),
2261 FREQ2FBIN(5310, 0),
2262 FREQ2FBIN(5510, 0),
2263 FREQ2FBIN(5590, 0),
2264 FREQ2FBIN(5670, 0),
2265 0xFF,
2266 0xFF
2267 },
2268
2269 {
2270 FREQ2FBIN(5180, 0),
2271 FREQ2FBIN(5200, 0),
2272 FREQ2FBIN(5220, 0),
2273 FREQ2FBIN(5260, 0),
2274 FREQ2FBIN(5500, 0),
2275 FREQ2FBIN(5600, 0),
2276 FREQ2FBIN(5700, 0),
2277 FREQ2FBIN(5745, 0)
2278 },
2279
2280 {
2281 FREQ2FBIN(5180, 0),
2282 FREQ2FBIN(5260, 0),
2283 FREQ2FBIN(5320, 0),
2284 FREQ2FBIN(5500, 0),
2285 FREQ2FBIN(5560, 0),
2286 FREQ2FBIN(5700, 0),
2287 FREQ2FBIN(5745, 0),
2288 FREQ2FBIN(5825, 0)
2289 },
2290
2291 {
2292 FREQ2FBIN(5190, 0),
2293 FREQ2FBIN(5230, 0),
2294 FREQ2FBIN(5270, 0),
2295 FREQ2FBIN(5510, 0),
2296 FREQ2FBIN(5550, 0),
2297 FREQ2FBIN(5670, 0),
2298 FREQ2FBIN(5755, 0),
2299 FREQ2FBIN(5795, 0)
2300 }
2301 },
2302 .ctlPowerData_5G = {
2303 {
2304 {
2305 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2306 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2307 }
2308 },
2309 {
2310 {
2311 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2312 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2313 }
2314 },
2315 {
2316 {
2317 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2318 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2319 }
2320 },
2321 {
2322 {
2323 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2324 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2325 }
2326 },
2327 {
2328 {
2329 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2330 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2331 }
2332 },
2333 {
2334 {
2335 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2336 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2337 }
2338 },
2339 {
2340 {
2341 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2342 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2343 }
2344 },
2345 {
2346 {
2347 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2348 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2349 }
2350 },
2351 {
2352 {
2353 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
2354 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2355 }
2356 },
2357 }
2358};
2359
2360static const struct ar9300_eeprom ar9300_h116 = {
2361 .eepromVersion = 2,
2362 .templateVersion = 4,
2363 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
2364 .custData = {"h116-041-f0000"},
2365 .baseEepHeader = {
2366 .regDmn = { LE16(0), LE16(0x1f) },
2367 .txrxMask = 0x33,
2368 .opCapFlags = {
2369 .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
2370 .eepMisc = 0,
2371 },
2372 .rfSilent = 0,
2373 .blueToothOptions = 0,
2374 .deviceCap = 0,
2375 .deviceType = 5,
2376 .pwrTableOffset = AR9300_PWR_TABLE_OFFSET,
2377 .params_for_tuning_caps = {0, 0},
2378 .featureEnable = 0x0d,
2379
2380
2381
2382
2383
2384
2385
2386
2387 .miscConfiguration = 0,
2388 .eepromWriteEnableGpio = 6,
2389 .wlanDisableGpio = 0,
2390 .wlanLedGpio = 8,
2391 .rxBandSelectGpio = 0xff,
2392 .txrxgain = 0x10,
2393 .swreg = 0,
2394 },
2395 .modalHeader2G = {
2396
2397
2398 .antCtrlCommon = LE32(0x110),
2399
2400 .antCtrlCommon2 = LE32(0x44444),
2401
2402
2403
2404
2405
2406 .antCtrlChain = { LE16(0x10), LE16(0x10), LE16(0x10) },
2407
2408
2409
2410
2411
2412 .xatten1DB = {0x1f, 0x1f, 0x1f},
2413
2414
2415
2416
2417
2418 .xatten1Margin = {0x12, 0x12, 0x12},
2419 .tempSlope = 25,
2420 .voltSlope = 0,
2421
2422
2423
2424
2425
2426 .spurChans = {FREQ2FBIN(2464, 1), 0, 0, 0, 0},
2427
2428
2429
2430
2431
2432 .noiseFloorThreshCh = {-1, 0, 0},
2433 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2434 .quick_drop = 0,
2435 .xpaBiasLvl = 0,
2436 .txFrameToDataStart = 0x0e,
2437 .txFrameToPaOn = 0x0e,
2438 .txClip = 3,
2439 .antennaGain = 0,
2440 .switchSettling = 0x2c,
2441 .adcDesiredSize = -30,
2442 .txEndToXpaOff = 0,
2443 .txEndToRxOn = 0x2,
2444 .txFrameToXpaOn = 0xe,
2445 .thresh62 = 28,
2446 .papdRateMaskHt20 = LE32(0x0c80C080),
2447 .papdRateMaskHt40 = LE32(0x0080C080),
2448 .switchcomspdt = 0,
2449 .xlna_bias_strength = 0,
2450 .futureModal = {
2451 0, 0, 0, 0, 0, 0, 0,
2452 },
2453 },
2454 .base_ext1 = {
2455 .ant_div_control = 0,
2456 .future = {0, 0},
2457 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
2458 },
2459 .calFreqPier2G = {
2460 FREQ2FBIN(2412, 1),
2461 FREQ2FBIN(2437, 1),
2462 FREQ2FBIN(2462, 1),
2463 },
2464
2465 .calPierData2G = {
2466 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2467 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2468 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2469 },
2470 .calTarget_freqbin_Cck = {
2471 FREQ2FBIN(2412, 1),
2472 FREQ2FBIN(2472, 1),
2473 },
2474 .calTarget_freqbin_2G = {
2475 FREQ2FBIN(2412, 1),
2476 FREQ2FBIN(2437, 1),
2477 FREQ2FBIN(2472, 1)
2478 },
2479 .calTarget_freqbin_2GHT20 = {
2480 FREQ2FBIN(2412, 1),
2481 FREQ2FBIN(2437, 1),
2482 FREQ2FBIN(2472, 1)
2483 },
2484 .calTarget_freqbin_2GHT40 = {
2485 FREQ2FBIN(2412, 1),
2486 FREQ2FBIN(2437, 1),
2487 FREQ2FBIN(2472, 1)
2488 },
2489 .calTargetPowerCck = {
2490
2491 { {34, 34, 34, 34} },
2492 { {34, 34, 34, 34} },
2493 },
2494 .calTargetPower2G = {
2495
2496 { {34, 34, 32, 32} },
2497 { {34, 34, 32, 32} },
2498 { {34, 34, 32, 32} },
2499 },
2500 .calTargetPower2GHT20 = {
2501 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2502 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2503 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2504 },
2505 .calTargetPower2GHT40 = {
2506 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2507 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2508 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2509 },
2510 .ctlIndex_2G = {
2511 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
2512 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
2513 },
2514 .ctl_freqbin_2G = {
2515 {
2516 FREQ2FBIN(2412, 1),
2517 FREQ2FBIN(2417, 1),
2518 FREQ2FBIN(2457, 1),
2519 FREQ2FBIN(2462, 1)
2520 },
2521 {
2522 FREQ2FBIN(2412, 1),
2523 FREQ2FBIN(2417, 1),
2524 FREQ2FBIN(2462, 1),
2525 0xFF,
2526 },
2527
2528 {
2529 FREQ2FBIN(2412, 1),
2530 FREQ2FBIN(2417, 1),
2531 FREQ2FBIN(2462, 1),
2532 0xFF,
2533 },
2534 {
2535 FREQ2FBIN(2422, 1),
2536 FREQ2FBIN(2427, 1),
2537 FREQ2FBIN(2447, 1),
2538 FREQ2FBIN(2452, 1)
2539 },
2540
2541 {
2542 FREQ2FBIN(2412, 1),
2543 FREQ2FBIN(2417, 1),
2544 FREQ2FBIN(2472, 1),
2545 FREQ2FBIN(2484, 1),
2546 },
2547
2548 {
2549 FREQ2FBIN(2412, 1),
2550 FREQ2FBIN(2417, 1),
2551 FREQ2FBIN(2472, 1),
2552 0,
2553 },
2554
2555 {
2556 FREQ2FBIN(2412, 1),
2557 FREQ2FBIN(2417, 1),
2558 FREQ2FBIN(2472, 1),
2559 0,
2560 },
2561
2562 {
2563 FREQ2FBIN(2422, 1),
2564 FREQ2FBIN(2427, 1),
2565 FREQ2FBIN(2447, 1),
2566 FREQ2FBIN(2462, 1),
2567 },
2568
2569 {
2570 FREQ2FBIN(2412, 1),
2571 FREQ2FBIN(2417, 1),
2572 FREQ2FBIN(2472, 1),
2573 },
2574
2575 {
2576 FREQ2FBIN(2412, 1),
2577 FREQ2FBIN(2417, 1),
2578 FREQ2FBIN(2472, 1),
2579 0
2580 },
2581
2582 {
2583 FREQ2FBIN(2412, 1),
2584 FREQ2FBIN(2417, 1),
2585 FREQ2FBIN(2472, 1),
2586 0
2587 },
2588
2589 {
2590 FREQ2FBIN(2422, 1),
2591 FREQ2FBIN(2427, 1),
2592 FREQ2FBIN(2447, 1),
2593 FREQ2FBIN(2462, 1),
2594 }
2595 },
2596 .ctlPowerData_2G = {
2597 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2598 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2599 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 1) } },
2600
2601 { { CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0) } },
2602 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2603 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2604
2605 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0) } },
2606 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2607 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2608
2609 { { CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 0) } },
2610 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
2611 { { CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 1) } },
2612 },
2613 .modalHeader5G = {
2614
2615 .antCtrlCommon = LE32(0x220),
2616
2617 .antCtrlCommon2 = LE32(0x44444),
2618
2619 .antCtrlChain = {
2620 LE16(0x150), LE16(0x150), LE16(0x150),
2621 },
2622
2623 .xatten1DB = {0x19, 0x19, 0x19},
2624
2625
2626
2627
2628
2629 .xatten1Margin = {0x14, 0x14, 0x14},
2630 .tempSlope = 70,
2631 .voltSlope = 0,
2632
2633 .spurChans = {0, 0, 0, 0, 0},
2634
2635 .noiseFloorThreshCh = {-1, 0, 0},
2636 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2637 .quick_drop = 0,
2638 .xpaBiasLvl = 0,
2639 .txFrameToDataStart = 0x0e,
2640 .txFrameToPaOn = 0x0e,
2641 .txClip = 3,
2642 .antennaGain = 0,
2643 .switchSettling = 0x2d,
2644 .adcDesiredSize = -30,
2645 .txEndToXpaOff = 0,
2646 .txEndToRxOn = 0x2,
2647 .txFrameToXpaOn = 0xe,
2648 .thresh62 = 28,
2649 .papdRateMaskHt20 = LE32(0x0cf0e0e0),
2650 .papdRateMaskHt40 = LE32(0x6cf0e0e0),
2651 .switchcomspdt = 0,
2652 .xlna_bias_strength = 0,
2653 .futureModal = {
2654 0, 0, 0, 0, 0, 0, 0,
2655 },
2656 },
2657 .base_ext2 = {
2658 .tempSlopeLow = 35,
2659 .tempSlopeHigh = 50,
2660 .xatten1DBLow = {0, 0, 0},
2661 .xatten1MarginLow = {0, 0, 0},
2662 .xatten1DBHigh = {0, 0, 0},
2663 .xatten1MarginHigh = {0, 0, 0}
2664 },
2665 .calFreqPier5G = {
2666 FREQ2FBIN(5160, 0),
2667 FREQ2FBIN(5220, 0),
2668 FREQ2FBIN(5320, 0),
2669 FREQ2FBIN(5400, 0),
2670 FREQ2FBIN(5500, 0),
2671 FREQ2FBIN(5600, 0),
2672 FREQ2FBIN(5700, 0),
2673 FREQ2FBIN(5785, 0)
2674 },
2675 .calPierData5G = {
2676 {
2677 {0, 0, 0, 0, 0},
2678 {0, 0, 0, 0, 0},
2679 {0, 0, 0, 0, 0},
2680 {0, 0, 0, 0, 0},
2681 {0, 0, 0, 0, 0},
2682 {0, 0, 0, 0, 0},
2683 {0, 0, 0, 0, 0},
2684 {0, 0, 0, 0, 0},
2685 },
2686 {
2687 {0, 0, 0, 0, 0},
2688 {0, 0, 0, 0, 0},
2689 {0, 0, 0, 0, 0},
2690 {0, 0, 0, 0, 0},
2691 {0, 0, 0, 0, 0},
2692 {0, 0, 0, 0, 0},
2693 {0, 0, 0, 0, 0},
2694 {0, 0, 0, 0, 0},
2695 },
2696 {
2697 {0, 0, 0, 0, 0},
2698 {0, 0, 0, 0, 0},
2699 {0, 0, 0, 0, 0},
2700 {0, 0, 0, 0, 0},
2701 {0, 0, 0, 0, 0},
2702 {0, 0, 0, 0, 0},
2703 {0, 0, 0, 0, 0},
2704 {0, 0, 0, 0, 0},
2705 },
2706
2707 },
2708 .calTarget_freqbin_5G = {
2709 FREQ2FBIN(5180, 0),
2710 FREQ2FBIN(5240, 0),
2711 FREQ2FBIN(5320, 0),
2712 FREQ2FBIN(5400, 0),
2713 FREQ2FBIN(5500, 0),
2714 FREQ2FBIN(5600, 0),
2715 FREQ2FBIN(5700, 0),
2716 FREQ2FBIN(5825, 0)
2717 },
2718 .calTarget_freqbin_5GHT20 = {
2719 FREQ2FBIN(5180, 0),
2720 FREQ2FBIN(5240, 0),
2721 FREQ2FBIN(5320, 0),
2722 FREQ2FBIN(5400, 0),
2723 FREQ2FBIN(5500, 0),
2724 FREQ2FBIN(5700, 0),
2725 FREQ2FBIN(5745, 0),
2726 FREQ2FBIN(5825, 0)
2727 },
2728 .calTarget_freqbin_5GHT40 = {
2729 FREQ2FBIN(5180, 0),
2730 FREQ2FBIN(5240, 0),
2731 FREQ2FBIN(5320, 0),
2732 FREQ2FBIN(5400, 0),
2733 FREQ2FBIN(5500, 0),
2734 FREQ2FBIN(5700, 0),
2735 FREQ2FBIN(5745, 0),
2736 FREQ2FBIN(5825, 0)
2737 },
2738 .calTargetPower5G = {
2739
2740 { {30, 30, 28, 24} },
2741 { {30, 30, 28, 24} },
2742 { {30, 30, 28, 24} },
2743 { {30, 30, 28, 24} },
2744 { {30, 30, 28, 24} },
2745 { {30, 30, 28, 24} },
2746 { {30, 30, 28, 24} },
2747 { {30, 30, 28, 24} },
2748 },
2749 .calTargetPower5GHT20 = {
2750
2751
2752
2753
2754 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
2755 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
2756 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
2757 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
2758 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
2759 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
2760 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
2761 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
2762 },
2763 .calTargetPower5GHT40 = {
2764
2765
2766
2767
2768 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
2769 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
2770 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
2771 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
2772 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
2773 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
2774 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
2775 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
2776 },
2777 .ctlIndex_5G = {
2778 0x10, 0x16, 0x18, 0x40, 0x46,
2779 0x48, 0x30, 0x36, 0x38
2780 },
2781 .ctl_freqbin_5G = {
2782 {
2783 FREQ2FBIN(5180, 0),
2784 FREQ2FBIN(5260, 0),
2785 FREQ2FBIN(5280, 0),
2786 FREQ2FBIN(5500, 0),
2787 FREQ2FBIN(5600, 0),
2788 FREQ2FBIN(5700, 0),
2789 FREQ2FBIN(5745, 0),
2790 FREQ2FBIN(5825, 0)
2791 },
2792 {
2793 FREQ2FBIN(5180, 0),
2794 FREQ2FBIN(5260, 0),
2795 FREQ2FBIN(5280, 0),
2796 FREQ2FBIN(5500, 0),
2797 FREQ2FBIN(5520, 0),
2798 FREQ2FBIN(5700, 0),
2799 FREQ2FBIN(5745, 0),
2800 FREQ2FBIN(5825, 0)
2801 },
2802
2803 {
2804 FREQ2FBIN(5190, 0),
2805 FREQ2FBIN(5230, 0),
2806 FREQ2FBIN(5270, 0),
2807 FREQ2FBIN(5310, 0),
2808 FREQ2FBIN(5510, 0),
2809 FREQ2FBIN(5550, 0),
2810 FREQ2FBIN(5670, 0),
2811 FREQ2FBIN(5755, 0)
2812 },
2813
2814 {
2815 FREQ2FBIN(5180, 0),
2816 FREQ2FBIN(5200, 0),
2817 FREQ2FBIN(5260, 0),
2818 FREQ2FBIN(5320, 0),
2819 FREQ2FBIN(5500, 0),
2820 FREQ2FBIN(5700, 0),
2821 0xFF,
2822 0xFF,
2823 },
2824
2825 {
2826 FREQ2FBIN(5180, 0),
2827 FREQ2FBIN(5260, 0),
2828 FREQ2FBIN(5500, 0),
2829 FREQ2FBIN(5700, 0),
2830 0xFF,
2831 0xFF,
2832 0xFF,
2833 0xFF,
2834 },
2835
2836 {
2837 FREQ2FBIN(5190, 0),
2838 FREQ2FBIN(5270, 0),
2839 FREQ2FBIN(5310, 0),
2840 FREQ2FBIN(5510, 0),
2841 FREQ2FBIN(5590, 0),
2842 FREQ2FBIN(5670, 0),
2843 0xFF,
2844 0xFF
2845 },
2846
2847 {
2848 FREQ2FBIN(5180, 0),
2849 FREQ2FBIN(5200, 0),
2850 FREQ2FBIN(5220, 0),
2851 FREQ2FBIN(5260, 0),
2852 FREQ2FBIN(5500, 0),
2853 FREQ2FBIN(5600, 0),
2854 FREQ2FBIN(5700, 0),
2855 FREQ2FBIN(5745, 0)
2856 },
2857
2858 {
2859 FREQ2FBIN(5180, 0),
2860 FREQ2FBIN(5260, 0),
2861 FREQ2FBIN(5320, 0),
2862 FREQ2FBIN(5500, 0),
2863 FREQ2FBIN(5560, 0),
2864 FREQ2FBIN(5700, 0),
2865 FREQ2FBIN(5745, 0),
2866 FREQ2FBIN(5825, 0)
2867 },
2868
2869 {
2870 FREQ2FBIN(5190, 0),
2871 FREQ2FBIN(5230, 0),
2872 FREQ2FBIN(5270, 0),
2873 FREQ2FBIN(5510, 0),
2874 FREQ2FBIN(5550, 0),
2875 FREQ2FBIN(5670, 0),
2876 FREQ2FBIN(5755, 0),
2877 FREQ2FBIN(5795, 0)
2878 }
2879 },
2880 .ctlPowerData_5G = {
2881 {
2882 {
2883 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2884 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2885 }
2886 },
2887 {
2888 {
2889 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2890 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2891 }
2892 },
2893 {
2894 {
2895 CTL(60, 0), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2896 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2897 }
2898 },
2899 {
2900 {
2901 CTL(60, 0), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2902 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2903 }
2904 },
2905 {
2906 {
2907 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2908 CTL(60, 0), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2909 }
2910 },
2911 {
2912 {
2913 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2914 CTL(60, 1), CTL(60, 0), CTL(60, 0), CTL(60, 0),
2915 }
2916 },
2917 {
2918 {
2919 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2920 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 1),
2921 }
2922 },
2923 {
2924 {
2925 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2926 CTL(60, 1), CTL(60, 1), CTL(60, 1), CTL(60, 0),
2927 }
2928 },
2929 {
2930 {
2931 CTL(60, 1), CTL(60, 0), CTL(60, 1), CTL(60, 1),
2932 CTL(60, 1), CTL(60, 1), CTL(60, 0), CTL(60, 1),
2933 }
2934 },
2935 }
2936};
2937
2938
2939static const struct ar9300_eeprom *ar9300_eep_templates[] = {
2940 &ar9300_default,
2941 &ar9300_x112,
2942 &ar9300_h116,
2943 &ar9300_h112,
2944 &ar9300_x113,
2945};
2946
2947static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(int id)
2948{
2949#define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0]))
2950 int it;
2951
2952 for (it = 0; it < N_LOOP; it++)
2953 if (ar9300_eep_templates[it]->templateVersion == id)
2954 return ar9300_eep_templates[it];
2955 return NULL;
2956#undef N_LOOP
2957}
2958
2959static int ath9k_hw_ar9300_check_eeprom(struct ath_hw *ah)
2960{
2961 return 0;
2962}
2963
2964static int interpolate(int x, int xa, int xb, int ya, int yb)
2965{
2966 int bf, factor, plus;
2967
2968 bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
2969 factor = bf / 2;
2970 plus = bf % 2;
2971 return ya + factor + plus;
2972}
2973
2974static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
2975 enum eeprom_param param)
2976{
2977 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
2978 struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
2979
2980 switch (param) {
2981 case EEP_MAC_LSW:
2982 return get_unaligned_be16(eep->macAddr);
2983 case EEP_MAC_MID:
2984 return get_unaligned_be16(eep->macAddr + 2);
2985 case EEP_MAC_MSW:
2986 return get_unaligned_be16(eep->macAddr + 4);
2987 case EEP_REG_0:
2988 return le16_to_cpu(pBase->regDmn[0]);
2989 case EEP_OP_CAP:
2990 return pBase->deviceCap;
2991 case EEP_OP_MODE:
2992 return pBase->opCapFlags.opFlags;
2993 case EEP_RF_SILENT:
2994 return pBase->rfSilent;
2995 case EEP_TX_MASK:
2996 return (pBase->txrxMask >> 4) & 0xf;
2997 case EEP_RX_MASK:
2998 return pBase->txrxMask & 0xf;
2999 case EEP_PAPRD:
3000 return !!(pBase->featureEnable & BIT(5));
3001 case EEP_CHAIN_MASK_REDUCE:
3002 return (pBase->miscConfiguration >> 0x3) & 0x1;
3003 case EEP_ANT_DIV_CTL1:
3004 if (AR_SREV_9565(ah))
3005 return AR9300_EEP_ANTDIV_CONTROL_DEFAULT_VALUE;
3006 else
3007 return eep->base_ext1.ant_div_control;
3008 case EEP_ANTENNA_GAIN_5G:
3009 return eep->modalHeader5G.antennaGain;
3010 case EEP_ANTENNA_GAIN_2G:
3011 return eep->modalHeader2G.antennaGain;
3012 default:
3013 return 0;
3014 }
3015}
3016
3017static bool ar9300_eeprom_read_byte(struct ath_hw *ah, int address,
3018 u8 *buffer)
3019{
3020 u16 val;
3021
3022 if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
3023 return false;
3024
3025 *buffer = (val >> (8 * (address % 2))) & 0xff;
3026 return true;
3027}
3028
3029static bool ar9300_eeprom_read_word(struct ath_hw *ah, int address,
3030 u8 *buffer)
3031{
3032 u16 val;
3033
3034 if (unlikely(!ath9k_hw_nvram_read(ah, address / 2, &val)))
3035 return false;
3036
3037 buffer[0] = val >> 8;
3038 buffer[1] = val & 0xff;
3039
3040 return true;
3041}
3042
3043static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
3044 int count)
3045{
3046 struct ath_common *common = ath9k_hw_common(ah);
3047 int i;
3048
3049 if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
3050 ath_dbg(common, EEPROM, "eeprom address not in range\n");
3051 return false;
3052 }
3053
3054
3055
3056
3057
3058
3059 if (address % 2 == 0) {
3060 if (!ar9300_eeprom_read_byte(ah, address--, buffer++))
3061 goto error;
3062
3063 count--;
3064 }
3065
3066 for (i = 0; i < count / 2; i++) {
3067 if (!ar9300_eeprom_read_word(ah, address, buffer))
3068 goto error;
3069
3070 address -= 2;
3071 buffer += 2;
3072 }
3073
3074 if (count % 2)
3075 if (!ar9300_eeprom_read_byte(ah, address, buffer))
3076 goto error;
3077
3078 return true;
3079
3080error:
3081 ath_dbg(common, EEPROM, "unable to read eeprom region at offset %d\n",
3082 address);
3083 return false;
3084}
3085
3086static bool ar9300_otp_read_word(struct ath_hw *ah, int addr, u32 *data)
3087{
3088 REG_READ(ah, AR9300_OTP_BASE + (4 * addr));
3089
3090 if (!ath9k_hw_wait(ah, AR9300_OTP_STATUS, AR9300_OTP_STATUS_TYPE,
3091 AR9300_OTP_STATUS_VALID, 1000))
3092 return false;
3093
3094 *data = REG_READ(ah, AR9300_OTP_READ_DATA);
3095 return true;
3096}
3097
3098static bool ar9300_read_otp(struct ath_hw *ah, int address, u8 *buffer,
3099 int count)
3100{
3101 u32 data;
3102 int i;
3103
3104 for (i = 0; i < count; i++) {
3105 int offset = 8 * ((address - i) % 4);
3106 if (!ar9300_otp_read_word(ah, (address - i) / 4, &data))
3107 return false;
3108
3109 buffer[i] = (data >> offset) & 0xff;
3110 }
3111
3112 return true;
3113}
3114
3115
3116static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
3117 int *length, int *major, int *minor)
3118{
3119 unsigned long value[4];
3120
3121 value[0] = best[0];
3122 value[1] = best[1];
3123 value[2] = best[2];
3124 value[3] = best[3];
3125 *code = ((value[0] >> 5) & 0x0007);
3126 *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
3127 *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
3128 *major = (value[2] & 0x000f);
3129 *minor = (value[3] & 0x00ff);
3130}
3131
3132static u16 ar9300_comp_cksum(u8 *data, int dsize)
3133{
3134 int it, checksum = 0;
3135
3136 for (it = 0; it < dsize; it++) {
3137 checksum += data[it];
3138 checksum &= 0xffff;
3139 }
3140
3141 return checksum;
3142}
3143
3144static bool ar9300_uncompress_block(struct ath_hw *ah,
3145 u8 *mptr,
3146 int mdataSize,
3147 u8 *block,
3148 int size)
3149{
3150 int it;
3151 int spot;
3152 int offset;
3153 int length;
3154 struct ath_common *common = ath9k_hw_common(ah);
3155
3156 spot = 0;
3157
3158 for (it = 0; it < size; it += (length+2)) {
3159 offset = block[it];
3160 offset &= 0xff;
3161 spot += offset;
3162 length = block[it+1];
3163 length &= 0xff;
3164
3165 if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
3166 ath_dbg(common, EEPROM,
3167 "Restore at %d: spot=%d offset=%d length=%d\n",
3168 it, spot, offset, length);
3169 memcpy(&mptr[spot], &block[it+2], length);
3170 spot += length;
3171 } else if (length > 0) {
3172 ath_dbg(common, EEPROM,
3173 "Bad restore at %d: spot=%d offset=%d length=%d\n",
3174 it, spot, offset, length);
3175 return false;
3176 }
3177 }
3178 return true;
3179}
3180
3181static int ar9300_compress_decision(struct ath_hw *ah,
3182 int it,
3183 int code,
3184 int reference,
3185 u8 *mptr,
3186 u8 *word, int length, int mdata_size)
3187{
3188 struct ath_common *common = ath9k_hw_common(ah);
3189 const struct ar9300_eeprom *eep = NULL;
3190
3191 switch (code) {
3192 case _CompressNone:
3193 if (length != mdata_size) {
3194 ath_dbg(common, EEPROM,
3195 "EEPROM structure size mismatch memory=%d eeprom=%d\n",
3196 mdata_size, length);
3197 return -1;
3198 }
3199 memcpy(mptr, word + COMP_HDR_LEN, length);
3200 ath_dbg(common, EEPROM,
3201 "restored eeprom %d: uncompressed, length %d\n",
3202 it, length);
3203 break;
3204 case _CompressBlock:
3205 if (reference == 0) {
3206 } else {
3207 eep = ar9003_eeprom_struct_find_by_id(reference);
3208 if (eep == NULL) {
3209 ath_dbg(common, EEPROM,
3210 "can't find reference eeprom struct %d\n",
3211 reference);
3212 return -1;
3213 }
3214 memcpy(mptr, eep, mdata_size);
3215 }
3216 ath_dbg(common, EEPROM,
3217 "restore eeprom %d: block, reference %d, length %d\n",
3218 it, reference, length);
3219 ar9300_uncompress_block(ah, mptr, mdata_size,
3220 (word + COMP_HDR_LEN), length);
3221 break;
3222 default:
3223 ath_dbg(common, EEPROM, "unknown compression code %d\n", code);
3224 return -1;
3225 }
3226 return 0;
3227}
3228
3229typedef bool (*eeprom_read_op)(struct ath_hw *ah, int address, u8 *buffer,
3230 int count);
3231
3232static bool ar9300_check_header(void *data)
3233{
3234 u32 *word = data;
3235 return !(*word == 0 || *word == ~0);
3236}
3237
3238static bool ar9300_check_eeprom_header(struct ath_hw *ah, eeprom_read_op read,
3239 int base_addr)
3240{
3241 u8 header[4];
3242
3243 if (!read(ah, base_addr, header, 4))
3244 return false;
3245
3246 return ar9300_check_header(header);
3247}
3248
3249static int ar9300_eeprom_restore_flash(struct ath_hw *ah, u8 *mptr,
3250 int mdata_size)
3251{
3252 u16 *data = (u16 *) mptr;
3253 int i;
3254
3255 for (i = 0; i < mdata_size / 2; i++, data++)
3256 ath9k_hw_nvram_read(ah, i, data);
3257
3258 return 0;
3259}
3260
3261
3262
3263
3264
3265
3266
3267static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
3268 u8 *mptr, int mdata_size)
3269{
3270#define MDEFAULT 15
3271#define MSTATE 100
3272 int cptr;
3273 u8 *word;
3274 int code;
3275 int reference, length, major, minor;
3276 int osize;
3277 int it;
3278 u16 checksum, mchecksum;
3279 struct ath_common *common = ath9k_hw_common(ah);
3280 struct ar9300_eeprom *eep;
3281 eeprom_read_op read;
3282
3283 if (ath9k_hw_use_flash(ah)) {
3284 u8 txrx;
3285
3286 ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
3287
3288
3289 eep = (struct ar9300_eeprom *) mptr;
3290 txrx = eep->baseEepHeader.txrxMask;
3291 if (txrx != 0 && txrx != 0xff)
3292 return 0;
3293 }
3294
3295 word = kzalloc(2048, GFP_KERNEL);
3296 if (!word)
3297 return -ENOMEM;
3298
3299 memcpy(mptr, &ar9300_default, mdata_size);
3300
3301 read = ar9300_read_eeprom;
3302 if (AR_SREV_9485(ah))
3303 cptr = AR9300_BASE_ADDR_4K;
3304 else if (AR_SREV_9330(ah))
3305 cptr = AR9300_BASE_ADDR_512;
3306 else
3307 cptr = AR9300_BASE_ADDR;
3308 ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
3309 cptr);
3310 if (ar9300_check_eeprom_header(ah, read, cptr))
3311 goto found;
3312
3313 cptr = AR9300_BASE_ADDR_512;
3314 ath_dbg(common, EEPROM, "Trying EEPROM access at Address 0x%04x\n",
3315 cptr);
3316 if (ar9300_check_eeprom_header(ah, read, cptr))
3317 goto found;
3318
3319 read = ar9300_read_otp;
3320 cptr = AR9300_BASE_ADDR;
3321 ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
3322 if (ar9300_check_eeprom_header(ah, read, cptr))
3323 goto found;
3324
3325 cptr = AR9300_BASE_ADDR_512;
3326 ath_dbg(common, EEPROM, "Trying OTP access at Address 0x%04x\n", cptr);
3327 if (ar9300_check_eeprom_header(ah, read, cptr))
3328 goto found;
3329
3330 goto fail;
3331
3332found:
3333 ath_dbg(common, EEPROM, "Found valid EEPROM data\n");
3334
3335 for (it = 0; it < MSTATE; it++) {
3336 if (!read(ah, cptr, word, COMP_HDR_LEN))
3337 goto fail;
3338
3339 if (!ar9300_check_header(word))
3340 break;
3341
3342 ar9300_comp_hdr_unpack(word, &code, &reference,
3343 &length, &major, &minor);
3344 ath_dbg(common, EEPROM,
3345 "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
3346 cptr, code, reference, length, major, minor);
3347 if ((!AR_SREV_9485(ah) && length >= 1024) ||
3348 (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
3349 ath_dbg(common, EEPROM, "Skipping bad header\n");
3350 cptr -= COMP_HDR_LEN;
3351 continue;
3352 }
3353
3354 osize = length;
3355 read(ah, cptr, word, COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
3356 checksum = ar9300_comp_cksum(&word[COMP_HDR_LEN], length);
3357 mchecksum = get_unaligned_le16(&word[COMP_HDR_LEN + osize]);
3358 ath_dbg(common, EEPROM, "checksum %x %x\n",
3359 checksum, mchecksum);
3360 if (checksum == mchecksum) {
3361 ar9300_compress_decision(ah, it, code, reference, mptr,
3362 word, length, mdata_size);
3363 } else {
3364 ath_dbg(common, EEPROM,
3365 "skipping block with bad checksum\n");
3366 }
3367 cptr -= (COMP_HDR_LEN + osize + COMP_CKSUM_LEN);
3368 }
3369
3370 kfree(word);
3371 return cptr;
3372
3373fail:
3374 kfree(word);
3375 return -1;
3376}
3377
3378
3379
3380
3381
3382
3383static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
3384{
3385 u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
3386
3387 if (ar9300_eeprom_restore_internal(ah, mptr,
3388 sizeof(struct ar9300_eeprom)) < 0)
3389 return false;
3390
3391 return true;
3392}
3393
3394#if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
3395static u32 ar9003_dump_modal_eeprom(char *buf, u32 len, u32 size,
3396 struct ar9300_modal_eep_header *modal_hdr)
3397{
3398 PR_EEP("Chain0 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[0]));
3399 PR_EEP("Chain1 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[1]));
3400 PR_EEP("Chain2 Ant. Control", le16_to_cpu(modal_hdr->antCtrlChain[2]));
3401 PR_EEP("Ant. Common Control", le32_to_cpu(modal_hdr->antCtrlCommon));
3402 PR_EEP("Ant. Common Control2", le32_to_cpu(modal_hdr->antCtrlCommon2));
3403 PR_EEP("Ant. Gain", modal_hdr->antennaGain);
3404 PR_EEP("Switch Settle", modal_hdr->switchSettling);
3405 PR_EEP("Chain0 xatten1DB", modal_hdr->xatten1DB[0]);
3406 PR_EEP("Chain1 xatten1DB", modal_hdr->xatten1DB[1]);
3407 PR_EEP("Chain2 xatten1DB", modal_hdr->xatten1DB[2]);
3408 PR_EEP("Chain0 xatten1Margin", modal_hdr->xatten1Margin[0]);
3409 PR_EEP("Chain1 xatten1Margin", modal_hdr->xatten1Margin[1]);
3410 PR_EEP("Chain2 xatten1Margin", modal_hdr->xatten1Margin[2]);
3411 PR_EEP("Temp Slope", modal_hdr->tempSlope);
3412 PR_EEP("Volt Slope", modal_hdr->voltSlope);
3413 PR_EEP("spur Channels0", modal_hdr->spurChans[0]);
3414 PR_EEP("spur Channels1", modal_hdr->spurChans[1]);
3415 PR_EEP("spur Channels2", modal_hdr->spurChans[2]);
3416 PR_EEP("spur Channels3", modal_hdr->spurChans[3]);
3417 PR_EEP("spur Channels4", modal_hdr->spurChans[4]);
3418 PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
3419 PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
3420 PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
3421 PR_EEP("Quick Drop", modal_hdr->quick_drop);
3422 PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
3423 PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
3424 PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
3425 PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
3426 PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
3427 PR_EEP("txClip", modal_hdr->txClip);
3428 PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
3429
3430 return len;
3431}
3432
3433static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
3434 u8 *buf, u32 len, u32 size)
3435{
3436 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3437 struct ar9300_base_eep_hdr *pBase;
3438
3439 if (!dump_base_hdr) {
3440 len += scnprintf(buf + len, size - len,
3441 "%20s :\n", "2GHz modal Header");
3442 len = ar9003_dump_modal_eeprom(buf, len, size,
3443 &eep->modalHeader2G);
3444 len += scnprintf(buf + len, size - len,
3445 "%20s :\n", "5GHz modal Header");
3446 len = ar9003_dump_modal_eeprom(buf, len, size,
3447 &eep->modalHeader5G);
3448 goto out;
3449 }
3450
3451 pBase = &eep->baseEepHeader;
3452
3453 PR_EEP("EEPROM Version", ah->eeprom.ar9300_eep.eepromVersion);
3454 PR_EEP("RegDomain1", le16_to_cpu(pBase->regDmn[0]));
3455 PR_EEP("RegDomain2", le16_to_cpu(pBase->regDmn[1]));
3456 PR_EEP("TX Mask", (pBase->txrxMask >> 4));
3457 PR_EEP("RX Mask", (pBase->txrxMask & 0x0f));
3458 PR_EEP("Allow 5GHz", !!(pBase->opCapFlags.opFlags &
3459 AR5416_OPFLAGS_11A));
3460 PR_EEP("Allow 2GHz", !!(pBase->opCapFlags.opFlags &
3461 AR5416_OPFLAGS_11G));
3462 PR_EEP("Disable 2GHz HT20", !!(pBase->opCapFlags.opFlags &
3463 AR5416_OPFLAGS_N_2G_HT20));
3464 PR_EEP("Disable 2GHz HT40", !!(pBase->opCapFlags.opFlags &
3465 AR5416_OPFLAGS_N_2G_HT40));
3466 PR_EEP("Disable 5Ghz HT20", !!(pBase->opCapFlags.opFlags &
3467 AR5416_OPFLAGS_N_5G_HT20));
3468 PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags.opFlags &
3469 AR5416_OPFLAGS_N_5G_HT40));
3470 PR_EEP("Big Endian", !!(pBase->opCapFlags.eepMisc & 0x01));
3471 PR_EEP("RF Silent", pBase->rfSilent);
3472 PR_EEP("BT option", pBase->blueToothOptions);
3473 PR_EEP("Device Cap", pBase->deviceCap);
3474 PR_EEP("Device Type", pBase->deviceType);
3475 PR_EEP("Power Table Offset", pBase->pwrTableOffset);
3476 PR_EEP("Tuning Caps1", pBase->params_for_tuning_caps[0]);
3477 PR_EEP("Tuning Caps2", pBase->params_for_tuning_caps[1]);
3478 PR_EEP("Enable Tx Temp Comp", !!(pBase->featureEnable & BIT(0)));
3479 PR_EEP("Enable Tx Volt Comp", !!(pBase->featureEnable & BIT(1)));
3480 PR_EEP("Enable fast clock", !!(pBase->featureEnable & BIT(2)));
3481 PR_EEP("Enable doubling", !!(pBase->featureEnable & BIT(3)));
3482 PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4)));
3483 PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5)));
3484 PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0)));
3485 PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1)));
3486 PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1);
3487 PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio);
3488 PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio);
3489 PR_EEP("WLAN LED Gpio", pBase->wlanLedGpio);
3490 PR_EEP("Rx Band Select Gpio", pBase->rxBandSelectGpio);
3491 PR_EEP("Tx Gain", pBase->txrxgain >> 4);
3492 PR_EEP("Rx Gain", pBase->txrxgain & 0xf);
3493 PR_EEP("SW Reg", le32_to_cpu(pBase->swreg));
3494
3495 len += scnprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
3496 ah->eeprom.ar9300_eep.macAddr);
3497out:
3498 if (len > size)
3499 len = size;
3500
3501 return len;
3502}
3503#else
3504static u32 ath9k_hw_ar9003_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
3505 u8 *buf, u32 len, u32 size)
3506{
3507 return 0;
3508}
3509#endif
3510
3511
3512static int ath9k_hw_ar9300_get_eeprom_ver(struct ath_hw *ah)
3513{
3514 return ah->eeprom.ar9300_eep.eepromVersion;
3515}
3516
3517
3518static int ath9k_hw_ar9300_get_eeprom_rev(struct ath_hw *ah)
3519{
3520 return 0;
3521}
3522
3523static struct ar9300_modal_eep_header *ar9003_modal_header(struct ath_hw *ah,
3524 bool is2ghz)
3525{
3526 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3527
3528 if (is2ghz)
3529 return &eep->modalHeader2G;
3530 else
3531 return &eep->modalHeader5G;
3532}
3533
3534static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
3535{
3536 int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
3537
3538 if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
3539 AR_SREV_9531(ah))
3540 REG_RMW_FIELD(ah, AR_CH0_TOP2, AR_CH0_TOP2_XPABIASLVL, bias);
3541 else if (AR_SREV_9462(ah) || AR_SREV_9550(ah) || AR_SREV_9565(ah))
3542 REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
3543 else {
3544 REG_RMW_FIELD(ah, AR_CH0_TOP, AR_CH0_TOP_XPABIASLVL, bias);
3545 REG_RMW_FIELD(ah, AR_CH0_THERM,
3546 AR_CH0_THERM_XPABIASLVL_MSB,
3547 bias >> 2);
3548 REG_RMW_FIELD(ah, AR_CH0_THERM,
3549 AR_CH0_THERM_XPASHORT2GND, 1);
3550 }
3551}
3552
3553static u16 ar9003_switch_com_spdt_get(struct ath_hw *ah, bool is2ghz)
3554{
3555 return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
3556}
3557
3558u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
3559{
3560 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
3561}
3562
3563u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
3564{
3565 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
3566}
3567
3568static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, int chain,
3569 bool is2ghz)
3570{
3571 __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[chain];
3572 return le16_to_cpu(val);
3573}
3574
3575static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
3576{
3577 struct ath_common *common = ath9k_hw_common(ah);
3578 struct ath9k_hw_capabilities *pCap = &ah->caps;
3579 int chain;
3580 u32 regval, value, gpio;
3581 static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
3582 AR_PHY_SWITCH_CHAIN_0,
3583 AR_PHY_SWITCH_CHAIN_1,
3584 AR_PHY_SWITCH_CHAIN_2,
3585 };
3586
3587 if (AR_SREV_9485(ah) && (ar9003_hw_get_rx_gain_idx(ah) == 0)) {
3588 if (ah->config.xlna_gpio)
3589 gpio = ah->config.xlna_gpio;
3590 else
3591 gpio = AR9300_EXT_LNA_CTL_GPIO_AR9485;
3592
3593 ath9k_hw_cfg_output(ah, gpio,
3594 AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED);
3595 }
3596
3597 value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz);
3598
3599 if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
3600 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
3601 AR_SWITCH_TABLE_COM_AR9462_ALL, value);
3602 } else if (AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
3603 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
3604 AR_SWITCH_TABLE_COM_AR9550_ALL, value);
3605 } else
3606 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM,
3607 AR_SWITCH_TABLE_COM_ALL, value);
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623 if (AR_SREV_9462_20_OR_LATER(ah) || AR_SREV_9565(ah)) {
3624 value = ar9003_switch_com_spdt_get(ah, is2ghz);
3625 REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL,
3626 AR_SWITCH_TABLE_COM_SPDT_ALL, value);
3627 REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, AR_BTCOEX_CTRL_SPDT_ENABLE);
3628 }
3629
3630 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
3631 if (AR_SREV_9485(ah) && common->bt_ant_diversity) {
3632 value &= ~AR_SWITCH_TABLE_COM2_ALL;
3633 value |= ah->config.ant_ctrl_comm2g_switch_enable;
3634
3635 }
3636 REG_RMW_FIELD(ah, AR_PHY_SWITCH_COM_2, AR_SWITCH_TABLE_COM2_ALL, value);
3637
3638 if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
3639 value = ar9003_hw_ant_ctrl_chain_get(ah, 1, is2ghz);
3640 REG_RMW_FIELD(ah, switch_chain_reg[0],
3641 AR_SWITCH_TABLE_ALL, value);
3642 }
3643
3644 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
3645 if ((ah->rxchainmask & BIT(chain)) ||
3646 (ah->txchainmask & BIT(chain))) {
3647 value = ar9003_hw_ant_ctrl_chain_get(ah, chain,
3648 is2ghz);
3649 REG_RMW_FIELD(ah, switch_chain_reg[chain],
3650 AR_SWITCH_TABLE_ALL, value);
3651 }
3652 }
3653
3654 if (AR_SREV_9330(ah) || AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
3655 value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
3656
3657
3658
3659
3660 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3661 regval &= (~AR_ANT_DIV_CTRL_ALL);
3662 regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
3663
3664 regval &= (~AR_PHY_ANT_DIV_LNADIV);
3665 regval |= ((value >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
3666
3667 if (AR_SREV_9485(ah) && common->bt_ant_diversity)
3668 regval |= AR_ANT_DIV_ENABLE;
3669
3670 if (AR_SREV_9565(ah)) {
3671 if (common->bt_ant_diversity) {
3672 regval |= (1 << AR_PHY_ANT_SW_RX_PROT_S);
3673
3674 REG_SET_BIT(ah, AR_PHY_RESTART,
3675 AR_PHY_RESTART_ENABLE_DIV_M2FLAG);
3676
3677
3678 REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV,
3679 AR_BTCOEX_WL_LNADIV_FORCE_ON);
3680 } else {
3681 regval &= ~(1 << AR_PHY_ANT_DIV_LNADIV_S);
3682 regval &= ~(1 << AR_PHY_ANT_SW_RX_PROT_S);
3683
3684 REG_CLR_BIT(ah, AR_PHY_MC_GAIN_CTRL,
3685 (1 << AR_PHY_ANT_SW_RX_PROT_S));
3686
3687
3688 REG_CLR_BIT(ah, AR_BTCOEX_WL_LNADIV,
3689 AR_BTCOEX_WL_LNADIV_FORCE_ON);
3690 }
3691 }
3692
3693 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3694
3695
3696 regval = REG_READ(ah, AR_PHY_CCK_DETECT);
3697 regval &= (~AR_FAST_DIV_ENABLE);
3698 regval |= ((value >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
3699
3700 if ((AR_SREV_9485(ah) || AR_SREV_9565(ah))
3701 && common->bt_ant_diversity)
3702 regval |= AR_FAST_DIV_ENABLE;
3703
3704 REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
3705
3706 if (pCap->hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) {
3707 regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
3708
3709
3710
3711
3712 regval &= (~(AR_PHY_ANT_DIV_MAIN_LNACONF |
3713 AR_PHY_ANT_DIV_ALT_LNACONF |
3714 AR_PHY_ANT_DIV_ALT_GAINTB |
3715 AR_PHY_ANT_DIV_MAIN_GAINTB));
3716
3717 regval |= (ATH_ANT_DIV_COMB_LNA1 <<
3718 AR_PHY_ANT_DIV_MAIN_LNACONF_S);
3719 regval |= (ATH_ANT_DIV_COMB_LNA2 <<
3720 AR_PHY_ANT_DIV_ALT_LNACONF_S);
3721 REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
3722 }
3723 }
3724}
3725
3726static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
3727{
3728 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3729 struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
3730 int drive_strength;
3731 unsigned long reg;
3732
3733 drive_strength = pBase->miscConfiguration & BIT(0);
3734 if (!drive_strength)
3735 return;
3736
3737 reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS1);
3738 reg &= ~0x00ffffc0;
3739 reg |= 0x5 << 21;
3740 reg |= 0x5 << 18;
3741 reg |= 0x5 << 15;
3742 reg |= 0x5 << 12;
3743 reg |= 0x5 << 9;
3744 reg |= 0x5 << 6;
3745 REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS1, reg);
3746
3747 reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS2);
3748 reg &= ~0xffffffe0;
3749 reg |= 0x5 << 29;
3750 reg |= 0x5 << 26;
3751 reg |= 0x5 << 23;
3752 reg |= 0x5 << 20;
3753 reg |= 0x5 << 17;
3754 reg |= 0x5 << 14;
3755 reg |= 0x5 << 11;
3756 reg |= 0x5 << 8;
3757 reg |= 0x5 << 5;
3758 REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS2, reg);
3759
3760 reg = REG_READ(ah, AR_PHY_65NM_CH0_BIAS4);
3761 reg &= ~0xff800000;
3762 reg |= 0x5 << 29;
3763 reg |= 0x5 << 26;
3764 reg |= 0x5 << 23;
3765 REG_WRITE(ah, AR_PHY_65NM_CH0_BIAS4, reg);
3766}
3767
3768static u16 ar9003_hw_atten_chain_get(struct ath_hw *ah, int chain,
3769 struct ath9k_channel *chan)
3770{
3771 int f[3], t[3];
3772 u16 value;
3773 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3774
3775 if (chain >= 0 && chain < 3) {
3776 if (IS_CHAN_2GHZ(chan))
3777 return eep->modalHeader2G.xatten1DB[chain];
3778 else if (eep->base_ext2.xatten1DBLow[chain] != 0) {
3779 t[0] = eep->base_ext2.xatten1DBLow[chain];
3780 f[0] = 5180;
3781 t[1] = eep->modalHeader5G.xatten1DB[chain];
3782 f[1] = 5500;
3783 t[2] = eep->base_ext2.xatten1DBHigh[chain];
3784 f[2] = 5785;
3785 value = ar9003_hw_power_interpolate((s32) chan->channel,
3786 f, t, 3);
3787 return value;
3788 } else
3789 return eep->modalHeader5G.xatten1DB[chain];
3790 }
3791
3792 return 0;
3793}
3794
3795
3796static u16 ar9003_hw_atten_chain_get_margin(struct ath_hw *ah, int chain,
3797 struct ath9k_channel *chan)
3798{
3799 int f[3], t[3];
3800 u16 value;
3801 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3802
3803 if (chain >= 0 && chain < 3) {
3804 if (IS_CHAN_2GHZ(chan))
3805 return eep->modalHeader2G.xatten1Margin[chain];
3806 else if (eep->base_ext2.xatten1MarginLow[chain] != 0) {
3807 t[0] = eep->base_ext2.xatten1MarginLow[chain];
3808 f[0] = 5180;
3809 t[1] = eep->modalHeader5G.xatten1Margin[chain];
3810 f[1] = 5500;
3811 t[2] = eep->base_ext2.xatten1MarginHigh[chain];
3812 f[2] = 5785;
3813 value = ar9003_hw_power_interpolate((s32) chan->channel,
3814 f, t, 3);
3815 return value;
3816 } else
3817 return eep->modalHeader5G.xatten1Margin[chain];
3818 }
3819
3820 return 0;
3821}
3822
3823static void ar9003_hw_atten_apply(struct ath_hw *ah, struct ath9k_channel *chan)
3824{
3825 int i;
3826 u16 value;
3827 unsigned long ext_atten_reg[3] = {AR_PHY_EXT_ATTEN_CTL_0,
3828 AR_PHY_EXT_ATTEN_CTL_1,
3829 AR_PHY_EXT_ATTEN_CTL_2,
3830 };
3831
3832 if ((AR_SREV_9462(ah)) && (ah->rxchainmask == 0x2)) {
3833 value = ar9003_hw_atten_chain_get(ah, 1, chan);
3834 REG_RMW_FIELD(ah, ext_atten_reg[0],
3835 AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
3836
3837 value = ar9003_hw_atten_chain_get_margin(ah, 1, chan);
3838 REG_RMW_FIELD(ah, ext_atten_reg[0],
3839 AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
3840 value);
3841 }
3842
3843
3844 for (i = 0; i < 3; i++) {
3845 if (ah->txchainmask & BIT(i)) {
3846 value = ar9003_hw_atten_chain_get(ah, i, chan);
3847 REG_RMW_FIELD(ah, ext_atten_reg[i],
3848 AR_PHY_EXT_ATTEN_CTL_XATTEN1_DB, value);
3849
3850 if (AR_SREV_9485(ah) &&
3851 (ar9003_hw_get_rx_gain_idx(ah) == 0) &&
3852 ah->config.xatten_margin_cfg)
3853 value = 5;
3854 else
3855 value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
3856
3857 if (ah->config.alt_mingainidx)
3858 REG_RMW_FIELD(ah, AR_PHY_EXT_ATTEN_CTL_0,
3859 AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
3860 value);
3861
3862 REG_RMW_FIELD(ah, ext_atten_reg[i],
3863 AR_PHY_EXT_ATTEN_CTL_XATTEN1_MARGIN,
3864 value);
3865 }
3866 }
3867}
3868
3869static bool is_pmu_set(struct ath_hw *ah, u32 pmu_reg, int pmu_set)
3870{
3871 int timeout = 100;
3872
3873 while (pmu_set != REG_READ(ah, pmu_reg)) {
3874 if (timeout-- == 0)
3875 return false;
3876 REG_WRITE(ah, pmu_reg, pmu_set);
3877 udelay(10);
3878 }
3879
3880 return true;
3881}
3882
3883void ar9003_hw_internal_regulator_apply(struct ath_hw *ah)
3884{
3885 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3886 struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
3887 u32 reg_val;
3888
3889 if (pBase->featureEnable & BIT(4)) {
3890 if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
3891 int reg_pmu_set;
3892
3893 reg_pmu_set = REG_READ(ah, AR_PHY_PMU2) & ~AR_PHY_PMU2_PGM;
3894 REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
3895 if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
3896 return;
3897
3898 if (AR_SREV_9330(ah)) {
3899 if (ah->is_clk_25mhz) {
3900 reg_pmu_set = (3 << 1) | (8 << 4) |
3901 (3 << 8) | (1 << 14) |
3902 (6 << 17) | (1 << 20) |
3903 (3 << 24);
3904 } else {
3905 reg_pmu_set = (4 << 1) | (7 << 4) |
3906 (3 << 8) | (1 << 14) |
3907 (6 << 17) | (1 << 20) |
3908 (3 << 24);
3909 }
3910 } else {
3911 reg_pmu_set = (5 << 1) | (7 << 4) |
3912 (2 << 8) | (2 << 14) |
3913 (6 << 17) | (1 << 20) |
3914 (3 << 24) | (1 << 28);
3915 }
3916
3917 REG_WRITE(ah, AR_PHY_PMU1, reg_pmu_set);
3918 if (!is_pmu_set(ah, AR_PHY_PMU1, reg_pmu_set))
3919 return;
3920
3921 reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0xFFC00000)
3922 | (4 << 26);
3923 REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
3924 if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
3925 return;
3926
3927 reg_pmu_set = (REG_READ(ah, AR_PHY_PMU2) & ~0x00200000)
3928 | (1 << 21);
3929 REG_WRITE(ah, AR_PHY_PMU2, reg_pmu_set);
3930 if (!is_pmu_set(ah, AR_PHY_PMU2, reg_pmu_set))
3931 return;
3932 } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
3933 reg_val = le32_to_cpu(pBase->swreg);
3934 REG_WRITE(ah, AR_PHY_PMU1, reg_val);
3935 } else {
3936
3937 reg_val = le32_to_cpu(pBase->swreg);
3938 REG_WRITE(ah, AR_RTC_REG_CONTROL1,
3939 REG_READ(ah, AR_RTC_REG_CONTROL1) &
3940 (~AR_RTC_REG_CONTROL1_SWREG_PROGRAM));
3941 REG_WRITE(ah, AR_RTC_REG_CONTROL0, reg_val);
3942
3943 REG_WRITE(ah, AR_RTC_REG_CONTROL1,
3944 REG_READ(ah,
3945 AR_RTC_REG_CONTROL1) |
3946 AR_RTC_REG_CONTROL1_SWREG_PROGRAM);
3947 }
3948 } else {
3949 if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) {
3950 REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0);
3951 while (REG_READ_FIELD(ah, AR_PHY_PMU2,
3952 AR_PHY_PMU2_PGM))
3953 udelay(10);
3954
3955 REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
3956 while (!REG_READ_FIELD(ah, AR_PHY_PMU1,
3957 AR_PHY_PMU1_PWD))
3958 udelay(10);
3959 REG_RMW_FIELD(ah, AR_PHY_PMU2, AR_PHY_PMU2_PGM, 0x1);
3960 while (!REG_READ_FIELD(ah, AR_PHY_PMU2,
3961 AR_PHY_PMU2_PGM))
3962 udelay(10);
3963 } else if (AR_SREV_9462(ah) || AR_SREV_9565(ah))
3964 REG_RMW_FIELD(ah, AR_PHY_PMU1, AR_PHY_PMU1_PWD, 0x1);
3965 else {
3966 reg_val = REG_READ(ah, AR_RTC_SLEEP_CLK) |
3967 AR_RTC_FORCE_SWREG_PRD;
3968 REG_WRITE(ah, AR_RTC_SLEEP_CLK, reg_val);
3969 }
3970 }
3971
3972}
3973
3974static void ar9003_hw_apply_tuning_caps(struct ath_hw *ah)
3975{
3976 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3977 u8 tuning_caps_param = eep->baseEepHeader.params_for_tuning_caps[0];
3978
3979 if (AR_SREV_9340(ah) || AR_SREV_9531(ah))
3980 return;
3981
3982 if (eep->baseEepHeader.featureEnable & 0x40) {
3983 tuning_caps_param &= 0x7f;
3984 REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPINDAC,
3985 tuning_caps_param);
3986 REG_RMW_FIELD(ah, AR_CH0_XTAL, AR_CH0_XTAL_CAPOUTDAC,
3987 tuning_caps_param);
3988 }
3989}
3990
3991static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
3992{
3993 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
3994 struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
3995 int quick_drop;
3996 s32 t[3], f[3] = {5180, 5500, 5785};
3997
3998 if (!(pBase->miscConfiguration & BIT(4)))
3999 return;
4000
4001 if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
4002 if (freq < 4000) {
4003 quick_drop = eep->modalHeader2G.quick_drop;
4004 } else {
4005 t[0] = eep->base_ext1.quick_drop_low;
4006 t[1] = eep->modalHeader5G.quick_drop;
4007 t[2] = eep->base_ext1.quick_drop_high;
4008 quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
4009 }
4010 REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
4011 }
4012}
4013
4014static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
4015{
4016 u32 value;
4017
4018 value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
4019
4020 REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
4021 AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value);
4022 REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
4023 AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value);
4024}
4025
4026static void ar9003_hw_xpa_timing_control_apply(struct ath_hw *ah, bool is2ghz)
4027{
4028 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4029 u8 xpa_ctl;
4030
4031 if (!(eep->baseEepHeader.featureEnable & 0x80))
4032 return;
4033
4034 if (!AR_SREV_9300(ah) &&
4035 !AR_SREV_9340(ah) &&
4036 !AR_SREV_9580(ah) &&
4037 !AR_SREV_9531(ah))
4038 return;
4039
4040 xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
4041 if (is2ghz)
4042 REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
4043 AR_PHY_XPA_TIMING_CTL_FRAME_XPAB_ON, xpa_ctl);
4044 else
4045 REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL,
4046 AR_PHY_XPA_TIMING_CTL_FRAME_XPAA_ON, xpa_ctl);
4047}
4048
4049static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
4050{
4051 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4052 u8 bias;
4053
4054 if (!(eep->baseEepHeader.miscConfiguration & 0x40))
4055 return;
4056
4057 if (!AR_SREV_9300(ah))
4058 return;
4059
4060 bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
4061 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
4062 bias & 0x3);
4063 bias >>= 2;
4064 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
4065 bias & 0x3);
4066 bias >>= 2;
4067 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4, AR_PHY_65NM_RXTX4_XLNA_BIAS,
4068 bias & 0x3);
4069}
4070
4071static int ar9003_hw_get_thermometer(struct ath_hw *ah)
4072{
4073 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4074 struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
4075 int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
4076
4077 return --thermometer;
4078}
4079
4080static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
4081{
4082 int thermometer = ar9003_hw_get_thermometer(ah);
4083 u8 therm_on = (thermometer < 0) ? 0 : 1;
4084
4085 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
4086 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4087 if (ah->caps.tx_chainmask & BIT(1))
4088 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
4089 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4090 if (ah->caps.tx_chainmask & BIT(2))
4091 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
4092 AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
4093
4094 therm_on = (thermometer < 0) ? 0 : (thermometer == 0);
4095 REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
4096 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
4097 if (ah->caps.tx_chainmask & BIT(1)) {
4098 therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
4099 REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
4100 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
4101 }
4102 if (ah->caps.tx_chainmask & BIT(2)) {
4103 therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
4104 REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
4105 AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
4106 }
4107}
4108
4109static void ar9003_hw_thermo_cal_apply(struct ath_hw *ah)
4110{
4111 u32 data, ko, kg;
4112
4113 if (!AR_SREV_9462_20_OR_LATER(ah))
4114 return;
4115
4116 ar9300_otp_read_word(ah, 1, &data);
4117 ko = data & 0xff;
4118 kg = (data >> 8) & 0xff;
4119 if (ko || kg) {
4120 REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
4121 AR_PHY_BB_THERM_ADC_3_THERM_ADC_OFFSET, ko);
4122 REG_RMW_FIELD(ah, AR_PHY_BB_THERM_ADC_3,
4123 AR_PHY_BB_THERM_ADC_3_THERM_ADC_SCALE_GAIN,
4124 kg + 256);
4125 }
4126}
4127
4128static void ar9003_hw_apply_minccapwr_thresh(struct ath_hw *ah,
4129 bool is2ghz)
4130{
4131 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4132 const u_int32_t cca_ctrl[AR9300_MAX_CHAINS] = {
4133 AR_PHY_CCA_CTRL_0,
4134 AR_PHY_CCA_CTRL_1,
4135 AR_PHY_CCA_CTRL_2,
4136 };
4137 int chain;
4138 u32 val;
4139
4140 if (is2ghz) {
4141 if (!(eep->base_ext1.misc_enable & BIT(2)))
4142 return;
4143 } else {
4144 if (!(eep->base_ext1.misc_enable & BIT(3)))
4145 return;
4146 }
4147
4148 for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
4149 if (!(ah->caps.tx_chainmask & BIT(chain)))
4150 continue;
4151
4152 val = ar9003_modal_header(ah, is2ghz)->noiseFloorThreshCh[chain];
4153 REG_RMW_FIELD(ah, cca_ctrl[chain],
4154 AR_PHY_EXT_CCA0_THRESH62_1, val);
4155 }
4156
4157}
4158
4159static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah,
4160 struct ath9k_channel *chan)
4161{
4162 bool is2ghz = IS_CHAN_2GHZ(chan);
4163 ar9003_hw_xpa_timing_control_apply(ah, is2ghz);
4164 ar9003_hw_xpa_bias_level_apply(ah, is2ghz);
4165 ar9003_hw_ant_ctrl_apply(ah, is2ghz);
4166 ar9003_hw_drive_strength_apply(ah);
4167 ar9003_hw_xlna_bias_strength_apply(ah, is2ghz);
4168 ar9003_hw_atten_apply(ah, chan);
4169 ar9003_hw_quick_drop_apply(ah, chan->channel);
4170 if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && !AR_SREV_9531(ah))
4171 ar9003_hw_internal_regulator_apply(ah);
4172 ar9003_hw_apply_tuning_caps(ah);
4173 ar9003_hw_apply_minccapwr_thresh(ah, chan);
4174 ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz);
4175 ar9003_hw_thermometer_apply(ah);
4176 ar9003_hw_thermo_cal_apply(ah);
4177}
4178
4179static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah,
4180 struct ath9k_channel *chan)
4181{
4182}
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193static int ar9003_hw_power_interpolate(int32_t x,
4194 int32_t *px, int32_t *py, u_int16_t np)
4195{
4196 int ip = 0;
4197 int lx = 0, ly = 0, lhave = 0;
4198 int hx = 0, hy = 0, hhave = 0;
4199 int dx = 0;
4200 int y = 0;
4201
4202 lhave = 0;
4203 hhave = 0;
4204
4205
4206 for (ip = 0; ip < np; ip++) {
4207 dx = x - px[ip];
4208
4209
4210 if (dx <= 0) {
4211 if (!hhave || dx > (x - hx)) {
4212
4213 hx = px[ip];
4214 hy = py[ip];
4215 hhave = 1;
4216 }
4217 }
4218
4219 if (dx >= 0) {
4220 if (!lhave || dx < (x - lx)) {
4221
4222 lx = px[ip];
4223 ly = py[ip];
4224 lhave = 1;
4225 }
4226 }
4227 }
4228
4229
4230 if (lhave) {
4231
4232 if (hhave) {
4233
4234 if (hx == lx)
4235 y = ly;
4236 else
4237 y = interpolate(x, lx, hx, ly, hy);
4238 } else
4239 y = ly;
4240 } else if (hhave)
4241 y = hy;
4242 else
4243 y = -(1 << 30);
4244 return y;
4245}
4246
4247static u8 ar9003_hw_eeprom_get_tgt_pwr(struct ath_hw *ah,
4248 u16 rateIndex, u16 freq, bool is2GHz)
4249{
4250 u16 numPiers, i;
4251 s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
4252 s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
4253 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4254 struct cal_tgt_pow_legacy *pEepromTargetPwr;
4255 u8 *pFreqBin;
4256
4257 if (is2GHz) {
4258 numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
4259 pEepromTargetPwr = eep->calTargetPower2G;
4260 pFreqBin = eep->calTarget_freqbin_2G;
4261 } else {
4262 numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
4263 pEepromTargetPwr = eep->calTargetPower5G;
4264 pFreqBin = eep->calTarget_freqbin_5G;
4265 }
4266
4267
4268
4269
4270
4271 for (i = 0; i < numPiers; i++) {
4272 freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4273 targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
4274 }
4275
4276
4277 return (u8) ar9003_hw_power_interpolate((s32) freq,
4278 freqArray,
4279 targetPowerArray, numPiers);
4280}
4281
4282static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(struct ath_hw *ah,
4283 u16 rateIndex,
4284 u16 freq, bool is2GHz)
4285{
4286 u16 numPiers, i;
4287 s32 targetPowerArray[AR9300_NUM_5G_20_TARGET_POWERS];
4288 s32 freqArray[AR9300_NUM_5G_20_TARGET_POWERS];
4289 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4290 struct cal_tgt_pow_ht *pEepromTargetPwr;
4291 u8 *pFreqBin;
4292
4293 if (is2GHz) {
4294 numPiers = AR9300_NUM_2G_20_TARGET_POWERS;
4295 pEepromTargetPwr = eep->calTargetPower2GHT20;
4296 pFreqBin = eep->calTarget_freqbin_2GHT20;
4297 } else {
4298 numPiers = AR9300_NUM_5G_20_TARGET_POWERS;
4299 pEepromTargetPwr = eep->calTargetPower5GHT20;
4300 pFreqBin = eep->calTarget_freqbin_5GHT20;
4301 }
4302
4303
4304
4305
4306
4307 for (i = 0; i < numPiers; i++) {
4308 freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4309 targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
4310 }
4311
4312
4313 return (u8) ar9003_hw_power_interpolate((s32) freq,
4314 freqArray,
4315 targetPowerArray, numPiers);
4316}
4317
4318static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(struct ath_hw *ah,
4319 u16 rateIndex,
4320 u16 freq, bool is2GHz)
4321{
4322 u16 numPiers, i;
4323 s32 targetPowerArray[AR9300_NUM_5G_40_TARGET_POWERS];
4324 s32 freqArray[AR9300_NUM_5G_40_TARGET_POWERS];
4325 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4326 struct cal_tgt_pow_ht *pEepromTargetPwr;
4327 u8 *pFreqBin;
4328
4329 if (is2GHz) {
4330 numPiers = AR9300_NUM_2G_40_TARGET_POWERS;
4331 pEepromTargetPwr = eep->calTargetPower2GHT40;
4332 pFreqBin = eep->calTarget_freqbin_2GHT40;
4333 } else {
4334 numPiers = AR9300_NUM_5G_40_TARGET_POWERS;
4335 pEepromTargetPwr = eep->calTargetPower5GHT40;
4336 pFreqBin = eep->calTarget_freqbin_5GHT40;
4337 }
4338
4339
4340
4341
4342
4343 for (i = 0; i < numPiers; i++) {
4344 freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4345 targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
4346 }
4347
4348
4349 return (u8) ar9003_hw_power_interpolate((s32) freq,
4350 freqArray,
4351 targetPowerArray, numPiers);
4352}
4353
4354static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(struct ath_hw *ah,
4355 u16 rateIndex, u16 freq)
4356{
4357 u16 numPiers = AR9300_NUM_2G_CCK_TARGET_POWERS, i;
4358 s32 targetPowerArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
4359 s32 freqArray[AR9300_NUM_2G_CCK_TARGET_POWERS];
4360 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4361 struct cal_tgt_pow_legacy *pEepromTargetPwr = eep->calTargetPowerCck;
4362 u8 *pFreqBin = eep->calTarget_freqbin_Cck;
4363
4364
4365
4366
4367
4368 for (i = 0; i < numPiers; i++) {
4369 freqArray[i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
4370 targetPowerArray[i] = pEepromTargetPwr[i].tPow2x[rateIndex];
4371 }
4372
4373
4374 return (u8) ar9003_hw_power_interpolate((s32) freq,
4375 freqArray,
4376 targetPowerArray, numPiers);
4377}
4378
4379
4380static int ar9003_hw_tx_power_regwrite(struct ath_hw *ah, u8 * pPwrArray)
4381{
4382#define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
4383
4384 REG_WRITE(ah, AR_PHY_TX_FORCED_GAIN, 0);
4385
4386
4387
4388
4389 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(0),
4390 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
4391 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) |
4392 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
4393 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
4394
4395
4396 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(1),
4397 POW_SM(pPwrArray[ALL_TARGET_LEGACY_54], 24) |
4398 POW_SM(pPwrArray[ALL_TARGET_LEGACY_48], 16) |
4399 POW_SM(pPwrArray[ALL_TARGET_LEGACY_36], 8) |
4400 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
4401
4402
4403
4404
4405 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(2),
4406 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 24) |
4407 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
4408
4409 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0));
4410
4411
4412 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(3),
4413 POW_SM(pPwrArray[ALL_TARGET_LEGACY_11S], 24) |
4414 POW_SM(pPwrArray[ALL_TARGET_LEGACY_11L], 16) |
4415 POW_SM(pPwrArray[ALL_TARGET_LEGACY_5S], 8) |
4416 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
4417 );
4418
4419
4420
4421
4422 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(8),
4423 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
4424 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
4425 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
4426 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
4427 );
4428
4429
4430
4431
4432 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(4),
4433 POW_SM(pPwrArray[ALL_TARGET_HT20_5], 24) |
4434 POW_SM(pPwrArray[ALL_TARGET_HT20_4], 16) |
4435 POW_SM(pPwrArray[ALL_TARGET_HT20_1_3_9_11_17_19], 8) |
4436 POW_SM(pPwrArray[ALL_TARGET_HT20_0_8_16], 0)
4437 );
4438
4439
4440 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(5),
4441 POW_SM(pPwrArray[ALL_TARGET_HT20_13], 24) |
4442 POW_SM(pPwrArray[ALL_TARGET_HT20_12], 16) |
4443 POW_SM(pPwrArray[ALL_TARGET_HT20_7], 8) |
4444 POW_SM(pPwrArray[ALL_TARGET_HT20_6], 0)
4445 );
4446
4447
4448 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(9),
4449 POW_SM(pPwrArray[ALL_TARGET_HT20_21], 24) |
4450 POW_SM(pPwrArray[ALL_TARGET_HT20_20], 16) |
4451 POW_SM(pPwrArray[ALL_TARGET_HT20_15], 8) |
4452 POW_SM(pPwrArray[ALL_TARGET_HT20_14], 0)
4453 );
4454
4455
4456
4457
4458 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(10),
4459 POW_SM(pPwrArray[ALL_TARGET_HT40_23], 24) |
4460 POW_SM(pPwrArray[ALL_TARGET_HT40_22], 16) |
4461 POW_SM(pPwrArray[ALL_TARGET_HT20_23], 8) |
4462 POW_SM(pPwrArray[ALL_TARGET_HT20_22], 0)
4463 );
4464
4465
4466
4467
4468
4469
4470 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(6),
4471 POW_SM(pPwrArray[ALL_TARGET_HT40_5], 24) |
4472 POW_SM(pPwrArray[ALL_TARGET_HT40_4], 16) |
4473 POW_SM(pPwrArray[ALL_TARGET_HT40_1_3_9_11_17_19], 8) |
4474 POW_SM(pPwrArray[ALL_TARGET_HT40_0_8_16], 0)
4475 );
4476
4477
4478 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(7),
4479 POW_SM(pPwrArray[ALL_TARGET_HT40_13], 24) |
4480 POW_SM(pPwrArray[ALL_TARGET_HT40_12], 16) |
4481 POW_SM(pPwrArray[ALL_TARGET_HT40_7], 8) |
4482 POW_SM(pPwrArray[ALL_TARGET_HT40_6], 0)
4483 );
4484
4485
4486 REG_WRITE(ah, AR_PHY_POWER_TX_RATE(11),
4487 POW_SM(pPwrArray[ALL_TARGET_HT40_21], 24) |
4488 POW_SM(pPwrArray[ALL_TARGET_HT40_20], 16) |
4489 POW_SM(pPwrArray[ALL_TARGET_HT40_15], 8) |
4490 POW_SM(pPwrArray[ALL_TARGET_HT40_14], 0)
4491 );
4492
4493 return 0;
4494#undef POW_SM
4495}
4496
4497static void ar9003_hw_get_legacy_target_powers(struct ath_hw *ah, u16 freq,
4498 u8 *targetPowerValT2,
4499 bool is2GHz)
4500{
4501 targetPowerValT2[ALL_TARGET_LEGACY_6_24] =
4502 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_6_24, freq,
4503 is2GHz);
4504 targetPowerValT2[ALL_TARGET_LEGACY_36] =
4505 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_36, freq,
4506 is2GHz);
4507 targetPowerValT2[ALL_TARGET_LEGACY_48] =
4508 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_48, freq,
4509 is2GHz);
4510 targetPowerValT2[ALL_TARGET_LEGACY_54] =
4511 ar9003_hw_eeprom_get_tgt_pwr(ah, LEGACY_TARGET_RATE_54, freq,
4512 is2GHz);
4513}
4514
4515static void ar9003_hw_get_cck_target_powers(struct ath_hw *ah, u16 freq,
4516 u8 *targetPowerValT2)
4517{
4518 targetPowerValT2[ALL_TARGET_LEGACY_1L_5L] =
4519 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_1L_5L,
4520 freq);
4521 targetPowerValT2[ALL_TARGET_LEGACY_5S] =
4522 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_5S, freq);
4523 targetPowerValT2[ALL_TARGET_LEGACY_11L] =
4524 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11L, freq);
4525 targetPowerValT2[ALL_TARGET_LEGACY_11S] =
4526 ar9003_hw_eeprom_get_cck_tgt_pwr(ah, LEGACY_TARGET_RATE_11S, freq);
4527}
4528
4529static void ar9003_hw_get_ht20_target_powers(struct ath_hw *ah, u16 freq,
4530 u8 *targetPowerValT2, bool is2GHz)
4531{
4532 targetPowerValT2[ALL_TARGET_HT20_0_8_16] =
4533 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
4534 is2GHz);
4535 targetPowerValT2[ALL_TARGET_HT20_1_3_9_11_17_19] =
4536 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
4537 freq, is2GHz);
4538 targetPowerValT2[ALL_TARGET_HT20_4] =
4539 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
4540 is2GHz);
4541 targetPowerValT2[ALL_TARGET_HT20_5] =
4542 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
4543 is2GHz);
4544 targetPowerValT2[ALL_TARGET_HT20_6] =
4545 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
4546 is2GHz);
4547 targetPowerValT2[ALL_TARGET_HT20_7] =
4548 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
4549 is2GHz);
4550 targetPowerValT2[ALL_TARGET_HT20_12] =
4551 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
4552 is2GHz);
4553 targetPowerValT2[ALL_TARGET_HT20_13] =
4554 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
4555 is2GHz);
4556 targetPowerValT2[ALL_TARGET_HT20_14] =
4557 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
4558 is2GHz);
4559 targetPowerValT2[ALL_TARGET_HT20_15] =
4560 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
4561 is2GHz);
4562 targetPowerValT2[ALL_TARGET_HT20_20] =
4563 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
4564 is2GHz);
4565 targetPowerValT2[ALL_TARGET_HT20_21] =
4566 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
4567 is2GHz);
4568 targetPowerValT2[ALL_TARGET_HT20_22] =
4569 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
4570 is2GHz);
4571 targetPowerValT2[ALL_TARGET_HT20_23] =
4572 ar9003_hw_eeprom_get_ht20_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
4573 is2GHz);
4574}
4575
4576static void ar9003_hw_get_ht40_target_powers(struct ath_hw *ah,
4577 u16 freq,
4578 u8 *targetPowerValT2,
4579 bool is2GHz)
4580{
4581
4582 u8 ht40PowerIncForPdadc = 0;
4583
4584 targetPowerValT2[ALL_TARGET_HT40_0_8_16] =
4585 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_0_8_16, freq,
4586 is2GHz) + ht40PowerIncForPdadc;
4587 targetPowerValT2[ALL_TARGET_HT40_1_3_9_11_17_19] =
4588 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_1_3_9_11_17_19,
4589 freq,
4590 is2GHz) + ht40PowerIncForPdadc;
4591 targetPowerValT2[ALL_TARGET_HT40_4] =
4592 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_4, freq,
4593 is2GHz) + ht40PowerIncForPdadc;
4594 targetPowerValT2[ALL_TARGET_HT40_5] =
4595 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_5, freq,
4596 is2GHz) + ht40PowerIncForPdadc;
4597 targetPowerValT2[ALL_TARGET_HT40_6] =
4598 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_6, freq,
4599 is2GHz) + ht40PowerIncForPdadc;
4600 targetPowerValT2[ALL_TARGET_HT40_7] =
4601 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_7, freq,
4602 is2GHz) + ht40PowerIncForPdadc;
4603 targetPowerValT2[ALL_TARGET_HT40_12] =
4604 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_12, freq,
4605 is2GHz) + ht40PowerIncForPdadc;
4606 targetPowerValT2[ALL_TARGET_HT40_13] =
4607 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_13, freq,
4608 is2GHz) + ht40PowerIncForPdadc;
4609 targetPowerValT2[ALL_TARGET_HT40_14] =
4610 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_14, freq,
4611 is2GHz) + ht40PowerIncForPdadc;
4612 targetPowerValT2[ALL_TARGET_HT40_15] =
4613 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_15, freq,
4614 is2GHz) + ht40PowerIncForPdadc;
4615 targetPowerValT2[ALL_TARGET_HT40_20] =
4616 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_20, freq,
4617 is2GHz) + ht40PowerIncForPdadc;
4618 targetPowerValT2[ALL_TARGET_HT40_21] =
4619 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_21, freq,
4620 is2GHz) + ht40PowerIncForPdadc;
4621 targetPowerValT2[ALL_TARGET_HT40_22] =
4622 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_22, freq,
4623 is2GHz) + ht40PowerIncForPdadc;
4624 targetPowerValT2[ALL_TARGET_HT40_23] =
4625 ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
4626 is2GHz) + ht40PowerIncForPdadc;
4627}
4628
4629static void ar9003_hw_get_target_power_eeprom(struct ath_hw *ah,
4630 struct ath9k_channel *chan,
4631 u8 *targetPowerValT2)
4632{
4633 bool is2GHz = IS_CHAN_2GHZ(chan);
4634 unsigned int i = 0;
4635 struct ath_common *common = ath9k_hw_common(ah);
4636 u16 freq = chan->channel;
4637
4638 if (is2GHz)
4639 ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
4640
4641 ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
4642 ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
4643
4644 if (IS_CHAN_HT40(chan))
4645 ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
4646 is2GHz);
4647
4648 for (i = 0; i < ar9300RateSize; i++) {
4649 ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
4650 i, targetPowerValT2[i]);
4651 }
4652}
4653
4654static int ar9003_hw_cal_pier_get(struct ath_hw *ah,
4655 int mode,
4656 int ipier,
4657 int ichain,
4658 int *pfrequency,
4659 int *pcorrection,
4660 int *ptemperature, int *pvoltage)
4661{
4662 u8 *pCalPier;
4663 struct ar9300_cal_data_per_freq_op_loop *pCalPierStruct;
4664 int is2GHz;
4665 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4666 struct ath_common *common = ath9k_hw_common(ah);
4667
4668 if (ichain >= AR9300_MAX_CHAINS) {
4669 ath_dbg(common, EEPROM,
4670 "Invalid chain index, must be less than %d\n",
4671 AR9300_MAX_CHAINS);
4672 return -1;
4673 }
4674
4675 if (mode) {
4676 if (ipier >= AR9300_NUM_5G_CAL_PIERS) {
4677 ath_dbg(common, EEPROM,
4678 "Invalid 5GHz cal pier index, must be less than %d\n",
4679 AR9300_NUM_5G_CAL_PIERS);
4680 return -1;
4681 }
4682 pCalPier = &(eep->calFreqPier5G[ipier]);
4683 pCalPierStruct = &(eep->calPierData5G[ichain][ipier]);
4684 is2GHz = 0;
4685 } else {
4686 if (ipier >= AR9300_NUM_2G_CAL_PIERS) {
4687 ath_dbg(common, EEPROM,
4688 "Invalid 2GHz cal pier index, must be less than %d\n",
4689 AR9300_NUM_2G_CAL_PIERS);
4690 return -1;
4691 }
4692
4693 pCalPier = &(eep->calFreqPier2G[ipier]);
4694 pCalPierStruct = &(eep->calPierData2G[ichain][ipier]);
4695 is2GHz = 1;
4696 }
4697
4698 *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2GHz);
4699 *pcorrection = pCalPierStruct->refPower;
4700 *ptemperature = pCalPierStruct->tempMeas;
4701 *pvoltage = pCalPierStruct->voltMeas;
4702
4703 return 0;
4704}
4705
4706static void ar9003_hw_power_control_override(struct ath_hw *ah,
4707 int frequency,
4708 int *correction,
4709 int *voltage, int *temperature)
4710{
4711 int temp_slope = 0, temp_slope1 = 0, temp_slope2 = 0;
4712 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4713 int f[8], t[8], t1[3], t2[3], i;
4714
4715 REG_RMW(ah, AR_PHY_TPC_11_B0,
4716 (correction[0] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
4717 AR_PHY_TPC_OLPC_GAIN_DELTA);
4718 if (ah->caps.tx_chainmask & BIT(1))
4719 REG_RMW(ah, AR_PHY_TPC_11_B1,
4720 (correction[1] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
4721 AR_PHY_TPC_OLPC_GAIN_DELTA);
4722 if (ah->caps.tx_chainmask & BIT(2))
4723 REG_RMW(ah, AR_PHY_TPC_11_B2,
4724 (correction[2] << AR_PHY_TPC_OLPC_GAIN_DELTA_S),
4725 AR_PHY_TPC_OLPC_GAIN_DELTA);
4726
4727
4728 REG_RMW(ah, AR_PHY_TPC_6_B0,
4729 (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
4730 AR_PHY_TPC_6_ERROR_EST_MODE);
4731 if (ah->caps.tx_chainmask & BIT(1))
4732 REG_RMW(ah, AR_PHY_TPC_6_B1,
4733 (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
4734 AR_PHY_TPC_6_ERROR_EST_MODE);
4735 if (ah->caps.tx_chainmask & BIT(2))
4736 REG_RMW(ah, AR_PHY_TPC_6_B2,
4737 (3 << AR_PHY_TPC_6_ERROR_EST_MODE_S),
4738 AR_PHY_TPC_6_ERROR_EST_MODE);
4739
4740
4741
4742
4743
4744 if (frequency < 4000) {
4745 temp_slope = eep->modalHeader2G.tempSlope;
4746 } else {
4747 if (AR_SREV_9550(ah)) {
4748 t[0] = eep->base_ext1.tempslopextension[2];
4749 t1[0] = eep->base_ext1.tempslopextension[3];
4750 t2[0] = eep->base_ext1.tempslopextension[4];
4751 f[0] = 5180;
4752
4753 t[1] = eep->modalHeader5G.tempSlope;
4754 t1[1] = eep->base_ext1.tempslopextension[0];
4755 t2[1] = eep->base_ext1.tempslopextension[1];
4756 f[1] = 5500;
4757
4758 t[2] = eep->base_ext1.tempslopextension[5];
4759 t1[2] = eep->base_ext1.tempslopextension[6];
4760 t2[2] = eep->base_ext1.tempslopextension[7];
4761 f[2] = 5785;
4762
4763 temp_slope = ar9003_hw_power_interpolate(frequency,
4764 f, t, 3);
4765 temp_slope1 = ar9003_hw_power_interpolate(frequency,
4766 f, t1, 3);
4767 temp_slope2 = ar9003_hw_power_interpolate(frequency,
4768 f, t2, 3);
4769
4770 goto tempslope;
4771 }
4772
4773 if ((eep->baseEepHeader.miscConfiguration & 0x20) != 0) {
4774 for (i = 0; i < 8; i++) {
4775 t[i] = eep->base_ext1.tempslopextension[i];
4776 f[i] = FBIN2FREQ(eep->calFreqPier5G[i], 0);
4777 }
4778 temp_slope = ar9003_hw_power_interpolate((s32) frequency,
4779 f, t, 8);
4780 } else if (eep->base_ext2.tempSlopeLow != 0) {
4781 t[0] = eep->base_ext2.tempSlopeLow;
4782 f[0] = 5180;
4783 t[1] = eep->modalHeader5G.tempSlope;
4784 f[1] = 5500;
4785 t[2] = eep->base_ext2.tempSlopeHigh;
4786 f[2] = 5785;
4787 temp_slope = ar9003_hw_power_interpolate((s32) frequency,
4788 f, t, 3);
4789 } else {
4790 temp_slope = eep->modalHeader5G.tempSlope;
4791 }
4792 }
4793
4794tempslope:
4795 if (AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
4796 u8 txmask = (eep->baseEepHeader.txrxMask & 0xf0) >> 4;
4797
4798
4799
4800
4801
4802 if (eep->baseEepHeader.featureEnable & 0x1) {
4803 if (frequency < 4000) {
4804 if (txmask & BIT(0))
4805 REG_RMW_FIELD(ah, AR_PHY_TPC_19,
4806 AR_PHY_TPC_19_ALPHA_THERM,
4807 eep->base_ext2.tempSlopeLow);
4808 if (txmask & BIT(1))
4809 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
4810 AR_PHY_TPC_19_ALPHA_THERM,
4811 temp_slope);
4812 if (txmask & BIT(2))
4813 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
4814 AR_PHY_TPC_19_ALPHA_THERM,
4815 eep->base_ext2.tempSlopeHigh);
4816 } else {
4817 if (txmask & BIT(0))
4818 REG_RMW_FIELD(ah, AR_PHY_TPC_19,
4819 AR_PHY_TPC_19_ALPHA_THERM,
4820 temp_slope);
4821 if (txmask & BIT(1))
4822 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
4823 AR_PHY_TPC_19_ALPHA_THERM,
4824 temp_slope1);
4825 if (txmask & BIT(2))
4826 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
4827 AR_PHY_TPC_19_ALPHA_THERM,
4828 temp_slope2);
4829 }
4830 } else {
4831
4832
4833
4834
4835 if (txmask & BIT(0))
4836 REG_RMW_FIELD(ah, AR_PHY_TPC_19,
4837 AR_PHY_TPC_19_ALPHA_THERM, 0);
4838 if (txmask & BIT(1))
4839 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
4840 AR_PHY_TPC_19_ALPHA_THERM, 0);
4841 if (txmask & BIT(2))
4842 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B2,
4843 AR_PHY_TPC_19_ALPHA_THERM, 0);
4844 }
4845 } else {
4846 REG_RMW_FIELD(ah, AR_PHY_TPC_19,
4847 AR_PHY_TPC_19_ALPHA_THERM, temp_slope);
4848 }
4849
4850 if (AR_SREV_9462_20_OR_LATER(ah))
4851 REG_RMW_FIELD(ah, AR_PHY_TPC_19_B1,
4852 AR_PHY_TPC_19_B1_ALPHA_THERM, temp_slope);
4853
4854
4855 REG_RMW_FIELD(ah, AR_PHY_TPC_18, AR_PHY_TPC_18_THERM_CAL_VALUE,
4856 temperature[0]);
4857}
4858
4859
4860static int ar9003_hw_calibration_apply(struct ath_hw *ah, int frequency)
4861{
4862 int ichain, ipier, npier;
4863 int mode;
4864 int lfrequency[AR9300_MAX_CHAINS],
4865 lcorrection[AR9300_MAX_CHAINS],
4866 ltemperature[AR9300_MAX_CHAINS], lvoltage[AR9300_MAX_CHAINS];
4867 int hfrequency[AR9300_MAX_CHAINS],
4868 hcorrection[AR9300_MAX_CHAINS],
4869 htemperature[AR9300_MAX_CHAINS], hvoltage[AR9300_MAX_CHAINS];
4870 int fdiff;
4871 int correction[AR9300_MAX_CHAINS],
4872 voltage[AR9300_MAX_CHAINS], temperature[AR9300_MAX_CHAINS];
4873 int pfrequency, pcorrection, ptemperature, pvoltage;
4874 struct ath_common *common = ath9k_hw_common(ah);
4875
4876 mode = (frequency >= 4000);
4877 if (mode)
4878 npier = AR9300_NUM_5G_CAL_PIERS;
4879 else
4880 npier = AR9300_NUM_2G_CAL_PIERS;
4881
4882 for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
4883 lfrequency[ichain] = 0;
4884 hfrequency[ichain] = 100000;
4885 }
4886
4887 for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
4888 for (ipier = 0; ipier < npier; ipier++) {
4889 if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
4890 &pfrequency, &pcorrection,
4891 &ptemperature, &pvoltage)) {
4892 fdiff = frequency - pfrequency;
4893
4894
4895
4896
4897
4898 if (fdiff <= 0) {
4899 if (hfrequency[ichain] <= 0 ||
4900 hfrequency[ichain] >= 100000 ||
4901 fdiff >
4902 (frequency - hfrequency[ichain])) {
4903
4904
4905
4906
4907 hfrequency[ichain] = pfrequency;
4908 hcorrection[ichain] =
4909 pcorrection;
4910 htemperature[ichain] =
4911 ptemperature;
4912 hvoltage[ichain] = pvoltage;
4913 }
4914 }
4915 if (fdiff >= 0) {
4916 if (lfrequency[ichain] <= 0
4917 || fdiff <
4918 (frequency - lfrequency[ichain])) {
4919
4920
4921
4922
4923 lfrequency[ichain] = pfrequency;
4924 lcorrection[ichain] =
4925 pcorrection;
4926 ltemperature[ichain] =
4927 ptemperature;
4928 lvoltage[ichain] = pvoltage;
4929 }
4930 }
4931 }
4932 }
4933 }
4934
4935
4936 for (ichain = 0; ichain < AR9300_MAX_CHAINS; ichain++) {
4937 ath_dbg(common, EEPROM, "ch=%d f=%d low=%d %d h=%d %d\n",
4938 ichain, frequency, lfrequency[ichain],
4939 lcorrection[ichain], hfrequency[ichain],
4940 hcorrection[ichain]);
4941
4942 if (hfrequency[ichain] == lfrequency[ichain]) {
4943 correction[ichain] = lcorrection[ichain];
4944 voltage[ichain] = lvoltage[ichain];
4945 temperature[ichain] = ltemperature[ichain];
4946 }
4947
4948 else if (frequency - lfrequency[ichain] < 1000) {
4949
4950 if (hfrequency[ichain] - frequency < 1000) {
4951
4952 correction[ichain] = interpolate(frequency,
4953 lfrequency[ichain],
4954 hfrequency[ichain],
4955 lcorrection[ichain],
4956 hcorrection[ichain]);
4957
4958 temperature[ichain] = interpolate(frequency,
4959 lfrequency[ichain],
4960 hfrequency[ichain],
4961 ltemperature[ichain],
4962 htemperature[ichain]);
4963
4964 voltage[ichain] = interpolate(frequency,
4965 lfrequency[ichain],
4966 hfrequency[ichain],
4967 lvoltage[ichain],
4968 hvoltage[ichain]);
4969 }
4970
4971 else {
4972 correction[ichain] = lcorrection[ichain];
4973 temperature[ichain] = ltemperature[ichain];
4974 voltage[ichain] = lvoltage[ichain];
4975 }
4976 }
4977
4978 else if (hfrequency[ichain] - frequency < 1000) {
4979 correction[ichain] = hcorrection[ichain];
4980 temperature[ichain] = htemperature[ichain];
4981 voltage[ichain] = hvoltage[ichain];
4982 } else {
4983 correction[ichain] = 0;
4984 temperature[ichain] = 0;
4985 voltage[ichain] = 0;
4986 }
4987 }
4988
4989 ar9003_hw_power_control_override(ah, frequency, correction, voltage,
4990 temperature);
4991
4992 ath_dbg(common, EEPROM,
4993 "for frequency=%d, calibration correction = %d %d %d\n",
4994 frequency, correction[0], correction[1], correction[2]);
4995
4996 return 0;
4997}
4998
4999static u16 ar9003_hw_get_direct_edge_power(struct ar9300_eeprom *eep,
5000 int idx,
5001 int edge,
5002 bool is2GHz)
5003{
5004 struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
5005 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
5006
5007 if (is2GHz)
5008 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge]);
5009 else
5010 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge]);
5011}
5012
5013static u16 ar9003_hw_get_indirect_edge_power(struct ar9300_eeprom *eep,
5014 int idx,
5015 unsigned int edge,
5016 u16 freq,
5017 bool is2GHz)
5018{
5019 struct cal_ctl_data_2g *ctl_2g = eep->ctlPowerData_2G;
5020 struct cal_ctl_data_5g *ctl_5g = eep->ctlPowerData_5G;
5021
5022 u8 *ctl_freqbin = is2GHz ?
5023 &eep->ctl_freqbin_2G[idx][0] :
5024 &eep->ctl_freqbin_5G[idx][0];
5025
5026 if (is2GHz) {
5027 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
5028 CTL_EDGE_FLAGS(ctl_2g[idx].ctlEdges[edge - 1]))
5029 return CTL_EDGE_TPOWER(ctl_2g[idx].ctlEdges[edge - 1]);
5030 } else {
5031 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
5032 CTL_EDGE_FLAGS(ctl_5g[idx].ctlEdges[edge - 1]))
5033 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
5034 }
5035
5036 return MAX_RATE_POWER;
5037}
5038
5039
5040
5041
5042static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
5043 u16 freq, int idx, bool is2GHz)
5044{
5045 u16 twiceMaxEdgePower = MAX_RATE_POWER;
5046 u8 *ctl_freqbin = is2GHz ?
5047 &eep->ctl_freqbin_2G[idx][0] :
5048 &eep->ctl_freqbin_5G[idx][0];
5049 u16 num_edges = is2GHz ?
5050 AR9300_NUM_BAND_EDGES_2G : AR9300_NUM_BAND_EDGES_5G;
5051 unsigned int edge;
5052
5053
5054 for (edge = 0;
5055 (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
5056 edge++) {
5057
5058
5059
5060
5061 if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
5062 twiceMaxEdgePower =
5063 ar9003_hw_get_direct_edge_power(eep, idx,
5064 edge, is2GHz);
5065 break;
5066 } else if ((edge > 0) &&
5067 (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
5068 is2GHz))) {
5069 twiceMaxEdgePower =
5070 ar9003_hw_get_indirect_edge_power(eep, idx,
5071 edge, freq,
5072 is2GHz);
5073
5074
5075
5076
5077 break;
5078 }
5079 }
5080
5081 if (is2GHz && !twiceMaxEdgePower)
5082 twiceMaxEdgePower = 60;
5083
5084 return twiceMaxEdgePower;
5085}
5086
5087static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
5088 struct ath9k_channel *chan,
5089 u8 *pPwrArray, u16 cfgCtl,
5090 u8 antenna_reduction,
5091 u16 powerLimit)
5092{
5093 struct ath_common *common = ath9k_hw_common(ah);
5094 struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
5095 u16 twiceMaxEdgePower;
5096 int i;
5097 u16 scaledPower = 0, minCtlPower;
5098 static const u16 ctlModesFor11a[] = {
5099 CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
5100 };
5101 static const u16 ctlModesFor11g[] = {
5102 CTL_11B, CTL_11G, CTL_2GHT20, CTL_11B_EXT,
5103 CTL_11G_EXT, CTL_2GHT40
5104 };
5105 u16 numCtlModes;
5106 const u16 *pCtlMode;
5107 u16 ctlMode, freq;
5108 struct chan_centers centers;
5109 u8 *ctlIndex;
5110 u8 ctlNum;
5111 u16 twiceMinEdgePower;
5112 bool is2ghz = IS_CHAN_2GHZ(chan);
5113
5114 ath9k_hw_get_channel_centers(ah, chan, ¢ers);
5115 scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
5116 antenna_reduction);
5117
5118 if (is2ghz) {
5119
5120
5121 numCtlModes =
5122 ARRAY_SIZE(ctlModesFor11g) -
5123 SUB_NUM_CTL_MODES_AT_2G_40;
5124 pCtlMode = ctlModesFor11g;
5125 if (IS_CHAN_HT40(chan))
5126
5127 numCtlModes = ARRAY_SIZE(ctlModesFor11g);
5128 } else {
5129
5130
5131 numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
5132 SUB_NUM_CTL_MODES_AT_5G_40;
5133 pCtlMode = ctlModesFor11a;
5134 if (IS_CHAN_HT40(chan))
5135
5136 numCtlModes = ARRAY_SIZE(ctlModesFor11a);
5137 }
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
5148 bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
5149 (pCtlMode[ctlMode] == CTL_2GHT40);
5150 if (isHt40CtlMode)
5151 freq = centers.synth_center;
5152 else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
5153 freq = centers.ext_center;
5154 else
5155 freq = centers.ctl_center;
5156
5157 ath_dbg(common, REGULATORY,
5158 "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n",
5159 ctlMode, numCtlModes, isHt40CtlMode,
5160 (pCtlMode[ctlMode] & EXT_ADDITIVE));
5161
5162
5163 if (is2ghz) {
5164 ctlIndex = pEepData->ctlIndex_2G;
5165 ctlNum = AR9300_NUM_CTLS_2G;
5166 } else {
5167 ctlIndex = pEepData->ctlIndex_5G;
5168 ctlNum = AR9300_NUM_CTLS_5G;
5169 }
5170
5171 twiceMaxEdgePower = MAX_RATE_POWER;
5172 for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
5173 ath_dbg(common, REGULATORY,
5174 "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
5175 i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
5176 chan->channel);
5177
5178
5179
5180
5181
5182
5183 if ((((cfgCtl & ~CTL_MODE_M) |
5184 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
5185 ctlIndex[i]) ||
5186 (((cfgCtl & ~CTL_MODE_M) |
5187 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
5188 ((ctlIndex[i] & CTL_MODE_M) |
5189 SD_NO_CTL))) {
5190 twiceMinEdgePower =
5191 ar9003_hw_get_max_edge_power(pEepData,
5192 freq, i,
5193 is2ghz);
5194
5195 if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL)
5196
5197
5198
5199
5200
5201 twiceMaxEdgePower =
5202 min(twiceMaxEdgePower,
5203 twiceMinEdgePower);
5204 else {
5205
5206 twiceMaxEdgePower = twiceMinEdgePower;
5207 break;
5208 }
5209 }
5210 }
5211
5212 minCtlPower = (u8)min(twiceMaxEdgePower, scaledPower);
5213
5214 ath_dbg(common, REGULATORY,
5215 "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n",
5216 ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
5217 scaledPower, minCtlPower);
5218
5219
5220 switch (pCtlMode[ctlMode]) {
5221 case CTL_11B:
5222 for (i = ALL_TARGET_LEGACY_1L_5L;
5223 i <= ALL_TARGET_LEGACY_11S; i++)
5224 pPwrArray[i] = (u8)min((u16)pPwrArray[i],
5225 minCtlPower);
5226 break;
5227 case CTL_11A:
5228 case CTL_11G:
5229 for (i = ALL_TARGET_LEGACY_6_24;
5230 i <= ALL_TARGET_LEGACY_54; i++)
5231 pPwrArray[i] = (u8)min((u16)pPwrArray[i],
5232 minCtlPower);
5233 break;
5234 case CTL_5GHT20:
5235 case CTL_2GHT20:
5236 for (i = ALL_TARGET_HT20_0_8_16;
5237 i <= ALL_TARGET_HT20_23; i++) {
5238 pPwrArray[i] = (u8)min((u16)pPwrArray[i],
5239 minCtlPower);
5240 if (ath9k_hw_mci_is_enabled(ah))
5241 pPwrArray[i] =
5242 (u8)min((u16)pPwrArray[i],
5243 ar9003_mci_get_max_txpower(ah,
5244 pCtlMode[ctlMode]));
5245 }
5246 break;
5247 case CTL_5GHT40:
5248 case CTL_2GHT40:
5249 for (i = ALL_TARGET_HT40_0_8_16;
5250 i <= ALL_TARGET_HT40_23; i++) {
5251 pPwrArray[i] = (u8)min((u16)pPwrArray[i],
5252 minCtlPower);
5253 if (ath9k_hw_mci_is_enabled(ah))
5254 pPwrArray[i] =
5255 (u8)min((u16)pPwrArray[i],
5256 ar9003_mci_get_max_txpower(ah,
5257 pCtlMode[ctlMode]));
5258 }
5259 break;
5260 default:
5261 break;
5262 }
5263 }
5264}
5265
5266static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx)
5267{
5268 u8 mod_idx = mcs_idx % 8;
5269
5270 if (mod_idx <= 3)
5271 return mod_idx ? (base_pwridx + 1) : base_pwridx;
5272 else
5273 return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2;
5274}
5275
5276static void ar9003_paprd_set_txpower(struct ath_hw *ah,
5277 struct ath9k_channel *chan,
5278 u8 *targetPowerValT2)
5279{
5280 int i;
5281
5282 if (!ar9003_is_paprd_enabled(ah))
5283 return;
5284
5285 if (IS_CHAN_HT40(chan))
5286 i = ALL_TARGET_HT40_7;
5287 else
5288 i = ALL_TARGET_HT20_7;
5289
5290 if (IS_CHAN_2GHZ(chan)) {
5291 if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) &&
5292 !AR_SREV_9462(ah) && !AR_SREV_9565(ah)) {
5293 if (IS_CHAN_HT40(chan))
5294 i = ALL_TARGET_HT40_0_8_16;
5295 else
5296 i = ALL_TARGET_HT20_0_8_16;
5297 }
5298 }
5299
5300 ah->paprd_target_power = targetPowerValT2[i];
5301}
5302
5303static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
5304 struct ath9k_channel *chan, u16 cfgCtl,
5305 u8 twiceAntennaReduction,
5306 u8 powerLimit, bool test)
5307{
5308 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
5309 struct ath_common *common = ath9k_hw_common(ah);
5310 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
5311 struct ar9300_modal_eep_header *modal_hdr;
5312 u8 targetPowerValT2[ar9300RateSize];
5313 u8 target_power_val_t2_eep[ar9300RateSize];
5314 unsigned int i = 0, paprd_scale_factor = 0;
5315 u8 pwr_idx, min_pwridx = 0;
5316
5317 memset(targetPowerValT2, 0 , sizeof(targetPowerValT2));
5318
5319
5320
5321
5322 ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
5323
5324 if (ar9003_is_paprd_enabled(ah)) {
5325 if (IS_CHAN_2GHZ(chan))
5326 modal_hdr = &eep->modalHeader2G;
5327 else
5328 modal_hdr = &eep->modalHeader5G;
5329
5330 ah->paprd_ratemask =
5331 le32_to_cpu(modal_hdr->papdRateMaskHt20) &
5332 AR9300_PAPRD_RATE_MASK;
5333
5334 ah->paprd_ratemask_ht40 =
5335 le32_to_cpu(modal_hdr->papdRateMaskHt40) &
5336 AR9300_PAPRD_RATE_MASK;
5337
5338 paprd_scale_factor = ar9003_get_paprd_scale_factor(ah, chan);
5339 min_pwridx = IS_CHAN_HT40(chan) ? ALL_TARGET_HT40_0_8_16 :
5340 ALL_TARGET_HT20_0_8_16;
5341
5342 if (!ah->paprd_table_write_done) {
5343 memcpy(target_power_val_t2_eep, targetPowerValT2,
5344 sizeof(targetPowerValT2));
5345 for (i = 0; i < 24; i++) {
5346 pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx);
5347 if (ah->paprd_ratemask & (1 << i)) {
5348 if (targetPowerValT2[pwr_idx] &&
5349 targetPowerValT2[pwr_idx] ==
5350 target_power_val_t2_eep[pwr_idx])
5351 targetPowerValT2[pwr_idx] -=
5352 paprd_scale_factor;
5353 }
5354 }
5355 }
5356 memcpy(target_power_val_t2_eep, targetPowerValT2,
5357 sizeof(targetPowerValT2));
5358 }
5359
5360 ar9003_hw_set_power_per_rate_table(ah, chan,
5361 targetPowerValT2, cfgCtl,
5362 twiceAntennaReduction,
5363 powerLimit);
5364
5365 if (ar9003_is_paprd_enabled(ah)) {
5366 for (i = 0; i < ar9300RateSize; i++) {
5367 if ((ah->paprd_ratemask & (1 << i)) &&
5368 (abs(targetPowerValT2[i] -
5369 target_power_val_t2_eep[i]) >
5370 paprd_scale_factor)) {
5371 ah->paprd_ratemask &= ~(1 << i);
5372 ath_dbg(common, EEPROM,
5373 "paprd disabled for mcs %d\n", i);
5374 }
5375 }
5376 }
5377
5378 regulatory->max_power_level = 0;
5379 for (i = 0; i < ar9300RateSize; i++) {
5380 if (targetPowerValT2[i] > regulatory->max_power_level)
5381 regulatory->max_power_level = targetPowerValT2[i];
5382 }
5383
5384 ath9k_hw_update_regulatory_maxpower(ah);
5385
5386 if (test)
5387 return;
5388
5389 for (i = 0; i < ar9300RateSize; i++) {
5390 ath_dbg(common, REGULATORY, "TPC[%02d] 0x%08x\n",
5391 i, targetPowerValT2[i]);
5392 }
5393
5394
5395 ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
5396 ar9003_hw_calibration_apply(ah, chan->channel);
5397 ar9003_paprd_set_txpower(ah, chan, targetPowerValT2);
5398}
5399
5400static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah,
5401 u16 i, bool is2GHz)
5402{
5403 return AR_NO_SPUR;
5404}
5405
5406s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah)
5407{
5408 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
5409
5410 return (eep->baseEepHeader.txrxgain >> 4) & 0xf;
5411}
5412
5413s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah)
5414{
5415 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
5416
5417 return (eep->baseEepHeader.txrxgain) & 0xf;
5418}
5419
5420u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is2ghz)
5421{
5422 return ar9003_modal_header(ah, is2ghz)->spurChans;
5423}
5424
5425unsigned int ar9003_get_paprd_scale_factor(struct ath_hw *ah,
5426 struct ath9k_channel *chan)
5427{
5428 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
5429
5430 if (IS_CHAN_2GHZ(chan))
5431 return MS(le32_to_cpu(eep->modalHeader2G.papdRateMaskHt20),
5432 AR9300_PAPRD_SCALE_1);
5433 else {
5434 if (chan->channel >= 5700)
5435 return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt20),
5436 AR9300_PAPRD_SCALE_1);
5437 else if (chan->channel >= 5400)
5438 return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
5439 AR9300_PAPRD_SCALE_2);
5440 else
5441 return MS(le32_to_cpu(eep->modalHeader5G.papdRateMaskHt40),
5442 AR9300_PAPRD_SCALE_1);
5443 }
5444}
5445
5446const struct eeprom_ops eep_ar9300_ops = {
5447 .check_eeprom = ath9k_hw_ar9300_check_eeprom,
5448 .get_eeprom = ath9k_hw_ar9300_get_eeprom,
5449 .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
5450 .dump_eeprom = ath9k_hw_ar9003_dump_eeprom,
5451 .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
5452 .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
5453 .set_board_values = ath9k_hw_ar9300_set_board_values,
5454 .set_addac = ath9k_hw_ar9300_set_addac,
5455 .set_txpower = ath9k_hw_ar9300_set_txpower,
5456 .get_spur_channel = ath9k_hw_ar9300_get_spur_channel
5457};
5458