|
@@ -246,13 +246,13 @@ static void ar9003_paprd_get_gain_table(struct ath_hw *ah)
|
|
|
static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
|
|
|
int target_power)
|
|
|
{
|
|
|
- int olpc_gain_delta = 0;
|
|
|
+ int olpc_gain_delta = 0, cl_gain_mod;
|
|
|
int alpha_therm, alpha_volt;
|
|
|
int therm_cal_value, volt_cal_value;
|
|
|
int therm_value, volt_value;
|
|
|
int thermal_gain_corr, voltage_gain_corr;
|
|
|
int desired_scale, desired_gain = 0;
|
|
|
- u32 reg;
|
|
|
+ u32 reg_olpc = 0, reg_cl_gain = 0;
|
|
|
|
|
|
REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1,
|
|
|
AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE);
|
|
@@ -271,15 +271,29 @@ static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
|
|
|
volt_value = REG_READ_FIELD(ah, AR_PHY_BB_THERM_ADC_4,
|
|
|
AR_PHY_BB_THERM_ADC_4_LATEST_VOLT_VALUE);
|
|
|
|
|
|
- if (chain == 0)
|
|
|
- reg = AR_PHY_TPC_11_B0;
|
|
|
- else if (chain == 1)
|
|
|
- reg = AR_PHY_TPC_11_B1;
|
|
|
- else
|
|
|
- reg = AR_PHY_TPC_11_B2;
|
|
|
+ switch (chain) {
|
|
|
+ case 0:
|
|
|
+ reg_olpc = AR_PHY_TPC_11_B0;
|
|
|
+ reg_cl_gain = AR_PHY_CL_TAB_0;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ reg_olpc = AR_PHY_TPC_11_B1;
|
|
|
+ reg_cl_gain = AR_PHY_CL_TAB_1;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ reg_olpc = AR_PHY_TPC_11_B2;
|
|
|
+ reg_cl_gain = AR_PHY_CL_TAB_2;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ath_dbg(ath9k_hw_common(ah), ATH_DBG_CALIBRATE,
|
|
|
+ "Invalid chainmask: %d\n", chain);
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- olpc_gain_delta = REG_READ_FIELD(ah, reg,
|
|
|
+ olpc_gain_delta = REG_READ_FIELD(ah, reg_olpc,
|
|
|
AR_PHY_TPC_11_OLPC_GAIN_DELTA);
|
|
|
+ cl_gain_mod = REG_READ_FIELD(ah, reg_cl_gain,
|
|
|
+ AR_PHY_CL_TAB_CL_GAIN_MOD);
|
|
|
|
|
|
if (olpc_gain_delta >= 128)
|
|
|
olpc_gain_delta = olpc_gain_delta - 256;
|
|
@@ -289,7 +303,7 @@ static unsigned int ar9003_get_desired_gain(struct ath_hw *ah, int chain,
|
|
|
voltage_gain_corr = (alpha_volt * (volt_value - volt_cal_value) +
|
|
|
(128 / 2)) / 128;
|
|
|
desired_gain = target_power - olpc_gain_delta - thermal_gain_corr -
|
|
|
- voltage_gain_corr + desired_scale;
|
|
|
+ voltage_gain_corr + desired_scale + cl_gain_mod;
|
|
|
|
|
|
return desired_gain;
|
|
|
}
|