diff options
author | Sujith <Sujith.Manoharan@atheros.com> | 2009-04-13 12:26:59 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-04-22 16:54:46 -0400 |
commit | 04d19ddd254b404703151ab25aa5041e50ff40f7 (patch) | |
tree | f6eee40252bacc49e774ce90e3df745adb60a232 /drivers | |
parent | cbfe946860ffc718c5d99a6b740e33ac95fe8b8d (diff) |
ath9k: Fix bug in calibration initialization
This patch fixes a bug in ath9k_hw_init_cal() where the wrong
calibration was being done for non-AR9285 chipsets.
Also add a few helpful comments.
Cc: stable@kernel.org
Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/calib.c | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index 67375adf23c0..08f690279789 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c | |||
@@ -918,83 +918,66 @@ static bool ar9285_clc(struct ath_hw *ah, struct ath9k_channel *chan) | |||
918 | return true; | 918 | return true; |
919 | } | 919 | } |
920 | 920 | ||
921 | bool ath9k_hw_init_cal(struct ath_hw *ah, | 921 | bool ath9k_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan) |
922 | struct ath9k_channel *chan) | ||
923 | { | 922 | { |
924 | if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) { | 923 | if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) { |
925 | if (!ar9285_clc(ah, chan)) | 924 | if (!ar9285_clc(ah, chan)) |
926 | return false; | 925 | return false; |
927 | } else if (AR_SREV_9280_10_OR_LATER(ah)) { | 926 | } else { |
928 | REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); | 927 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
929 | REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); | 928 | REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); |
930 | REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); | 929 | REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); |
930 | } | ||
931 | 931 | ||
932 | /* Kick off the cal */ | 932 | /* Calibrate the AGC */ |
933 | REG_WRITE(ah, AR_PHY_AGC_CONTROL, | 933 | REG_WRITE(ah, AR_PHY_AGC_CONTROL, |
934 | REG_READ(ah, AR_PHY_AGC_CONTROL) | | 934 | REG_READ(ah, AR_PHY_AGC_CONTROL) | |
935 | AR_PHY_AGC_CONTROL_CAL); | 935 | AR_PHY_AGC_CONTROL_CAL); |
936 | 936 | ||
937 | if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, | 937 | /* Poll for offset calibration complete */ |
938 | AR_PHY_AGC_CONTROL_CAL, 0, | 938 | if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, |
939 | AH_WAIT_TIMEOUT)) { | 939 | 0, AH_WAIT_TIMEOUT)) { |
940 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, | 940 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, |
941 | "offset calibration failed to complete in 1ms; " | 941 | "offset calibration failed to complete in 1ms; " |
942 | "noisy environment?\n"); | 942 | "noisy environment?\n"); |
943 | return false; | 943 | return false; |
944 | } | 944 | } |
945 | 945 | ||
946 | REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); | 946 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
947 | REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); | 947 | REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); |
948 | REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); | 948 | REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); |
949 | } | 949 | } |
950 | |||
951 | /* Calibrate the AGC */ | ||
952 | REG_WRITE(ah, AR_PHY_AGC_CONTROL, | ||
953 | REG_READ(ah, AR_PHY_AGC_CONTROL) | | ||
954 | AR_PHY_AGC_CONTROL_CAL); | ||
955 | |||
956 | if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, | ||
957 | 0, AH_WAIT_TIMEOUT)) { | ||
958 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, | ||
959 | "offset calibration failed to complete in 1ms; " | ||
960 | "noisy environment?\n"); | ||
961 | return false; | ||
962 | } | ||
963 | |||
964 | if (AR_SREV_9280_10_OR_LATER(ah)) { | ||
965 | REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); | ||
966 | REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); | ||
967 | } | 950 | } |
968 | 951 | ||
969 | /* Do PA Calibration */ | 952 | /* Do PA Calibration */ |
970 | if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah)) | 953 | if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah)) |
971 | ath9k_hw_9285_pa_cal(ah); | 954 | ath9k_hw_9285_pa_cal(ah); |
972 | 955 | ||
973 | /* Do NF Calibration */ | 956 | /* Do NF Calibration after DC offset and other calibrations */ |
974 | REG_WRITE(ah, AR_PHY_AGC_CONTROL, | 957 | REG_WRITE(ah, AR_PHY_AGC_CONTROL, |
975 | REG_READ(ah, AR_PHY_AGC_CONTROL) | | 958 | REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_NF); |
976 | AR_PHY_AGC_CONTROL_NF); | ||
977 | 959 | ||
978 | ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; | 960 | ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; |
979 | 961 | ||
962 | /* Enable IQ, ADC Gain and ADC DC offset CALs */ | ||
980 | if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) { | 963 | if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) { |
981 | if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) { | 964 | if (ath9k_hw_iscal_supported(ah, ADC_GAIN_CAL)) { |
982 | INIT_CAL(&ah->adcgain_caldata); | 965 | INIT_CAL(&ah->adcgain_caldata); |
983 | INSERT_CAL(ah, &ah->adcgain_caldata); | 966 | INSERT_CAL(ah, &ah->adcgain_caldata); |
984 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, | 967 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, |
985 | "enabling ADC Gain Calibration.\n"); | 968 | "enabling ADC Gain Calibration.\n"); |
986 | } | 969 | } |
987 | if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) { | 970 | if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) { |
988 | INIT_CAL(&ah->adcdc_caldata); | 971 | INIT_CAL(&ah->adcdc_caldata); |
989 | INSERT_CAL(ah, &ah->adcdc_caldata); | 972 | INSERT_CAL(ah, &ah->adcdc_caldata); |
990 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, | 973 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, |
991 | "enabling ADC DC Calibration.\n"); | 974 | "enabling ADC DC Calibration.\n"); |
992 | } | 975 | } |
993 | if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { | 976 | if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { |
994 | INIT_CAL(&ah->iq_caldata); | 977 | INIT_CAL(&ah->iq_caldata); |
995 | INSERT_CAL(ah, &ah->iq_caldata); | 978 | INSERT_CAL(ah, &ah->iq_caldata); |
996 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, | 979 | DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, |
997 | "enabling IQ Calibration.\n"); | 980 | "enabling IQ Calibration.\n"); |
998 | } | 981 | } |
999 | 982 | ||
1000 | ah->cal_list_curr = ah->cal_list; | 983 | ah->cal_list_curr = ah->cal_list; |