aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-10-03 13:07:16 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-10-06 16:26:01 -0400
commit6497827f53eb90dcf30c5d6414c83238f722e8ae (patch)
tree0d62c5406b55c30158daf0421f4e075f287e0ba9
parent373426cac0cbb7f762018127803dcd70838e2cdf (diff)
ath9k_hw: clean up calibration flags
The calibration actual calibration flags are only used by the per chip family source files, so it makes more sense to define them in those files instead of globally. That way the code has to test for less flags. Also instead of using a separate callback for testing whether a particular calibration type is supported, simply adjust ah->supp_cals in the calibration init which is called right after the hardware reset, before any of the calibrations are run. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c51
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_calib.c36
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h9
-rw-r--r--drivers/net/wireless/ath/ath9k/hw-ops.h6
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
6 files changed, 31 insertions, 77 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index f2da119bbf02..f0525fb62a2c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -20,6 +20,13 @@
20 20
21#define AR9285_CLCAL_REDO_THRESH 1 21#define AR9285_CLCAL_REDO_THRESH 1
22 22
23enum ar9002_cal_types {
24 ADC_GAIN_CAL = BIT(0),
25 ADC_DC_CAL = BIT(1),
26 IQ_MISMATCH_CAL = BIT(2),
27};
28
29
23static void ar9002_hw_setup_calibration(struct ath_hw *ah, 30static void ar9002_hw_setup_calibration(struct ath_hw *ah,
24 struct ath9k_cal_list *currCal) 31 struct ath9k_cal_list *currCal)
25{ 32{
@@ -45,8 +52,6 @@ static void ar9002_hw_setup_calibration(struct ath_hw *ah,
45 ath_print(common, ATH_DBG_CALIBRATE, 52 ath_print(common, ATH_DBG_CALIBRATE,
46 "starting ADC DC Calibration\n"); 53 "starting ADC DC Calibration\n");
47 break; 54 break;
48 case TEMP_COMP_CAL:
49 break; /* Not supported */
50 } 55 }
51 56
52 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0), 57 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
@@ -91,25 +96,6 @@ static bool ar9002_hw_per_calibration(struct ath_hw *ah,
91 return iscaldone; 96 return iscaldone;
92} 97}
93 98
94/* Assumes you are talking about the currently configured channel */
95static bool ar9002_hw_iscal_supported(struct ath_hw *ah,
96 enum ath9k_cal_types calType)
97{
98 struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
99
100 switch (calType & ah->supp_cals) {
101 case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
102 return true;
103 case ADC_GAIN_CAL:
104 case ADC_DC_CAL:
105 if (!(conf->channel->band == IEEE80211_BAND_2GHZ &&
106 conf_is_ht20(conf)))
107 return true;
108 break;
109 }
110 return false;
111}
112
113static void ar9002_hw_iqcal_collect(struct ath_hw *ah) 99static void ar9002_hw_iqcal_collect(struct ath_hw *ah)
114{ 100{
115 int i; 101 int i;
@@ -872,24 +858,28 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
872 858
873 /* Enable IQ, ADC Gain and ADC DC offset CALs */ 859 /* Enable IQ, ADC Gain and ADC DC offset CALs */
874 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) { 860 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
875 if (ar9002_hw_iscal_supported(ah, ADC_GAIN_CAL)) { 861 ah->supp_cals = IQ_MISMATCH_CAL;
862
863 if (AR_SREV_9160_10_OR_LATER(ah) &&
864 !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan))) {
865 ah->supp_cals |= ADC_GAIN_CAL | ADC_DC_CAL;
866
867
876 INIT_CAL(&ah->adcgain_caldata); 868 INIT_CAL(&ah->adcgain_caldata);
877 INSERT_CAL(ah, &ah->adcgain_caldata); 869 INSERT_CAL(ah, &ah->adcgain_caldata);
878 ath_print(common, ATH_DBG_CALIBRATE, 870 ath_print(common, ATH_DBG_CALIBRATE,
879 "enabling ADC Gain Calibration.\n"); 871 "enabling ADC Gain Calibration.\n");
880 } 872
881 if (ar9002_hw_iscal_supported(ah, ADC_DC_CAL)) {
882 INIT_CAL(&ah->adcdc_caldata); 873 INIT_CAL(&ah->adcdc_caldata);
883 INSERT_CAL(ah, &ah->adcdc_caldata); 874 INSERT_CAL(ah, &ah->adcdc_caldata);
884 ath_print(common, ATH_DBG_CALIBRATE, 875 ath_print(common, ATH_DBG_CALIBRATE,
885 "enabling ADC DC Calibration.\n"); 876 "enabling ADC DC Calibration.\n");
886 } 877 }
887 if (ar9002_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { 878
888 INIT_CAL(&ah->iq_caldata); 879 INIT_CAL(&ah->iq_caldata);
889 INSERT_CAL(ah, &ah->iq_caldata); 880 INSERT_CAL(ah, &ah->iq_caldata);
890 ath_print(common, ATH_DBG_CALIBRATE, 881 ath_print(common, ATH_DBG_CALIBRATE,
891 "enabling IQ Calibration.\n"); 882 "enabling IQ Calibration.\n");
892 }
893 883
894 ah->cal_list_curr = ah->cal_list; 884 ah->cal_list_curr = ah->cal_list;
895 885
@@ -980,7 +970,6 @@ void ar9002_hw_attach_calib_ops(struct ath_hw *ah)
980 priv_ops->init_cal_settings = ar9002_hw_init_cal_settings; 970 priv_ops->init_cal_settings = ar9002_hw_init_cal_settings;
981 priv_ops->init_cal = ar9002_hw_init_cal; 971 priv_ops->init_cal = ar9002_hw_init_cal;
982 priv_ops->setup_calibration = ar9002_hw_setup_calibration; 972 priv_ops->setup_calibration = ar9002_hw_setup_calibration;
983 priv_ops->iscal_supported = ar9002_hw_iscal_supported;
984 973
985 ops->calibrate = ar9002_hw_calibrate; 974 ops->calibrate = ar9002_hw_calibrate;
986} 975}
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
index b41f5cda824b..9e6edffe0bd1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
@@ -18,6 +18,11 @@
18#include "hw-ops.h" 18#include "hw-ops.h"
19#include "ar9003_phy.h" 19#include "ar9003_phy.h"
20 20
21enum ar9003_cal_types {
22 IQ_MISMATCH_CAL = BIT(0),
23 TEMP_COMP_CAL = BIT(1),
24};
25
21static void ar9003_hw_setup_calibration(struct ath_hw *ah, 26static void ar9003_hw_setup_calibration(struct ath_hw *ah,
22 struct ath9k_cal_list *currCal) 27 struct ath9k_cal_list *currCal)
23{ 28{
@@ -50,10 +55,6 @@ static void ar9003_hw_setup_calibration(struct ath_hw *ah,
50 ath_print(common, ATH_DBG_CALIBRATE, 55 ath_print(common, ATH_DBG_CALIBRATE,
51 "starting Temperature Compensation Calibration\n"); 56 "starting Temperature Compensation Calibration\n");
52 break; 57 break;
53 case ADC_GAIN_CAL:
54 case ADC_DC_CAL:
55 /* Not yet */
56 break;
57 } 58 }
58} 59}
59 60
@@ -313,27 +314,6 @@ static const struct ath9k_percal_data iq_cal_single_sample = {
313static void ar9003_hw_init_cal_settings(struct ath_hw *ah) 314static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
314{ 315{
315 ah->iq_caldata.calData = &iq_cal_single_sample; 316 ah->iq_caldata.calData = &iq_cal_single_sample;
316 ah->supp_cals = IQ_MISMATCH_CAL;
317}
318
319static bool ar9003_hw_iscal_supported(struct ath_hw *ah,
320 enum ath9k_cal_types calType)
321{
322 switch (calType & ah->supp_cals) {
323 case IQ_MISMATCH_CAL:
324 /*
325 * XXX: Run IQ Mismatch for non-CCK only
326 * Note that CHANNEL_B is never set though.
327 */
328 return true;
329 case ADC_GAIN_CAL:
330 case ADC_DC_CAL:
331 return false;
332 case TEMP_COMP_CAL:
333 return true;
334 }
335
336 return false;
337} 317}
338 318
339/* 319/*
@@ -772,15 +752,16 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,
772 752
773 /* Initialize list pointers */ 753 /* Initialize list pointers */
774 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; 754 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
755 ah->supp_cals = IQ_MISMATCH_CAL;
775 756
776 if (ar9003_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) { 757 if (ah->supp_cals & IQ_MISMATCH_CAL) {
777 INIT_CAL(&ah->iq_caldata); 758 INIT_CAL(&ah->iq_caldata);
778 INSERT_CAL(ah, &ah->iq_caldata); 759 INSERT_CAL(ah, &ah->iq_caldata);
779 ath_print(common, ATH_DBG_CALIBRATE, 760 ath_print(common, ATH_DBG_CALIBRATE,
780 "enabling IQ Calibration.\n"); 761 "enabling IQ Calibration.\n");
781 } 762 }
782 763
783 if (ar9003_hw_iscal_supported(ah, TEMP_COMP_CAL)) { 764 if (ah->supp_cals & TEMP_COMP_CAL) {
784 INIT_CAL(&ah->tempCompCalData); 765 INIT_CAL(&ah->tempCompCalData);
785 INSERT_CAL(ah, &ah->tempCompCalData); 766 INSERT_CAL(ah, &ah->tempCompCalData);
786 ath_print(common, ATH_DBG_CALIBRATE, 767 ath_print(common, ATH_DBG_CALIBRATE,
@@ -807,7 +788,6 @@ void ar9003_hw_attach_calib_ops(struct ath_hw *ah)
807 priv_ops->init_cal_settings = ar9003_hw_init_cal_settings; 788 priv_ops->init_cal_settings = ar9003_hw_init_cal_settings;
808 priv_ops->init_cal = ar9003_hw_init_cal; 789 priv_ops->init_cal = ar9003_hw_init_cal;
809 priv_ops->setup_calibration = ar9003_hw_setup_calibration; 790 priv_ops->setup_calibration = ar9003_hw_setup_calibration;
810 priv_ops->iscal_supported = ar9003_hw_iscal_supported;
811 791
812 ops->calibrate = ar9003_hw_calibrate; 792 ops->calibrate = ar9003_hw_calibrate;
813} 793}
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 6351e76792a6..6c38c72915c1 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -186,7 +186,7 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah)
186 return true; 186 return true;
187 } 187 }
188 188
189 if (!ath9k_hw_iscal_supported(ah, currCal->calData->calType)) 189 if (!(ah->supp_cals & currCal->calData->calType))
190 return true; 190 return true;
191 191
192 ath_print(common, ATH_DBG_CALIBRATE, 192 ath_print(common, ATH_DBG_CALIBRATE,
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 1fa56c91a894..b8973eb8d858 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -58,13 +58,6 @@ struct ar5416IniArray {
58 } \ 58 } \
59 } while (0) 59 } while (0)
60 60
61enum ath9k_cal_types {
62 ADC_GAIN_CAL = 0x2,
63 ADC_DC_CAL = 0x4,
64 IQ_MISMATCH_CAL = 0x8,
65 TEMP_COMP_CAL = 0x10,
66};
67
68enum ath9k_cal_state { 61enum ath9k_cal_state {
69 CAL_INACTIVE, 62 CAL_INACTIVE,
70 CAL_WAITING, 63 CAL_WAITING,
@@ -79,7 +72,7 @@ enum ath9k_cal_state {
79#define PER_MAX_LOG_COUNT 10 72#define PER_MAX_LOG_COUNT 10
80 73
81struct ath9k_percal_data { 74struct ath9k_percal_data {
82 enum ath9k_cal_types calType; 75 u32 calType;
83 u32 calNumSamples; 76 u32 calNumSamples;
84 u32 calCountMax; 77 u32 calCountMax;
85 void (*calCollect) (struct ath_hw *); 78 void (*calCollect) (struct ath_hw *);
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h
index ffecbadaea4a..9c4dd0ec9a15 100644
--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
@@ -276,12 +276,6 @@ static inline void ath9k_hw_setup_calibration(struct ath_hw *ah,
276 ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal); 276 ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal);
277} 277}
278 278
279static inline bool ath9k_hw_iscal_supported(struct ath_hw *ah,
280 enum ath9k_cal_types calType)
281{
282 return ath9k_hw_private_ops(ah)->iscal_supported(ah, calType);
283}
284
285static inline void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning) 279static inline void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
286{ 280{
287 ath9k_hw_private_ops(ah)->ani_reset(ah, is_scanning); 281 ath9k_hw_private_ops(ah)->ani_reset(ah, is_scanning);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 235cb5357a22..246c707cea00 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -535,8 +535,6 @@ struct ath_hw_private_ops {
535 bool (*macversion_supported)(u32 macversion); 535 bool (*macversion_supported)(u32 macversion);
536 void (*setup_calibration)(struct ath_hw *ah, 536 void (*setup_calibration)(struct ath_hw *ah,
537 struct ath9k_cal_list *currCal); 537 struct ath9k_cal_list *currCal);
538 bool (*iscal_supported)(struct ath_hw *ah,
539 enum ath9k_cal_types calType);
540 538
541 /* PHY ops */ 539 /* PHY ops */
542 int (*rf_set_freq)(struct ath_hw *ah, 540 int (*rf_set_freq)(struct ath_hw *ah,
@@ -689,7 +687,7 @@ struct ath_hw {
689 u32 atim_window; 687 u32 atim_window;
690 688
691 /* Calibration */ 689 /* Calibration */
692 enum ath9k_cal_types supp_cals; 690 u32 supp_cals;
693 struct ath9k_cal_list iq_caldata; 691 struct ath9k_cal_list iq_caldata;
694 struct ath9k_cal_list adcgain_caldata; 692 struct ath9k_cal_list adcgain_caldata;
695 struct ath9k_cal_list adcdc_caldata; 693 struct ath9k_cal_list adcdc_caldata;