[package] libtool: don't install aclocal directory again if symlink into $(STAGING_DI...
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 320-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
2 +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
3 @@ -26,24 +26,6 @@ MODULE_PARM_DESC(nohwcrypt, "Force new A
4
5 /* General hardware code for the A5008/AR9001/AR9002 hadware families */
6
7 -static bool ar9002_hw_macversion_supported(u32 macversion)
8 -{
9 - switch (macversion) {
10 - case AR_SREV_VERSION_5416_PCI:
11 - case AR_SREV_VERSION_5416_PCIE:
12 - case AR_SREV_VERSION_9160:
13 - case AR_SREV_VERSION_9100:
14 - case AR_SREV_VERSION_9280:
15 - case AR_SREV_VERSION_9285:
16 - case AR_SREV_VERSION_9287:
17 - case AR_SREV_VERSION_9271:
18 - return true;
19 - default:
20 - break;
21 - }
22 - return false;
23 -}
24 -
25 static void ar9002_hw_init_mode_regs(struct ath_hw *ah)
26 {
27 if (AR_SREV_9271(ah)) {
28 @@ -565,7 +547,6 @@ void ar9002_hw_attach_ops(struct ath_hw
29
30 priv_ops->init_mode_regs = ar9002_hw_init_mode_regs;
31 priv_ops->init_mode_gain_regs = ar9002_hw_init_mode_gain_regs;
32 - priv_ops->macversion_supported = ar9002_hw_macversion_supported;
33
34 ops->config_pci_powersave = ar9002_hw_configpcipowersave;
35
36 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
37 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
38 @@ -283,7 +283,6 @@ static void ar9002_hw_set11n_txdesc(stru
39 {
40 struct ar5416_desc *ads = AR5416DESC(ds);
41
42 - txPower += ah->txpower_indexoffset;
43 if (txPower > 63)
44 txPower = 63;
45
46 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
47 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
48 @@ -71,7 +71,7 @@ static const struct ar9300_eeprom ar9300
49 .regDmn = { LE16(0), LE16(0x1f) },
50 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
51 .opCapFlags = {
52 - .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
53 + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
54 .eepMisc = 0,
55 },
56 .rfSilent = 0,
57 @@ -648,7 +648,7 @@ static const struct ar9300_eeprom ar9300
58 .regDmn = { LE16(0), LE16(0x1f) },
59 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
60 .opCapFlags = {
61 - .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
62 + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
63 .eepMisc = 0,
64 },
65 .rfSilent = 0,
66 @@ -1226,7 +1226,7 @@ static const struct ar9300_eeprom ar9300
67 .regDmn = { LE16(0), LE16(0x1f) },
68 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
69 .opCapFlags = {
70 - .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
71 + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
72 .eepMisc = 0,
73 },
74 .rfSilent = 0,
75 @@ -1804,7 +1804,7 @@ static const struct ar9300_eeprom ar9300
76 .regDmn = { LE16(0), LE16(0x1f) },
77 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
78 .opCapFlags = {
79 - .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
80 + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
81 .eepMisc = 0,
82 },
83 .rfSilent = 0,
84 @@ -2381,7 +2381,7 @@ static const struct ar9300_eeprom ar9300
85 .regDmn = { LE16(0), LE16(0x1f) },
86 .txrxMask = 0x33, /* 4 bits tx and 4 bits rx */
87 .opCapFlags = {
88 - .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
89 + .opFlags = AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A,
90 .eepMisc = 0,
91 },
92 .rfSilent = 0,
93 @@ -2973,7 +2973,7 @@ static const struct ar9300_eeprom *ar900
94
95 static u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
96 {
97 - if (fbin == AR9300_BCHAN_UNUSED)
98 + if (fbin == AR5416_BCHAN_UNUSED)
99 return fbin;
100
101 return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
102 @@ -3422,18 +3422,6 @@ static int ath9k_hw_ar9300_get_eeprom_re
103 return 0;
104 }
105
106 -static u8 ath9k_hw_ar9300_get_num_ant_config(struct ath_hw *ah,
107 - enum ath9k_hal_freq_band freq_band)
108 -{
109 - return 1;
110 -}
111 -
112 -static u32 ath9k_hw_ar9300_get_eeprom_antenna_cfg(struct ath_hw *ah,
113 - struct ath9k_channel *chan)
114 -{
115 - return -EINVAL;
116 -}
117 -
118 static s32 ar9003_hw_xpa_bias_level_get(struct ath_hw *ah, bool is2ghz)
119 {
120 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
121 @@ -4395,7 +4383,7 @@ static u16 ar9003_hw_get_indirect_edge_p
122 return CTL_EDGE_TPOWER(ctl_5g[idx].ctlEdges[edge - 1]);
123 }
124
125 - return AR9300_MAX_RATE_POWER;
126 + return MAX_RATE_POWER;
127 }
128
129 /*
130 @@ -4404,7 +4392,7 @@ static u16 ar9003_hw_get_indirect_edge_p
131 static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
132 u16 freq, int idx, bool is2GHz)
133 {
134 - u16 twiceMaxEdgePower = AR9300_MAX_RATE_POWER;
135 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
136 u8 *ctl_freqbin = is2GHz ?
137 &eep->ctl_freqbin_2G[idx][0] :
138 &eep->ctl_freqbin_5G[idx][0];
139 @@ -4414,7 +4402,7 @@ static u16 ar9003_hw_get_max_edge_power(
140
141 /* Get the edge power */
142 for (edge = 0;
143 - (edge < num_edges) && (ctl_freqbin[edge] != AR9300_BCHAN_UNUSED);
144 + (edge < num_edges) && (ctl_freqbin[edge] != AR5416_BCHAN_UNUSED);
145 edge++) {
146 /*
147 * If there's an exact channel match or an inband flag set
148 @@ -4452,9 +4440,9 @@ static void ar9003_hw_set_power_per_rate
149 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
150 struct ath_common *common = ath9k_hw_common(ah);
151 struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
152 - u16 twiceMaxEdgePower = AR9300_MAX_RATE_POWER;
153 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
154 static const u16 tpScaleReductionTable[5] = {
155 - 0, 3, 6, 9, AR9300_MAX_RATE_POWER
156 + 0, 3, 6, 9, MAX_RATE_POWER
157 };
158 int i;
159 int16_t twiceLargestAntenna;
160 @@ -4762,8 +4750,6 @@ const struct eeprom_ops eep_ar9300_ops =
161 .fill_eeprom = ath9k_hw_ar9300_fill_eeprom,
162 .get_eeprom_ver = ath9k_hw_ar9300_get_eeprom_ver,
163 .get_eeprom_rev = ath9k_hw_ar9300_get_eeprom_rev,
164 - .get_num_ant_config = ath9k_hw_ar9300_get_num_ant_config,
165 - .get_eeprom_antenna_cfg = ath9k_hw_ar9300_get_eeprom_antenna_cfg,
166 .set_board_values = ath9k_hw_ar9300_set_board_values,
167 .set_addac = ath9k_hw_ar9300_set_addac,
168 .set_txpower = ath9k_hw_ar9300_set_txpower,
169 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
170 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
171 @@ -20,48 +20,17 @@
172 /* #define AR9300_NUM_CTLS 21 */
173 #define AR9300_NUM_CTLS_5G 9
174 #define AR9300_NUM_CTLS_2G 12
175 -#define AR9300_CTL_MODE_M 0xF
176 #define AR9300_NUM_BAND_EDGES_5G 8
177 #define AR9300_NUM_BAND_EDGES_2G 4
178 -#define AR9300_NUM_PD_GAINS 4
179 -#define AR9300_PD_GAINS_IN_MASK 4
180 -#define AR9300_PD_GAIN_ICEPTS 5
181 -#define AR9300_EEPROM_MODAL_SPURS 5
182 -#define AR9300_MAX_RATE_POWER 63
183 -#define AR9300_NUM_PDADC_VALUES 128
184 -#define AR9300_NUM_RATES 16
185 -#define AR9300_BCHAN_UNUSED 0xFF
186 -#define AR9300_MAX_PWR_RANGE_IN_HALF_DB 64
187 -#define AR9300_OPFLAGS_11A 0x01
188 -#define AR9300_OPFLAGS_11G 0x02
189 -#define AR9300_OPFLAGS_5G_HT40 0x04
190 -#define AR9300_OPFLAGS_2G_HT40 0x08
191 -#define AR9300_OPFLAGS_5G_HT20 0x10
192 -#define AR9300_OPFLAGS_2G_HT20 0x20
193 #define AR9300_EEPMISC_BIG_ENDIAN 0x01
194 #define AR9300_EEPMISC_WOW 0x02
195 #define AR9300_CUSTOMER_DATA_SIZE 20
196
197 -#define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
198 #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
199 #define AR9300_MAX_CHAINS 3
200 #define AR9300_ANT_16S 25
201 #define AR9300_FUTURE_MODAL_SZ 6
202
203 -#define AR9300_NUM_ANT_CHAIN_FIELDS 7
204 -#define AR9300_NUM_ANT_COMMON_FIELDS 4
205 -#define AR9300_SIZE_ANT_CHAIN_FIELD 3
206 -#define AR9300_SIZE_ANT_COMMON_FIELD 4
207 -#define AR9300_ANT_CHAIN_MASK 0x7
208 -#define AR9300_ANT_COMMON_MASK 0xf
209 -#define AR9300_CHAIN_0_IDX 0
210 -#define AR9300_CHAIN_1_IDX 1
211 -#define AR9300_CHAIN_2_IDX 2
212 -
213 -#define AR928X_NUM_ANT_CHAIN_FIELDS 6
214 -#define AR928X_SIZE_ANT_CHAIN_FIELD 2
215 -#define AR928X_ANT_CHAIN_MASK 0x3
216 -
217 /* Delta from which to start power to pdadc table */
218 /* This offset is used in both open loop and closed loop power control
219 * schemes. In open loop power control, it is not really needed, but for
220 @@ -71,12 +40,8 @@
221 */
222 #define AR9300_PWR_TABLE_OFFSET 0
223
224 -/* enable flags for voltage and temp compensation */
225 -#define ENABLE_TEMP_COMPENSATION 0x01
226 -#define ENABLE_VOLT_COMPENSATION 0x02
227 /* byte addressable */
228 #define AR9300_EEPROM_SIZE (16*1024)
229 -#define FIXED_CCA_THRESHOLD 15
230
231 #define AR9300_BASE_ADDR 0x3ff
232 #define AR9300_BASE_ADDR_512 0x1ff
233 @@ -225,7 +190,7 @@ struct ar9300_modal_eep_header {
234 int8_t tempSlope;
235 int8_t voltSlope;
236 /* spur channels in usual fbin coding format */
237 - u8 spurChans[AR9300_EEPROM_MODAL_SPURS];
238 + u8 spurChans[AR_EEPROM_MODAL_SPURS];
239 /* 3 Check if the register is per chain */
240 int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS];
241 u8 ob[AR9300_MAX_CHAINS];
242 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
243 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
244 @@ -20,17 +20,6 @@
245
246 /* General hardware code for the AR9003 hadware family */
247
248 -static bool ar9003_hw_macversion_supported(u32 macversion)
249 -{
250 - switch (macversion) {
251 - case AR_SREV_VERSION_9300:
252 - return true;
253 - default:
254 - break;
255 - }
256 - return false;
257 -}
258 -
259 /*
260 * The AR9003 family uses a new INI format (pre, core, post
261 * arrays per subsystem). This provides support for the
262 @@ -216,7 +205,6 @@ void ar9003_hw_attach_ops(struct ath_hw
263
264 priv_ops->init_mode_regs = ar9003_hw_init_mode_regs;
265 priv_ops->init_mode_gain_regs = ar9003_hw_init_mode_gain_regs;
266 - priv_ops->macversion_supported = ar9003_hw_macversion_supported;
267
268 ops->config_pci_powersave = ar9003_hw_configpcipowersave;
269
270 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
271 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
272 @@ -322,7 +322,6 @@ static void ar9003_hw_set11n_txdesc(stru
273 if (txpower > ah->txpower_limit)
274 txpower = ah->txpower_limit;
275
276 - txpower += ah->txpower_indexoffset;
277 if (txpower > 63)
278 txpower = 63;
279
280 --- a/drivers/net/wireless/ath/ath9k/eeprom.c
281 +++ b/drivers/net/wireless/ath/ath9k/eeprom.c
282 @@ -234,7 +234,7 @@ void ath9k_hw_get_target_powers(struct a
283 u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
284 bool is2GHz, int num_band_edges)
285 {
286 - u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
287 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
288 int i;
289
290 for (i = 0; (i < num_band_edges) &&
291 @@ -279,6 +279,219 @@ void ath9k_hw_update_regulatory_maxpower
292 }
293 }
294
295 +void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
296 + struct ath9k_channel *chan,
297 + void *pRawDataSet,
298 + u8 *bChans, u16 availPiers,
299 + u16 tPdGainOverlap,
300 + u16 *pPdGainBoundaries, u8 *pPDADCValues,
301 + u16 numXpdGains)
302 +{
303 + int i, j, k;
304 + int16_t ss;
305 + u16 idxL = 0, idxR = 0, numPiers;
306 + static u8 vpdTableL[AR5416_NUM_PD_GAINS]
307 + [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
308 + static u8 vpdTableR[AR5416_NUM_PD_GAINS]
309 + [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
310 + static u8 vpdTableI[AR5416_NUM_PD_GAINS]
311 + [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
312 +
313 + u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
314 + u8 minPwrT4[AR5416_NUM_PD_GAINS];
315 + u8 maxPwrT4[AR5416_NUM_PD_GAINS];
316 + int16_t vpdStep;
317 + int16_t tmpVal;
318 + u16 sizeCurrVpdTable, maxIndex, tgtIndex;
319 + bool match;
320 + int16_t minDelta = 0;
321 + struct chan_centers centers;
322 + int pdgain_boundary_default;
323 + struct cal_data_per_freq *data_def = pRawDataSet;
324 + struct cal_data_per_freq_4k *data_4k = pRawDataSet;
325 + struct cal_data_per_freq_ar9287 *data_9287 = pRawDataSet;
326 + bool eeprom_4k = AR_SREV_9285(ah) || AR_SREV_9271(ah);
327 + int intercepts;
328 +
329 + if (AR_SREV_9287(ah))
330 + intercepts = AR9287_PD_GAIN_ICEPTS;
331 + else
332 + intercepts = AR5416_PD_GAIN_ICEPTS;
333 +
334 + memset(&minPwrT4, 0, AR5416_NUM_PD_GAINS);
335 + ath9k_hw_get_channel_centers(ah, chan, &centers);
336 +
337 + for (numPiers = 0; numPiers < availPiers; numPiers++) {
338 + if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
339 + break;
340 + }
341 +
342 + match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center,
343 + IS_CHAN_2GHZ(chan)),
344 + bChans, numPiers, &idxL, &idxR);
345 +
346 + if (match) {
347 + if (AR_SREV_9287(ah)) {
348 + /* FIXME: array overrun? */
349 + for (i = 0; i < numXpdGains; i++) {
350 + minPwrT4[i] = data_9287[idxL].pwrPdg[i][0];
351 + maxPwrT4[i] = data_9287[idxL].pwrPdg[i][4];
352 + ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
353 + data_9287[idxL].pwrPdg[i],
354 + data_9287[idxL].vpdPdg[i],
355 + intercepts,
356 + vpdTableI[i]);
357 + }
358 + } else if (eeprom_4k) {
359 + for (i = 0; i < numXpdGains; i++) {
360 + minPwrT4[i] = data_4k[idxL].pwrPdg[i][0];
361 + maxPwrT4[i] = data_4k[idxL].pwrPdg[i][4];
362 + ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
363 + data_4k[idxL].pwrPdg[i],
364 + data_4k[idxL].vpdPdg[i],
365 + intercepts,
366 + vpdTableI[i]);
367 + }
368 + } else {
369 + for (i = 0; i < numXpdGains; i++) {
370 + minPwrT4[i] = data_def[idxL].pwrPdg[i][0];
371 + maxPwrT4[i] = data_def[idxL].pwrPdg[i][4];
372 + ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
373 + data_def[idxL].pwrPdg[i],
374 + data_def[idxL].vpdPdg[i],
375 + intercepts,
376 + vpdTableI[i]);
377 + }
378 + }
379 + } else {
380 + for (i = 0; i < numXpdGains; i++) {
381 + if (AR_SREV_9287(ah)) {
382 + pVpdL = data_9287[idxL].vpdPdg[i];
383 + pPwrL = data_9287[idxL].pwrPdg[i];
384 + pVpdR = data_9287[idxR].vpdPdg[i];
385 + pPwrR = data_9287[idxR].pwrPdg[i];
386 + } else if (eeprom_4k) {
387 + pVpdL = data_4k[idxL].vpdPdg[i];
388 + pPwrL = data_4k[idxL].pwrPdg[i];
389 + pVpdR = data_4k[idxR].vpdPdg[i];
390 + pPwrR = data_4k[idxR].pwrPdg[i];
391 + } else {
392 + pVpdL = data_def[idxL].vpdPdg[i];
393 + pPwrL = data_def[idxL].pwrPdg[i];
394 + pVpdR = data_def[idxR].vpdPdg[i];
395 + pPwrR = data_def[idxR].pwrPdg[i];
396 + }
397 +
398 + minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
399 +
400 + maxPwrT4[i] =
401 + min(pPwrL[intercepts - 1],
402 + pPwrR[intercepts - 1]);
403 +
404 +
405 + ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
406 + pPwrL, pVpdL,
407 + intercepts,
408 + vpdTableL[i]);
409 + ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
410 + pPwrR, pVpdR,
411 + intercepts,
412 + vpdTableR[i]);
413 +
414 + for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
415 + vpdTableI[i][j] =
416 + (u8)(ath9k_hw_interpolate((u16)
417 + FREQ2FBIN(centers.
418 + synth_center,
419 + IS_CHAN_2GHZ
420 + (chan)),
421 + bChans[idxL], bChans[idxR],
422 + vpdTableL[i][j], vpdTableR[i][j]));
423 + }
424 + }
425 + }
426 +
427 + k = 0;
428 +
429 + for (i = 0; i < numXpdGains; i++) {
430 + if (i == (numXpdGains - 1))
431 + pPdGainBoundaries[i] =
432 + (u16)(maxPwrT4[i] / 2);
433 + else
434 + pPdGainBoundaries[i] =
435 + (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
436 +
437 + pPdGainBoundaries[i] =
438 + min((u16)MAX_RATE_POWER, pPdGainBoundaries[i]);
439 +
440 + if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
441 + minDelta = pPdGainBoundaries[0] - 23;
442 + pPdGainBoundaries[0] = 23;
443 + } else {
444 + minDelta = 0;
445 + }
446 +
447 + if (i == 0) {
448 + if (AR_SREV_9280_20_OR_LATER(ah))
449 + ss = (int16_t)(0 - (minPwrT4[i] / 2));
450 + else
451 + ss = 0;
452 + } else {
453 + ss = (int16_t)((pPdGainBoundaries[i - 1] -
454 + (minPwrT4[i] / 2)) -
455 + tPdGainOverlap + 1 + minDelta);
456 + }
457 + vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
458 + vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
459 +
460 + while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
461 + tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
462 + pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
463 + ss++;
464 + }
465 +
466 + sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
467 + tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
468 + (minPwrT4[i] / 2));
469 + maxIndex = (tgtIndex < sizeCurrVpdTable) ?
470 + tgtIndex : sizeCurrVpdTable;
471 +
472 + while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
473 + pPDADCValues[k++] = vpdTableI[i][ss++];
474 + }
475 +
476 + vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
477 + vpdTableI[i][sizeCurrVpdTable - 2]);
478 + vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
479 +
480 + if (tgtIndex >= maxIndex) {
481 + while ((ss <= tgtIndex) &&
482 + (k < (AR5416_NUM_PDADC_VALUES - 1))) {
483 + tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
484 + (ss - maxIndex + 1) * vpdStep));
485 + pPDADCValues[k++] = (u8)((tmpVal > 255) ?
486 + 255 : tmpVal);
487 + ss++;
488 + }
489 + }
490 + }
491 +
492 + if (eeprom_4k)
493 + pdgain_boundary_default = 58;
494 + else
495 + pdgain_boundary_default = pPdGainBoundaries[i - 1];
496 +
497 + while (i < AR5416_PD_GAINS_IN_MASK) {
498 + pPdGainBoundaries[i] = pdgain_boundary_default;
499 + i++;
500 + }
501 +
502 + while (k < AR5416_NUM_PDADC_VALUES) {
503 + pPDADCValues[k] = pPDADCValues[k - 1];
504 + k++;
505 + }
506 +}
507 +
508 int ath9k_hw_eeprom_init(struct ath_hw *ah)
509 {
510 int status;
511 --- a/drivers/net/wireless/ath/ath9k/eeprom.h
512 +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
513 @@ -17,6 +17,8 @@
514 #ifndef EEPROM_H
515 #define EEPROM_H
516
517 +#define AR_EEPROM_MODAL_SPURS 5
518 +
519 #include "../ath.h"
520 #include <net/cfg80211.h>
521 #include "ar9003_eeprom.h"
522 @@ -149,8 +151,6 @@
523 #define AR5416_NUM_PD_GAINS 4
524 #define AR5416_PD_GAINS_IN_MASK 4
525 #define AR5416_PD_GAIN_ICEPTS 5
526 -#define AR5416_EEPROM_MODAL_SPURS 5
527 -#define AR5416_MAX_RATE_POWER 63
528 #define AR5416_NUM_PDADC_VALUES 128
529 #define AR5416_BCHAN_UNUSED 0xFF
530 #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
531 @@ -175,8 +175,6 @@
532 #define AR5416_EEP4K_NUM_CTLS 12
533 #define AR5416_EEP4K_NUM_BAND_EDGES 4
534 #define AR5416_EEP4K_NUM_PD_GAINS 2
535 -#define AR5416_EEP4K_PD_GAINS_IN_MASK 4
536 -#define AR5416_EEP4K_PD_GAIN_ICEPTS 5
537 #define AR5416_EEP4K_MAX_CHAINS 1
538
539 #define AR9280_TX_GAIN_TABLE_SIZE 22
540 @@ -198,35 +196,12 @@
541 #define AR9287_NUM_2G_40_TARGET_POWERS 3
542 #define AR9287_NUM_CTLS 12
543 #define AR9287_NUM_BAND_EDGES 4
544 -#define AR9287_NUM_PD_GAINS 4
545 -#define AR9287_PD_GAINS_IN_MASK 4
546 #define AR9287_PD_GAIN_ICEPTS 1
547 -#define AR9287_EEPROM_MODAL_SPURS 5
548 -#define AR9287_MAX_RATE_POWER 63
549 -#define AR9287_NUM_PDADC_VALUES 128
550 -#define AR9287_NUM_RATES 16
551 -#define AR9287_BCHAN_UNUSED 0xFF
552 -#define AR9287_MAX_PWR_RANGE_IN_HALF_DB 64
553 -#define AR9287_OPFLAGS_11A 0x01
554 -#define AR9287_OPFLAGS_11G 0x02
555 -#define AR9287_OPFLAGS_2G_HT40 0x08
556 -#define AR9287_OPFLAGS_2G_HT20 0x20
557 -#define AR9287_OPFLAGS_5G_HT40 0x04
558 -#define AR9287_OPFLAGS_5G_HT20 0x10
559 #define AR9287_EEPMISC_BIG_ENDIAN 0x01
560 #define AR9287_EEPMISC_WOW 0x02
561 #define AR9287_MAX_CHAINS 2
562 #define AR9287_ANT_16S 32
563 -#define AR9287_custdatasize 20
564
565 -#define AR9287_NUM_ANT_CHAIN_FIELDS 6
566 -#define AR9287_NUM_ANT_COMMON_FIELDS 4
567 -#define AR9287_SIZE_ANT_CHAIN_FIELD 2
568 -#define AR9287_SIZE_ANT_COMMON_FIELD 4
569 -#define AR9287_ANT_CHAIN_MASK 0x3
570 -#define AR9287_ANT_COMMON_MASK 0xf
571 -#define AR9287_CHAIN_0_IDX 0
572 -#define AR9287_CHAIN_1_IDX 1
573 #define AR9287_DATA_SZ 32
574
575 #define AR9287_PWR_TABLE_OFFSET_DB -5
576 @@ -396,7 +371,7 @@ struct modal_eep_header {
577 u16 xpaBiasLvlFreq[3];
578 u8 futureModal[6];
579
580 - struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
581 + struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
582 } __packed;
583
584 struct calDataPerFreqOpLoop {
585 @@ -464,7 +439,7 @@ struct modal_eep_4k_header {
586 u8 db2_4:4, reserved:4;
587 #endif
588 u8 futureModal[4];
589 - struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
590 + struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
591 } __packed;
592
593 struct base_eep_ar9287_header {
594 @@ -522,7 +497,7 @@ struct modal_eep_ar9287_header {
595 u8 ob_qam;
596 u8 ob_pal_off;
597 u8 futureModal[30];
598 - struct spur_chan spurChans[AR9287_EEPROM_MODAL_SPURS];
599 + struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
600 } __packed;
601
602 struct cal_data_per_freq {
603 @@ -531,8 +506,8 @@ struct cal_data_per_freq {
604 } __packed;
605
606 struct cal_data_per_freq_4k {
607 - u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
608 - u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
609 + u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
610 + u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
611 } __packed;
612
613 struct cal_target_power_leg {
614 @@ -558,8 +533,8 @@ struct cal_data_op_loop_ar9287 {
615 } __packed;
616
617 struct cal_data_per_freq_ar9287 {
618 - u8 pwrPdg[AR9287_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
619 - u8 vpdPdg[AR9287_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
620 + u8 pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
621 + u8 vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
622 } __packed;
623
624 union cal_data_per_freq_ar9287_u {
625 @@ -674,10 +649,6 @@ struct eeprom_ops {
626 bool (*fill_eeprom)(struct ath_hw *hw);
627 int (*get_eeprom_ver)(struct ath_hw *hw);
628 int (*get_eeprom_rev)(struct ath_hw *hw);
629 - u8 (*get_num_ant_config)(struct ath_hw *hw,
630 - enum ath9k_hal_freq_band band);
631 - u32 (*get_eeprom_antenna_cfg)(struct ath_hw *hw,
632 - struct ath9k_channel *chan);
633 void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
634 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
635 void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
636 @@ -716,6 +687,14 @@ u16 ath9k_hw_get_max_edge_power(u16 freq
637 void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah);
638 int ath9k_hw_eeprom_init(struct ath_hw *ah);
639
640 +void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
641 + struct ath9k_channel *chan,
642 + void *pRawDataSet,
643 + u8 *bChans, u16 availPiers,
644 + u16 tPdGainOverlap,
645 + u16 *pPdGainBoundaries, u8 *pPDADCValues,
646 + u16 numXpdGains);
647 +
648 #define ar5416_get_ntxchains(_txchainmask) \
649 (((_txchainmask >> 2) & 1) + \
650 ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
651 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
652 +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
653 @@ -155,7 +155,7 @@ static int ath9k_hw_4k_check_eeprom(stru
654 eep->modalHeader.antCtrlChain[i] = integer;
655 }
656
657 - for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
658 + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
659 word = swab16(eep->modalHeader.spurChans[i].spurChan);
660 eep->modalHeader.spurChans[i].spurChan = word;
661 }
662 @@ -230,173 +230,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct
663 }
664 }
665
666 -static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
667 - struct ath9k_channel *chan,
668 - struct cal_data_per_freq_4k *pRawDataSet,
669 - u8 *bChans, u16 availPiers,
670 - u16 tPdGainOverlap,
671 - u16 *pPdGainBoundaries, u8 *pPDADCValues,
672 - u16 numXpdGains)
673 -{
674 -#define TMP_VAL_VPD_TABLE \
675 - ((vpdTableI[i][sizeCurrVpdTable - 1] + (ss - maxIndex + 1) * vpdStep));
676 - int i, j, k;
677 - int16_t ss;
678 - u16 idxL = 0, idxR = 0, numPiers;
679 - static u8 vpdTableL[AR5416_EEP4K_NUM_PD_GAINS]
680 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
681 - static u8 vpdTableR[AR5416_EEP4K_NUM_PD_GAINS]
682 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
683 - static u8 vpdTableI[AR5416_EEP4K_NUM_PD_GAINS]
684 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
685 -
686 - u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
687 - u8 minPwrT4[AR5416_EEP4K_NUM_PD_GAINS];
688 - u8 maxPwrT4[AR5416_EEP4K_NUM_PD_GAINS];
689 - int16_t vpdStep;
690 - int16_t tmpVal;
691 - u16 sizeCurrVpdTable, maxIndex, tgtIndex;
692 - bool match;
693 - int16_t minDelta = 0;
694 - struct chan_centers centers;
695 -#define PD_GAIN_BOUNDARY_DEFAULT 58;
696 -
697 - memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
698 - ath9k_hw_get_channel_centers(ah, chan, &centers);
699 -
700 - for (numPiers = 0; numPiers < availPiers; numPiers++) {
701 - if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
702 - break;
703 - }
704 -
705 - match = ath9k_hw_get_lower_upper_index(
706 - (u8)FREQ2FBIN(centers.synth_center,
707 - IS_CHAN_2GHZ(chan)), bChans, numPiers,
708 - &idxL, &idxR);
709 -
710 - if (match) {
711 - for (i = 0; i < numXpdGains; i++) {
712 - minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
713 - maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
714 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
715 - pRawDataSet[idxL].pwrPdg[i],
716 - pRawDataSet[idxL].vpdPdg[i],
717 - AR5416_EEP4K_PD_GAIN_ICEPTS,
718 - vpdTableI[i]);
719 - }
720 - } else {
721 - for (i = 0; i < numXpdGains; i++) {
722 - pVpdL = pRawDataSet[idxL].vpdPdg[i];
723 - pPwrL = pRawDataSet[idxL].pwrPdg[i];
724 - pVpdR = pRawDataSet[idxR].vpdPdg[i];
725 - pPwrR = pRawDataSet[idxR].pwrPdg[i];
726 -
727 - minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
728 -
729 - maxPwrT4[i] =
730 - min(pPwrL[AR5416_EEP4K_PD_GAIN_ICEPTS - 1],
731 - pPwrR[AR5416_EEP4K_PD_GAIN_ICEPTS - 1]);
732 -
733 -
734 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
735 - pPwrL, pVpdL,
736 - AR5416_EEP4K_PD_GAIN_ICEPTS,
737 - vpdTableL[i]);
738 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
739 - pPwrR, pVpdR,
740 - AR5416_EEP4K_PD_GAIN_ICEPTS,
741 - vpdTableR[i]);
742 -
743 - for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
744 - vpdTableI[i][j] =
745 - (u8)(ath9k_hw_interpolate((u16)
746 - FREQ2FBIN(centers.
747 - synth_center,
748 - IS_CHAN_2GHZ
749 - (chan)),
750 - bChans[idxL], bChans[idxR],
751 - vpdTableL[i][j], vpdTableR[i][j]));
752 - }
753 - }
754 - }
755 -
756 - k = 0;
757 -
758 - for (i = 0; i < numXpdGains; i++) {
759 - if (i == (numXpdGains - 1))
760 - pPdGainBoundaries[i] =
761 - (u16)(maxPwrT4[i] / 2);
762 - else
763 - pPdGainBoundaries[i] =
764 - (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
765 -
766 - pPdGainBoundaries[i] =
767 - min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
768 -
769 - if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
770 - minDelta = pPdGainBoundaries[0] - 23;
771 - pPdGainBoundaries[0] = 23;
772 - } else {
773 - minDelta = 0;
774 - }
775 -
776 - if (i == 0) {
777 - if (AR_SREV_9280_20_OR_LATER(ah))
778 - ss = (int16_t)(0 - (minPwrT4[i] / 2));
779 - else
780 - ss = 0;
781 - } else {
782 - ss = (int16_t)((pPdGainBoundaries[i - 1] -
783 - (minPwrT4[i] / 2)) -
784 - tPdGainOverlap + 1 + minDelta);
785 - }
786 - vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
787 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
788 -
789 - while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
790 - tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
791 - pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
792 - ss++;
793 - }
794 -
795 - sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
796 - tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
797 - (minPwrT4[i] / 2));
798 - maxIndex = (tgtIndex < sizeCurrVpdTable) ?
799 - tgtIndex : sizeCurrVpdTable;
800 -
801 - while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1)))
802 - pPDADCValues[k++] = vpdTableI[i][ss++];
803 -
804 - vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
805 - vpdTableI[i][sizeCurrVpdTable - 2]);
806 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
807 -
808 - if (tgtIndex >= maxIndex) {
809 - while ((ss <= tgtIndex) &&
810 - (k < (AR5416_NUM_PDADC_VALUES - 1))) {
811 - tmpVal = (int16_t) TMP_VAL_VPD_TABLE;
812 - pPDADCValues[k++] = (u8)((tmpVal > 255) ?
813 - 255 : tmpVal);
814 - ss++;
815 - }
816 - }
817 - }
818 -
819 - while (i < AR5416_EEP4K_PD_GAINS_IN_MASK) {
820 - pPdGainBoundaries[i] = PD_GAIN_BOUNDARY_DEFAULT;
821 - i++;
822 - }
823 -
824 - while (k < AR5416_NUM_PDADC_VALUES) {
825 - pPDADCValues[k] = pPDADCValues[k - 1];
826 - k++;
827 - }
828 -
829 - return;
830 -#undef TMP_VAL_VPD_TABLE
831 -}
832 -
833 static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
834 struct ath9k_channel *chan,
835 int16_t *pTxPowerIndexOffset)
836 @@ -407,7 +240,7 @@ static void ath9k_hw_set_4k_power_cal_ta
837 u8 *pCalBChans = NULL;
838 u16 pdGainOverlap_t2;
839 static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
840 - u16 gainBoundaries[AR5416_EEP4K_PD_GAINS_IN_MASK];
841 + u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
842 u16 numPiers, i, j;
843 u16 numXpdGain, xpdMask;
844 u16 xpdGainValues[AR5416_EEP4K_NUM_PD_GAINS] = { 0, 0 };
845 @@ -429,12 +262,12 @@ static void ath9k_hw_set_4k_power_cal_ta
846
847 numXpdGain = 0;
848
849 - for (i = 1; i <= AR5416_EEP4K_PD_GAINS_IN_MASK; i++) {
850 - if ((xpdMask >> (AR5416_EEP4K_PD_GAINS_IN_MASK - i)) & 1) {
851 + for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) {
852 + if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) {
853 if (numXpdGain >= AR5416_EEP4K_NUM_PD_GAINS)
854 break;
855 xpdGainValues[numXpdGain] =
856 - (u16)(AR5416_EEP4K_PD_GAINS_IN_MASK - i);
857 + (u16)(AR5416_PD_GAINS_IN_MASK - i);
858 numXpdGain++;
859 }
860 }
861 @@ -458,7 +291,7 @@ static void ath9k_hw_set_4k_power_cal_ta
862 if (pEepData->baseEepHeader.txMask & (1 << i)) {
863 pRawDataset = pEepData->calPierData2G[i];
864
865 - ath9k_hw_get_4k_gain_boundaries_pdadcs(ah, chan,
866 + ath9k_hw_get_gain_boundaries_pdadcs(ah, chan,
867 pRawDataset, pCalBChans,
868 numPiers, pdGainOverlap_t2,
869 gainBoundaries,
870 @@ -532,7 +365,7 @@ static void ath9k_hw_set_4k_power_per_ra
871 int i;
872 int16_t twiceLargestAntenna;
873 u16 twiceMinEdgePower;
874 - u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
875 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
876 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
877 u16 numCtlModes;
878 const u16 *pCtlMode;
879 @@ -541,7 +374,7 @@ static void ath9k_hw_set_4k_power_per_ra
880 struct cal_ctl_data_4k *rep;
881 struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
882 static const u16 tpScaleReductionTable[5] =
883 - { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
884 + { 0, 3, 6, 9, MAX_RATE_POWER };
885 struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
886 0, { 0, 0, 0, 0}
887 };
888 @@ -617,7 +450,7 @@ static void ath9k_hw_set_4k_power_per_ra
889
890 if (ah->eep_ops->get_eeprom_ver(ah) == 14 &&
891 ah->eep_ops->get_eeprom_rev(ah) <= 2)
892 - twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
893 + twiceMaxEdgePower = MAX_RATE_POWER;
894
895 for (i = 0; (i < AR5416_EEP4K_NUM_CTLS) &&
896 pEepData->ctlIndex[i]; i++) {
897 @@ -756,8 +589,8 @@ static void ath9k_hw_4k_set_txpower(stru
898 regulatory->max_power_level = 0;
899 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
900 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
901 - if (ratesArray[i] > AR5416_MAX_RATE_POWER)
902 - ratesArray[i] = AR5416_MAX_RATE_POWER;
903 + if (ratesArray[i] > MAX_RATE_POWER)
904 + ratesArray[i] = MAX_RATE_POWER;
905
906 if (ratesArray[i] > regulatory->max_power_level)
907 regulatory->max_power_level = ratesArray[i];
908 @@ -941,8 +774,7 @@ static void ath9k_hw_4k_set_board_values
909 pModal = &eep->modalHeader;
910 txRxAttenLocal = 23;
911
912 - REG_WRITE(ah, AR_PHY_SWITCH_COM,
913 - ah->eep_ops->get_eeprom_antenna_cfg(ah, chan));
914 + REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
915
916 /* Single chain for 4K EEPROM*/
917 ath9k_hw_4k_set_gain(ah, pModal, eep, txRxAttenLocal);
918 @@ -1158,21 +990,6 @@ static void ath9k_hw_4k_set_board_values
919 }
920 }
921
922 -static u32 ath9k_hw_4k_get_eeprom_antenna_cfg(struct ath_hw *ah,
923 - struct ath9k_channel *chan)
924 -{
925 - struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
926 - struct modal_eep_4k_header *pModal = &eep->modalHeader;
927 -
928 - return pModal->antCtrlCommon;
929 -}
930 -
931 -static u8 ath9k_hw_4k_get_num_ant_config(struct ath_hw *ah,
932 - enum ath9k_hal_freq_band freq_band)
933 -{
934 - return 1;
935 -}
936 -
937 static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
938 {
939 #define EEP_MAP4K_SPURCHAN \
940 @@ -1209,8 +1026,6 @@ const struct eeprom_ops eep_4k_ops = {
941 .fill_eeprom = ath9k_hw_4k_fill_eeprom,
942 .get_eeprom_ver = ath9k_hw_4k_get_eeprom_ver,
943 .get_eeprom_rev = ath9k_hw_4k_get_eeprom_rev,
944 - .get_num_ant_config = ath9k_hw_4k_get_num_ant_config,
945 - .get_eeprom_antenna_cfg = ath9k_hw_4k_get_eeprom_antenna_cfg,
946 .set_board_values = ath9k_hw_4k_set_board_values,
947 .set_addac = ath9k_hw_4k_set_addac,
948 .set_txpower = ath9k_hw_4k_set_txpower,
949 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
950 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
951 @@ -152,7 +152,7 @@ static int ath9k_hw_ar9287_check_eeprom(
952 eep->modalHeader.antCtrlChain[i] = integer;
953 }
954
955 - for (i = 0; i < AR9287_EEPROM_MODAL_SPURS; i++) {
956 + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
957 word = swab16(eep->modalHeader.spurChans[i].spurChan);
958 eep->modalHeader.spurChans[i].spurChan = word;
959 }
960 @@ -223,163 +223,6 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
961 }
962 }
963
964 -static void ath9k_hw_get_ar9287_gain_boundaries_pdadcs(struct ath_hw *ah,
965 - struct ath9k_channel *chan,
966 - struct cal_data_per_freq_ar9287 *pRawDataSet,
967 - u8 *bChans, u16 availPiers,
968 - u16 tPdGainOverlap,
969 - u16 *pPdGainBoundaries,
970 - u8 *pPDADCValues,
971 - u16 numXpdGains)
972 -{
973 -#define TMP_VAL_VPD_TABLE \
974 - ((vpdTableI[i][sizeCurrVpdTable - 1] + (ss - maxIndex + 1) * vpdStep));
975 -
976 - int i, j, k;
977 - int16_t ss;
978 - u16 idxL = 0, idxR = 0, numPiers;
979 - u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
980 - u8 minPwrT4[AR9287_NUM_PD_GAINS];
981 - u8 maxPwrT4[AR9287_NUM_PD_GAINS];
982 - int16_t vpdStep;
983 - int16_t tmpVal;
984 - u16 sizeCurrVpdTable, maxIndex, tgtIndex;
985 - bool match;
986 - int16_t minDelta = 0;
987 - struct chan_centers centers;
988 - static u8 vpdTableL[AR5416_EEP4K_NUM_PD_GAINS]
989 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
990 - static u8 vpdTableR[AR5416_EEP4K_NUM_PD_GAINS]
991 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
992 - static u8 vpdTableI[AR5416_EEP4K_NUM_PD_GAINS]
993 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
994 -
995 - memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
996 - ath9k_hw_get_channel_centers(ah, chan, &centers);
997 -
998 - for (numPiers = 0; numPiers < availPiers; numPiers++) {
999 - if (bChans[numPiers] == AR9287_BCHAN_UNUSED)
1000 - break;
1001 - }
1002 -
1003 - match = ath9k_hw_get_lower_upper_index(
1004 - (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)),
1005 - bChans, numPiers, &idxL, &idxR);
1006 -
1007 - if (match) {
1008 - for (i = 0; i < numXpdGains; i++) {
1009 - minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
1010 - maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
1011 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1012 - pRawDataSet[idxL].pwrPdg[i],
1013 - pRawDataSet[idxL].vpdPdg[i],
1014 - AR9287_PD_GAIN_ICEPTS,
1015 - vpdTableI[i]);
1016 - }
1017 - } else {
1018 - for (i = 0; i < numXpdGains; i++) {
1019 - pVpdL = pRawDataSet[idxL].vpdPdg[i];
1020 - pPwrL = pRawDataSet[idxL].pwrPdg[i];
1021 - pVpdR = pRawDataSet[idxR].vpdPdg[i];
1022 - pPwrR = pRawDataSet[idxR].pwrPdg[i];
1023 -
1024 - minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
1025 -
1026 - maxPwrT4[i] = min(pPwrL[AR9287_PD_GAIN_ICEPTS - 1],
1027 - pPwrR[AR9287_PD_GAIN_ICEPTS - 1]);
1028 -
1029 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1030 - pPwrL, pVpdL,
1031 - AR9287_PD_GAIN_ICEPTS,
1032 - vpdTableL[i]);
1033 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1034 - pPwrR, pVpdR,
1035 - AR9287_PD_GAIN_ICEPTS,
1036 - vpdTableR[i]);
1037 -
1038 - for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
1039 - vpdTableI[i][j] = (u8)(ath9k_hw_interpolate(
1040 - (u16)FREQ2FBIN(centers. synth_center,
1041 - IS_CHAN_2GHZ(chan)),
1042 - bChans[idxL], bChans[idxR],
1043 - vpdTableL[i][j], vpdTableR[i][j]));
1044 - }
1045 - }
1046 - }
1047 -
1048 - k = 0;
1049 -
1050 - for (i = 0; i < numXpdGains; i++) {
1051 - if (i == (numXpdGains - 1))
1052 - pPdGainBoundaries[i] =
1053 - (u16)(maxPwrT4[i] / 2);
1054 - else
1055 - pPdGainBoundaries[i] =
1056 - (u16)((maxPwrT4[i] + minPwrT4[i+1]) / 4);
1057 -
1058 - pPdGainBoundaries[i] = min((u16)AR5416_MAX_RATE_POWER,
1059 - pPdGainBoundaries[i]);
1060 -
1061 -
1062 - minDelta = 0;
1063 -
1064 - if (i == 0) {
1065 - if (AR_SREV_9280_20_OR_LATER(ah))
1066 - ss = (int16_t)(0 - (minPwrT4[i] / 2));
1067 - else
1068 - ss = 0;
1069 - } else {
1070 - ss = (int16_t)((pPdGainBoundaries[i-1] -
1071 - (minPwrT4[i] / 2)) -
1072 - tPdGainOverlap + 1 + minDelta);
1073 - }
1074 -
1075 - vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
1076 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
1077 -
1078 - while ((ss < 0) && (k < (AR9287_NUM_PDADC_VALUES - 1))) {
1079 - tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
1080 - pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
1081 - ss++;
1082 - }
1083 -
1084 - sizeCurrVpdTable = (u8)((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
1085 - tgtIndex = (u8)(pPdGainBoundaries[i] +
1086 - tPdGainOverlap - (minPwrT4[i] / 2));
1087 - maxIndex = (tgtIndex < sizeCurrVpdTable) ?
1088 - tgtIndex : sizeCurrVpdTable;
1089 -
1090 - while ((ss < maxIndex) && (k < (AR9287_NUM_PDADC_VALUES - 1)))
1091 - pPDADCValues[k++] = vpdTableI[i][ss++];
1092 -
1093 - vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
1094 - vpdTableI[i][sizeCurrVpdTable - 2]);
1095 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
1096 -
1097 - if (tgtIndex > maxIndex) {
1098 - while ((ss <= tgtIndex) &&
1099 - (k < (AR9287_NUM_PDADC_VALUES - 1))) {
1100 - tmpVal = (int16_t) TMP_VAL_VPD_TABLE;
1101 - pPDADCValues[k++] =
1102 - (u8)((tmpVal > 255) ? 255 : tmpVal);
1103 - ss++;
1104 - }
1105 - }
1106 - }
1107 -
1108 - while (i < AR9287_PD_GAINS_IN_MASK) {
1109 - pPdGainBoundaries[i] = pPdGainBoundaries[i-1];
1110 - i++;
1111 - }
1112 -
1113 - while (k < AR9287_NUM_PDADC_VALUES) {
1114 - pPDADCValues[k] = pPDADCValues[k-1];
1115 - k++;
1116 - }
1117 -
1118 -#undef TMP_VAL_VPD_TABLE
1119 -}
1120 -
1121 static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah,
1122 struct ath9k_channel *chan,
1123 struct cal_data_op_loop_ar9287 *pRawDatasetOpLoop,
1124 @@ -392,7 +235,7 @@ static void ar9287_eeprom_get_tx_gain_in
1125 ath9k_hw_get_channel_centers(ah, chan, &centers);
1126
1127 for (numPiers = 0; numPiers < availPiers; numPiers++) {
1128 - if (pCalChans[numPiers] == AR9287_BCHAN_UNUSED)
1129 + if (pCalChans[numPiers] == AR5416_BCHAN_UNUSED)
1130 break;
1131 }
1132
1133 @@ -458,11 +301,11 @@ static void ath9k_hw_set_ar9287_power_ca
1134 struct cal_data_op_loop_ar9287 *pRawDatasetOpenLoop;
1135 u8 *pCalBChans = NULL;
1136 u16 pdGainOverlap_t2;
1137 - u8 pdadcValues[AR9287_NUM_PDADC_VALUES];
1138 - u16 gainBoundaries[AR9287_PD_GAINS_IN_MASK];
1139 + u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
1140 + u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
1141 u16 numPiers = 0, i, j;
1142 u16 numXpdGain, xpdMask;
1143 - u16 xpdGainValues[AR9287_NUM_PD_GAINS] = {0, 0, 0, 0};
1144 + u16 xpdGainValues[AR5416_NUM_PD_GAINS] = {0, 0, 0, 0};
1145 u32 reg32, regOffset, regChainOffset, regval;
1146 int16_t modalIdx, diff = 0;
1147 struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
1148 @@ -490,12 +333,12 @@ static void ath9k_hw_set_ar9287_power_ca
1149 numXpdGain = 0;
1150
1151 /* Calculate the value of xpdgains from the xpdGain Mask */
1152 - for (i = 1; i <= AR9287_PD_GAINS_IN_MASK; i++) {
1153 - if ((xpdMask >> (AR9287_PD_GAINS_IN_MASK - i)) & 1) {
1154 - if (numXpdGain >= AR9287_NUM_PD_GAINS)
1155 + for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) {
1156 + if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) {
1157 + if (numXpdGain >= AR5416_NUM_PD_GAINS)
1158 break;
1159 xpdGainValues[numXpdGain] =
1160 - (u16)(AR9287_PD_GAINS_IN_MASK-i);
1161 + (u16)(AR5416_PD_GAINS_IN_MASK-i);
1162 numXpdGain++;
1163 }
1164 }
1165 @@ -528,7 +371,7 @@ static void ath9k_hw_set_ar9287_power_ca
1166 (struct cal_data_per_freq_ar9287 *)
1167 pEepData->calPierData2G[i];
1168
1169 - ath9k_hw_get_ar9287_gain_boundaries_pdadcs(ah, chan,
1170 + ath9k_hw_get_gain_boundaries_pdadcs(ah, chan,
1171 pRawDataset,
1172 pCalBChans, numPiers,
1173 pdGainOverlap_t2,
1174 @@ -564,13 +407,13 @@ static void ath9k_hw_set_ar9287_power_ca
1175 (int32_t)AR9287_PWR_TABLE_OFFSET_DB);
1176 diff *= 2;
1177
1178 - for (j = 0; j < ((u16)AR9287_NUM_PDADC_VALUES-diff); j++)
1179 + for (j = 0; j < ((u16)AR5416_NUM_PDADC_VALUES-diff); j++)
1180 pdadcValues[j] = pdadcValues[j+diff];
1181
1182 - for (j = (u16)(AR9287_NUM_PDADC_VALUES-diff);
1183 - j < AR9287_NUM_PDADC_VALUES; j++)
1184 + for (j = (u16)(AR5416_NUM_PDADC_VALUES-diff);
1185 + j < AR5416_NUM_PDADC_VALUES; j++)
1186 pdadcValues[j] =
1187 - pdadcValues[AR9287_NUM_PDADC_VALUES-diff];
1188 + pdadcValues[AR5416_NUM_PDADC_VALUES-diff];
1189 }
1190
1191 if (!ath9k_hw_ar9287_get_eeprom(ah, EEP_OL_PWRCTRL)) {
1192 @@ -613,9 +456,9 @@ static void ath9k_hw_set_ar9287_power_pe
1193 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10
1194
1195 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1196 - u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1197 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
1198 static const u16 tpScaleReductionTable[5] =
1199 - { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
1200 + { 0, 3, 6, 9, MAX_RATE_POWER };
1201 int i;
1202 int16_t twiceLargestAntenna;
1203 struct cal_ctl_data_ar9287 *rep;
1204 @@ -880,8 +723,8 @@ static void ath9k_hw_ar9287_set_txpower(
1205 regulatory->max_power_level = 0;
1206 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
1207 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
1208 - if (ratesArray[i] > AR9287_MAX_RATE_POWER)
1209 - ratesArray[i] = AR9287_MAX_RATE_POWER;
1210 + if (ratesArray[i] > MAX_RATE_POWER)
1211 + ratesArray[i] = MAX_RATE_POWER;
1212
1213 if (ratesArray[i] > regulatory->max_power_level)
1214 regulatory->max_power_level = ratesArray[i];
1215 @@ -1026,8 +869,7 @@ static void ath9k_hw_ar9287_set_board_va
1216 antWrites[j++] = (u16)(pModal->antCtrlChain[i] & 0x3);
1217 }
1218
1219 - REG_WRITE(ah, AR_PHY_SWITCH_COM,
1220 - ah->eep_ops->get_eeprom_antenna_cfg(ah, chan));
1221 + REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon);
1222
1223 for (i = 0; i < AR9287_MAX_CHAINS; i++) {
1224 regChainOffset = i * 0x1000;
1225 @@ -1128,21 +970,6 @@ static void ath9k_hw_ar9287_set_board_va
1226 pModal->xpaBiasLvl);
1227 }
1228
1229 -static u8 ath9k_hw_ar9287_get_num_ant_config(struct ath_hw *ah,
1230 - enum ath9k_hal_freq_band freq_band)
1231 -{
1232 - return 1;
1233 -}
1234 -
1235 -static u32 ath9k_hw_ar9287_get_eeprom_antenna_cfg(struct ath_hw *ah,
1236 - struct ath9k_channel *chan)
1237 -{
1238 - struct ar9287_eeprom *eep = &ah->eeprom.map9287;
1239 - struct modal_eep_ar9287_header *pModal = &eep->modalHeader;
1240 -
1241 - return pModal->antCtrlCommon;
1242 -}
1243 -
1244 static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah,
1245 u16 i, bool is2GHz)
1246 {
1247 @@ -1180,8 +1007,6 @@ const struct eeprom_ops eep_ar9287_ops =
1248 .fill_eeprom = ath9k_hw_ar9287_fill_eeprom,
1249 .get_eeprom_ver = ath9k_hw_ar9287_get_eeprom_ver,
1250 .get_eeprom_rev = ath9k_hw_ar9287_get_eeprom_rev,
1251 - .get_num_ant_config = ath9k_hw_ar9287_get_num_ant_config,
1252 - .get_eeprom_antenna_cfg = ath9k_hw_ar9287_get_eeprom_antenna_cfg,
1253 .set_board_values = ath9k_hw_ar9287_set_board_values,
1254 .set_addac = ath9k_hw_ar9287_set_addac,
1255 .set_txpower = ath9k_hw_ar9287_set_txpower,
1256 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
1257 +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
1258 @@ -207,7 +207,7 @@ static int ath9k_hw_def_check_eeprom(str
1259 pModal->antCtrlChain[i] = integer;
1260 }
1261
1262 - for (i = 0; i < AR5416_EEPROM_MODAL_SPURS; i++) {
1263 + for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
1264 word = swab16(pModal->spurChans[i].spurChan);
1265 pModal->spurChans[i].spurChan = word;
1266 }
1267 @@ -376,8 +376,7 @@ static void ath9k_hw_def_set_board_value
1268 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
1269 txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
1270
1271 - REG_WRITE(ah, AR_PHY_SWITCH_COM,
1272 - ah->eep_ops->get_eeprom_antenna_cfg(ah, chan));
1273 + REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
1274
1275 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
1276 if (AR_SREV_9280(ah)) {
1277 @@ -590,168 +589,6 @@ static void ath9k_hw_def_set_addac(struc
1278 #undef XPA_LVL_FREQ
1279 }
1280
1281 -static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
1282 - struct ath9k_channel *chan,
1283 - struct cal_data_per_freq *pRawDataSet,
1284 - u8 *bChans, u16 availPiers,
1285 - u16 tPdGainOverlap,
1286 - u16 *pPdGainBoundaries, u8 *pPDADCValues,
1287 - u16 numXpdGains)
1288 -{
1289 - int i, j, k;
1290 - int16_t ss;
1291 - u16 idxL = 0, idxR = 0, numPiers;
1292 - static u8 vpdTableL[AR5416_NUM_PD_GAINS]
1293 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
1294 - static u8 vpdTableR[AR5416_NUM_PD_GAINS]
1295 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
1296 - static u8 vpdTableI[AR5416_NUM_PD_GAINS]
1297 - [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
1298 -
1299 - u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
1300 - u8 minPwrT4[AR5416_NUM_PD_GAINS];
1301 - u8 maxPwrT4[AR5416_NUM_PD_GAINS];
1302 - int16_t vpdStep;
1303 - int16_t tmpVal;
1304 - u16 sizeCurrVpdTable, maxIndex, tgtIndex;
1305 - bool match;
1306 - int16_t minDelta = 0;
1307 - struct chan_centers centers;
1308 -
1309 - memset(&minPwrT4, 0, AR9287_NUM_PD_GAINS);
1310 - ath9k_hw_get_channel_centers(ah, chan, &centers);
1311 -
1312 - for (numPiers = 0; numPiers < availPiers; numPiers++) {
1313 - if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
1314 - break;
1315 - }
1316 -
1317 - match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center,
1318 - IS_CHAN_2GHZ(chan)),
1319 - bChans, numPiers, &idxL, &idxR);
1320 -
1321 - if (match) {
1322 - for (i = 0; i < numXpdGains; i++) {
1323 - minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
1324 - maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
1325 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1326 - pRawDataSet[idxL].pwrPdg[i],
1327 - pRawDataSet[idxL].vpdPdg[i],
1328 - AR5416_PD_GAIN_ICEPTS,
1329 - vpdTableI[i]);
1330 - }
1331 - } else {
1332 - for (i = 0; i < numXpdGains; i++) {
1333 - pVpdL = pRawDataSet[idxL].vpdPdg[i];
1334 - pPwrL = pRawDataSet[idxL].pwrPdg[i];
1335 - pVpdR = pRawDataSet[idxR].vpdPdg[i];
1336 - pPwrR = pRawDataSet[idxR].pwrPdg[i];
1337 -
1338 - minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
1339 -
1340 - maxPwrT4[i] =
1341 - min(pPwrL[AR5416_PD_GAIN_ICEPTS - 1],
1342 - pPwrR[AR5416_PD_GAIN_ICEPTS - 1]);
1343 -
1344 -
1345 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1346 - pPwrL, pVpdL,
1347 - AR5416_PD_GAIN_ICEPTS,
1348 - vpdTableL[i]);
1349 - ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
1350 - pPwrR, pVpdR,
1351 - AR5416_PD_GAIN_ICEPTS,
1352 - vpdTableR[i]);
1353 -
1354 - for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
1355 - vpdTableI[i][j] =
1356 - (u8)(ath9k_hw_interpolate((u16)
1357 - FREQ2FBIN(centers.
1358 - synth_center,
1359 - IS_CHAN_2GHZ
1360 - (chan)),
1361 - bChans[idxL], bChans[idxR],
1362 - vpdTableL[i][j], vpdTableR[i][j]));
1363 - }
1364 - }
1365 - }
1366 -
1367 - k = 0;
1368 -
1369 - for (i = 0; i < numXpdGains; i++) {
1370 - if (i == (numXpdGains - 1))
1371 - pPdGainBoundaries[i] =
1372 - (u16)(maxPwrT4[i] / 2);
1373 - else
1374 - pPdGainBoundaries[i] =
1375 - (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
1376 -
1377 - pPdGainBoundaries[i] =
1378 - min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
1379 -
1380 - if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
1381 - minDelta = pPdGainBoundaries[0] - 23;
1382 - pPdGainBoundaries[0] = 23;
1383 - } else {
1384 - minDelta = 0;
1385 - }
1386 -
1387 - if (i == 0) {
1388 - if (AR_SREV_9280_20_OR_LATER(ah))
1389 - ss = (int16_t)(0 - (minPwrT4[i] / 2));
1390 - else
1391 - ss = 0;
1392 - } else {
1393 - ss = (int16_t)((pPdGainBoundaries[i - 1] -
1394 - (minPwrT4[i] / 2)) -
1395 - tPdGainOverlap + 1 + minDelta);
1396 - }
1397 - vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
1398 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
1399 -
1400 - while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
1401 - tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
1402 - pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
1403 - ss++;
1404 - }
1405 -
1406 - sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
1407 - tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
1408 - (minPwrT4[i] / 2));
1409 - maxIndex = (tgtIndex < sizeCurrVpdTable) ?
1410 - tgtIndex : sizeCurrVpdTable;
1411 -
1412 - while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
1413 - pPDADCValues[k++] = vpdTableI[i][ss++];
1414 - }
1415 -
1416 - vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
1417 - vpdTableI[i][sizeCurrVpdTable - 2]);
1418 - vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
1419 -
1420 - if (tgtIndex >= maxIndex) {
1421 - while ((ss <= tgtIndex) &&
1422 - (k < (AR5416_NUM_PDADC_VALUES - 1))) {
1423 - tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
1424 - (ss - maxIndex + 1) * vpdStep));
1425 - pPDADCValues[k++] = (u8)((tmpVal > 255) ?
1426 - 255 : tmpVal);
1427 - ss++;
1428 - }
1429 - }
1430 - }
1431 -
1432 - while (i < AR5416_PD_GAINS_IN_MASK) {
1433 - pPdGainBoundaries[i] = pPdGainBoundaries[i - 1];
1434 - i++;
1435 - }
1436 -
1437 - while (k < AR5416_NUM_PDADC_VALUES) {
1438 - pPDADCValues[k] = pPDADCValues[k - 1];
1439 - k++;
1440 - }
1441 -}
1442 -
1443 static int16_t ath9k_change_gain_boundary_setting(struct ath_hw *ah,
1444 u16 *gb,
1445 u16 numXpdGain,
1446 @@ -784,7 +621,7 @@ static int16_t ath9k_change_gain_boundar
1447 /* Because of a hardware limitation, ensure the gain boundary
1448 * is not larger than (63 - overlap)
1449 */
1450 - gb_limit = (u16)(AR5416_MAX_RATE_POWER - pdGainOverlap_t2);
1451 + gb_limit = (u16)(MAX_RATE_POWER - pdGainOverlap_t2);
1452
1453 for (k = 0; k < numXpdGain; k++)
1454 gb[k] = (u16)min(gb_limit, gb[k]);
1455 @@ -918,7 +755,7 @@ static void ath9k_hw_set_def_power_cal_t
1456 ath9k_olc_get_pdadcs(ah, pcdacIdx,
1457 txPower/2, pdadcValues);
1458 } else {
1459 - ath9k_hw_get_def_gain_boundaries_pdadcs(ah,
1460 + ath9k_hw_get_gain_boundaries_pdadcs(ah,
1461 chan, pRawDataset,
1462 pCalBChans, numPiers,
1463 pdGainOverlap_t2,
1464 @@ -1004,9 +841,9 @@ static void ath9k_hw_set_def_power_per_r
1465
1466 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1467 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
1468 - u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1469 + u16 twiceMaxEdgePower = MAX_RATE_POWER;
1470 static const u16 tpScaleReductionTable[5] =
1471 - { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
1472 + { 0, 3, 6, 9, MAX_RATE_POWER };
1473
1474 int i;
1475 int16_t twiceLargestAntenna;
1476 @@ -1147,7 +984,7 @@ static void ath9k_hw_set_def_power_per_r
1477
1478 if (ah->eep_ops->get_eeprom_ver(ah) == 14 &&
1479 ah->eep_ops->get_eeprom_rev(ah) <= 2)
1480 - twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1481 + twiceMaxEdgePower = MAX_RATE_POWER;
1482
1483 for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) {
1484 if ((((cfgCtl & ~CTL_MODE_M) |
1485 @@ -1292,8 +1129,8 @@ static void ath9k_hw_def_set_txpower(str
1486 regulatory->max_power_level = 0;
1487 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
1488 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
1489 - if (ratesArray[i] > AR5416_MAX_RATE_POWER)
1490 - ratesArray[i] = AR5416_MAX_RATE_POWER;
1491 + if (ratesArray[i] > MAX_RATE_POWER)
1492 + ratesArray[i] = MAX_RATE_POWER;
1493 if (ratesArray[i] > regulatory->max_power_level)
1494 regulatory->max_power_level = ratesArray[i];
1495 }
1496 @@ -1425,34 +1262,6 @@ static void ath9k_hw_def_set_txpower(str
1497 | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
1498 }
1499
1500 -static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
1501 - enum ath9k_hal_freq_band freq_band)
1502 -{
1503 - struct ar5416_eeprom_def *eep = &ah->eeprom.def;
1504 - struct modal_eep_header *pModal =
1505 - &(eep->modalHeader[freq_band]);
1506 - struct base_eep_header *pBase = &eep->baseEepHeader;
1507 - u8 num_ant_config;
1508 -
1509 - num_ant_config = 1;
1510 -
1511 - if (pBase->version >= 0x0E0D &&
1512 - (pModal->lna_ctl & LNA_CTL_USE_ANT1))
1513 - num_ant_config += 1;
1514 -
1515 - return num_ant_config;
1516 -}
1517 -
1518 -static u32 ath9k_hw_def_get_eeprom_antenna_cfg(struct ath_hw *ah,
1519 - struct ath9k_channel *chan)
1520 -{
1521 - struct ar5416_eeprom_def *eep = &ah->eeprom.def;
1522 - struct modal_eep_header *pModal =
1523 - &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
1524 -
1525 - return pModal->antCtrlCommon;
1526 -}
1527 -
1528 static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
1529 {
1530 #define EEP_DEF_SPURCHAN \
1531 @@ -1489,8 +1298,6 @@ const struct eeprom_ops eep_def_ops = {
1532 .fill_eeprom = ath9k_hw_def_fill_eeprom,
1533 .get_eeprom_ver = ath9k_hw_def_get_eeprom_ver,
1534 .get_eeprom_rev = ath9k_hw_def_get_eeprom_rev,
1535 - .get_num_ant_config = ath9k_hw_def_get_num_ant_config,
1536 - .get_eeprom_antenna_cfg = ath9k_hw_def_get_eeprom_antenna_cfg,
1537 .set_board_values = ath9k_hw_def_set_board_values,
1538 .set_addac = ath9k_hw_def_set_addac,
1539 .set_txpower = ath9k_hw_def_set_txpower,
1540 --- a/drivers/net/wireless/ath/ath9k/hw.c
1541 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1542 @@ -54,13 +54,6 @@ static void ath9k_hw_init_mode_regs(stru
1543 ath9k_hw_private_ops(ah)->init_mode_regs(ah);
1544 }
1545
1546 -static bool ath9k_hw_macversion_supported(struct ath_hw *ah)
1547 -{
1548 - struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1549 -
1550 - return priv_ops->macversion_supported(ah->hw_version.macVersion);
1551 -}
1552 -
1553 static u32 ath9k_hw_compute_pll_control(struct ath_hw *ah,
1554 struct ath9k_channel *chan)
1555 {
1556 @@ -284,11 +277,9 @@ static void ath9k_hw_read_revisions(stru
1557
1558 static void ath9k_hw_disablepcie(struct ath_hw *ah)
1559 {
1560 - if (AR_SREV_9100(ah))
1561 + if (!AR_SREV_5416(ah))
1562 return;
1563
1564 - ENABLE_REGWRITE_BUFFER(ah);
1565 -
1566 REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
1567 REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
1568 REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
1569 @@ -300,8 +291,6 @@ static void ath9k_hw_disablepcie(struct
1570 REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
1571
1572 REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
1573 -
1574 - REGWRITE_BUFFER_FLUSH(ah);
1575 }
1576
1577 /* This should work for all families including legacy */
1578 @@ -422,7 +411,6 @@ static void ath9k_hw_init_defaults(struc
1579 ah->sta_id1_defaults =
1580 AR_STA_ID1_CRPT_MIC_ENABLE |
1581 AR_STA_ID1_MCAST_KSRCH;
1582 - ah->beacon_interval = 100;
1583 ah->enable_32kHz_clock = DONT_USE_32KHZ;
1584 ah->slottime = (u32) -1;
1585 ah->globaltxtimeout = (u32) -1;
1586 @@ -544,7 +532,18 @@ static int __ath9k_hw_init(struct ath_hw
1587 else
1588 ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD;
1589
1590 - if (!ath9k_hw_macversion_supported(ah)) {
1591 + switch (ah->hw_version.macVersion) {
1592 + case AR_SREV_VERSION_5416_PCI:
1593 + case AR_SREV_VERSION_5416_PCIE:
1594 + case AR_SREV_VERSION_9160:
1595 + case AR_SREV_VERSION_9100:
1596 + case AR_SREV_VERSION_9280:
1597 + case AR_SREV_VERSION_9285:
1598 + case AR_SREV_VERSION_9287:
1599 + case AR_SREV_VERSION_9271:
1600 + case AR_SREV_VERSION_9300:
1601 + break;
1602 + default:
1603 ath_print(common, ATH_DBG_FATAL,
1604 "Mac Chip Rev 0x%02x.%x is not supported by "
1605 "this driver\n", ah->hw_version.macVersion,
1606 @@ -1643,8 +1642,6 @@ void ath9k_hw_beaconinit(struct ath_hw *
1607 {
1608 int flags = 0;
1609
1610 - ah->beacon_interval = beacon_period;
1611 -
1612 ENABLE_REGWRITE_BUFFER(ah);
1613
1614 switch (ah->opmode) {
1615 @@ -1936,11 +1933,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw
1616 AR_SREV_5416(ah))
1617 pCap->reg_cap |= AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND;
1618
1619 - pCap->num_antcfg_5ghz =
1620 - ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_5GHZ);
1621 - pCap->num_antcfg_2ghz =
1622 - ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_2GHZ);
1623 -
1624 if (AR_SREV_9280_20_OR_LATER(ah) && common->btcoex_enabled) {
1625 btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO;
1626 btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO;
1627 --- a/drivers/net/wireless/ath/ath9k/hw.h
1628 +++ b/drivers/net/wireless/ath/ath9k/hw.h
1629 @@ -202,8 +202,6 @@ struct ath9k_hw_capabilities {
1630 u16 tx_triglevel_max;
1631 u16 reg_cap;
1632 u8 num_gpio_pins;
1633 - u8 num_antcfg_2ghz;
1634 - u8 num_antcfg_5ghz;
1635 u8 rx_hp_qdepth;
1636 u8 rx_lp_qdepth;
1637 u8 rx_status_len;
1638 @@ -234,7 +232,6 @@ struct ath9k_ops_config {
1639 #define SPUR_DISABLE 0
1640 #define SPUR_ENABLE_IOCTL 1
1641 #define SPUR_ENABLE_EEPROM 2
1642 -#define AR_EEPROM_MODAL_SPURS 5
1643 #define AR_SPUR_5413_1 1640
1644 #define AR_SPUR_5413_2 1200
1645 #define AR_NO_SPUR 0x8000
1646 @@ -530,7 +527,6 @@ struct ath_hw_radar_conf {
1647 *
1648 * @init_mode_regs: Initializes mode registers
1649 * @init_mode_gain_regs: Initialize TX/RX gain registers
1650 - * @macversion_supported: If this specific mac revision is supported
1651 *
1652 * @rf_set_freq: change frequency
1653 * @spur_mitigate_freq: spur mitigation
1654 @@ -552,7 +548,6 @@ struct ath_hw_private_ops {
1655
1656 void (*init_mode_regs)(struct ath_hw *ah);
1657 void (*init_mode_gain_regs)(struct ath_hw *ah);
1658 - bool (*macversion_supported)(u32 macversion);
1659 void (*setup_calibration)(struct ath_hw *ah,
1660 struct ath9k_cal_list *currCal);
1661
1662 @@ -762,9 +757,7 @@ struct ath_hw {
1663 u32 *bank6Temp;
1664
1665 u8 txpower_limit;
1666 - int16_t txpower_indexoffset;
1667 int coverage_class;
1668 - u32 beacon_interval;
1669 u32 slottime;
1670 u32 globaltxtimeout;
1671
1672 --- a/net/mac80211/led.c
1673 +++ b/net/mac80211/led.c
1674 @@ -54,12 +54,22 @@ void ieee80211_led_radio(struct ieee8021
1675 led_trigger_event(local->radio_led, LED_OFF);
1676 }
1677
1678 +void ieee80211_led_names(struct ieee80211_local *local)
1679 +{
1680 + snprintf(local->rx_led_name, sizeof(local->rx_led_name),
1681 + "%srx", wiphy_name(local->hw.wiphy));
1682 + snprintf(local->tx_led_name, sizeof(local->tx_led_name),
1683 + "%stx", wiphy_name(local->hw.wiphy));
1684 + snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
1685 + "%sassoc", wiphy_name(local->hw.wiphy));
1686 + snprintf(local->radio_led_name, sizeof(local->radio_led_name),
1687 + "%sradio", wiphy_name(local->hw.wiphy));
1688 +}
1689 +
1690 void ieee80211_led_init(struct ieee80211_local *local)
1691 {
1692 local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
1693 if (local->rx_led) {
1694 - snprintf(local->rx_led_name, sizeof(local->rx_led_name),
1695 - "%srx", wiphy_name(local->hw.wiphy));
1696 local->rx_led->name = local->rx_led_name;
1697 if (led_trigger_register(local->rx_led)) {
1698 kfree(local->rx_led);
1699 @@ -69,8 +79,6 @@ void ieee80211_led_init(struct ieee80211
1700
1701 local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
1702 if (local->tx_led) {
1703 - snprintf(local->tx_led_name, sizeof(local->tx_led_name),
1704 - "%stx", wiphy_name(local->hw.wiphy));
1705 local->tx_led->name = local->tx_led_name;
1706 if (led_trigger_register(local->tx_led)) {
1707 kfree(local->tx_led);
1708 @@ -80,8 +88,6 @@ void ieee80211_led_init(struct ieee80211
1709
1710 local->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
1711 if (local->assoc_led) {
1712 - snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
1713 - "%sassoc", wiphy_name(local->hw.wiphy));
1714 local->assoc_led->name = local->assoc_led_name;
1715 if (led_trigger_register(local->assoc_led)) {
1716 kfree(local->assoc_led);
1717 @@ -91,14 +97,19 @@ void ieee80211_led_init(struct ieee80211
1718
1719 local->radio_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
1720 if (local->radio_led) {
1721 - snprintf(local->radio_led_name, sizeof(local->radio_led_name),
1722 - "%sradio", wiphy_name(local->hw.wiphy));
1723 local->radio_led->name = local->radio_led_name;
1724 if (led_trigger_register(local->radio_led)) {
1725 kfree(local->radio_led);
1726 local->radio_led = NULL;
1727 }
1728 }
1729 +
1730 + if (local->tpt_led_trigger) {
1731 + if (led_trigger_register(&local->tpt_led_trigger->trig)) {
1732 + kfree(local->tpt_led_trigger);
1733 + local->tpt_led_trigger = NULL;
1734 + }
1735 + }
1736 }
1737
1738 void ieee80211_led_exit(struct ieee80211_local *local)
1739 @@ -119,15 +130,18 @@ void ieee80211_led_exit(struct ieee80211
1740 led_trigger_unregister(local->rx_led);
1741 kfree(local->rx_led);
1742 }
1743 +
1744 + if (local->tpt_led_trigger) {
1745 + led_trigger_unregister(&local->tpt_led_trigger->trig);
1746 + kfree(local->tpt_led_trigger);
1747 + }
1748 }
1749
1750 char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
1751 {
1752 struct ieee80211_local *local = hw_to_local(hw);
1753
1754 - if (local->radio_led)
1755 - return local->radio_led_name;
1756 - return NULL;
1757 + return local->radio_led_name;
1758 }
1759 EXPORT_SYMBOL(__ieee80211_get_radio_led_name);
1760
1761 @@ -135,9 +149,7 @@ char *__ieee80211_get_assoc_led_name(str
1762 {
1763 struct ieee80211_local *local = hw_to_local(hw);
1764
1765 - if (local->assoc_led)
1766 - return local->assoc_led_name;
1767 - return NULL;
1768 + return local->assoc_led_name;
1769 }
1770 EXPORT_SYMBOL(__ieee80211_get_assoc_led_name);
1771
1772 @@ -145,9 +157,7 @@ char *__ieee80211_get_tx_led_name(struct
1773 {
1774 struct ieee80211_local *local = hw_to_local(hw);
1775
1776 - if (local->tx_led)
1777 - return local->tx_led_name;
1778 - return NULL;
1779 + return local->tx_led_name;
1780 }
1781 EXPORT_SYMBOL(__ieee80211_get_tx_led_name);
1782
1783 @@ -155,8 +165,115 @@ char *__ieee80211_get_rx_led_name(struct
1784 {
1785 struct ieee80211_local *local = hw_to_local(hw);
1786
1787 - if (local->rx_led)
1788 - return local->rx_led_name;
1789 - return NULL;
1790 + return local->rx_led_name;
1791 }
1792 EXPORT_SYMBOL(__ieee80211_get_rx_led_name);
1793 +
1794 +static unsigned long tpt_trig_traffic(struct ieee80211_local *local,
1795 + struct tpt_led_trigger *tpt_trig)
1796 +{
1797 + unsigned long traffic, delta;
1798 +
1799 + traffic = tpt_trig->tx_bytes + tpt_trig->rx_bytes;
1800 +
1801 + delta = traffic - tpt_trig->prev_traffic;
1802 + tpt_trig->prev_traffic = traffic;
1803 + return DIV_ROUND_UP(delta, 1024 / 8);
1804 +}
1805 +
1806 +static void tpt_trig_timer(unsigned long data)
1807 +{
1808 + struct ieee80211_local *local = (void *)data;
1809 + struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
1810 + struct led_classdev *led_cdev;
1811 + unsigned long on, off, tpt;
1812 + int i;
1813 +
1814 + if (!tpt_trig->running)
1815 + return;
1816 +
1817 + mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
1818 +
1819 + tpt = tpt_trig_traffic(local, tpt_trig);
1820 +
1821 + /* default to just solid on */
1822 + on = 1;
1823 + off = 0;
1824 +
1825 + for (i = tpt_trig->blink_table_len - 1; i >= 0; i--) {
1826 + if (tpt_trig->blink_table[i].throughput < 0 ||
1827 + tpt > tpt_trig->blink_table[i].throughput) {
1828 + off = tpt_trig->blink_table[i].blink_time / 2;
1829 + on = tpt_trig->blink_table[i].blink_time - off;
1830 + break;
1831 + }
1832 + }
1833 +
1834 + read_lock(&tpt_trig->trig.leddev_list_lock);
1835 + list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
1836 + led_blink_set(led_cdev, &on, &off);
1837 + read_unlock(&tpt_trig->trig.leddev_list_lock);
1838 +}
1839 +
1840 +extern char *__ieee80211_create_tpt_led_trigger(
1841 + struct ieee80211_hw *hw,
1842 + const struct ieee80211_tpt_blink *blink_table,
1843 + unsigned int blink_table_len)
1844 +{
1845 + struct ieee80211_local *local = hw_to_local(hw);
1846 + struct tpt_led_trigger *tpt_trig;
1847 +
1848 + if (WARN_ON(local->tpt_led_trigger))
1849 + return NULL;
1850 +
1851 + tpt_trig = kzalloc(sizeof(struct tpt_led_trigger), GFP_KERNEL);
1852 + if (!tpt_trig)
1853 + return NULL;
1854 +
1855 + snprintf(tpt_trig->name, sizeof(tpt_trig->name),
1856 + "%stpt", wiphy_name(local->hw.wiphy));
1857 +
1858 + tpt_trig->trig.name = tpt_trig->name;
1859 +
1860 + tpt_trig->blink_table = blink_table;
1861 + tpt_trig->blink_table_len = blink_table_len;
1862 +
1863 + setup_timer(&tpt_trig->timer, tpt_trig_timer, (unsigned long)local);
1864 +
1865 + local->tpt_led_trigger = tpt_trig;
1866 +
1867 + return tpt_trig->name;
1868 +}
1869 +EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger);
1870 +
1871 +void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
1872 +{
1873 + struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
1874 +
1875 + if (!tpt_trig)
1876 + return;
1877 +
1878 + /* reset traffic */
1879 + tpt_trig_traffic(local, tpt_trig);
1880 + tpt_trig->running = true;
1881 +
1882 + tpt_trig_timer((unsigned long)local);
1883 + mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ));
1884 +}
1885 +
1886 +void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
1887 +{
1888 + struct tpt_led_trigger *tpt_trig = local->tpt_led_trigger;
1889 + struct led_classdev *led_cdev;
1890 +
1891 + if (!tpt_trig)
1892 + return;
1893 +
1894 + tpt_trig->running = false;
1895 + del_timer_sync(&tpt_trig->timer);
1896 +
1897 + read_lock(&tpt_trig->trig.leddev_list_lock);
1898 + list_for_each_entry(led_cdev, &tpt_trig->trig.led_cdevs, trig_list)
1899 + led_brightness_set(led_cdev, LED_OFF);
1900 + read_unlock(&tpt_trig->trig.leddev_list_lock);
1901 +}
1902 --- a/net/mac80211/led.h
1903 +++ b/net/mac80211/led.h
1904 @@ -12,14 +12,17 @@
1905 #include "ieee80211_i.h"
1906
1907 #ifdef CONFIG_MAC80211_LEDS
1908 -extern void ieee80211_led_rx(struct ieee80211_local *local);
1909 -extern void ieee80211_led_tx(struct ieee80211_local *local, int q);
1910 -extern void ieee80211_led_assoc(struct ieee80211_local *local,
1911 - bool associated);
1912 -extern void ieee80211_led_radio(struct ieee80211_local *local,
1913 - bool enabled);
1914 -extern void ieee80211_led_init(struct ieee80211_local *local);
1915 -extern void ieee80211_led_exit(struct ieee80211_local *local);
1916 +void ieee80211_led_rx(struct ieee80211_local *local);
1917 +void ieee80211_led_tx(struct ieee80211_local *local, int q);
1918 +void ieee80211_led_assoc(struct ieee80211_local *local,
1919 + bool associated);
1920 +void ieee80211_led_radio(struct ieee80211_local *local,
1921 + bool enabled);
1922 +void ieee80211_led_names(struct ieee80211_local *local);
1923 +void ieee80211_led_init(struct ieee80211_local *local);
1924 +void ieee80211_led_exit(struct ieee80211_local *local);
1925 +void ieee80211_start_tpt_led_trig(struct ieee80211_local *local);
1926 +void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local);
1927 #else
1928 static inline void ieee80211_led_rx(struct ieee80211_local *local)
1929 {
1930 @@ -35,10 +38,37 @@ static inline void ieee80211_led_radio(s
1931 bool enabled)
1932 {
1933 }
1934 +static inline void ieee80211_led_names(struct ieee80211_local *local)
1935 +{
1936 +}
1937 static inline void ieee80211_led_init(struct ieee80211_local *local)
1938 {
1939 }
1940 static inline void ieee80211_led_exit(struct ieee80211_local *local)
1941 {
1942 }
1943 +static inline void ieee80211_start_tpt_led_trig(struct ieee80211_local *local)
1944 +{
1945 +}
1946 +static inline void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local)
1947 +{
1948 +}
1949 +#endif
1950 +
1951 +static inline void
1952 +ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
1953 +{
1954 +#ifdef CONFIG_MAC80211_LEDS
1955 + if (local->tpt_led_trigger && ieee80211_is_data(fc))
1956 + local->tpt_led_trigger->tx_bytes += bytes;
1957 +#endif
1958 +}
1959 +
1960 +static inline void
1961 +ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
1962 +{
1963 +#ifdef CONFIG_MAC80211_LEDS
1964 + if (local->tpt_led_trigger && ieee80211_is_data(fc))
1965 + local->tpt_led_trigger->rx_bytes += bytes;
1966 #endif
1967 +}
1968 --- a/net/mac80211/main.c
1969 +++ b/net/mac80211/main.c
1970 @@ -599,6 +599,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(
1971 /* init dummy netdev for use w/ NAPI */
1972 init_dummy_netdev(&local->napi_dev);
1973
1974 + ieee80211_led_names(local);
1975 +
1976 return local_to_hw(local);
1977 }
1978 EXPORT_SYMBOL(ieee80211_alloc_hw);
1979 --- a/include/net/mac80211.h
1980 +++ b/include/net/mac80211.h
1981 @@ -1856,11 +1856,26 @@ struct ieee80211_hw *ieee80211_alloc_hw(
1982 */
1983 int ieee80211_register_hw(struct ieee80211_hw *hw);
1984
1985 +/**
1986 + * struct ieee80211_tpt_blink - throughput blink description
1987 + * @throughput: throughput in Kbit/sec
1988 + * @blink_time: blink time in milliseconds
1989 + * (full cycle, ie. one off + one on period)
1990 + */
1991 +struct ieee80211_tpt_blink {
1992 + int throughput;
1993 + int blink_time;
1994 +};
1995 +
1996 #ifdef CONFIG_MAC80211_LEDS
1997 extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
1998 extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
1999 extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
2000 extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
2001 +extern char *__ieee80211_create_tpt_led_trigger(
2002 + struct ieee80211_hw *hw,
2003 + const struct ieee80211_tpt_blink *blink_table,
2004 + unsigned int blink_table_len);
2005 #endif
2006 /**
2007 * ieee80211_get_tx_led_name - get name of TX LED
2008 @@ -1939,6 +1954,29 @@ static inline char *ieee80211_get_radio_
2009 }
2010
2011 /**
2012 + * ieee80211_create_tpt_led_trigger - create throughput LED trigger
2013 + * @hw: the hardware to create the trigger for
2014 + * @blink_table: the blink table -- needs to be ordered by throughput
2015 + * @blink_table_len: size of the blink table
2016 + *
2017 + * This function returns %NULL (in case of error, or if no LED
2018 + * triggers are configured) or the name of the new trigger.
2019 + * This function must be called before ieee80211_register_hw().
2020 + */
2021 +static inline char *
2022 +ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
2023 + const struct ieee80211_tpt_blink *blink_table,
2024 + unsigned int blink_table_len)
2025 +{
2026 +#ifdef CONFIG_MAC80211_LEDS
2027 + return __ieee80211_create_tpt_led_trigger(hw, blink_table,
2028 + blink_table_len);
2029 +#else
2030 + return NULL;
2031 +#endif
2032 +}
2033 +
2034 +/**
2035 * ieee80211_unregister_hw - Unregister a hardware device
2036 *
2037 * This function instructs mac80211 to free allocated resources
2038 --- a/net/mac80211/ieee80211_i.h
2039 +++ b/net/mac80211/ieee80211_i.h
2040 @@ -23,6 +23,7 @@
2041 #include <linux/types.h>
2042 #include <linux/spinlock.h>
2043 #include <linux/etherdevice.h>
2044 +#include <linux/leds.h>
2045 #include <net/ieee80211_radiotap.h>
2046 #include <net/cfg80211.h>
2047 #include <net/mac80211.h>
2048 @@ -641,6 +642,17 @@ enum queue_stop_reason {
2049 IEEE80211_QUEUE_STOP_REASON_SKB_ADD,
2050 };
2051
2052 +struct tpt_led_trigger {
2053 + struct led_trigger trig;
2054 + char name[32];
2055 + const struct ieee80211_tpt_blink *blink_table;
2056 + unsigned int blink_table_len;
2057 + struct timer_list timer;
2058 + bool running;
2059 + unsigned long prev_traffic;
2060 + unsigned long tx_bytes, rx_bytes;
2061 +};
2062 +
2063 /**
2064 * mac80211 scan flags - currently active scan mode
2065 *
2066 @@ -854,6 +866,7 @@ struct ieee80211_local {
2067 #ifdef CONFIG_MAC80211_LEDS
2068 int tx_led_counter, rx_led_counter;
2069 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led;
2070 + struct tpt_led_trigger *tpt_led_trigger;
2071 char tx_led_name[32], rx_led_name[32],
2072 assoc_led_name[32], radio_led_name[32];
2073 #endif
2074 --- a/net/mac80211/iface.c
2075 +++ b/net/mac80211/iface.c
2076 @@ -225,6 +225,7 @@ static int ieee80211_do_open(struct net_
2077 /* we're brought up, everything changes */
2078 hw_reconf_flags = ~0;
2079 ieee80211_led_radio(local, true);
2080 + ieee80211_start_tpt_led_trig(local);
2081 }
2082
2083 /*
2084 --- a/net/mac80211/rx.c
2085 +++ b/net/mac80211/rx.c
2086 @@ -2887,6 +2887,9 @@ void ieee80211_rx(struct ieee80211_hw *h
2087 return;
2088 }
2089
2090 + ieee80211_tpt_led_trig_rx(local,
2091 + ((struct ieee80211_hdr *)skb->data)->frame_control,
2092 + skb->len);
2093 __ieee80211_rx_handle_packet(hw, skb);
2094
2095 rcu_read_unlock();
2096 --- a/net/mac80211/tx.c
2097 +++ b/net/mac80211/tx.c
2098 @@ -1292,6 +1292,7 @@ static int __ieee80211_tx(struct ieee802
2099
2100 while (skb) {
2101 int q = skb_get_queue_mapping(skb);
2102 + __le16 fc;
2103
2104 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
2105 ret = IEEE80211_TX_OK;
2106 @@ -1334,6 +1335,7 @@ static int __ieee80211_tx(struct ieee802
2107 else
2108 info->control.sta = NULL;
2109
2110 + fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
2111 ret = drv_tx(local, skb);
2112 if (WARN_ON(ret != NETDEV_TX_OK && skb->len != len)) {
2113 dev_kfree_skb(skb);
2114 @@ -1344,6 +1346,7 @@ static int __ieee80211_tx(struct ieee802
2115 return IEEE80211_TX_AGAIN;
2116 }
2117
2118 + ieee80211_tpt_led_trig_tx(local, fc, len);
2119 *skbp = skb = next;
2120 ieee80211_led_tx(local, 1);
2121 fragm = true;
2122 --- a/net/mac80211/util.c
2123 +++ b/net/mac80211/util.c
2124 @@ -1141,6 +1141,7 @@ u32 ieee80211_sta_get_rates(struct ieee8
2125 void ieee80211_stop_device(struct ieee80211_local *local)
2126 {
2127 ieee80211_led_radio(local, false);
2128 + ieee80211_stop_tpt_led_trig(local);
2129
2130 cancel_work_sync(&local->reconfig_filter);
2131
2132 @@ -1175,6 +1176,7 @@ int ieee80211_reconfig(struct ieee80211_
2133 }
2134
2135 ieee80211_led_radio(local, true);
2136 + ieee80211_start_tpt_led_trig(local);
2137 }
2138
2139 /* add interfaces */
2140 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2141 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
2142 @@ -1745,7 +1745,10 @@ int ath_tx_start(struct ieee80211_hw *hw
2143 int frmlen = skb->len + FCS_LEN;
2144 int q;
2145
2146 - txctl->an = (struct ath_node *)sta->drv_priv;
2147 + /* NOTE: sta can be NULL according to net/mac80211.h */
2148 + if (sta)
2149 + txctl->an = (struct ath_node *)sta->drv_priv;
2150 +
2151 if (info->control.hw_key)
2152 frmlen += info->control.hw_key->icv_len;
2153