24 static const int firstep_table[] =
26 { -4, -2, 0, 2, 4, 6, 8, 10, 12 };
28 static const int cycpwrThr1_table[] =
30 { -6, -4, -2, 0, 2, 4, 6, 8 };
35 static const int m1ThreshLow_off = 127;
36 static const int m2ThreshLow_off = 127;
37 static const int m1Thresh_off = 127;
38 static const int m2Thresh_off = 127;
39 static const int m2CountThr_off = 31;
40 static const int m2CountThrLow_off = 63;
41 static const int m1ThreshLowExt_off = 127;
42 static const int m2ThreshLowExt_off = 127;
43 static const int m1ThreshExt_off = 127;
44 static const int m2ThreshExt_off = 127;
52 for (i = 0; i < array->
ia_rows; i++)
53 bank[i] =
INI_RA(array, i, col);
57 #define REG_WRITE_RF_ARRAY(iniarray, regData, regWr) \
58 ar5008_write_rf_array(ah, iniarray, regData, &(regWr))
61 u32 *
data,
unsigned int *writecnt)
67 for (r = 0; r < array->
ia_rows; r++) {
86 static void ar5008_hw_phy_modify_rx_buffer(
u32 *rfBuf,
u32 reg32,
90 u32 tmp32,
mask, arrayEntry, lastBit;
94 arrayEntry = (firstBit - 1) / 8;
95 bitPosition = (firstBit - 1) % 8;
97 while (bitsLeft > 0) {
98 lastBit = (bitPosition + bitsLeft > 8) ?
99 8 : bitPosition + bitsLeft;
100 mask = (((1 << lastBit) - 1) ^ ((1 << bitPosition) - 1)) <<
102 rfBuf[arrayEntry] &= ~mask;
103 rfBuf[arrayEntry] |= ((tmp32 << bitPosition) <<
104 (column * 8)) & mask;
105 bitsLeft -= 8 - bitPosition;
106 tmp32 = tmp32 >> (8 - bitPosition);
139 static void ar5008_hw_force_bias(
struct ath_hw *
ah,
u16 synth_freq)
151 if (synth_freq < 2412)
153 else if (synth_freq < 2422)
161 ath_dbg(common,
CONFIG,
"Force rf_pwd_icsyndiv to %1d on %4d\n",
162 new_bias, synth_freq);
165 ar5008_hw_phy_modify_rx_buffer(ah->
analogBank6Data, tmp_reg, 3, 181, 3);
182 struct ath_common *common = ath9k_hw_common(ah);
191 freq = centers.synth_center;
196 if (((freq - 2192) % 5) == 0) {
197 channelSel = ((freq - 672) * 2 - 3040) / 10;
199 }
else if (((freq - 2224) % 5) == 0) {
200 channelSel = ((freq - 704) * 2 - 3040) / 10;
203 ath_err(common,
"Invalid channel %u MHz\n", freq);
207 channelSel = (channelSel << 2) & 0xff;
220 }
else if ((freq % 20) == 0 && freq >= 5120) {
224 }
else if ((freq % 10) == 0) {
231 }
else if ((freq % 5) == 0) {
235 ath_err(common,
"Invalid channel %u MHz\n", freq);
239 ar5008_hw_force_bias(ah, freq);
242 (channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) |
260 static void ar5008_hw_spur_mitigate(
struct ath_hw *ah,
266 int spur_delta_phase;
268 int upper, lower, cur_vit_mask;
271 static int pilot_mask_reg[4] = {
275 static int chan_mask_reg[4] = {
279 static int inc[4] = { 0, 100, 0, 0 };
292 cur_bb_spur = ah->
eep_ops->get_spur_channel(ah, i, is2GHz);
295 cur_bb_spur = cur_bb_spur - (chan->
channel * 10);
296 if ((cur_bb_spur > -95) && (cur_bb_spur < 95)) {
297 bb_spur = cur_bb_spur;
322 spur_delta_phase = ((bb_spur * 524288) / 100) &
326 spur_freq_sd = ((bb_spur * 2048) / denominator) & 0x3ff;
337 for (i = 0; i < 4; i++) {
341 for (bp = 0; bp < 30; bp++) {
342 if ((cur_bin > lower) && (cur_bin < upper)) {
343 pilot_mask = pilot_mask | 0x1 << bp;
344 chan_mask = chan_mask | 0x1 << bp;
349 REG_WRITE(ah, pilot_mask_reg[i], pilot_mask);
350 REG_WRITE(ah, chan_mask_reg[i], chan_mask);
357 for (i = 0; i < 123; i++) {
358 if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) {
361 volatile int tmp_v =
abs(cur_vit_mask - bin);
367 if (cur_vit_mask < 0)
368 mask_m[
abs(cur_vit_mask / 100)] = mask_amt;
370 mask_p[cur_vit_mask / 100] = mask_amt;
375 tmp_mask = (mask_m[46] << 30) | (mask_m[47] << 28)
376 | (mask_m[48] << 26) | (mask_m[49] << 24)
377 | (mask_m[50] << 22) | (mask_m[51] << 20)
378 | (mask_m[52] << 18) | (mask_m[53] << 16)
379 | (mask_m[54] << 14) | (mask_m[55] << 12)
380 | (mask_m[56] << 10) | (mask_m[57] << 8)
381 | (mask_m[58] << 6) | (mask_m[59] << 4)
382 | (mask_m[60] << 2) | (mask_m[61] << 0);
386 tmp_mask = (mask_m[31] << 28)
387 | (mask_m[32] << 26) | (mask_m[33] << 24)
388 | (mask_m[34] << 22) | (mask_m[35] << 20)
389 | (mask_m[36] << 18) | (mask_m[37] << 16)
390 | (mask_m[48] << 14) | (mask_m[39] << 12)
391 | (mask_m[40] << 10) | (mask_m[41] << 8)
392 | (mask_m[42] << 6) | (mask_m[43] << 4)
393 | (mask_m[44] << 2) | (mask_m[45] << 0);
397 tmp_mask = (mask_m[16] << 30) | (mask_m[16] << 28)
398 | (mask_m[18] << 26) | (mask_m[18] << 24)
399 | (mask_m[20] << 22) | (mask_m[20] << 20)
400 | (mask_m[22] << 18) | (mask_m[22] << 16)
401 | (mask_m[24] << 14) | (mask_m[24] << 12)
402 | (mask_m[25] << 10) | (mask_m[26] << 8)
403 | (mask_m[27] << 6) | (mask_m[28] << 4)
404 | (mask_m[29] << 2) | (mask_m[30] << 0);
408 tmp_mask = (mask_m[0] << 30) | (mask_m[1] << 28)
409 | (mask_m[2] << 26) | (mask_m[3] << 24)
410 | (mask_m[4] << 22) | (mask_m[5] << 20)
411 | (mask_m[6] << 18) | (mask_m[7] << 16)
412 | (mask_m[8] << 14) | (mask_m[9] << 12)
413 | (mask_m[10] << 10) | (mask_m[11] << 8)
414 | (mask_m[12] << 6) | (mask_m[13] << 4)
415 | (mask_m[14] << 2) | (mask_m[15] << 0);
419 tmp_mask = (mask_p[15] << 28)
420 | (mask_p[14] << 26) | (mask_p[13] << 24)
421 | (mask_p[12] << 22) | (mask_p[11] << 20)
422 | (mask_p[10] << 18) | (mask_p[9] << 16)
423 | (mask_p[8] << 14) | (mask_p[7] << 12)
424 | (mask_p[6] << 10) | (mask_p[5] << 8)
425 | (mask_p[4] << 6) | (mask_p[3] << 4)
426 | (mask_p[2] << 2) | (mask_p[1] << 0);
430 tmp_mask = (mask_p[30] << 28)
431 | (mask_p[29] << 26) | (mask_p[28] << 24)
432 | (mask_p[27] << 22) | (mask_p[26] << 20)
433 | (mask_p[25] << 18) | (mask_p[24] << 16)
434 | (mask_p[23] << 14) | (mask_p[22] << 12)
435 | (mask_p[21] << 10) | (mask_p[20] << 8)
436 | (mask_p[19] << 6) | (mask_p[18] << 4)
437 | (mask_p[17] << 2) | (mask_p[16] << 0);
441 tmp_mask = (mask_p[45] << 28)
442 | (mask_p[44] << 26) | (mask_p[43] << 24)
443 | (mask_p[42] << 22) | (mask_p[41] << 20)
444 | (mask_p[40] << 18) | (mask_p[39] << 16)
445 | (mask_p[38] << 14) | (mask_p[37] << 12)
446 | (mask_p[36] << 10) | (mask_p[35] << 8)
447 | (mask_p[34] << 6) | (mask_p[33] << 4)
448 | (mask_p[32] << 2) | (mask_p[31] << 0);
452 tmp_mask = (mask_p[61] << 30) | (mask_p[60] << 28)
453 | (mask_p[59] << 26) | (mask_p[58] << 24)
454 | (mask_p[57] << 22) | (mask_p[56] << 20)
455 | (mask_p[55] << 18) | (mask_p[54] << 16)
456 | (mask_p[53] << 14) | (mask_p[52] << 12)
457 | (mask_p[51] << 10) | (mask_p[50] << 8)
458 | (mask_p[49] << 6) | (mask_p[48] << 4)
459 | (mask_p[47] << 2) | (mask_p[46] << 0);
470 static int ar5008_hw_rf_alloc_ext_banks(
struct ath_hw *ah)
472 #define ATH_ALLOC_BANK(bank, size) do { \
473 bank = kzalloc((sizeof(u32) * size), GFP_KERNEL); \
475 ath_err(common, "Cannot allocate RF banks\n"); \
480 struct ath_common *common = ath9k_hw_common(ah);
494 #undef ATH_ALLOC_BANK
503 static void ar5008_hw_rf_free_ext_banks(
struct ath_hw *ah)
505 #define ATH_FREE_BANK(bank) do { \
536 static bool ar5008_hw_set_rf_regs(
struct ath_hw *ah,
541 u32 ob5GHz = 0, db5GHz = 0;
542 u32 ob2GHz = 0, db2GHz = 0;
577 if (eepMinorRev >= 2) {
615 static void ar5008_hw_init_bb(
struct ath_hw *ah,
627 static void ar5008_hw_init_chain_masks(
struct ath_hw *ah)
629 int rx_chainmask, tx_chainmask;
635 switch (rx_chainmask) {
661 if (tx_chainmask == 0x5) {
670 static void ar5008_hw_override_ini(
struct ath_hw *ah,
703 REG_WRITE(ah, 0x9800 + (651 << 2), 0x11);
716 static void ar5008_hw_set_channel_regs(
struct ath_hw *ah,
720 u32 enableDacFifo = 0;
750 static int ar5008_hw_process_ini(
struct ath_hw *ah,
753 struct ath_common *common = ath9k_hw_common(ah);
754 int i, regWrites = 0;
755 u32 modesIndex, freqIndex;
793 ah->
eep_ops->set_addac(ah, chan);
800 for (i = 0; i < ah->
iniModes.ia_rows; i++) {
809 if (reg >= 0x7800 && reg < 0x78a0
810 && ah->
config.analog_shiftreg
835 for (i = 0; i < ah->
iniCommon.ia_rows; i++) {
841 if (reg >= 0x7800 && reg < 0x78a0
842 && ah->
config.analog_shiftreg
858 ar5008_hw_override_ini(ah, chan);
859 ar5008_hw_set_channel_regs(ah, chan);
860 ar5008_hw_init_chain_masks(ah);
865 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
866 ath_err(ath9k_hw_common(ah),
"ar5416SetRfRegs failed\n");
893 static void ar5008_hw_mark_phy_inactive(
struct ath_hw *ah)
898 static void ar5008_hw_set_delta_slope(
struct ath_hw *ah,
901 u32 coef_scaled, ds_coef_exp, ds_coef_man;
902 u32 clockMhzScaled = 0x64000000;
906 clockMhzScaled = clockMhzScaled >> 1;
908 clockMhzScaled = clockMhzScaled >> 2;
911 coef_scaled = clockMhzScaled / centers.synth_center;
921 coef_scaled = (9 * coef_scaled) / 10;
932 static bool ar5008_hw_rfbus_req(
struct ath_hw *ah)
939 static void ar5008_hw_rfbus_done(
struct ath_hw *ah)
948 static void ar5008_restore_chainmask(
struct ath_hw *ah)
952 if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) {
958 static u32 ar9160_hw_compute_pll_control(
struct ath_hw *ah,
978 static u32 ar5008_hw_compute_pll_control(
struct ath_hw *ah,
998 static bool ar5008_hw_ani_control_new(
struct ath_hw *ah,
1002 struct ath_common *common = ath9k_hw_common(ah);
1016 u32 on = param ? 1 : 0;
1021 int m1ThreshLow = on ?
1022 aniState->
iniDef.m1ThreshLow : m1ThreshLow_off;
1023 int m2ThreshLow = on ?
1024 aniState->
iniDef.m2ThreshLow : m2ThreshLow_off;
1026 aniState->
iniDef.m1Thresh : m1Thresh_off;
1028 aniState->
iniDef.m2Thresh : m2Thresh_off;
1029 int m2CountThr = on ?
1030 aniState->
iniDef.m2CountThr : m2CountThr_off;
1031 int m2CountThrLow = on ?
1032 aniState->
iniDef.m2CountThrLow : m2CountThrLow_off;
1033 int m1ThreshLowExt = on ?
1034 aniState->
iniDef.m1ThreshLowExt : m1ThreshLowExt_off;
1035 int m2ThreshLowExt = on ?
1036 aniState->
iniDef.m2ThreshLowExt : m2ThreshLowExt_off;
1037 int m1ThreshExt = on ?
1038 aniState->
iniDef.m1ThreshExt : m1ThreshExt_off;
1039 int m2ThreshExt = on ?
1040 aniState->
iniDef.m2ThreshExt : m2ThreshExt_off;
1076 "** ch %d: ofdm weak signal: %s=>%s\n",
1082 ah->
stats.ast_ani_ofdmon++;
1084 ah->
stats.ast_ani_ofdmoff++;
1094 "ATH9K_ANI_FIRSTEP_LEVEL: level out of range (%u > %zu)\n",
1103 value = firstep_table[
level] -
1105 aniState->
iniDef.firstep;
1118 value2 = firstep_table[
level] -
1120 aniState->
iniDef.firstepLow;
1131 "** ch %d: level %d=>%d[def:%d] firstep[level]=%d ini=%d\n",
1137 aniState->
iniDef.firstep);
1139 "** ch %d: level %d=>%d[def:%d] firstep_low[level]=%d ini=%d\n",
1145 aniState->
iniDef.firstepLow);
1147 ah->
stats.ast_ani_stepup++;
1149 ah->
stats.ast_ani_stepdown++;
1159 "ATH9K_ANI_SPUR_IMMUNITY_LEVEL: level out of range (%u > %zu)\n",
1167 value = cycpwrThr1_table[
level] -
1169 aniState->
iniDef.cycpwrThr1;
1183 value2 = cycpwrThr1_table[
level] -
1185 aniState->
iniDef.cycpwrThr1Ext;
1195 "** ch %d: level %d=>%d[def:%d] cycpwrThr1[level]=%d ini=%d\n",
1201 aniState->
iniDef.cycpwrThr1);
1203 "** ch %d: level %d=>%d[def:%d] cycpwrThr1Ext[level]=%d ini=%d\n",
1209 aniState->
iniDef.cycpwrThr1Ext);
1211 ah->
stats.ast_ani_spurup++;
1213 ah->
stats.ast_ani_spurdown++;
1228 ath_dbg(common, ANI,
"invalid cmd %u\n", cmd);
1233 "ANI parameters: SI=%d, ofdmWS=%s FS=%d MRCcck=%s listenTime=%d ofdmErrs=%d cckErrs=%d\n",
1237 aniState->
mrcCCK ?
"on" :
"off",
1244 static void ar5008_hw_do_getnf(
struct ath_hw *ah,
1250 nfarray[0] = sign_extend32(nf, 8);
1253 nfarray[1] = sign_extend32(nf, 8);
1256 nfarray[2] = sign_extend32(nf, 8);
1262 nfarray[3] = sign_extend32(nf, 8);
1265 nfarray[4] = sign_extend32(nf, 8);
1268 nfarray[5] = sign_extend32(nf, 8);
1276 static void ar5008_hw_ani_cache_ini_regs(
struct ath_hw *ah)
1278 struct ath_common *common = ath9k_hw_common(ah);
1284 iniDef = &aniState->
iniDef;
1286 ath_dbg(common, ANI,
"ver %d.%d opmode %u chan %d Mhz/0x%x\n",
1325 aniState->
mrcCCK =
false;
1328 static void ar5008_hw_set_nf_limits(
struct ath_hw *ah)
1338 static void ar5008_hw_set_radar_params(
struct ath_hw *ah,
1341 u32 radar_0 = 0, radar_1 = 0;
1369 static void ar5008_hw_set_radar_conf(
struct ath_hw *ah)
1386 static const u32 ar5416_cca_regs[6] = {
1402 priv_ops->
init_bb = ar5008_hw_init_bb;
1407 priv_ops->
rfbus_req = ar5008_hw_rfbus_req;
1410 priv_ops->
do_getnf = ar5008_hw_do_getnf;
1413 priv_ops->
ani_control = ar5008_hw_ani_control_new;
1421 ar5008_hw_set_nf_limits(ah);
1422 ar5008_hw_set_radar_conf(ah);