ath9k: add a few fixes and cleanups
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 531-ath9k_cal_cleanup.patch
1 --- a/drivers/net/wireless/ath/ath9k/hw.h
2 +++ b/drivers/net/wireless/ath/ath9k/hw.h
3 @@ -535,8 +535,6 @@ struct ath_hw_private_ops {
4 bool (*macversion_supported)(u32 macversion);
5 void (*setup_calibration)(struct ath_hw *ah,
6 struct ath9k_cal_list *currCal);
7 - bool (*iscal_supported)(struct ath_hw *ah,
8 - enum ath9k_cal_types calType);
9
10 /* PHY ops */
11 int (*rf_set_freq)(struct ath_hw *ah,
12 @@ -689,7 +687,7 @@ struct ath_hw {
13 u32 atim_window;
14
15 /* Calibration */
16 - enum ath9k_cal_types supp_cals;
17 + u32 supp_cals;
18 struct ath9k_cal_list iq_caldata;
19 struct ath9k_cal_list adcgain_caldata;
20 struct ath9k_cal_list adcdc_caldata;
21 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
22 +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
23 @@ -20,6 +20,13 @@
24
25 #define AR9285_CLCAL_REDO_THRESH 1
26
27 +enum ar9002_cal_types {
28 + ADC_GAIN_CAL = BIT(0),
29 + ADC_DC_CAL = BIT(1),
30 + IQ_MISMATCH_CAL = BIT(2),
31 +};
32 +
33 +
34 static void ar9002_hw_setup_calibration(struct ath_hw *ah,
35 struct ath9k_cal_list *currCal)
36 {
37 @@ -45,8 +52,6 @@ static void ar9002_hw_setup_calibration(
38 ath_print(common, ATH_DBG_CALIBRATE,
39 "starting ADC DC Calibration\n");
40 break;
41 - case TEMP_COMP_CAL:
42 - break; /* Not supported */
43 }
44
45 REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
46 @@ -91,25 +96,6 @@ static bool ar9002_hw_per_calibration(st
47 return iscaldone;
48 }
49
50 -/* Assumes you are talking about the currently configured channel */
51 -static bool ar9002_hw_iscal_supported(struct ath_hw *ah,
52 - enum ath9k_cal_types calType)
53 -{
54 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
55 -
56 - switch (calType & ah->supp_cals) {
57 - case IQ_MISMATCH_CAL: /* Both 2 GHz and 5 GHz support OFDM */
58 - return true;
59 - case ADC_GAIN_CAL:
60 - case ADC_DC_CAL:
61 - if (!(conf->channel->band == IEEE80211_BAND_2GHZ &&
62 - conf_is_ht20(conf)))
63 - return true;
64 - break;
65 - }
66 - return false;
67 -}
68 -
69 static void ar9002_hw_iqcal_collect(struct ath_hw *ah)
70 {
71 int i;
72 @@ -872,24 +858,28 @@ static bool ar9002_hw_init_cal(struct at
73
74 /* Enable IQ, ADC Gain and ADC DC offset CALs */
75 if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
76 - if (ar9002_hw_iscal_supported(ah, ADC_GAIN_CAL)) {
77 + ah->supp_cals = IQ_MISMATCH_CAL;
78 +
79 + if (AR_SREV_9160_10_OR_LATER(ah) &&
80 + !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan))) {
81 + ah->supp_cals |= ADC_GAIN_CAL | ADC_DC_CAL;
82 +
83 +
84 INIT_CAL(&ah->adcgain_caldata);
85 INSERT_CAL(ah, &ah->adcgain_caldata);
86 ath_print(common, ATH_DBG_CALIBRATE,
87 "enabling ADC Gain Calibration.\n");
88 - }
89 - if (ar9002_hw_iscal_supported(ah, ADC_DC_CAL)) {
90 +
91 INIT_CAL(&ah->adcdc_caldata);
92 INSERT_CAL(ah, &ah->adcdc_caldata);
93 ath_print(common, ATH_DBG_CALIBRATE,
94 "enabling ADC DC Calibration.\n");
95 }
96 - if (ar9002_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
97 - INIT_CAL(&ah->iq_caldata);
98 - INSERT_CAL(ah, &ah->iq_caldata);
99 - ath_print(common, ATH_DBG_CALIBRATE,
100 - "enabling IQ Calibration.\n");
101 - }
102 +
103 + INIT_CAL(&ah->iq_caldata);
104 + INSERT_CAL(ah, &ah->iq_caldata);
105 + ath_print(common, ATH_DBG_CALIBRATE,
106 + "enabling IQ Calibration.\n");
107
108 ah->cal_list_curr = ah->cal_list;
109
110 @@ -980,7 +970,6 @@ void ar9002_hw_attach_calib_ops(struct a
111 priv_ops->init_cal_settings = ar9002_hw_init_cal_settings;
112 priv_ops->init_cal = ar9002_hw_init_cal;
113 priv_ops->setup_calibration = ar9002_hw_setup_calibration;
114 - priv_ops->iscal_supported = ar9002_hw_iscal_supported;
115
116 ops->calibrate = ar9002_hw_calibrate;
117 }
118 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
119 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
120 @@ -18,6 +18,11 @@
121 #include "hw-ops.h"
122 #include "ar9003_phy.h"
123
124 +enum ar9003_cal_types {
125 + IQ_MISMATCH_CAL = BIT(0),
126 + TEMP_COMP_CAL = BIT(1),
127 +};
128 +
129 static void ar9003_hw_setup_calibration(struct ath_hw *ah,
130 struct ath9k_cal_list *currCal)
131 {
132 @@ -50,10 +55,6 @@ static void ar9003_hw_setup_calibration(
133 ath_print(common, ATH_DBG_CALIBRATE,
134 "starting Temperature Compensation Calibration\n");
135 break;
136 - case ADC_GAIN_CAL:
137 - case ADC_DC_CAL:
138 - /* Not yet */
139 - break;
140 }
141 }
142
143 @@ -313,27 +314,6 @@ static const struct ath9k_percal_data iq
144 static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
145 {
146 ah->iq_caldata.calData = &iq_cal_single_sample;
147 - ah->supp_cals = IQ_MISMATCH_CAL;
148 -}
149 -
150 -static bool ar9003_hw_iscal_supported(struct ath_hw *ah,
151 - enum ath9k_cal_types calType)
152 -{
153 - switch (calType & ah->supp_cals) {
154 - case IQ_MISMATCH_CAL:
155 - /*
156 - * XXX: Run IQ Mismatch for non-CCK only
157 - * Note that CHANNEL_B is never set though.
158 - */
159 - return true;
160 - case ADC_GAIN_CAL:
161 - case ADC_DC_CAL:
162 - return false;
163 - case TEMP_COMP_CAL:
164 - return true;
165 - }
166 -
167 - return false;
168 }
169
170 /*
171 @@ -772,15 +752,16 @@ static bool ar9003_hw_init_cal(struct at
172
173 /* Initialize list pointers */
174 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
175 + ah->supp_cals = IQ_MISMATCH_CAL;
176
177 - if (ar9003_hw_iscal_supported(ah, IQ_MISMATCH_CAL)) {
178 + if (ah->supp_cals & IQ_MISMATCH_CAL) {
179 INIT_CAL(&ah->iq_caldata);
180 INSERT_CAL(ah, &ah->iq_caldata);
181 ath_print(common, ATH_DBG_CALIBRATE,
182 "enabling IQ Calibration.\n");
183 }
184
185 - if (ar9003_hw_iscal_supported(ah, TEMP_COMP_CAL)) {
186 + if (ah->supp_cals & TEMP_COMP_CAL) {
187 INIT_CAL(&ah->tempCompCalData);
188 INSERT_CAL(ah, &ah->tempCompCalData);
189 ath_print(common, ATH_DBG_CALIBRATE,
190 @@ -807,7 +788,6 @@ void ar9003_hw_attach_calib_ops(struct a
191 priv_ops->init_cal_settings = ar9003_hw_init_cal_settings;
192 priv_ops->init_cal = ar9003_hw_init_cal;
193 priv_ops->setup_calibration = ar9003_hw_setup_calibration;
194 - priv_ops->iscal_supported = ar9003_hw_iscal_supported;
195
196 ops->calibrate = ar9003_hw_calibrate;
197 }
198 --- a/drivers/net/wireless/ath/ath9k/calib.h
199 +++ b/drivers/net/wireless/ath/ath9k/calib.h
200 @@ -58,13 +58,6 @@ struct ar5416IniArray {
201 } \
202 } while (0)
203
204 -enum ath9k_cal_types {
205 - ADC_GAIN_CAL = 0x2,
206 - ADC_DC_CAL = 0x4,
207 - IQ_MISMATCH_CAL = 0x8,
208 - TEMP_COMP_CAL = 0x10,
209 -};
210 -
211 enum ath9k_cal_state {
212 CAL_INACTIVE,
213 CAL_WAITING,
214 @@ -79,7 +72,7 @@ enum ath9k_cal_state {
215 #define PER_MAX_LOG_COUNT 10
216
217 struct ath9k_percal_data {
218 - enum ath9k_cal_types calType;
219 + u32 calType;
220 u32 calNumSamples;
221 u32 calCountMax;
222 void (*calCollect) (struct ath_hw *);
223 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
224 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
225 @@ -276,12 +276,6 @@ static inline void ath9k_hw_setup_calibr
226 ath9k_hw_private_ops(ah)->setup_calibration(ah, currCal);
227 }
228
229 -static inline bool ath9k_hw_iscal_supported(struct ath_hw *ah,
230 - enum ath9k_cal_types calType)
231 -{
232 - return ath9k_hw_private_ops(ah)->iscal_supported(ah, calType);
233 -}
234 -
235 static inline void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning)
236 {
237 ath9k_hw_private_ops(ah)->ani_reset(ah, is_scanning);
238 --- a/drivers/net/wireless/ath/ath9k/calib.c
239 +++ b/drivers/net/wireless/ath/ath9k/calib.c
240 @@ -186,7 +186,7 @@ bool ath9k_hw_reset_calvalid(struct ath_
241 return true;
242 }
243
244 - if (!ath9k_hw_iscal_supported(ah, currCal->calData->calType))
245 + if (!(ah->supp_cals & currCal->calData->calType))
246 return true;
247
248 ath_print(common, ATH_DBG_CALIBRATE,