1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 11 Jul 2016 11:35:55 +0200
3 Subject: [PATCH] ath9k_hw: implement temperature compensation support for
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
10 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
11 @@ -33,6 +33,7 @@ struct coeff {
13 enum ar9003_cal_types {
14 IQ_MISMATCH_CAL = BIT(0),
15 + TEMP_COMP_CAL = BIT(1),
18 static void ar9003_hw_setup_calibration(struct ath_hw *ah,
19 @@ -58,6 +59,12 @@ static void ar9003_hw_setup_calibration(
21 REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
24 + ath_dbg(common, CALIBRATE,
25 + "starting Temperature Compensation Calibration\n");
26 + REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_LOCAL);
27 + REG_SET_BIT(ah, AR_CH0_THERM, AR_CH0_THERM_START);
30 ath_err(common, "Invalid calibration type\n");
32 @@ -86,7 +93,8 @@ static bool ar9003_hw_per_calibration(st
34 * Accumulate cal measures for active chains
36 - cur_caldata->calCollect(ah);
37 + if (cur_caldata->calCollect)
38 + cur_caldata->calCollect(ah);
41 if (ah->cal_samples >= cur_caldata->calNumSamples) {
42 @@ -99,7 +107,8 @@ static bool ar9003_hw_per_calibration(st
44 * Process accumulated data
46 - cur_caldata->calPostProc(ah, numChains);
47 + if (cur_caldata->calPostProc)
48 + cur_caldata->calPostProc(ah, numChains);
50 /* Calibration has finished. */
51 caldata->CalValid |= cur_caldata->calType;
52 @@ -314,9 +323,16 @@ static const struct ath9k_percal_data iq
56 +static const struct ath9k_percal_data temp_cal_single_sample = {
62 static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
64 ah->iq_caldata.calData = &iq_cal_single_sample;
65 + ah->temp_caldata.calData = &temp_cal_single_sample;
67 if (AR_SREV_9300_20_OR_LATER(ah)) {
68 ah->enabled_cals |= TX_IQ_CAL;
69 @@ -324,7 +340,7 @@ static void ar9003_hw_init_cal_settings(
70 ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
73 - ah->supp_cals = IQ_MISMATCH_CAL;
74 + ah->supp_cals = IQ_MISMATCH_CAL | TEMP_COMP_CAL;
77 #define OFF_UPPER_LT 24
78 @@ -1383,6 +1399,9 @@ static void ar9003_hw_init_cal_common(st
79 INIT_CAL(&ah->iq_caldata);
80 INSERT_CAL(ah, &ah->iq_caldata);
82 + INIT_CAL(&ah->temp_caldata);
83 + INSERT_CAL(ah, &ah->temp_caldata);
85 /* Initialize current pointer to first element in list */
86 ah->cal_list_curr = ah->cal_list;
88 --- a/drivers/net/wireless/ath/ath9k/hw.h
89 +++ b/drivers/net/wireless/ath/ath9k/hw.h
90 @@ -830,6 +830,7 @@ struct ath_hw {
93 struct ath9k_cal_list iq_caldata;
94 + struct ath9k_cal_list temp_caldata;
95 struct ath9k_cal_list adcgain_caldata;
96 struct ath9k_cal_list adcdc_caldata;
97 struct ath9k_cal_list *cal_list;