aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/calib.c
diff options
context:
space:
mode:
authorSenthil Balasubramanian <senthilkumar@atheros.com>2009-03-06 00:54:10 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-03-16 18:09:31 -0400
commit4e845168380a5954dd8702be5229e3e1b477ed81 (patch)
treede3f029f4ab97e2c7f7cf3693e3b08194d9f5b2a /drivers/net/wireless/ath9k/calib.c
parentb03a9db95a285e13a5e4f2913e9d22a84bf50cc6 (diff)
ath9k: INI update for AR9285 and periodic PA offset caliberation
This patch updates the initvalues for AR9285 chipset and also adds periodic PA offset caliberation. Signed-off-by: Senthil Balasubramanian <senthilkumar@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/calib.c')
-rw-r--r--drivers/net/wireless/ath9k/calib.c145
1 files changed, 95 insertions, 50 deletions
diff --git a/drivers/net/wireless/ath9k/calib.c b/drivers/net/wireless/ath9k/calib.c
index 1c074c059b5c..a652e9bb16de 100644
--- a/drivers/net/wireless/ath9k/calib.c
+++ b/drivers/net/wireless/ath9k/calib.c
@@ -745,43 +745,6 @@ static void ath9k_olc_temp_compensation(struct ath_hw *ah)
745 } 745 }
746} 746}
747 747
748bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
749 u8 rxchainmask, bool longcal,
750 bool *isCalDone)
751{
752 struct hal_cal_list *currCal = ah->cal_list_curr;
753
754 *isCalDone = true;
755
756 if (currCal &&
757 (currCal->calState == CAL_RUNNING ||
758 currCal->calState == CAL_WAITING)) {
759 ath9k_hw_per_calibration(ah, chan, rxchainmask, currCal,
760 isCalDone);
761 if (*isCalDone) {
762 ah->cal_list_curr = currCal = currCal->calNext;
763
764 if (currCal->calState == CAL_WAITING) {
765 *isCalDone = false;
766 ath9k_hw_reset_calibration(ah, currCal);
767 }
768 }
769 }
770
771 if (longcal) {
772 if (OLC_FOR_AR9280_20_LATER)
773 ath9k_olc_temp_compensation(ah);
774 ath9k_hw_getnf(ah, chan);
775 ath9k_hw_loadnf(ah, ah->curchan);
776 ath9k_hw_start_nfcal(ah);
777
778 if (chan->channelFlags & CHANNEL_CW_INT)
779 chan->channelFlags &= ~CHANNEL_CW_INT;
780 }
781
782 return true;
783}
784
785static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah) 748static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
786{ 749{
787 750
@@ -877,22 +840,104 @@ static inline void ath9k_hw_9285_pa_cal(struct ath_hw *ah)
877 840
878} 841}
879 842
843bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
844 u8 rxchainmask, bool longcal,
845 bool *isCalDone)
846{
847 struct hal_cal_list *currCal = ah->cal_list_curr;
848
849 *isCalDone = true;
850
851 if (currCal &&
852 (currCal->calState == CAL_RUNNING ||
853 currCal->calState == CAL_WAITING)) {
854 ath9k_hw_per_calibration(ah, chan, rxchainmask, currCal,
855 isCalDone);
856 if (*isCalDone) {
857 ah->cal_list_curr = currCal = currCal->calNext;
858
859 if (currCal->calState == CAL_WAITING) {
860 *isCalDone = false;
861 ath9k_hw_reset_calibration(ah, currCal);
862 }
863 }
864 }
865
866 if (longcal) {
867 if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah))
868 ath9k_hw_9285_pa_cal(ah);
869
870 if (OLC_FOR_AR9280_20_LATER)
871 ath9k_olc_temp_compensation(ah);
872 ath9k_hw_getnf(ah, chan);
873 ath9k_hw_loadnf(ah, ah->curchan);
874 ath9k_hw_start_nfcal(ah);
875
876 if (chan->channelFlags & CHANNEL_CW_INT)
877 chan->channelFlags &= ~CHANNEL_CW_INT;
878 }
879
880 return true;
881}
882
883bool ar9285_clc(struct ath_hw *ah, struct ath9k_channel *chan)
884{
885 REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
886 if (chan->channelFlags & CHANNEL_HT20) {
887 REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_PARALLEL_CAL_ENABLE);
888 REG_SET_BIT(ah, AR_PHY_TURBO, AR_PHY_FC_DYN2040_EN);
889 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
890 AR_PHY_AGC_CONTROL_FLTR_CAL);
891 REG_CLR_BIT(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_CAL_ENABLE);
892 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL);
893 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
894 AR_PHY_AGC_CONTROL_CAL, 0, AH_WAIT_TIMEOUT)) {
895 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "offset "
896 "calibration failed to complete in "
897 "1ms; noisy ??\n");
898 return false;
899 }
900 REG_CLR_BIT(ah, AR_PHY_TURBO, AR_PHY_FC_DYN2040_EN);
901 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_PARALLEL_CAL_ENABLE);
902 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
903 }
904 REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
905 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
906 REG_SET_BIT(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_CAL_ENABLE);
907 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL);
908 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL,
909 0, AH_WAIT_TIMEOUT)) {
910 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "offset calibration "
911 "failed to complete in 1ms; noisy ??\n");
912 return false;
913 }
914
915 REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
916 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
917 REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
918
919 return true;
920}
921
880bool ath9k_hw_init_cal(struct ath_hw *ah, 922bool ath9k_hw_init_cal(struct ath_hw *ah,
881 struct ath9k_channel *chan) 923 struct ath9k_channel *chan)
882{ 924{
883 if (AR_SREV_9280_10_OR_LATER(ah)) { 925 if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) {
926 if (!ar9285_clc(ah, chan))
927 return false;
928 } else if (AR_SREV_9280_10_OR_LATER(ah)) {
884 REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); 929 REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
885 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); 930 REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
886 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); 931 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
887 932
888 /* Kick off the cal */ 933 /* Kick off the cal */
889 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 934 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
890 REG_READ(ah, AR_PHY_AGC_CONTROL) | 935 REG_READ(ah, AR_PHY_AGC_CONTROL) |
891 AR_PHY_AGC_CONTROL_CAL); 936 AR_PHY_AGC_CONTROL_CAL);
892 937
893 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, 938 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
894 AR_PHY_AGC_CONTROL_CAL, 0, 939 AR_PHY_AGC_CONTROL_CAL, 0,
895 AH_WAIT_TIMEOUT)) { 940 AH_WAIT_TIMEOUT)) {
896 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 941 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
897 "offset calibration failed to complete in 1ms; " 942 "offset calibration failed to complete in 1ms; "
898 "noisy environment?\n"); 943 "noisy environment?\n");
@@ -906,11 +951,11 @@ bool ath9k_hw_init_cal(struct ath_hw *ah,
906 951
907 /* Calibrate the AGC */ 952 /* Calibrate the AGC */
908 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 953 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
909 REG_READ(ah, AR_PHY_AGC_CONTROL) | 954 REG_READ(ah, AR_PHY_AGC_CONTROL) |
910 AR_PHY_AGC_CONTROL_CAL); 955 AR_PHY_AGC_CONTROL_CAL);
911 956
912 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 957 if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL,
913 0, AH_WAIT_TIMEOUT)) { 958 0, AH_WAIT_TIMEOUT)) {
914 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 959 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
915 "offset calibration failed to complete in 1ms; " 960 "offset calibration failed to complete in 1ms; "
916 "noisy environment?\n"); 961 "noisy environment?\n");
@@ -928,8 +973,8 @@ bool ath9k_hw_init_cal(struct ath_hw *ah,
928 973
929 /* Do NF Calibration */ 974 /* Do NF Calibration */
930 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 975 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
931 REG_READ(ah, AR_PHY_AGC_CONTROL) | 976 REG_READ(ah, AR_PHY_AGC_CONTROL) |
932 AR_PHY_AGC_CONTROL_NF); 977 AR_PHY_AGC_CONTROL_NF);
933 978
934 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; 979 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
935 980
@@ -938,19 +983,19 @@ bool ath9k_hw_init_cal(struct ath_hw *ah,
938 INIT_CAL(&ah->adcgain_caldata); 983 INIT_CAL(&ah->adcgain_caldata);
939 INSERT_CAL(ah, &ah->adcgain_caldata); 984 INSERT_CAL(ah, &ah->adcgain_caldata);
940 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 985 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
941 "enabling ADC Gain Calibration.\n"); 986 "enabling ADC Gain Calibration.\n");
942 } 987 }
943 if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) { 988 if (ath9k_hw_iscal_supported(ah, ADC_DC_CAL)) {
944 INIT_CAL(&ah->adcdc_caldata); 989 INIT_CAL(&ah->adcdc_caldata);
945 INSERT_CAL(ah, &ah->adcdc_caldata); 990 INSERT_CAL(ah, &ah->adcdc_caldata);
946 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 991 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
947 "enabling ADC DC Calibration.\n"); 992 "enabling ADC DC Calibration.\n");
948 } 993 }
949 if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { 994 if (ath9k_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
950 INIT_CAL(&ah->iq_caldata); 995 INIT_CAL(&ah->iq_caldata);
951 INSERT_CAL(ah, &ah->iq_caldata); 996 INSERT_CAL(ah, &ah->iq_caldata);
952 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 997 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
953 "enabling IQ Calibration.\n"); 998 "enabling IQ Calibration.\n");
954 } 999 }
955 1000
956 ah->cal_list_curr = ah->cal_list; 1001 ah->cal_list_curr = ah->cal_list;