diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/ar9003_paprd.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 105 |
1 files changed, 104 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index 2c9f7d7ed4cc..0ed3846f9cbb 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c | |||
@@ -142,6 +142,7 @@ static int ar9003_paprd_setup_single_table(struct ath_hw *ah) | |||
142 | }; | 142 | }; |
143 | int training_power; | 143 | int training_power; |
144 | int i, val; | 144 | int i, val; |
145 | u32 am2pm_mask = ah->paprd_ratemask; | ||
145 | 146 | ||
146 | if (IS_CHAN_2GHZ(ah->curchan)) | 147 | if (IS_CHAN_2GHZ(ah->curchan)) |
147 | training_power = ar9003_get_training_power_2g(ah); | 148 | training_power = ar9003_get_training_power_2g(ah); |
@@ -158,10 +159,13 @@ static int ar9003_paprd_setup_single_table(struct ath_hw *ah) | |||
158 | } | 159 | } |
159 | ah->paprd_training_power = training_power; | 160 | ah->paprd_training_power = training_power; |
160 | 161 | ||
162 | if (AR_SREV_9330(ah)) | ||
163 | am2pm_mask = 0; | ||
164 | |||
161 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2AM, AR_PHY_PAPRD_AM2AM_MASK, | 165 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2AM, AR_PHY_PAPRD_AM2AM_MASK, |
162 | ah->paprd_ratemask); | 166 | ah->paprd_ratemask); |
163 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2PM, AR_PHY_PAPRD_AM2PM_MASK, | 167 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_AM2PM, AR_PHY_PAPRD_AM2PM_MASK, |
164 | ah->paprd_ratemask); | 168 | am2pm_mask); |
165 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_HT40, AR_PHY_PAPRD_HT40_MASK, | 169 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_HT40, AR_PHY_PAPRD_HT40_MASK, |
166 | ah->paprd_ratemask_ht40); | 170 | ah->paprd_ratemask_ht40); |
167 | 171 | ||
@@ -782,6 +786,102 @@ int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain) | |||
782 | } | 786 | } |
783 | EXPORT_SYMBOL(ar9003_paprd_setup_gain_table); | 787 | EXPORT_SYMBOL(ar9003_paprd_setup_gain_table); |
784 | 788 | ||
789 | static bool ar9003_paprd_retrain_pa_in(struct ath_hw *ah, | ||
790 | struct ath9k_hw_cal_data *caldata, | ||
791 | int chain) | ||
792 | { | ||
793 | u32 *pa_in = caldata->pa_table[chain]; | ||
794 | int capdiv_offset, quick_drop_offset; | ||
795 | int capdiv2g, quick_drop; | ||
796 | int count = 0; | ||
797 | int i; | ||
798 | |||
799 | if (!AR_SREV_9485(ah) && !AR_SREV_9330(ah)) | ||
800 | return false; | ||
801 | |||
802 | capdiv2g = REG_READ_FIELD(ah, AR_PHY_65NM_CH0_TXRF3, | ||
803 | AR_PHY_65NM_CH0_TXRF3_CAPDIV2G); | ||
804 | |||
805 | quick_drop = REG_READ_FIELD(ah, AR_PHY_PAPRD_TRAINER_CNTL3, | ||
806 | AR_PHY_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP); | ||
807 | |||
808 | if (quick_drop) | ||
809 | quick_drop -= 0x40; | ||
810 | |||
811 | for (i = 0; i < NUM_BIN + 1; i++) { | ||
812 | if (pa_in[i] == 1400) | ||
813 | count++; | ||
814 | } | ||
815 | |||
816 | if (AR_SREV_9485(ah)) { | ||
817 | if (pa_in[23] < 800) { | ||
818 | capdiv_offset = (int)((1000 - pa_in[23] + 75) / 150); | ||
819 | capdiv2g += capdiv_offset; | ||
820 | if (capdiv2g > 7) { | ||
821 | capdiv2g = 7; | ||
822 | if (pa_in[23] < 600) { | ||
823 | quick_drop++; | ||
824 | if (quick_drop > 0) | ||
825 | quick_drop = 0; | ||
826 | } | ||
827 | } | ||
828 | } else if (pa_in[23] == 1400) { | ||
829 | quick_drop_offset = min_t(int, count / 3, 2); | ||
830 | quick_drop += quick_drop_offset; | ||
831 | capdiv2g += quick_drop_offset / 2; | ||
832 | |||
833 | if (capdiv2g > 7) | ||
834 | capdiv2g = 7; | ||
835 | |||
836 | if (quick_drop > 0) { | ||
837 | quick_drop = 0; | ||
838 | capdiv2g -= quick_drop_offset; | ||
839 | if (capdiv2g < 0) | ||
840 | capdiv2g = 0; | ||
841 | } | ||
842 | } else { | ||
843 | return false; | ||
844 | } | ||
845 | } else if (AR_SREV_9330(ah)) { | ||
846 | if (pa_in[23] < 1000) { | ||
847 | capdiv_offset = (1000 - pa_in[23]) / 100; | ||
848 | capdiv2g += capdiv_offset; | ||
849 | if (capdiv_offset > 3) { | ||
850 | capdiv_offset = 1; | ||
851 | quick_drop--; | ||
852 | } | ||
853 | |||
854 | capdiv2g += capdiv_offset; | ||
855 | if (capdiv2g > 6) | ||
856 | capdiv2g = 6; | ||
857 | if (quick_drop < -4) | ||
858 | quick_drop = -4; | ||
859 | } else if (pa_in[23] == 1400) { | ||
860 | if (count > 3) { | ||
861 | quick_drop++; | ||
862 | capdiv2g -= count / 4; | ||
863 | if (quick_drop > -2) | ||
864 | quick_drop = -2; | ||
865 | } else { | ||
866 | capdiv2g--; | ||
867 | } | ||
868 | |||
869 | if (capdiv2g < 0) | ||
870 | capdiv2g = 0; | ||
871 | } else { | ||
872 | return false; | ||
873 | } | ||
874 | } | ||
875 | |||
876 | REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_TXRF3, | ||
877 | AR_PHY_65NM_CH0_TXRF3_CAPDIV2G, capdiv2g); | ||
878 | REG_RMW_FIELD(ah, AR_PHY_PAPRD_TRAINER_CNTL3, | ||
879 | AR_PHY_PAPRD_TRAINER_CNTL3_CF_PAPRD_QUICK_DROP, | ||
880 | quick_drop); | ||
881 | |||
882 | return true; | ||
883 | } | ||
884 | |||
785 | int ar9003_paprd_create_curve(struct ath_hw *ah, | 885 | int ar9003_paprd_create_curve(struct ath_hw *ah, |
786 | struct ath9k_hw_cal_data *caldata, int chain) | 886 | struct ath9k_hw_cal_data *caldata, int chain) |
787 | { | 887 | { |
@@ -817,6 +917,9 @@ int ar9003_paprd_create_curve(struct ath_hw *ah, | |||
817 | if (!create_pa_curve(data_L, data_U, pa_table, small_signal_gain)) | 917 | if (!create_pa_curve(data_L, data_U, pa_table, small_signal_gain)) |
818 | status = -2; | 918 | status = -2; |
819 | 919 | ||
920 | if (ar9003_paprd_retrain_pa_in(ah, caldata, chain)) | ||
921 | status = -EINPROGRESS; | ||
922 | |||
820 | REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1, | 923 | REG_CLR_BIT(ah, AR_PHY_PAPRD_TRAINER_STAT1, |
821 | AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); | 924 | AR_PHY_PAPRD_TRAINER_STAT1_PAPRD_TRAIN_DONE); |
822 | 925 | ||