aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/calib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath9k/calib.c')
-rw-r--r--drivers/net/wireless/ath9k/calib.c190
1 files changed, 86 insertions, 104 deletions
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
index 69ff01ce968b..1fc3a08e85c6 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -14,10 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include "core.h" 17#include "ath9k.h"
18#include "hw.h"
19#include "reg.h"
20#include "phy.h"
21 18
22/* We can tune this as we go by monitoring really low values */ 19/* We can tune this as we go by monitoring really low values */
23#define ATH9K_NF_TOO_LOW -60 20#define ATH9K_NF_TOO_LOW -60
@@ -26,7 +23,7 @@
26 * is incorrect and we should use the static NF value. Later we can try to 23 * is incorrect and we should use the static NF value. Later we can try to
27 * find out why they are reporting these values */ 24 * find out why they are reporting these values */
28 25
29static bool ath9k_hw_nf_in_range(struct ath_hal *ah, s16 nf) 26static bool ath9k_hw_nf_in_range(struct ath_hw *ah, s16 nf)
30{ 27{
31 if (nf > ATH9K_NF_TOO_LOW) { 28 if (nf > ATH9K_NF_TOO_LOW) {
32 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 29 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
@@ -89,7 +86,7 @@ static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
89 return; 86 return;
90} 87}
91 88
92static void ath9k_hw_do_getnf(struct ath_hal *ah, 89static void ath9k_hw_do_getnf(struct ath_hw *ah,
93 int16_t nfarray[NUM_NF_READINGS]) 90 int16_t nfarray[NUM_NF_READINGS])
94{ 91{
95 int16_t nf; 92 int16_t nf;
@@ -169,16 +166,16 @@ static void ath9k_hw_do_getnf(struct ath_hal *ah,
169 } 166 }
170} 167}
171 168
172static bool getNoiseFloorThresh(struct ath_hal *ah, 169static bool getNoiseFloorThresh(struct ath_hw *ah,
173 enum ieee80211_band band, 170 enum ieee80211_band band,
174 int16_t *nft) 171 int16_t *nft)
175{ 172{
176 switch (band) { 173 switch (band) {
177 case IEEE80211_BAND_5GHZ: 174 case IEEE80211_BAND_5GHZ:
178 *nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_5); 175 *nft = (int8_t)ah->eep_ops->get_eeprom(ah, EEP_NFTHRESH_5);
179 break; 176 break;
180 case IEEE80211_BAND_2GHZ: 177 case IEEE80211_BAND_2GHZ:
181 *nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_2); 178 *nft = (int8_t)ah->eep_ops->get_eeprom(ah, EEP_NFTHRESH_2);
182 break; 179 break;
183 default: 180 default:
184 BUG_ON(1); 181 BUG_ON(1);
@@ -188,7 +185,7 @@ static bool getNoiseFloorThresh(struct ath_hal *ah,
188 return true; 185 return true;
189} 186}
190 187
191static void ath9k_hw_setup_calibration(struct ath_hal *ah, 188static void ath9k_hw_setup_calibration(struct ath_hw *ah,
192 struct hal_cal_list *currCal) 189 struct hal_cal_list *currCal)
193{ 190{
194 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0), 191 REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0),
@@ -222,10 +219,9 @@ static void ath9k_hw_setup_calibration(struct ath_hal *ah,
222 AR_PHY_TIMING_CTRL4_DO_CAL); 219 AR_PHY_TIMING_CTRL4_DO_CAL);
223} 220}
224 221
225static void ath9k_hw_reset_calibration(struct ath_hal *ah, 222static void ath9k_hw_reset_calibration(struct ath_hw *ah,
226 struct hal_cal_list *currCal) 223 struct hal_cal_list *currCal)
227{ 224{
228 struct ath_hal_5416 *ahp = AH5416(ah);
229 int i; 225 int i;
230 226
231 ath9k_hw_setup_calibration(ah, currCal); 227 ath9k_hw_setup_calibration(ah, currCal);
@@ -233,23 +229,21 @@ static void ath9k_hw_reset_calibration(struct ath_hal *ah,
233 currCal->calState = CAL_RUNNING; 229 currCal->calState = CAL_RUNNING;
234 230
235 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 231 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
236 ahp->ah_Meas0.sign[i] = 0; 232 ah->meas0.sign[i] = 0;
237 ahp->ah_Meas1.sign[i] = 0; 233 ah->meas1.sign[i] = 0;
238 ahp->ah_Meas2.sign[i] = 0; 234 ah->meas2.sign[i] = 0;
239 ahp->ah_Meas3.sign[i] = 0; 235 ah->meas3.sign[i] = 0;
240 } 236 }
241 237
242 ahp->ah_CalSamples = 0; 238 ah->cal_samples = 0;
243} 239}
244 240
245static void ath9k_hw_per_calibration(struct ath_hal *ah, 241static void ath9k_hw_per_calibration(struct ath_hw *ah,
246 struct ath9k_channel *ichan, 242 struct ath9k_channel *ichan,
247 u8 rxchainmask, 243 u8 rxchainmask,
248 struct hal_cal_list *currCal, 244 struct hal_cal_list *currCal,
249 bool *isCalDone) 245 bool *isCalDone)
250{ 246{
251 struct ath_hal_5416 *ahp = AH5416(ah);
252
253 *isCalDone = false; 247 *isCalDone = false;
254 248
255 if (currCal->calState == CAL_RUNNING) { 249 if (currCal->calState == CAL_RUNNING) {
@@ -257,9 +251,9 @@ static void ath9k_hw_per_calibration(struct ath_hal *ah,
257 AR_PHY_TIMING_CTRL4_DO_CAL)) { 251 AR_PHY_TIMING_CTRL4_DO_CAL)) {
258 252
259 currCal->calData->calCollect(ah); 253 currCal->calData->calCollect(ah);
260 ahp->ah_CalSamples++; 254 ah->cal_samples++;
261 255
262 if (ahp->ah_CalSamples >= currCal->calData->calNumSamples) { 256 if (ah->cal_samples >= currCal->calData->calNumSamples) {
263 int i, numChains = 0; 257 int i, numChains = 0;
264 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 258 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
265 if (rxchainmask & (1 << i)) 259 if (rxchainmask & (1 << i))
@@ -280,13 +274,12 @@ static void ath9k_hw_per_calibration(struct ath_hal *ah,
280} 274}
281 275
282/* Assumes you are talking about the currently configured channel */ 276/* Assumes you are talking about the currently configured channel */
283static bool ath9k_hw_iscal_supported(struct ath_hal *ah, 277static bool ath9k_hw_iscal_supported(struct ath_hw *ah,
284 enum hal_cal_types calType) 278 enum hal_cal_types calType)
285{ 279{
286 struct ath_hal_5416 *ahp = AH5416(ah);
287 struct ieee80211_conf *conf = &ah->ah_sc->hw->conf; 280 struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
288 281
289 switch (calType & ahp->ah_suppCals) { 282 switch (calType & ah->supp_cals) {
290 case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */ 283 case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
291 return true; 284 return true;
292 case ADC_GAIN_CAL: 285 case ADC_GAIN_CAL:
@@ -299,90 +292,86 @@ static bool ath9k_hw_iscal_supported(struct ath_hal *ah,
299 return false; 292 return false;
300} 293}
301 294
302static void ath9k_hw_iqcal_collect(struct ath_hal *ah) 295static void ath9k_hw_iqcal_collect(struct ath_hw *ah)
303{ 296{
304 struct ath_hal_5416 *ahp = AH5416(ah);
305 int i; 297 int i;
306 298
307 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 299 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
308 ahp->ah_totalPowerMeasI[i] += 300 ah->totalPowerMeasI[i] +=
309 REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 301 REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
310 ahp->ah_totalPowerMeasQ[i] += 302 ah->totalPowerMeasQ[i] +=
311 REG_READ(ah, AR_PHY_CAL_MEAS_1(i)); 303 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
312 ahp->ah_totalIqCorrMeas[i] += 304 ah->totalIqCorrMeas[i] +=
313 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i)); 305 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
314 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 306 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
315 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n", 307 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
316 ahp->ah_CalSamples, i, ahp->ah_totalPowerMeasI[i], 308 ah->cal_samples, i, ah->totalPowerMeasI[i],
317 ahp->ah_totalPowerMeasQ[i], 309 ah->totalPowerMeasQ[i],
318 ahp->ah_totalIqCorrMeas[i]); 310 ah->totalIqCorrMeas[i]);
319 } 311 }
320} 312}
321 313
322static void ath9k_hw_adc_gaincal_collect(struct ath_hal *ah) 314static void ath9k_hw_adc_gaincal_collect(struct ath_hw *ah)
323{ 315{
324 struct ath_hal_5416 *ahp = AH5416(ah);
325 int i; 316 int i;
326 317
327 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 318 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
328 ahp->ah_totalAdcIOddPhase[i] += 319 ah->totalAdcIOddPhase[i] +=
329 REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 320 REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
330 ahp->ah_totalAdcIEvenPhase[i] += 321 ah->totalAdcIEvenPhase[i] +=
331 REG_READ(ah, AR_PHY_CAL_MEAS_1(i)); 322 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
332 ahp->ah_totalAdcQOddPhase[i] += 323 ah->totalAdcQOddPhase[i] +=
333 REG_READ(ah, AR_PHY_CAL_MEAS_2(i)); 324 REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
334 ahp->ah_totalAdcQEvenPhase[i] += 325 ah->totalAdcQEvenPhase[i] +=
335 REG_READ(ah, AR_PHY_CAL_MEAS_3(i)); 326 REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
336 327
337 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 328 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
338 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; " 329 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
339 "oddq=0x%08x; evenq=0x%08x;\n", 330 "oddq=0x%08x; evenq=0x%08x;\n",
340 ahp->ah_CalSamples, i, 331 ah->cal_samples, i,
341 ahp->ah_totalAdcIOddPhase[i], 332 ah->totalAdcIOddPhase[i],
342 ahp->ah_totalAdcIEvenPhase[i], 333 ah->totalAdcIEvenPhase[i],
343 ahp->ah_totalAdcQOddPhase[i], 334 ah->totalAdcQOddPhase[i],
344 ahp->ah_totalAdcQEvenPhase[i]); 335 ah->totalAdcQEvenPhase[i]);
345 } 336 }
346} 337}
347 338
348static void ath9k_hw_adc_dccal_collect(struct ath_hal *ah) 339static void ath9k_hw_adc_dccal_collect(struct ath_hw *ah)
349{ 340{
350 struct ath_hal_5416 *ahp = AH5416(ah);
351 int i; 341 int i;
352 342
353 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 343 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
354 ahp->ah_totalAdcDcOffsetIOddPhase[i] += 344 ah->totalAdcDcOffsetIOddPhase[i] +=
355 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_0(i)); 345 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
356 ahp->ah_totalAdcDcOffsetIEvenPhase[i] += 346 ah->totalAdcDcOffsetIEvenPhase[i] +=
357 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_1(i)); 347 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
358 ahp->ah_totalAdcDcOffsetQOddPhase[i] += 348 ah->totalAdcDcOffsetQOddPhase[i] +=
359 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i)); 349 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
360 ahp->ah_totalAdcDcOffsetQEvenPhase[i] += 350 ah->totalAdcDcOffsetQEvenPhase[i] +=
361 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_3(i)); 351 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
362 352
363 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 353 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
364 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; " 354 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
365 "oddq=0x%08x; evenq=0x%08x;\n", 355 "oddq=0x%08x; evenq=0x%08x;\n",
366 ahp->ah_CalSamples, i, 356 ah->cal_samples, i,
367 ahp->ah_totalAdcDcOffsetIOddPhase[i], 357 ah->totalAdcDcOffsetIOddPhase[i],
368 ahp->ah_totalAdcDcOffsetIEvenPhase[i], 358 ah->totalAdcDcOffsetIEvenPhase[i],
369 ahp->ah_totalAdcDcOffsetQOddPhase[i], 359 ah->totalAdcDcOffsetQOddPhase[i],
370 ahp->ah_totalAdcDcOffsetQEvenPhase[i]); 360 ah->totalAdcDcOffsetQEvenPhase[i]);
371 } 361 }
372} 362}
373 363
374static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains) 364static void ath9k_hw_iqcalibrate(struct ath_hw *ah, u8 numChains)
375{ 365{
376 struct ath_hal_5416 *ahp = AH5416(ah);
377 u32 powerMeasQ, powerMeasI, iqCorrMeas; 366 u32 powerMeasQ, powerMeasI, iqCorrMeas;
378 u32 qCoffDenom, iCoffDenom; 367 u32 qCoffDenom, iCoffDenom;
379 int32_t qCoff, iCoff; 368 int32_t qCoff, iCoff;
380 int iqCorrNeg, i; 369 int iqCorrNeg, i;
381 370
382 for (i = 0; i < numChains; i++) { 371 for (i = 0; i < numChains; i++) {
383 powerMeasI = ahp->ah_totalPowerMeasI[i]; 372 powerMeasI = ah->totalPowerMeasI[i];
384 powerMeasQ = ahp->ah_totalPowerMeasQ[i]; 373 powerMeasQ = ah->totalPowerMeasQ[i];
385 iqCorrMeas = ahp->ah_totalIqCorrMeas[i]; 374 iqCorrMeas = ah->totalIqCorrMeas[i];
386 375
387 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 376 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
388 "Starting IQ Cal and Correction for Chain %d\n", 377 "Starting IQ Cal and Correction for Chain %d\n",
@@ -390,7 +379,7 @@ static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains)
390 379
391 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 380 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
392 "Orignal: Chn %diq_corr_meas = 0x%08x\n", 381 "Orignal: Chn %diq_corr_meas = 0x%08x\n",
393 i, ahp->ah_totalIqCorrMeas[i]); 382 i, ah->totalIqCorrMeas[i]);
394 383
395 iqCorrNeg = 0; 384 iqCorrNeg = 0;
396 385
@@ -448,17 +437,16 @@ static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains)
448 AR_PHY_TIMING_CTRL4_IQCORR_ENABLE); 437 AR_PHY_TIMING_CTRL4_IQCORR_ENABLE);
449} 438}
450 439
451static void ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah, u8 numChains) 440static void ath9k_hw_adc_gaincal_calibrate(struct ath_hw *ah, u8 numChains)
452{ 441{
453 struct ath_hal_5416 *ahp = AH5416(ah);
454 u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset, qEvenMeasOffset; 442 u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset, qEvenMeasOffset;
455 u32 qGainMismatch, iGainMismatch, val, i; 443 u32 qGainMismatch, iGainMismatch, val, i;
456 444
457 for (i = 0; i < numChains; i++) { 445 for (i = 0; i < numChains; i++) {
458 iOddMeasOffset = ahp->ah_totalAdcIOddPhase[i]; 446 iOddMeasOffset = ah->totalAdcIOddPhase[i];
459 iEvenMeasOffset = ahp->ah_totalAdcIEvenPhase[i]; 447 iEvenMeasOffset = ah->totalAdcIEvenPhase[i];
460 qOddMeasOffset = ahp->ah_totalAdcQOddPhase[i]; 448 qOddMeasOffset = ah->totalAdcQOddPhase[i];
461 qEvenMeasOffset = ahp->ah_totalAdcQEvenPhase[i]; 449 qEvenMeasOffset = ah->totalAdcQEvenPhase[i];
462 450
463 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 451 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
464 "Starting ADC Gain Cal for Chain %d\n", i); 452 "Starting ADC Gain Cal for Chain %d\n", i);
@@ -506,21 +494,20 @@ static void ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah, u8 numChains)
506 AR_PHY_NEW_ADC_GAIN_CORR_ENABLE); 494 AR_PHY_NEW_ADC_GAIN_CORR_ENABLE);
507} 495}
508 496
509static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains) 497static void ath9k_hw_adc_dccal_calibrate(struct ath_hw *ah, u8 numChains)
510{ 498{
511 struct ath_hal_5416 *ahp = AH5416(ah);
512 u32 iOddMeasOffset, iEvenMeasOffset, val, i; 499 u32 iOddMeasOffset, iEvenMeasOffset, val, i;
513 int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch; 500 int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch;
514 const struct hal_percal_data *calData = 501 const struct hal_percal_data *calData =
515 ahp->ah_cal_list_curr->calData; 502 ah->cal_list_curr->calData;
516 u32 numSamples = 503 u32 numSamples =
517 (1 << (calData->calCountMax + 5)) * calData->calNumSamples; 504 (1 << (calData->calCountMax + 5)) * calData->calNumSamples;
518 505
519 for (i = 0; i < numChains; i++) { 506 for (i = 0; i < numChains; i++) {
520 iOddMeasOffset = ahp->ah_totalAdcDcOffsetIOddPhase[i]; 507 iOddMeasOffset = ah->totalAdcDcOffsetIOddPhase[i];
521 iEvenMeasOffset = ahp->ah_totalAdcDcOffsetIEvenPhase[i]; 508 iEvenMeasOffset = ah->totalAdcDcOffsetIEvenPhase[i];
522 qOddMeasOffset = ahp->ah_totalAdcDcOffsetQOddPhase[i]; 509 qOddMeasOffset = ah->totalAdcDcOffsetQOddPhase[i];
523 qEvenMeasOffset = ahp->ah_totalAdcDcOffsetQEvenPhase[i]; 510 qEvenMeasOffset = ah->totalAdcDcOffsetQEvenPhase[i];
524 511
525 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 512 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
526 "Starting ADC DC Offset Cal for Chain %d\n", i); 513 "Starting ADC DC Offset Cal for Chain %d\n", i);
@@ -565,13 +552,12 @@ static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains)
565} 552}
566 553
567/* This is done for the currently configured channel */ 554/* This is done for the currently configured channel */
568bool ath9k_hw_reset_calvalid(struct ath_hal *ah) 555bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
569{ 556{
570 struct ath_hal_5416 *ahp = AH5416(ah);
571 struct ieee80211_conf *conf = &ah->ah_sc->hw->conf; 557 struct ieee80211_conf *conf = &ah->ah_sc->hw->conf;
572 struct hal_cal_list *currCal = ahp->ah_cal_list_curr; 558 struct hal_cal_list *currCal = ah->cal_list_curr;
573 559
574 if (!ah->ah_curchan) 560 if (!ah->curchan)
575 return true; 561 return true;
576 562
577 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah)) 563 if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
@@ -594,13 +580,13 @@ bool ath9k_hw_reset_calvalid(struct ath_hal *ah)
594 "Resetting Cal %d state for channel %u\n", 580 "Resetting Cal %d state for channel %u\n",
595 currCal->calData->calType, conf->channel->center_freq); 581 currCal->calData->calType, conf->channel->center_freq);
596 582
597 ah->ah_curchan->CalValid &= ~currCal->calData->calType; 583 ah->curchan->CalValid &= ~currCal->calData->calType;
598 currCal->calState = CAL_WAITING; 584 currCal->calState = CAL_WAITING;
599 585
600 return false; 586 return false;
601} 587}
602 588
603void ath9k_hw_start_nfcal(struct ath_hal *ah) 589void ath9k_hw_start_nfcal(struct ath_hw *ah)
604{ 590{
605 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, 591 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
606 AR_PHY_AGC_CONTROL_ENABLE_NF); 592 AR_PHY_AGC_CONTROL_ENABLE_NF);
@@ -609,7 +595,7 @@ void ath9k_hw_start_nfcal(struct ath_hal *ah)
609 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); 595 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
610} 596}
611 597
612void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan) 598void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
613{ 599{
614 struct ath9k_nfcal_hist *h; 600 struct ath9k_nfcal_hist *h;
615 int i, j; 601 int i, j;
@@ -665,7 +651,7 @@ void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan)
665 } 651 }
666} 652}
667 653
668int16_t ath9k_hw_getnf(struct ath_hal *ah, 654int16_t ath9k_hw_getnf(struct ath_hw *ah,
669 struct ath9k_channel *chan) 655 struct ath9k_channel *chan)
670{ 656{
671 int16_t nf, nfThresh; 657 int16_t nf, nfThresh;
@@ -701,7 +687,7 @@ int16_t ath9k_hw_getnf(struct ath_hal *ah,
701 return chan->rawNoiseFloor; 687 return chan->rawNoiseFloor;
702} 688}
703 689
704void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah) 690void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah)
705{ 691{
706 int i, j; 692 int i, j;
707 693
@@ -715,10 +701,9 @@ void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah)
715 AR_PHY_CCA_MAX_GOOD_VALUE; 701 AR_PHY_CCA_MAX_GOOD_VALUE;
716 } 702 }
717 } 703 }
718 return;
719} 704}
720 705
721s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan) 706s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan)
722{ 707{
723 s16 nf; 708 s16 nf;
724 709
@@ -733,12 +718,11 @@ s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan)
733 return nf; 718 return nf;
734} 719}
735 720
736bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan, 721bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
737 u8 rxchainmask, bool longcal, 722 u8 rxchainmask, bool longcal,
738 bool *isCalDone) 723 bool *isCalDone)
739{ 724{
740 struct ath_hal_5416 *ahp = AH5416(ah); 725 struct hal_cal_list *currCal = ah->cal_list_curr;
741 struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
742 726
743 *isCalDone = true; 727 *isCalDone = true;
744 728
@@ -748,7 +732,7 @@ bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
748 ath9k_hw_per_calibration(ah, chan, rxchainmask, currCal, 732 ath9k_hw_per_calibration(ah, chan, rxchainmask, currCal,
749 isCalDone); 733 isCalDone);
750 if (*isCalDone) { 734 if (*isCalDone) {
751 ahp->ah_cal_list_curr = currCal = currCal->calNext; 735 ah->cal_list_curr = currCal = currCal->calNext;
752 736
753 if (currCal->calState == CAL_WAITING) { 737 if (currCal->calState == CAL_WAITING) {
754 *isCalDone = false; 738 *isCalDone = false;
@@ -759,7 +743,7 @@ bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
759 743
760 if (longcal) { 744 if (longcal) {
761 ath9k_hw_getnf(ah, chan); 745 ath9k_hw_getnf(ah, chan);
762 ath9k_hw_loadnf(ah, ah->ah_curchan); 746 ath9k_hw_loadnf(ah, ah->curchan);
763 ath9k_hw_start_nfcal(ah); 747 ath9k_hw_start_nfcal(ah);
764 748
765 if (chan->channelFlags & CHANNEL_CW_INT) 749 if (chan->channelFlags & CHANNEL_CW_INT)
@@ -769,7 +753,7 @@ bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
769 return true; 753 return true;
770} 754}
771 755
772static inline void ath9k_hw_9285_pa_cal(struct ath_hal *ah) 756static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
773{ 757{
774 758
775 u32 regVal; 759 u32 regVal;
@@ -864,11 +848,9 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hal *ah)
864 848
865} 849}
866 850
867bool ath9k_hw_init_cal(struct ath_hal *ah, 851bool ath9k_hw_init_cal(struct ath_hw *ah,
868 struct ath9k_channel *chan) 852 struct ath9k_channel *chan)
869{ 853{
870 struct ath_hal_5416 *ahp = AH5416(ah);
871
872 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 854 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
873 REG_READ(ah, AR_PHY_AGC_CONTROL) | 855 REG_READ(ah, AR_PHY_AGC_CONTROL) |
874 AR_PHY_AGC_CONTROL_CAL); 856 AR_PHY_AGC_CONTROL_CAL);
@@ -887,32 +869,32 @@ bool ath9k_hw_init_cal(struct ath_hal *ah,
887 REG_READ(ah, AR_PHY_AGC_CONTROL) | 869 REG_READ(ah, AR_PHY_AGC_CONTROL) |
888 AR_PHY_AGC_CONTROL_NF); 870 AR_PHY_AGC_CONTROL_NF);
889 871
890 ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr = NULL; 872 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
891 873
892 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) { 874 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
893 if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) { 875 if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) {
894 INIT_CAL(&ahp->ah_adcGainCalData); 876 INIT_CAL(&ah->adcgain_caldata);
895 INSERT_CAL(ahp, &ahp->ah_adcGainCalData); 877 INSERT_CAL(ah, &ah->adcgain_caldata);
896 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 878 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
897 "enabling ADC Gain Calibration.\n"); 879 "enabling ADC Gain Calibration.\n");
898 } 880 }
899 if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) { 881 if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) {
900 INIT_CAL(&ahp->ah_adcDcCalData); 882 INIT_CAL(&ah->adcdc_caldata);
901 INSERT_CAL(ahp, &ahp->ah_adcDcCalData); 883 INSERT_CAL(ah, &ah->adcdc_caldata);
902 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 884 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
903 "enabling ADC DC Calibration.\n"); 885 "enabling ADC DC Calibration.\n");
904 } 886 }
905 if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { 887 if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
906 INIT_CAL(&ahp->ah_iqCalData); 888 INIT_CAL(&ah->iq_caldata);
907 INSERT_CAL(ahp, &ahp->ah_iqCalData); 889 INSERT_CAL(ah, &ah->iq_caldata);
908 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 890 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
909 "enabling IQ Calibration.\n"); 891 "enabling IQ Calibration.\n");
910 } 892 }
911 893
912 ahp->ah_cal_list_curr = ahp->ah_cal_list; 894 ah->cal_list_curr = ah->cal_list;
913 895
914 if (ahp->ah_cal_list_curr) 896 if (ah->cal_list_curr)
915 ath9k_hw_reset_calibration(ah, ahp->ah_cal_list_curr); 897 ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
916 } 898 }
917 899
918 chan->CalValid = 0; 900 chan->CalValid = 0;