17 #include <asm/unaligned.h>
22 #define COMP_HDR_LEN 4
23 #define COMP_CKSUM_LEN 2
25 #define LE16(x) __constant_cpu_to_le16(x)
26 #define LE32(x) __constant_cpu_to_le32(x)
29 #define EXT_ADDITIVE (0x8000)
30 #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
31 #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
32 #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
34 #define SUB_NUM_CTL_MODES_AT_5G_40 2
35 #define SUB_NUM_CTL_MODES_AT_2G_40 3
37 #define CTL(_tpower, _flag) ((_tpower) | ((_flag) << 6))
39 #define EEPROM_DATA_LEN_9485 1088
41 static int ar9003_hw_power_interpolate(
int32_t x,
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},
59 .blueToothOptions = 0,
63 .params_for_tuning_caps = {0, 0},
64 .featureEnable = 0x0c,
73 .miscConfiguration = 0,
74 .eepromWriteEnableGpio = 3,
77 .rxBandSelectGpio = 0xff,
84 .antCtrlCommon =
LE32(0x110),
86 .antCtrlCommon2 =
LE32(0x22222),
92 .antCtrlChain = {
LE16(0x150),
LE16(0x150),
LE16(0x150) },
98 .xatten1DB = {0, 0, 0},
104 .xatten1Margin = {0, 0, 0},
112 .spurChans = {0, 0, 0, 0, 0},
118 .noiseFloorThreshCh = {-1, 0, 0},
119 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
122 .txFrameToDataStart = 0x0e,
123 .txFrameToPaOn = 0x0e,
126 .switchSettling = 0x2c,
127 .adcDesiredSize = -30,
130 .txFrameToXpaOn = 0xe,
132 .papdRateMaskHt20 =
LE32(0x0cf0e0e0),
133 .papdRateMaskHt40 =
LE32(0x6cf0e0e0),
134 .xlna_bias_strength = 0,
140 .ant_div_control = 0,
142 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
151 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
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} },
155 .calTarget_freqbin_Cck = {
159 .calTarget_freqbin_2G = {
164 .calTarget_freqbin_2GHT20 = {
169 .calTarget_freqbin_2GHT40 = {
174 .calTargetPowerCck = {
176 { {36, 36, 36, 36} },
177 { {36, 36, 36, 36} },
179 .calTargetPower2G = {
181 { {32, 32, 28, 24} },
182 { {32, 32, 28, 24} },
183 { {32, 32, 28, 24} },
185 .calTargetPower2GHT20 = {
186 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
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} },
190 .calTargetPower2GHT40 = {
191 { {32, 32, 32, 32, 28, 20, 32, 32, 28, 20, 32, 32, 28, 20} },
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} },
196 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
197 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
300 .antCtrlCommon =
LE32(0x110),
302 .antCtrlCommon2 =
LE32(0x22222),
308 .xatten1DB = {0, 0, 0},
314 .xatten1Margin = {0, 0, 0},
318 .spurChans = {0, 0, 0, 0, 0},
320 .noiseFloorThreshCh = {-1, 0, 0},
321 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
324 .txFrameToDataStart = 0x0e,
325 .txFrameToPaOn = 0x0e,
328 .switchSettling = 0x2d,
329 .adcDesiredSize = -30,
332 .txFrameToXpaOn = 0xe,
334 .papdRateMaskHt20 =
LE32(0x0c80c080),
335 .papdRateMaskHt40 =
LE32(0x0080c080),
336 .xlna_bias_strength = 0,
344 .xatten1DBLow = {0, 0, 0},
345 .xatten1MarginLow = {0, 0, 0},
346 .xatten1DBHigh = {0, 0, 0},
347 .xatten1MarginHigh = {0, 0, 0}
392 .calTarget_freqbin_5G = {
402 .calTarget_freqbin_5GHT20 = {
412 .calTarget_freqbin_5GHT40 = {
422 .calTargetPower5G = {
424 { {20, 20, 20, 10} },
425 { {20, 20, 20, 10} },
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} },
433 .calTargetPower5GHT20 = {
438 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
439 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
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} },
447 .calTargetPower5GHT40 = {
452 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
453 { {20, 20, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10, 0, 0} },
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} },
462 0x10, 0x16, 0x18, 0x40, 0x46,
463 0x48, 0x30, 0x36, 0x38
624 .templateVersion = 6,
625 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
626 .custData = {
"x113-023-f0000"},
635 .blueToothOptions = 0,
639 .params_for_tuning_caps = {0, 0},
640 .featureEnable = 0x0d,
649 .miscConfiguration = 0,
650 .eepromWriteEnableGpio = 6,
651 .wlanDisableGpio = 0,
653 .rxBandSelectGpio = 0xff,
660 .antCtrlCommon =
LE32(0x110),
662 .antCtrlCommon2 =
LE32(0x44444),
668 .antCtrlChain = {
LE16(0x150),
LE16(0x150),
LE16(0x150) },
674 .xatten1DB = {0, 0, 0},
680 .xatten1Margin = {0, 0, 0},
688 .spurChans = {
FREQ2FBIN(2464, 1), 0, 0, 0, 0},
694 .noiseFloorThreshCh = {-1, 0, 0},
695 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
698 .txFrameToDataStart = 0x0e,
699 .txFrameToPaOn = 0x0e,
702 .switchSettling = 0x2c,
703 .adcDesiredSize = -30,
706 .txFrameToXpaOn = 0xe,
708 .papdRateMaskHt20 =
LE32(0x0c80c080),
709 .papdRateMaskHt40 =
LE32(0x0080c080),
710 .xlna_bias_strength = 0,
716 .ant_div_control = 0,
718 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
727 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
728 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
729 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
731 .calTarget_freqbin_Cck = {
735 .calTarget_freqbin_2G = {
740 .calTarget_freqbin_2GHT20 = {
745 .calTarget_freqbin_2GHT40 = {
750 .calTargetPowerCck = {
752 { {34, 34, 34, 34} },
753 { {34, 34, 34, 34} },
755 .calTargetPower2G = {
757 { {34, 34, 32, 32} },
758 { {34, 34, 32, 32} },
759 { {34, 34, 32, 32} },
761 .calTargetPower2GHT20 = {
762 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
763 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
764 { {32, 32, 32, 32, 32, 28, 32, 32, 30, 28, 0, 0, 0, 0} },
766 .calTargetPower2GHT40 = {
767 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
768 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
769 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
772 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
773 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
876 .antCtrlCommon =
LE32(0x220),
878 .antCtrlCommon2 =
LE32(0x11111),
884 .xatten1DB = {0, 0, 0},
890 .xatten1Margin = {0, 0, 0},
894 .spurChans = {
FREQ2FBIN(5500, 0), 0, 0, 0, 0},
896 .noiseFloorThreshCh = {-1, 0, 0},
897 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
900 .txFrameToDataStart = 0x0e,
901 .txFrameToPaOn = 0x0e,
904 .switchSettling = 0x2d,
905 .adcDesiredSize = -30,
908 .txFrameToXpaOn = 0xe,
910 .papdRateMaskHt20 =
LE32(0x0cf0e0e0),
911 .papdRateMaskHt40 =
LE32(0x6cf0e0e0),
912 .xlna_bias_strength = 0,
919 .tempSlopeHigh = 105,
920 .xatten1DBLow = {0, 0, 0},
921 .xatten1MarginLow = {0, 0, 0},
922 .xatten1DBHigh = {0, 0, 0},
923 .xatten1MarginHigh = {0, 0, 0}
968 .calTarget_freqbin_5G = {
978 .calTarget_freqbin_5GHT20 = {
988 .calTarget_freqbin_5GHT40 = {
998 .calTargetPower5G = {
1000 { {42, 40, 40, 34} },
1001 { {42, 40, 40, 34} },
1002 { {42, 40, 40, 34} },
1003 { {42, 40, 40, 34} },
1004 { {42, 40, 40, 34} },
1005 { {42, 40, 40, 34} },
1006 { {42, 40, 40, 34} },
1007 { {42, 40, 40, 34} },
1009 .calTargetPower5GHT20 = {
1014 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1015 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1016 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
1017 { {40, 40, 40, 40, 32, 28, 40, 40, 32, 28, 40, 40, 32, 20} },
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 { {38, 38, 38, 38, 32, 28, 38, 38, 32, 28, 38, 38, 32, 26} },
1021 { {36, 36, 36, 36, 32, 28, 36, 36, 32, 28, 36, 36, 32, 26} },
1023 .calTargetPower5GHT40 = {
1028 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1029 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1030 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
1031 { {40, 40, 40, 38, 30, 26, 40, 40, 30, 26, 40, 40, 30, 24} },
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 { {36, 36, 36, 36, 30, 26, 36, 36, 30, 26, 36, 36, 30, 24} },
1035 { {34, 34, 34, 34, 30, 26, 34, 34, 30, 26, 34, 34, 30, 24} },
1038 0x10, 0x16, 0x18, 0x40, 0x46,
1039 0x48, 0x30, 0x36, 0x38
1140 .ctlPowerData_5G = {
1201 .templateVersion = 3,
1202 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
1203 .custData = {
"h112-241-f0000"},
1212 .blueToothOptions = 0,
1216 .params_for_tuning_caps = {0, 0},
1217 .featureEnable = 0x0d,
1226 .miscConfiguration = 0,
1227 .eepromWriteEnableGpio = 6,
1228 .wlanDisableGpio = 0,
1230 .rxBandSelectGpio = 0xff,
1237 .antCtrlCommon =
LE32(0x110),
1239 .antCtrlCommon2 =
LE32(0x44444),
1245 .antCtrlChain = {
LE16(0x150),
LE16(0x150),
LE16(0x150) },
1251 .xatten1DB = {0, 0, 0},
1257 .xatten1Margin = {0, 0, 0},
1265 .spurChans = {
FREQ2FBIN(2464, 1), 0, 0, 0, 0},
1271 .noiseFloorThreshCh = {-1, 0, 0},
1272 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1275 .txFrameToDataStart = 0x0e,
1276 .txFrameToPaOn = 0x0e,
1279 .switchSettling = 0x2c,
1280 .adcDesiredSize = -30,
1283 .txFrameToXpaOn = 0xe,
1285 .papdRateMaskHt20 =
LE32(0x0c80c080),
1286 .papdRateMaskHt40 =
LE32(0x0080c080),
1287 .xlna_bias_strength = 0,
1289 0, 0, 0, 0, 0, 0, 0,
1293 .ant_div_control = 0,
1294 .future = {0, 0, 0},
1295 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
1304 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1305 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1306 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1308 .calTarget_freqbin_Cck = {
1312 .calTarget_freqbin_2G = {
1317 .calTarget_freqbin_2GHT20 = {
1322 .calTarget_freqbin_2GHT40 = {
1327 .calTargetPowerCck = {
1329 { {34, 34, 34, 34} },
1330 { {34, 34, 34, 34} },
1332 .calTargetPower2G = {
1334 { {34, 34, 32, 32} },
1335 { {34, 34, 32, 32} },
1336 { {34, 34, 32, 32} },
1338 .calTargetPower2GHT20 = {
1339 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1340 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1341 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 28, 28, 28, 24} },
1343 .calTargetPower2GHT40 = {
1344 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1345 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1346 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 26, 26, 26, 22} },
1349 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
1350 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
1434 .ctlPowerData_2G = {
1435 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
1436 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
1437 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 1) } },
1439 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 0) } },
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) } },
1443 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 0) } },
1444 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
1445 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
1447 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
1448 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 1) } },
1449 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 1) } },
1453 .antCtrlCommon =
LE32(0x220),
1455 .antCtrlCommon2 =
LE32(0x44444),
1461 .xatten1DB = {0, 0, 0},
1467 .xatten1Margin = {0, 0, 0},
1471 .spurChans = {0, 0, 0, 0, 0},
1473 .noiseFloorThreshCh = {-1, 0, 0},
1474 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1477 .txFrameToDataStart = 0x0e,
1478 .txFrameToPaOn = 0x0e,
1481 .switchSettling = 0x2d,
1482 .adcDesiredSize = -30,
1485 .txFrameToXpaOn = 0xe,
1487 .papdRateMaskHt20 =
LE32(0x0cf0e0e0),
1488 .papdRateMaskHt40 =
LE32(0x6cf0e0e0),
1489 .xlna_bias_strength = 0,
1491 0, 0, 0, 0, 0, 0, 0,
1496 .tempSlopeHigh = 50,
1497 .xatten1DBLow = {0, 0, 0},
1498 .xatten1MarginLow = {0, 0, 0},
1499 .xatten1DBHigh = {0, 0, 0},
1500 .xatten1MarginHigh = {0, 0, 0}
1545 .calTarget_freqbin_5G = {
1555 .calTarget_freqbin_5GHT20 = {
1565 .calTarget_freqbin_5GHT40 = {
1575 .calTargetPower5G = {
1577 { {30, 30, 28, 24} },
1578 { {30, 30, 28, 24} },
1579 { {30, 30, 28, 24} },
1580 { {30, 30, 28, 24} },
1581 { {30, 30, 28, 24} },
1582 { {30, 30, 28, 24} },
1583 { {30, 30, 28, 24} },
1584 { {30, 30, 28, 24} },
1586 .calTargetPower5GHT20 = {
1591 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
1592 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 20, 20, 20, 16} },
1593 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
1594 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 18, 18, 18, 16} },
1595 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
1596 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 16, 16, 16, 14} },
1597 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
1598 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 14, 14, 14, 12} },
1600 .calTargetPower5GHT40 = {
1605 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
1606 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 18, 18, 18, 14} },
1607 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
1608 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 16, 16, 16, 12} },
1609 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
1610 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 14, 14, 14, 10} },
1611 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
1612 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 12, 12, 12, 8} },
1615 0x10, 0x16, 0x18, 0x40, 0x46,
1616 0x48, 0x30, 0x36, 0x38
1717 .ctlPowerData_5G = {
1778 .templateVersion = 5,
1779 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
1780 .custData = {
"x112-041-f0000"},
1789 .blueToothOptions = 0,
1793 .params_for_tuning_caps = {0, 0},
1794 .featureEnable = 0x0d,
1803 .miscConfiguration = 0,
1804 .eepromWriteEnableGpio = 6,
1805 .wlanDisableGpio = 0,
1807 .rxBandSelectGpio = 0xff,
1814 .antCtrlCommon =
LE32(0x110),
1816 .antCtrlCommon2 =
LE32(0x22222),
1822 .antCtrlChain = {
LE16(0x10),
LE16(0x10),
LE16(0x10) },
1828 .xatten1DB = {0x1b, 0x1b, 0x1b},
1834 .xatten1Margin = {0x15, 0x15, 0x15},
1842 .spurChans = {
FREQ2FBIN(2464, 1), 0, 0, 0, 0},
1848 .noiseFloorThreshCh = {-1, 0, 0},
1849 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
1852 .txFrameToDataStart = 0x0e,
1853 .txFrameToPaOn = 0x0e,
1856 .switchSettling = 0x2c,
1857 .adcDesiredSize = -30,
1860 .txFrameToXpaOn = 0xe,
1862 .papdRateMaskHt20 =
LE32(0x0c80c080),
1863 .papdRateMaskHt40 =
LE32(0x0080c080),
1864 .xlna_bias_strength = 0,
1866 0, 0, 0, 0, 0, 0, 0,
1870 .ant_div_control = 0,
1871 .future = {0, 0, 0},
1872 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
1881 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1882 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1883 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
1885 .calTarget_freqbin_Cck = {
1889 .calTarget_freqbin_2G = {
1894 .calTarget_freqbin_2GHT20 = {
1899 .calTarget_freqbin_2GHT40 = {
1904 .calTargetPowerCck = {
1906 { {38, 38, 38, 38} },
1907 { {38, 38, 38, 38} },
1909 .calTargetPower2G = {
1911 { {38, 38, 36, 34} },
1912 { {38, 38, 36, 34} },
1913 { {38, 38, 34, 32} },
1915 .calTargetPower2GHT20 = {
1916 { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
1917 { {36, 36, 36, 36, 36, 34, 36, 34, 32, 30, 30, 30, 28, 26} },
1918 { {36, 36, 36, 36, 36, 34, 34, 32, 30, 28, 28, 28, 28, 26} },
1920 .calTargetPower2GHT40 = {
1921 { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
1922 { {36, 36, 36, 36, 34, 32, 34, 32, 30, 28, 28, 28, 28, 24} },
1923 { {36, 36, 36, 36, 34, 32, 32, 30, 28, 26, 26, 26, 26, 24} },
1926 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
1927 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
2011 .ctlPowerData_2G = {
2012 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2013 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2014 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 1) } },
2016 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 0) } },
2017 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2018 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2020 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 0) } },
2021 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2022 { {
CTL(60, 0),
CTL(60, 1),
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, 1),
CTL(60, 1) } },
2026 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 1) } },
2030 .antCtrlCommon =
LE32(0x110),
2032 .antCtrlCommon2 =
LE32(0x22222),
2038 .xatten1DB = {0x13, 0x19, 0x17},
2044 .xatten1Margin = {0x19, 0x19, 0x19},
2048 .spurChans = {0, 0, 0, 0, 0},
2050 .noiseFloorThreshCh = {-1, 0, 0},
2051 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2054 .txFrameToDataStart = 0x0e,
2055 .txFrameToPaOn = 0x0e,
2058 .switchSettling = 0x2d,
2059 .adcDesiredSize = -30,
2062 .txFrameToXpaOn = 0xe,
2064 .papdRateMaskHt20 =
LE32(0x0cf0e0e0),
2065 .papdRateMaskHt40 =
LE32(0x6cf0e0e0),
2066 .xlna_bias_strength = 0,
2068 0, 0, 0, 0, 0, 0, 0,
2073 .tempSlopeHigh = 105,
2074 .xatten1DBLow = {0x10, 0x14, 0x10},
2075 .xatten1MarginLow = {0x19, 0x19 , 0x19},
2076 .xatten1DBHigh = {0x1d, 0x20, 0x24},
2077 .xatten1MarginHigh = {0x10, 0x10, 0x10}
2122 .calTarget_freqbin_5G = {
2132 .calTarget_freqbin_5GHT20 = {
2142 .calTarget_freqbin_5GHT40 = {
2152 .calTargetPower5G = {
2154 { {32, 32, 28, 26} },
2155 { {32, 32, 28, 26} },
2156 { {32, 32, 28, 26} },
2157 { {32, 32, 26, 24} },
2158 { {32, 32, 26, 24} },
2159 { {32, 32, 24, 22} },
2160 { {30, 30, 24, 22} },
2161 { {30, 30, 24, 22} },
2163 .calTargetPower5GHT20 = {
2168 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2169 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2170 { {32, 32, 32, 32, 28, 26, 32, 28, 26, 24, 24, 24, 22, 22} },
2171 { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 22, 22, 20, 20} },
2172 { {32, 32, 32, 32, 28, 26, 32, 26, 24, 22, 20, 18, 16, 16} },
2173 { {32, 32, 32, 32, 28, 26, 32, 24, 20, 16, 18, 16, 14, 14} },
2174 { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
2175 { {30, 30, 30, 30, 28, 26, 30, 24, 20, 16, 18, 16, 14, 14} },
2177 .calTargetPower5GHT40 = {
2182 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2183 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2184 { {32, 32, 32, 30, 28, 26, 30, 28, 26, 24, 24, 24, 22, 22} },
2185 { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 22, 22, 20, 20} },
2186 { {32, 32, 32, 30, 28, 26, 30, 26, 24, 22, 20, 18, 16, 16} },
2187 { {32, 32, 32, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2188 { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2189 { {30, 30, 30, 30, 28, 26, 30, 22, 20, 16, 18, 16, 14, 14} },
2192 0x10, 0x16, 0x18, 0x40, 0x46,
2193 0x48, 0x30, 0x36, 0x38
2294 .ctlPowerData_5G = {
2354 .templateVersion = 4,
2355 .macAddr = {0x00, 0x03, 0x7f, 0x0, 0x0, 0x0},
2356 .custData = {
"h116-041-f0000"},
2365 .blueToothOptions = 0,
2369 .params_for_tuning_caps = {0, 0},
2370 .featureEnable = 0x0d,
2379 .miscConfiguration = 0,
2380 .eepromWriteEnableGpio = 6,
2381 .wlanDisableGpio = 0,
2383 .rxBandSelectGpio = 0xff,
2390 .antCtrlCommon =
LE32(0x110),
2392 .antCtrlCommon2 =
LE32(0x44444),
2398 .antCtrlChain = {
LE16(0x10),
LE16(0x10),
LE16(0x10) },
2404 .xatten1DB = {0x1f, 0x1f, 0x1f},
2410 .xatten1Margin = {0x12, 0x12, 0x12},
2418 .spurChans = {
FREQ2FBIN(2464, 1), 0, 0, 0, 0},
2424 .noiseFloorThreshCh = {-1, 0, 0},
2425 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2428 .txFrameToDataStart = 0x0e,
2429 .txFrameToPaOn = 0x0e,
2432 .switchSettling = 0x2c,
2433 .adcDesiredSize = -30,
2436 .txFrameToXpaOn = 0xe,
2438 .papdRateMaskHt20 =
LE32(0x0c80C080),
2439 .papdRateMaskHt40 =
LE32(0x0080C080),
2440 .xlna_bias_strength = 0,
2442 0, 0, 0, 0, 0, 0, 0,
2446 .ant_div_control = 0,
2447 .future = {0, 0, 0},
2448 .tempslopextension = {0, 0, 0, 0, 0, 0, 0, 0}
2457 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2458 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2459 { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} },
2461 .calTarget_freqbin_Cck = {
2465 .calTarget_freqbin_2G = {
2470 .calTarget_freqbin_2GHT20 = {
2475 .calTarget_freqbin_2GHT40 = {
2480 .calTargetPowerCck = {
2482 { {34, 34, 34, 34} },
2483 { {34, 34, 34, 34} },
2485 .calTargetPower2G = {
2487 { {34, 34, 32, 32} },
2488 { {34, 34, 32, 32} },
2489 { {34, 34, 32, 32} },
2491 .calTargetPower2GHT20 = {
2492 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2493 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2494 { {32, 32, 32, 32, 32, 30, 32, 32, 30, 28, 0, 0, 0, 0} },
2496 .calTargetPower2GHT40 = {
2497 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2498 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2499 { {30, 30, 30, 30, 30, 28, 30, 30, 28, 26, 0, 0, 0, 0} },
2502 0x11, 0x12, 0x15, 0x17, 0x41, 0x42,
2503 0x45, 0x47, 0x31, 0x32, 0x35, 0x37,
2587 .ctlPowerData_2G = {
2588 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2589 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2590 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 1) } },
2592 { {
CTL(60, 1),
CTL(60, 0),
CTL(60, 0),
CTL(60, 0) } },
2593 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2594 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2596 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 0) } },
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) } },
2600 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 0),
CTL(60, 0) } },
2601 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 1) } },
2602 { {
CTL(60, 0),
CTL(60, 1),
CTL(60, 1),
CTL(60, 1) } },
2606 .antCtrlCommon =
LE32(0x220),
2608 .antCtrlCommon2 =
LE32(0x44444),
2614 .xatten1DB = {0x19, 0x19, 0x19},
2620 .xatten1Margin = {0x14, 0x14, 0x14},
2624 .spurChans = {0, 0, 0, 0, 0},
2626 .noiseFloorThreshCh = {-1, 0, 0},
2627 .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
2630 .txFrameToDataStart = 0x0e,
2631 .txFrameToPaOn = 0x0e,
2634 .switchSettling = 0x2d,
2635 .adcDesiredSize = -30,
2638 .txFrameToXpaOn = 0xe,
2640 .papdRateMaskHt20 =
LE32(0x0cf0e0e0),
2641 .papdRateMaskHt40 =
LE32(0x6cf0e0e0),
2642 .xlna_bias_strength = 0,
2644 0, 0, 0, 0, 0, 0, 0,
2649 .tempSlopeHigh = 50,
2650 .xatten1DBLow = {0, 0, 0},
2651 .xatten1MarginLow = {0, 0, 0},
2652 .xatten1DBHigh = {0, 0, 0},
2653 .xatten1MarginHigh = {0, 0, 0}
2698 .calTarget_freqbin_5G = {
2708 .calTarget_freqbin_5GHT20 = {
2718 .calTarget_freqbin_5GHT40 = {
2728 .calTargetPower5G = {
2730 { {30, 30, 28, 24} },
2731 { {30, 30, 28, 24} },
2732 { {30, 30, 28, 24} },
2733 { {30, 30, 28, 24} },
2734 { {30, 30, 28, 24} },
2735 { {30, 30, 28, 24} },
2736 { {30, 30, 28, 24} },
2737 { {30, 30, 28, 24} },
2739 .calTargetPower5GHT20 = {
2744 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
2745 { {30, 30, 30, 28, 24, 20, 30, 28, 24, 20, 0, 0, 0, 0} },
2746 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
2747 { {30, 30, 30, 26, 22, 18, 30, 26, 22, 18, 0, 0, 0, 0} },
2748 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
2749 { {30, 30, 30, 24, 20, 16, 30, 24, 20, 16, 0, 0, 0, 0} },
2750 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
2751 { {30, 30, 30, 22, 18, 14, 30, 22, 18, 14, 0, 0, 0, 0} },
2753 .calTargetPower5GHT40 = {
2758 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
2759 { {28, 28, 28, 26, 22, 18, 28, 26, 22, 18, 0, 0, 0, 0} },
2760 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
2761 { {28, 28, 28, 24, 20, 16, 28, 24, 20, 16, 0, 0, 0, 0} },
2762 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
2763 { {28, 28, 28, 22, 18, 14, 28, 22, 18, 14, 0, 0, 0, 0} },
2764 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
2765 { {28, 28, 28, 20, 16, 12, 28, 20, 16, 12, 0, 0, 0, 0} },
2768 0x10, 0x16, 0x18, 0x40, 0x46,
2769 0x48, 0x30, 0x36, 0x38
2870 .ctlPowerData_5G = {
2929 static const struct ar9300_eeprom *ar9300_eep_templates[] = {
2937 static const struct ar9300_eeprom *ar9003_eeprom_struct_find_by_id(
int id)
2939 #define N_LOOP (sizeof(ar9300_eep_templates) / sizeof(ar9300_eep_templates[0]))
2942 for (it = 0; it <
N_LOOP; it++)
2944 return ar9300_eep_templates[it];
2949 static int ath9k_hw_ar9300_check_eeprom(
struct ath_hw *
ah)
2956 int bf, factor, plus;
2958 bf = 2 * (yb - ya) * (x - xa) / (xb - xa);
2961 return ya + factor + plus;
2964 static u32 ath9k_hw_ar9300_get_eeprom(
struct ath_hw *
ah,
2972 return get_unaligned_be16(eep->
macAddr);
2974 return get_unaligned_be16(eep->
macAddr + 2);
2976 return get_unaligned_be16(eep->
macAddr + 4);
2986 return (pBase->
txrxMask >> 4) & 0xf;
2992 if (!ah->
config.enable_paprd);
3016 *buffer = (val >> (8 * (address % 2))) & 0xff;
3020 static bool ar9300_eeprom_read_word(
struct ath_common *common,
int address,
3028 buffer[0] = val >> 8;
3029 buffer[1] = val & 0xff;
3034 static bool ar9300_read_eeprom(
struct ath_hw *ah,
int address,
u8 *buffer,
3037 struct ath_common *common = ath9k_hw_common(ah);
3050 if (address % 2 == 0) {
3051 if (!ar9300_eeprom_read_byte(common, address--, buffer++))
3057 for (i = 0; i < count / 2; i++) {
3058 if (!ar9300_eeprom_read_word(common, address, buffer))
3066 if (!ar9300_eeprom_read_byte(common, address, buffer))
3072 ath_dbg(common,
EEPROM,
"unable to read eeprom region at offset %d\n",
3089 static bool ar9300_read_otp(
struct ath_hw *ah,
int address,
u8 *buffer,
3095 for (i = 0; i <
count; i++) {
3096 int offset = 8 * ((address -
i) % 4);
3097 if (!ar9300_otp_read_word(ah, (address - i) / 4, &
data))
3100 buffer[
i] = (data >>
offset) & 0xff;
3107 static void ar9300_comp_hdr_unpack(
u8 *best,
int *
code,
int *
reference,
3108 int *
length,
int *major,
int *minor)
3110 unsigned long value[4];
3116 *code = ((value[0] >> 5) & 0x0007);
3117 *reference = (value[0] & 0x001f) | ((value[1] >> 2) & 0x0020);
3118 *length = ((value[1] << 4) & 0x07f0) | ((value[2] >> 4) & 0x000f);
3119 *major = (value[2] & 0x000f);
3120 *minor = (value[3] & 0x00ff);
3123 static u16 ar9300_comp_cksum(
u8 *data,
int dsize)
3127 for (it = 0; it < dsize; it++) {
3128 checksum += data[it];
3135 static bool ar9300_uncompress_block(
struct ath_hw *ah,
3145 struct ath_common *common = ath9k_hw_common(ah);
3149 for (it = 0; it <
size; it += (length+2)) {
3153 length = block[it+1];
3156 if (length > 0 && spot >= 0 && spot+length <= mdataSize) {
3158 "Restore at %d: spot=%d offset=%d length=%d\n",
3159 it, spot, offset, length);
3160 memcpy(&mptr[spot], &block[it+2], length);
3162 }
else if (length > 0) {
3164 "Bad restore at %d: spot=%d offset=%d length=%d\n",
3165 it, spot, offset, length);
3172 static int ar9300_compress_decision(
struct ath_hw *ah,
3177 u8 *
word,
int length,
int mdata_size)
3179 struct ath_common *common = ath9k_hw_common(ah);
3184 if (length != mdata_size) {
3186 "EEPROM structure size mismatch memory=%d eeprom=%d\n",
3187 mdata_size, length);
3192 "restored eeprom %d: uncompressed, length %d\n",
3196 if (reference == 0) {
3198 eep = ar9003_eeprom_struct_find_by_id(reference);
3201 "can't find reference eeprom struct %d\n",
3205 memcpy(mptr, eep, mdata_size);
3208 "restore eeprom %d: block, reference %d, length %d\n",
3209 it, reference, length);
3210 ar9300_uncompress_block(ah, mptr, mdata_size,
3214 ath_dbg(common,
EEPROM,
"unknown compression code %d\n", code);
3223 static bool ar9300_check_header(
void *data)
3226 return !(*word == 0 || *word == ~0);
3234 if (!
read(ah, base_addr, header, 4))
3237 return ar9300_check_header(header);
3240 static int ar9300_eeprom_restore_flash(
struct ath_hw *ah,
u8 *mptr,
3243 struct ath_common *common = ath9k_hw_common(ah);
3244 u16 *data = (
u16 *) mptr;
3247 for (i = 0; i < mdata_size / 2; i++, data++)
3259 static int ar9300_eeprom_restore_internal(
struct ath_hw *ah,
3260 u8 *mptr,
int mdata_size)
3267 int reference,
length, major, minor;
3271 struct ath_common *common = ath9k_hw_common(ah);
3278 ar9300_eeprom_restore_flash(ah, mptr, mdata_size);
3283 if (txrx != 0 && txrx != 0xff)
3291 memcpy(mptr, &ar9300_default, mdata_size);
3293 read = ar9300_read_eeprom;
3300 ath_dbg(common,
EEPROM,
"Trying EEPROM access at Address 0x%04x\n",
3302 if (ar9300_check_eeprom_header(ah, read, cptr))
3306 ath_dbg(common,
EEPROM,
"Trying EEPROM access at Address 0x%04x\n",
3308 if (ar9300_check_eeprom_header(ah, read, cptr))
3311 read = ar9300_read_otp;
3313 ath_dbg(common,
EEPROM,
"Trying OTP access at Address 0x%04x\n", cptr);
3314 if (ar9300_check_eeprom_header(ah, read, cptr))
3318 ath_dbg(common,
EEPROM,
"Trying OTP access at Address 0x%04x\n", cptr);
3319 if (ar9300_check_eeprom_header(ah, read, cptr))
3327 for (it = 0; it <
MSTATE; it++) {
3331 if (!ar9300_check_header(word))
3334 ar9300_comp_hdr_unpack(word, &code, &reference,
3335 &length, &major, &minor);
3337 "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
3338 cptr, code, reference, length, major, minor);
3348 checksum = ar9300_comp_cksum(&word[
COMP_HDR_LEN], length);
3349 mchecksum = get_unaligned_le16(&word[
COMP_HDR_LEN + osize]);
3351 checksum, mchecksum);
3352 if (checksum == mchecksum) {
3353 ar9300_compress_decision(ah, it, code, reference, mptr,
3354 word, length, mdata_size);
3357 "skipping block with bad checksum\n");
3375 static bool ath9k_hw_ar9300_fill_eeprom(
struct ath_hw *ah)
3379 if (ar9300_eeprom_restore_internal(ah, mptr,
3386 #if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
3387 static u32 ar9003_dump_modal_eeprom(
char *
buf,
u32 len,
u32 size,
3425 static u32 ath9k_hw_ar9003_dump_eeprom(
struct ath_hw *ah,
bool dump_base_hdr,
3431 if (!dump_base_hdr) {
3432 len +=
snprintf(buf + len, size - len,
3433 "%20s :\n",
"2GHz modal Header");
3434 len = ar9003_dump_modal_eeprom(buf, len, size,
3436 len +=
snprintf(buf + len, size - len,
3437 "%20s :\n",
"5GHz modal Header");
3438 len = ar9003_dump_modal_eeprom(buf, len, size,
3487 len +=
snprintf(buf + len, size - len,
"%20s : %pM\n",
"MacAddress",
3496 static u32 ath9k_hw_ar9003_dump_eeprom(
struct ath_hw *ah,
bool dump_base_hdr,
3504 static int ath9k_hw_ar9300_get_eeprom_ver(
struct ath_hw *ah)
3510 static int ath9k_hw_ar9300_get_eeprom_rev(
struct ath_hw *ah)
3526 static void ar9003_hw_xpa_bias_level_apply(
struct ath_hw *ah,
bool is2ghz)
3528 int bias = ar9003_modal_header(ah, is2ghz)->xpaBiasLvl;
3544 static u16 ar9003_switch_com_spdt_get(
struct ath_hw *ah,
bool is2ghz)
3546 return le16_to_cpu(ar9003_modal_header(ah, is2ghz)->switchcomspdt);
3550 static u32 ar9003_hw_ant_ctrl_common_get(
struct ath_hw *ah,
bool is2ghz)
3552 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon);
3555 static u32 ar9003_hw_ant_ctrl_common_2_get(
struct ath_hw *ah,
bool is2ghz)
3557 return le32_to_cpu(ar9003_modal_header(ah, is2ghz)->antCtrlCommon2);
3560 static u16 ar9003_hw_ant_ctrl_chain_get(
struct ath_hw *ah,
int chain,
3563 __le16 val = ar9003_modal_header(ah, is2ghz)->antCtrlChain[
chain];
3567 static void ar9003_hw_ant_ctrl_apply(
struct ath_hw *ah,
bool is2ghz)
3578 u32 value = ar9003_hw_ant_ctrl_common_get(ah, is2ghz);
3605 value = ar9003_switch_com_spdt_get(ah, is2ghz);
3611 value = ar9003_hw_ant_ctrl_common_2_get(ah, is2ghz);
3617 value = ar9003_hw_ant_ctrl_chain_get(ah, chain,
3674 static void ar9003_hw_drive_strength_apply(
struct ath_hw *ah)
3682 if (!drive_strength)
3716 static u16 ar9003_hw_atten_chain_get(
struct ath_hw *ah,
int chain,
3723 if (chain >= 0 && chain < 3) {
3726 else if (eep->
base_ext2.xatten1DBLow[chain] != 0) {
3733 value = ar9003_hw_power_interpolate((
s32) chan->
channel,
3744 static u16 ar9003_hw_atten_chain_get_margin(
struct ath_hw *ah,
int chain,
3751 if (chain >= 0 && chain < 3) {
3754 else if (eep->
base_ext2.xatten1MarginLow[chain] != 0) {
3761 value = ar9003_hw_power_interpolate((
s32) chan->
channel,
3781 for (i = 0; i < 3; i++) {
3783 value = ar9003_hw_atten_chain_get(ah, i, chan);
3787 value = ar9003_hw_atten_chain_get_margin(ah, i, chan);
3795 static bool is_pmu_set(
struct ath_hw *ah,
u32 pmu_reg,
int pmu_set)
3799 while (pmu_set !=
REG_READ(ah, pmu_reg)) {
3826 reg_pmu_set = (3 << 1) | (8 << 4) |
3827 (3 << 8) | (1 << 14) |
3828 (6 << 17) | (1 << 20) |
3831 reg_pmu_set = (4 << 1) | (7 << 4) |
3832 (3 << 8) | (1 << 14) |
3833 (6 << 17) | (1 << 20) |
3837 reg_pmu_set = (5 << 1) | (7 << 4) |
3838 (2 << 8) | (2 << 14) |
3839 (6 << 17) | (1 << 20) |
3840 (3 << 24) | (1 << 28);
3900 static void ar9003_hw_apply_tuning_caps(
struct ath_hw *ah)
3909 tuning_caps_param &= 0x7f;
3917 static void ar9003_hw_quick_drop_apply(
struct ath_hw *ah,
u16 freq)
3922 s32 t[3], f[3] = {5180, 5500, 5785};
3933 quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
3938 static void ar9003_hw_txend_to_xpa_off_apply(
struct ath_hw *ah,
bool is2ghz)
3942 value = ar9003_modal_header(ah, is2ghz)->txEndToXpaOff;
3950 static void ar9003_hw_xpa_timing_control_apply(
struct ath_hw *ah,
bool is2ghz)
3961 xpa_ctl = ar9003_modal_header(ah, is2ghz)->txFrameToXpaOn;
3970 static void ar9003_hw_xlna_bias_strength_apply(
struct ath_hw *ah,
bool is2ghz)
3981 bias = ar9003_modal_header(ah, is2ghz)->xlna_bias_strength;
3992 static int ar9003_hw_get_thermometer(
struct ath_hw *ah)
3998 return --thermometer;
4001 static void ar9003_hw_thermometer_apply(
struct ath_hw *ah)
4003 int thermometer = ar9003_hw_get_thermometer(ah);
4004 u8 therm_on = (thermometer < 0) ? 0 : 1;
4008 if (ah->
caps.tx_chainmask &
BIT(1))
4011 if (ah->
caps.tx_chainmask &
BIT(2))
4015 therm_on = (thermometer < 0) ? 0 : (thermometer == 0);
4018 if (ah->
caps.tx_chainmask &
BIT(1)) {
4019 therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
4023 if (ah->
caps.tx_chainmask &
BIT(2)) {
4024 therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
4030 static void ar9003_hw_thermo_cal_apply(
struct ath_hw *ah)
4036 ar9300_otp_read_word(ah, 1, &data);
4038 kg = (data >> 8) & 0xff;
4048 static void ath9k_hw_ar9300_set_board_values(
struct ath_hw *ah,
4052 ar9003_hw_xpa_timing_control_apply(ah, is2ghz);
4053 ar9003_hw_xpa_bias_level_apply(ah, is2ghz);
4054 ar9003_hw_ant_ctrl_apply(ah, is2ghz);
4055 ar9003_hw_drive_strength_apply(ah);
4056 ar9003_hw_xlna_bias_strength_apply(ah, is2ghz);
4057 ar9003_hw_atten_apply(ah, chan);
4058 ar9003_hw_quick_drop_apply(ah, chan->
channel);
4061 ar9003_hw_apply_tuning_caps(ah);
4062 ar9003_hw_txend_to_xpa_off_apply(ah, is2ghz);
4063 ar9003_hw_thermometer_apply(ah);
4064 ar9003_hw_thermo_cal_apply(ah);
4067 static void ath9k_hw_ar9300_set_addac(
struct ath_hw *ah,
4081 static int ar9003_hw_power_interpolate(
int32_t x,
4085 int lx = 0, ly = 0, lhave = 0;
4086 int hx = 0, hy = 0, hhave = 0;
4094 for (ip = 0; ip < np; ip++) {
4099 if (!hhave || dx > (x - hx)) {
4108 if (!lhave || dx < (x - lx)) {
4135 static u8 ar9003_hw_eeprom_get_tgt_pwr(
struct ath_hw *ah,
4136 u16 rateIndex,
u16 freq,
bool is2GHz)
4159 for (i = 0; i < numPiers; i++) {
4160 freqArray[
i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4161 targetPowerArray[
i] = pEepromTargetPwr[
i].
tPow2x[rateIndex];
4165 return (
u8) ar9003_hw_power_interpolate((
s32) freq,
4167 targetPowerArray, numPiers);
4170 static u8 ar9003_hw_eeprom_get_ht20_tgt_pwr(
struct ath_hw *ah,
4172 u16 freq,
bool is2GHz)
4195 for (i = 0; i < numPiers; i++) {
4196 freqArray[
i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4197 targetPowerArray[
i] = pEepromTargetPwr[
i].
tPow2x[rateIndex];
4201 return (
u8) ar9003_hw_power_interpolate((
s32) freq,
4203 targetPowerArray, numPiers);
4206 static u8 ar9003_hw_eeprom_get_ht40_tgt_pwr(
struct ath_hw *ah,
4208 u16 freq,
bool is2GHz)
4231 for (i = 0; i < numPiers; i++) {
4232 freqArray[
i] = ath9k_hw_fbin2freq(pFreqBin[i], is2GHz);
4233 targetPowerArray[
i] = pEepromTargetPwr[
i].
tPow2x[rateIndex];
4237 return (
u8) ar9003_hw_power_interpolate((
s32) freq,
4239 targetPowerArray, numPiers);
4242 static u8 ar9003_hw_eeprom_get_cck_tgt_pwr(
struct ath_hw *ah,
4256 for (i = 0; i < numPiers; i++) {
4257 freqArray[
i] = ath9k_hw_fbin2freq(pFreqBin[i], 1);
4258 targetPowerArray[
i] = pEepromTargetPwr[
i].
tPow2x[rateIndex];
4262 return (
u8) ar9003_hw_power_interpolate((
s32) freq,
4264 targetPowerArray, numPiers);
4268 static int ar9003_hw_tx_power_regwrite(
struct ath_hw *ah,
u8 * pPwrArray)
4270 #define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
4279 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 16) |
4280 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
4281 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
4288 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 0));
4295 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
4297 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0));
4304 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
4311 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 24) |
4312 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 16) |
4313 POW_SM(pPwrArray[ALL_TARGET_LEGACY_6_24], 8) |
4314 POW_SM(pPwrArray[ALL_TARGET_LEGACY_1L_5L], 0)
4385 static void ar9003_hw_get_legacy_target_powers(
struct ath_hw *ah,
u16 freq,
4386 u8 *targetPowerValT2,
4403 static void ar9003_hw_get_cck_target_powers(
struct ath_hw *ah,
u16 freq,
4404 u8 *targetPowerValT2)
4417 static void ar9003_hw_get_ht20_target_powers(
struct ath_hw *ah,
u16 freq,
4418 u8 *targetPowerValT2,
bool is2GHz)
4464 static void ar9003_hw_get_ht40_target_powers(
struct ath_hw *ah,
4466 u8 *targetPowerValT2,
4470 u8 ht40PowerIncForPdadc = 0;
4474 is2GHz) + ht40PowerIncForPdadc;
4478 is2GHz) + ht40PowerIncForPdadc;
4481 is2GHz) + ht40PowerIncForPdadc;
4484 is2GHz) + ht40PowerIncForPdadc;
4487 is2GHz) + ht40PowerIncForPdadc;
4490 is2GHz) + ht40PowerIncForPdadc;
4493 is2GHz) + ht40PowerIncForPdadc;
4496 is2GHz) + ht40PowerIncForPdadc;
4499 is2GHz) + ht40PowerIncForPdadc;
4502 is2GHz) + ht40PowerIncForPdadc;
4505 is2GHz) + ht40PowerIncForPdadc;
4508 is2GHz) + ht40PowerIncForPdadc;
4511 is2GHz) + ht40PowerIncForPdadc;
4514 is2GHz) + ht40PowerIncForPdadc;
4517 static void ar9003_hw_get_target_power_eeprom(
struct ath_hw *ah,
4519 u8 *targetPowerValT2)
4523 struct ath_common *common = ath9k_hw_common(ah);
4527 ar9003_hw_get_cck_target_powers(ah, freq, targetPowerValT2);
4529 ar9003_hw_get_legacy_target_powers(ah, freq, targetPowerValT2, is2GHz);
4530 ar9003_hw_get_ht20_target_powers(ah, freq, targetPowerValT2, is2GHz);
4533 ar9003_hw_get_ht40_target_powers(ah, freq, targetPowerValT2,
4538 i, targetPowerValT2[i]);
4542 static int ar9003_hw_cal_pier_get(
struct ath_hw *ah,
4548 int *ptemperature,
int *pvoltage)
4554 struct ath_common *common = ath9k_hw_common(ah);
4556 if (ichain >= AR9300_MAX_CHAINS) {
4558 "Invalid chain index, must be less than %d\n",
4566 "Invalid 5GHz cal pier index, must be less than %d\n",
4576 "Invalid 2GHz cal pier index, must be less than %d\n",
4586 *pfrequency = ath9k_hw_fbin2freq(*pCalPier, is2GHz);
4587 *pcorrection = pCalPierStruct->
refPower;
4588 *ptemperature = pCalPierStruct->
tempMeas;
4589 *pvoltage = pCalPierStruct->
voltMeas;
4594 static int ar9003_hw_power_control_override(
struct ath_hw *ah,
4606 if (ah->
caps.tx_chainmask &
BIT(1))
4610 if (ah->
caps.tx_chainmask &
BIT(2))
4619 if (ah->
caps.tx_chainmask &
BIT(1))
4623 if (ah->
caps.tx_chainmask &
BIT(2))
4632 if (frequency < 4000)
4634 else if ((eep->
baseEepHeader.miscConfiguration & 0x20) != 0) {
4635 for (i = 0; i < 8; i++) {
4639 tempSlope = ar9003_hw_power_interpolate((
s32) frequency,
4641 }
else if (eep->
base_ext2.tempSlopeLow != 0) {
4648 tempSlope = ar9003_hw_power_interpolate((
s32) frequency,
4667 static int ar9003_hw_calibration_apply(
struct ath_hw *ah,
int frequency)
4669 int ichain, ipier, npier;
4680 int pfrequency, pcorrection, ptemperature, pvoltage;
4681 struct ath_common *common = ath9k_hw_common(ah);
4683 mode = (frequency >= 4000);
4690 lfrequency[ichain] = 0;
4691 hfrequency[ichain] = 100000;
4695 for (ipier = 0; ipier < npier; ipier++) {
4696 if (!ar9003_hw_cal_pier_get(ah, mode, ipier, ichain,
4697 &pfrequency, &pcorrection,
4698 &ptemperature, &pvoltage)) {
4699 fdiff = frequency - pfrequency;
4706 if (hfrequency[ichain] <= 0 ||
4707 hfrequency[ichain] >= 100000 ||
4709 (frequency - hfrequency[ichain])) {
4714 hfrequency[ichain] = pfrequency;
4715 hcorrection[ichain] =
4717 htemperature[ichain] =
4719 hvoltage[ichain] = pvoltage;
4723 if (lfrequency[ichain] <= 0
4725 (frequency - lfrequency[ichain])) {
4730 lfrequency[ichain] = pfrequency;
4731 lcorrection[ichain] =
4733 ltemperature[ichain] =
4735 lvoltage[ichain] = pvoltage;
4745 ichain, frequency, lfrequency[ichain],
4746 lcorrection[ichain], hfrequency[ichain],
4747 hcorrection[ichain]);
4749 if (hfrequency[ichain] == lfrequency[ichain]) {
4750 correction[ichain] = lcorrection[ichain];
4751 voltage[ichain] = lvoltage[ichain];
4752 temperature[ichain] = ltemperature[ichain];
4755 else if (frequency - lfrequency[ichain] < 1000) {
4757 if (hfrequency[ichain] - frequency < 1000) {
4762 lcorrection[ichain],
4763 hcorrection[ichain]);
4768 ltemperature[ichain],
4769 htemperature[ichain]);
4779 correction[ichain] = lcorrection[ichain];
4780 temperature[ichain] = ltemperature[ichain];
4781 voltage[ichain] = lvoltage[ichain];
4785 else if (hfrequency[ichain] - frequency < 1000) {
4786 correction[ichain] = hcorrection[ichain];
4787 temperature[ichain] = htemperature[ichain];
4788 voltage[ichain] = hvoltage[ichain];
4790 correction[ichain] = 0;
4791 temperature[ichain] = 0;
4792 voltage[ichain] = 0;
4796 ar9003_hw_power_control_override(ah, frequency, correction, voltage,
4800 "for frequency=%d, calibration correction = %d %d %d\n",
4801 frequency, correction[0], correction[1], correction[2]);
4829 u8 *ctl_freqbin = is2GHz ?
4834 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 1) < freq &&
4838 if (ath9k_hw_fbin2freq(ctl_freqbin[edge - 1], 0) < freq &&
4850 u16 freq,
int idx,
bool is2GHz)
4853 u8 *ctl_freqbin = is2GHz ?
4856 u16 num_edges = is2GHz ?
4868 if (freq == ath9k_hw_fbin2freq(ctl_freqbin[edge], is2GHz)) {
4870 ar9003_hw_get_direct_edge_power(eep, idx,
4873 }
else if ((edge > 0) &&
4874 (freq < ath9k_hw_fbin2freq(ctl_freqbin[edge],
4877 ar9003_hw_get_indirect_edge_power(eep, idx,
4887 return twiceMaxEdgePower;
4890 static void ar9003_hw_set_power_per_rate_table(
struct ath_hw *ah,
4892 u8 *pPwrArray,
u16 cfgCtl,
4893 u8 antenna_reduction,
4896 struct ath_common *common = ath9k_hw_common(ah);
4898 u16 twiceMaxEdgePower;
4900 u16 scaledPower = 0, minCtlPower;
4901 static const u16 ctlModesFor11a[] = {
4904 static const u16 ctlModesFor11g[] = {
4909 const u16 *pCtlMode;
4914 u16 twiceMinEdgePower;
4927 pCtlMode = ctlModesFor11g;
4936 pCtlMode = ctlModesFor11a;
4950 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
4951 bool isHt40CtlMode = (pCtlMode[ctlMode] ==
CTL_5GHT40) ||
4954 freq = centers.synth_center;
4956 freq = centers.ext_center;
4958 freq = centers.ctl_center;
4961 "LOOP-Mode ctlMode %d < %d, isHt40CtlMode %d, EXT_ADDITIVE %d\n",
4962 ctlMode, numCtlModes, isHt40CtlMode,
4963 (pCtlMode[ctlMode] & EXT_ADDITIVE));
4975 for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) {
4977 "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n",
4978 i, cfgCtl, pCtlMode[ctlMode], ctlIndex[i],
4989 (((cfgCtl & ~CTL_MODE_M) |
4990 (pCtlMode[ctlMode] & CTL_MODE_M)) ==
4991 ((ctlIndex[i] & CTL_MODE_M) |
4994 ar9003_hw_get_max_edge_power(pEepData,
4998 if ((cfgCtl & ~CTL_MODE_M) ==
SD_NO_CTL)
5005 min(twiceMaxEdgePower,
5009 twiceMaxEdgePower = twiceMinEdgePower;
5015 minCtlPower = (
u8)
min(twiceMaxEdgePower, scaledPower);
5018 "SEL-Min ctlMode %d pCtlMode %d 2xMaxEdge %d sP %d minCtlPwr %d\n",
5019 ctlMode, pCtlMode[ctlMode], twiceMaxEdgePower,
5020 scaledPower, minCtlPower);
5023 switch (pCtlMode[ctlMode]) {
5025 for (i = ALL_TARGET_LEGACY_1L_5L;
5027 pPwrArray[i] = (
u8)
min((
u16)pPwrArray[i],
5032 for (i = ALL_TARGET_LEGACY_6_24;
5034 pPwrArray[i] = (
u8)
min((
u16)pPwrArray[i],
5041 pPwrArray[i] = (
u8)
min((
u16)pPwrArray[i],
5048 pPwrArray[i] = (
u8)
min((
u16)pPwrArray[i],
5057 static inline u8 mcsidx_to_tgtpwridx(
unsigned int mcs_idx,
u8 base_pwridx)
5059 u8 mod_idx = mcs_idx % 8;
5062 return mod_idx ? (base_pwridx + 1) : base_pwridx;
5064 return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2;
5067 static void ath9k_hw_ar9300_set_txpower(
struct ath_hw *ah,
5069 u8 twiceAntennaReduction,
5070 u8 powerLimit,
bool test)
5073 struct ath_common *common = ath9k_hw_common(ah);
5078 unsigned int i = 0, paprd_scale_factor = 0;
5079 u8 pwr_idx, min_pwridx = 0;
5081 memset(targetPowerValT2, 0 ,
sizeof(targetPowerValT2));
5086 ar9003_hw_get_target_power_eeprom(ah, chan, targetPowerValT2);
5107 memcpy(target_power_val_t2_eep, targetPowerValT2,
5108 sizeof(targetPowerValT2));
5109 for (i = 0; i < 24; i++) {
5110 pwr_idx = mcsidx_to_tgtpwridx(i, min_pwridx);
5112 if (targetPowerValT2[pwr_idx] &&
5113 targetPowerValT2[pwr_idx] ==
5114 target_power_val_t2_eep[pwr_idx])
5115 targetPowerValT2[pwr_idx] -=
5120 memcpy(target_power_val_t2_eep, targetPowerValT2,
5121 sizeof(targetPowerValT2));
5124 ar9003_hw_set_power_per_rate_table(ah, chan,
5125 targetPowerValT2, cfgCtl,
5126 twiceAntennaReduction,
5132 (
abs(targetPowerValT2[i] -
5133 target_power_val_t2_eep[i]) >
5134 paprd_scale_factor)) {
5137 "paprd disabled for mcs %d\n", i);
5155 i, targetPowerValT2[i]);
5159 ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
5160 ar9003_hw_calibration_apply(ah, chan->
channel);
5176 static u16 ath9k_hw_ar9300_get_spur_channel(
struct ath_hw *ah,
5198 return ar9003_modal_header(ah, is2ghz)->spurChans;
5213 else if (chan->
channel >= 5400)
5223 .check_eeprom = ath9k_hw_ar9300_check_eeprom,
5224 .get_eeprom = ath9k_hw_ar9300_get_eeprom,
5225 .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
5226 .dump_eeprom = ath9k_hw_ar9003_dump_eeprom,
5227 .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
5228 .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
5229 .set_board_values = ath9k_hw_ar9300_set_board_values,
5230 .set_addac = ath9k_hw_ar9300_set_addac,
5231 .set_txpower = ath9k_hw_ar9300_set_txpower,
5232 .get_spur_channel = ath9k_hw_ar9300_get_spur_channel