]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
ath9k_hw: Add carrier leak correction in desired gain calculation
authorMohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Thu, 23 Jun 2011 14:33:38 +0000 (20:03 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 27 Jun 2011 19:09:40 +0000 (15:09 -0400)
Cc: muddin@qca.qualcomm.com
Signed-off-by: Mohammed Shafi Shajakhan <mohammed@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ar9003_paprd.c
drivers/net/wireless/ath/ath9k/ar9003_phy.h

index 8f6d11dfa371fa57d01e9b70fe356ed0209fe82a..6e9e892e528188b559beacd2a5935df8bc67c38b 100644 (file)
@@ -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;
 }
index 9eb3aa211688942de42ed07d6ccd0576b17e0772..6de3f0bc18e6f34ab9c69d171972237823d5ad84 100644 (file)
 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5     0x3F00
 #define AR_PHY_POWERTX_RATE8_POWERTXHT40_5_S   8
 
+#define AR_PHY_CL_TAB_CL_GAIN_MOD              0x1f
+#define AR_PHY_CL_TAB_CL_GAIN_MOD_S            0
+
 void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
 
 #endif  /* AR9003_PHY_H */