diff options
author | Sujith Manoharan <c_manoha@qca.qualcomm.com> | 2012-12-09 20:52:38 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-12-10 15:49:51 -0500 |
commit | 1562580e37e7a6936d591fd04cf9d7b79a096bf0 (patch) | |
tree | a32b35a602c71daf045441fd7ff17fa70936142b /drivers/net/wireless | |
parent | 0f21ee8d9c8a041b974cfb75d81d07b61bd0869f (diff) |
ath9k_hw: Calculate the correct training power for PAPRD
Assign the training power for PAPRD based on the chip.
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 41 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 22 |
2 files changed, 43 insertions, 20 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index 6b8861c559ed..11082b417d24 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | |||
@@ -5072,6 +5072,33 @@ static inline u8 mcsidx_to_tgtpwridx(unsigned int mcs_idx, u8 base_pwridx) | |||
5072 | return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2; | 5072 | return base_pwridx + 4 * (mcs_idx / 8) + mod_idx - 2; |
5073 | } | 5073 | } |
5074 | 5074 | ||
5075 | static void ar9003_paprd_set_txpower(struct ath_hw *ah, | ||
5076 | struct ath9k_channel *chan, | ||
5077 | u8 *targetPowerValT2) | ||
5078 | { | ||
5079 | int i; | ||
5080 | |||
5081 | if (!ar9003_is_paprd_enabled(ah)) | ||
5082 | return; | ||
5083 | |||
5084 | if (IS_CHAN_HT40(chan)) | ||
5085 | i = ALL_TARGET_HT40_7; | ||
5086 | else | ||
5087 | i = ALL_TARGET_HT20_7; | ||
5088 | |||
5089 | if (IS_CHAN_2GHZ(chan)) { | ||
5090 | if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah) && | ||
5091 | !AR_SREV_9462(ah) && !AR_SREV_9565(ah)) { | ||
5092 | if (IS_CHAN_HT40(chan)) | ||
5093 | i = ALL_TARGET_HT40_0_8_16; | ||
5094 | else | ||
5095 | i = ALL_TARGET_HT20_0_8_16; | ||
5096 | } | ||
5097 | } | ||
5098 | |||
5099 | ah->paprd_target_power = targetPowerValT2[i]; | ||
5100 | } | ||
5101 | |||
5075 | static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, | 5102 | static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, |
5076 | struct ath9k_channel *chan, u16 cfgCtl, | 5103 | struct ath9k_channel *chan, u16 cfgCtl, |
5077 | u8 twiceAntennaReduction, | 5104 | u8 twiceAntennaReduction, |
@@ -5166,19 +5193,7 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, | |||
5166 | /* Write target power array to registers */ | 5193 | /* Write target power array to registers */ |
5167 | ar9003_hw_tx_power_regwrite(ah, targetPowerValT2); | 5194 | ar9003_hw_tx_power_regwrite(ah, targetPowerValT2); |
5168 | ar9003_hw_calibration_apply(ah, chan->channel); | 5195 | ar9003_hw_calibration_apply(ah, chan->channel); |
5169 | 5196 | ar9003_paprd_set_txpower(ah, chan, targetPowerValT2); | |
5170 | if (IS_CHAN_2GHZ(chan)) { | ||
5171 | if (IS_CHAN_HT40(chan)) | ||
5172 | i = ALL_TARGET_HT40_0_8_16; | ||
5173 | else | ||
5174 | i = ALL_TARGET_HT20_0_8_16; | ||
5175 | } else { | ||
5176 | if (IS_CHAN_HT40(chan)) | ||
5177 | i = ALL_TARGET_HT40_7; | ||
5178 | else | ||
5179 | i = ALL_TARGET_HT20_7; | ||
5180 | } | ||
5181 | ah->paprd_target_power = targetPowerValT2[i]; | ||
5182 | } | 5197 | } |
5183 | 5198 | ||
5184 | static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah, | 5199 | static u16 ath9k_hw_ar9300_get_spur_channel(struct ath_hw *ah, |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index aea190883141..09c1f9da67a0 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c | |||
@@ -74,15 +74,23 @@ static int ar9003_get_training_power_2g(struct ath_hw *ah) | |||
74 | unsigned int power, scale, delta; | 74 | unsigned int power, scale, delta; |
75 | 75 | ||
76 | scale = ar9003_get_paprd_scale_factor(ah, chan); | 76 | scale = ar9003_get_paprd_scale_factor(ah, chan); |
77 | power = REG_READ_FIELD(ah, AR_PHY_POWERTX_RATE5, | ||
78 | AR_PHY_POWERTX_RATE5_POWERTXHT20_0); | ||
79 | 77 | ||
80 | delta = abs((int) ah->paprd_target_power - (int) power); | 78 | if (AR_SREV_9330(ah) || AR_SREV_9340(ah) || |
81 | if (delta > scale) | 79 | AR_SREV_9462(ah) || AR_SREV_9565(ah)) { |
82 | return -1; | 80 | power = ah->paprd_target_power + 2; |
81 | } else if (AR_SREV_9485(ah)) { | ||
82 | power = 25; | ||
83 | } else { | ||
84 | power = REG_READ_FIELD(ah, AR_PHY_POWERTX_RATE5, | ||
85 | AR_PHY_POWERTX_RATE5_POWERTXHT20_0); | ||
86 | |||
87 | delta = abs((int) ah->paprd_target_power - (int) power); | ||
88 | if (delta > scale) | ||
89 | return -1; | ||
83 | 90 | ||
84 | if (delta < 4) | 91 | if (delta < 4) |
85 | power -= 4 - delta; | 92 | power -= 4 - delta; |
93 | } | ||
86 | 94 | ||
87 | return power; | 95 | return power; |
88 | } | 96 | } |