1 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
2 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
3 @@ -1678,6 +1678,15 @@ static void ar5008_hw_ani_cache_ini_regs
4 aniState->cycleCount = 0;
7 +static void ar5008_hw_set_nf_limits(struct ath_hw *ah)
9 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_5416_2GHZ;
10 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_5416_2GHZ;
11 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_5416_2GHZ;
12 + ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_5416_5GHZ;
13 + ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_5416_5GHZ;
14 + ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_5416_5GHZ;
17 void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
19 @@ -1715,4 +1724,6 @@ void ar5008_hw_attach_phy_ops(struct ath
20 priv_ops->compute_pll_control = ar9160_hw_compute_pll_control;
22 priv_ops->compute_pll_control = ar5008_hw_compute_pll_control;
24 + ar5008_hw_set_nf_limits(ah);
26 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
27 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
28 @@ -481,9 +481,6 @@ static void ar9002_hw_do_getnf(struct at
29 ath_print(common, ATH_DBG_CALIBRATE,
30 "NF calibrated [ctl] [chain 0] is %d\n", nf);
32 - if (AR_SREV_9271(ah) && (nf >= -114))
37 if (!AR_SREV_9285(ah) && !AR_SREV_9271(ah)) {
38 @@ -503,9 +500,6 @@ static void ar9002_hw_do_getnf(struct at
39 ath_print(common, ATH_DBG_CALIBRATE,
40 "NF calibrated [ext] [chain 0] is %d\n", nf);
42 - if (AR_SREV_9271(ah) && (nf >= -114))
47 if (!AR_SREV_9285(ah) && !AR_SREV_9271(ah)) {
48 @@ -520,6 +514,30 @@ static void ar9002_hw_do_getnf(struct at
52 +static void ar9002_hw_set_nf_limits(struct ath_hw *ah)
54 + if (AR_SREV_9285(ah)) {
55 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9285_2GHZ;
56 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9285_2GHZ;
57 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9285_2GHZ;
58 + } else if (AR_SREV_9287(ah)) {
59 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9287_2GHZ;
60 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9287_2GHZ;
61 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9287_2GHZ;
62 + } else if (AR_SREV_9271(ah)) {
63 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9271_2GHZ;
64 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9271_2GHZ;
65 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9271_2GHZ;
67 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_2GHZ;
68 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_2GHZ;
69 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9280_2GHZ;
70 + ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_5GHZ;
71 + ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_5GHZ;
72 + ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9280_5GHZ;
76 void ar9002_hw_attach_phy_ops(struct ath_hw *ah)
78 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
79 @@ -532,4 +550,6 @@ void ar9002_hw_attach_phy_ops(struct ath
80 priv_ops->olc_init = ar9002_olc_init;
81 priv_ops->compute_pll_control = ar9002_hw_compute_pll_control;
82 priv_ops->do_getnf = ar9002_hw_do_getnf;
84 + ar9002_hw_set_nf_limits(ah);
86 --- a/drivers/net/wireless/ath/ath9k/ar9002_phy.h
87 +++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.h
89 #define AR_PHY_CH2_EXT_MINCCA_PWR 0xFF800000
90 #define AR_PHY_CH2_EXT_MINCCA_PWR_S 23
92 +#define AR_PHY_CCA_NOM_VAL_5416_2GHZ -90
93 +#define AR_PHY_CCA_NOM_VAL_5416_5GHZ -100
94 +#define AR_PHY_CCA_MIN_GOOD_VAL_5416_2GHZ -100
95 +#define AR_PHY_CCA_MIN_GOOD_VAL_5416_5GHZ -110
96 +#define AR_PHY_CCA_MAX_GOOD_VAL_5416_2GHZ -80
97 +#define AR_PHY_CCA_MAX_GOOD_VAL_5416_5GHZ -90
99 +#define AR_PHY_CCA_NOM_VAL_9280_2GHZ -112
100 +#define AR_PHY_CCA_NOM_VAL_9280_5GHZ -112
101 +#define AR_PHY_CCA_MIN_GOOD_VAL_9280_2GHZ -127
102 +#define AR_PHY_CCA_MIN_GOOD_VAL_9280_5GHZ -122
103 +#define AR_PHY_CCA_MAX_GOOD_VAL_9280_2GHZ -97
104 +#define AR_PHY_CCA_MAX_GOOD_VAL_9280_5GHZ -102
106 +#define AR_PHY_CCA_NOM_VAL_9285_2GHZ -118
107 +#define AR_PHY_CCA_MIN_GOOD_VAL_9285_2GHZ -127
108 +#define AR_PHY_CCA_MAX_GOOD_VAL_9285_2GHZ -108
110 +#define AR_PHY_CCA_NOM_VAL_9271_2GHZ -118
111 +#define AR_PHY_CCA_MIN_GOOD_VAL_9271_2GHZ -127
112 +#define AR_PHY_CCA_MAX_GOOD_VAL_9271_2GHZ -116
114 +#define AR_PHY_CCA_NOM_VAL_9287_2GHZ -120
115 +#define AR_PHY_CCA_MIN_GOOD_VAL_9287_2GHZ -127
116 +#define AR_PHY_CCA_MAX_GOOD_VAL_9287_2GHZ -110
119 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
120 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
121 @@ -1015,52 +1015,6 @@ static bool ar9003_hw_ani_control(struct
125 -static void ar9003_hw_nf_sanitize_2g(struct ath_hw *ah, s16 *nf)
127 - struct ath_common *common = ath9k_hw_common(ah);
129 - if (*nf > ah->nf_2g_max) {
130 - ath_print(common, ATH_DBG_CALIBRATE,
131 - "2 GHz NF (%d) > MAX (%d), "
132 - "correcting to MAX",
133 - *nf, ah->nf_2g_max);
134 - *nf = ah->nf_2g_max;
135 - } else if (*nf < ah->nf_2g_min) {
136 - ath_print(common, ATH_DBG_CALIBRATE,
137 - "2 GHz NF (%d) < MIN (%d), "
138 - "correcting to MIN",
139 - *nf, ah->nf_2g_min);
140 - *nf = ah->nf_2g_min;
144 -static void ar9003_hw_nf_sanitize_5g(struct ath_hw *ah, s16 *nf)
146 - struct ath_common *common = ath9k_hw_common(ah);
148 - if (*nf > ah->nf_5g_max) {
149 - ath_print(common, ATH_DBG_CALIBRATE,
150 - "5 GHz NF (%d) > MAX (%d), "
151 - "correcting to MAX",
152 - *nf, ah->nf_5g_max);
153 - *nf = ah->nf_5g_max;
154 - } else if (*nf < ah->nf_5g_min) {
155 - ath_print(common, ATH_DBG_CALIBRATE,
156 - "5 GHz NF (%d) < MIN (%d), "
157 - "correcting to MIN",
158 - *nf, ah->nf_5g_min);
159 - *nf = ah->nf_5g_min;
163 -static void ar9003_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
165 - if (IS_CHAN_2GHZ(ah->curchan))
166 - ar9003_hw_nf_sanitize_2g(ah, nf);
168 - ar9003_hw_nf_sanitize_5g(ah, nf);
171 static void ar9003_hw_do_getnf(struct ath_hw *ah,
172 int16_t nfarray[NUM_NF_READINGS])
174 @@ -1070,7 +1024,6 @@ static void ar9003_hw_do_getnf(struct at
175 nf = MS(REG_READ(ah, AR_PHY_CCA_0), AR_PHY_MINCCA_PWR);
177 nf = 0 - ((nf ^ 0x1ff) + 1);
178 - ar9003_hw_nf_sanitize(ah, &nf);
179 ath_print(common, ATH_DBG_CALIBRATE,
180 "NF calibrated [ctl] [chain 0] is %d\n", nf);
182 @@ -1078,7 +1031,6 @@ static void ar9003_hw_do_getnf(struct at
183 nf = MS(REG_READ(ah, AR_PHY_CCA_1), AR_PHY_CH1_MINCCA_PWR);
185 nf = 0 - ((nf ^ 0x1ff) + 1);
186 - ar9003_hw_nf_sanitize(ah, &nf);
187 ath_print(common, ATH_DBG_CALIBRATE,
188 "NF calibrated [ctl] [chain 1] is %d\n", nf);
190 @@ -1086,7 +1038,6 @@ static void ar9003_hw_do_getnf(struct at
191 nf = MS(REG_READ(ah, AR_PHY_CCA_2), AR_PHY_CH2_MINCCA_PWR);
193 nf = 0 - ((nf ^ 0x1ff) + 1);
194 - ar9003_hw_nf_sanitize(ah, &nf);
195 ath_print(common, ATH_DBG_CALIBRATE,
196 "NF calibrated [ctl] [chain 2] is %d\n", nf);
198 @@ -1094,7 +1045,6 @@ static void ar9003_hw_do_getnf(struct at
199 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA), AR_PHY_EXT_MINCCA_PWR);
201 nf = 0 - ((nf ^ 0x1ff) + 1);
202 - ar9003_hw_nf_sanitize(ah, &nf);
203 ath_print(common, ATH_DBG_CALIBRATE,
204 "NF calibrated [ext] [chain 0] is %d\n", nf);
206 @@ -1102,7 +1052,6 @@ static void ar9003_hw_do_getnf(struct at
207 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA_1), AR_PHY_CH1_EXT_MINCCA_PWR);
209 nf = 0 - ((nf ^ 0x1ff) + 1);
210 - ar9003_hw_nf_sanitize(ah, &nf);
211 ath_print(common, ATH_DBG_CALIBRATE,
212 "NF calibrated [ext] [chain 1] is %d\n", nf);
214 @@ -1110,18 +1059,19 @@ static void ar9003_hw_do_getnf(struct at
215 nf = MS(REG_READ(ah, AR_PHY_EXT_CCA_2), AR_PHY_CH2_EXT_MINCCA_PWR);
217 nf = 0 - ((nf ^ 0x1ff) + 1);
218 - ar9003_hw_nf_sanitize(ah, &nf);
219 ath_print(common, ATH_DBG_CALIBRATE,
220 "NF calibrated [ext] [chain 2] is %d\n", nf);
224 -void ar9003_hw_set_nf_limits(struct ath_hw *ah)
225 +static void ar9003_hw_set_nf_limits(struct ath_hw *ah)
227 - ah->nf_2g_max = AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ;
228 - ah->nf_2g_min = AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ;
229 - ah->nf_5g_max = AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ;
230 - ah->nf_5g_min = AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ;
231 + ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_2GHZ;
232 + ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_2GHZ;
233 + ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9300_2GHZ;
234 + ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_5GHZ;
235 + ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9300_5GHZ;
236 + ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9300_5GHZ;
240 @@ -1309,6 +1259,8 @@ void ar9003_hw_attach_phy_ops(struct ath
241 priv_ops->do_getnf = ar9003_hw_do_getnf;
242 priv_ops->loadnf = ar9003_hw_loadnf;
243 priv_ops->ani_cache_ini_regs = ar9003_hw_ani_cache_ini_regs;
245 + ar9003_hw_set_nf_limits(ah);
248 void ar9003_hw_bb_watchdog_config(struct ath_hw *ah)
249 --- a/drivers/net/wireless/ath/ath9k/calib.c
250 +++ b/drivers/net/wireless/ath/ath9k/calib.c
251 @@ -74,13 +74,8 @@ static void ath9k_hw_update_nfcal_hist_b
254 if (h[i].invalidNFcount > 0) {
255 - if (nfarray[i] < AR_PHY_CCA_MIN_BAD_VALUE ||
256 - nfarray[i] > AR_PHY_CCA_MAX_HIGH_VALUE) {
257 - h[i].invalidNFcount = ATH9K_NF_CAL_HIST_MAX;
259 - h[i].invalidNFcount--;
260 - h[i].privNF = nfarray[i];
262 + h[i].invalidNFcount--;
263 + h[i].privNF = nfarray[i];
266 ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
267 @@ -172,6 +167,35 @@ void ath9k_hw_start_nfcal(struct ath_hw
268 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
271 +static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
273 + struct ath_common *common = ath9k_hw_common(ah);
274 + struct ath_nf_limits *limit;
277 + if (IS_CHAN_2GHZ(ah->curchan))
278 + limit = &ah->nf_2g;
280 + limit = &ah->nf_5g;
282 + for (i = 0; i < NUM_NF_READINGS; i++) {
286 + if (nf[i] > limit->max) {
287 + ath_print(common, ATH_DBG_CALIBRATE,
288 + "NF[%d] (%d) > MAX (%d), correcting to MAX",
289 + i, nf[i], limit->max);
290 + nf[i] = limit->max;
291 + } else if (nf[i] < limit->min) {
292 + ath_print(common, ATH_DBG_CALIBRATE,
293 + "NF[%d] (%d) < MIN (%d), correcting to NOM",
294 + i, nf[i], limit->min);
295 + nf[i] = limit->nominal;
300 int16_t ath9k_hw_getnf(struct ath_hw *ah,
301 struct ath9k_channel *chan)
303 @@ -190,6 +214,7 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah
304 return chan->rawNoiseFloor;
306 ath9k_hw_do_getnf(ah, nfarray);
307 + ath9k_hw_nf_sanitize(ah, nfarray);
309 if (ath9k_hw_get_nf_thresh(ah, c->band, &nfThresh)
311 @@ -211,25 +236,21 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah
313 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah)
315 + struct ath_nf_limits *limit;
319 - if (AR_SREV_9280(ah))
320 - noise_floor = AR_PHY_CCA_MAX_AR9280_GOOD_VALUE;
321 - else if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
322 - noise_floor = AR_PHY_CCA_MAX_AR9285_GOOD_VALUE;
323 - else if (AR_SREV_9287(ah))
324 - noise_floor = AR_PHY_CCA_MAX_AR9287_GOOD_VALUE;
325 + if (!ah->curchan || IS_CHAN_2GHZ(ah->curchan))
326 + limit = &ah->nf_2g;
328 - noise_floor = AR_PHY_CCA_MAX_AR5416_GOOD_VALUE;
329 + limit = &ah->nf_5g;
331 for (i = 0; i < NUM_NF_READINGS; i++) {
332 ah->nfCalHist[i].currIndex = 0;
333 - ah->nfCalHist[i].privNF = noise_floor;
334 + ah->nfCalHist[i].privNF = limit->nominal;
335 ah->nfCalHist[i].invalidNFcount =
336 AR_PHY_CCA_FILTERWINDOW_LENGTH;
337 for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
338 - ah->nfCalHist[i].nfCalBuffer[j] = noise_floor;
339 + ah->nfCalHist[i].nfCalBuffer[j] = limit->nominal;
343 --- a/drivers/net/wireless/ath/ath9k/calib.h
344 +++ b/drivers/net/wireless/ath/ath9k/calib.h
349 -#define AR_PHY_CCA_MAX_AR5416_GOOD_VALUE -85
350 -#define AR_PHY_CCA_MAX_AR9280_GOOD_VALUE -112
351 -#define AR_PHY_CCA_MAX_AR9285_GOOD_VALUE -118
352 -#define AR_PHY_CCA_MAX_AR9287_GOOD_VALUE -118
353 -#define AR_PHY_CCA_MAX_HIGH_VALUE -62
354 -#define AR_PHY_CCA_MIN_BAD_VALUE -140
355 #define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
356 #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
358 --- a/drivers/net/wireless/ath/ath9k/hw.c
359 +++ b/drivers/net/wireless/ath/ath9k/hw.c
360 @@ -621,9 +621,6 @@ static int __ath9k_hw_init(struct ath_hw
362 ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S);
364 - if (AR_SREV_9300_20_OR_LATER(ah))
365 - ar9003_hw_set_nf_limits(ah);
367 ath9k_init_nfcal_hist_buffer(ah);
368 ah->bb_watchdog_timeout_ms = 25;
370 --- a/drivers/net/wireless/ath/ath9k/hw.h
371 +++ b/drivers/net/wireless/ath/ath9k/hw.h
372 @@ -630,6 +630,12 @@ struct ath_hw_ops {
373 void (*ani_monitor)(struct ath_hw *ah, struct ath9k_channel *chan);
376 +struct ath_nf_limits {
383 struct ieee80211_hw *hw;
384 struct ath_common common;
385 @@ -651,10 +657,9 @@ struct ath_hw {
387 bool need_an_top2_fixup;
394 + struct ath_nf_limits nf_2g;
395 + struct ath_nf_limits nf_5g;
399 @@ -945,7 +950,6 @@ void ar9002_hw_enable_wep_aggregation(st
400 * Code specific to AR9003, we stuff these here to avoid callbacks
403 -void ar9003_hw_set_nf_limits(struct ath_hw *ah);
404 void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);
405 void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
406 void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);