1 --- a/drivers/net/wireless/ath/ath.h
2 +++ b/drivers/net/wireless/ath/ath.h
3 @@ -71,7 +71,6 @@ struct ath_regulatory {
11 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
12 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
13 @@ -3040,6 +3040,10 @@ static u32 ath9k_hw_ar9300_get_eeprom(st
14 return (pBase->miscConfiguration >> 0x3) & 0x1;
15 case EEP_ANT_DIV_CTL1:
16 return eep->base_ext1.ant_div_control;
17 + case EEP_ANTENNA_GAIN_5G:
18 + return eep->modalHeader5G.antennaGain;
19 + case EEP_ANTENNA_GAIN_2G:
20 + return eep->modalHeader2G.antennaGain;
24 @@ -4727,20 +4731,14 @@ static u16 ar9003_hw_get_max_edge_power(
25 static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
26 struct ath9k_channel *chan,
27 u8 *pPwrArray, u16 cfgCtl,
28 - u8 twiceAntennaReduction,
29 - u8 twiceMaxRegulatoryPower,
30 + u8 antenna_reduction,
33 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
34 struct ath_common *common = ath9k_hw_common(ah);
35 struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep;
36 u16 twiceMaxEdgePower = MAX_RATE_POWER;
37 - static const u16 tpScaleReductionTable[5] = {
38 - 0, 3, 6, 9, MAX_RATE_POWER
41 - int16_t twiceLargestAntenna;
42 - u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
43 + u16 scaledPower = 0, minCtlPower;
44 static const u16 ctlModesFor11a[] = {
45 CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
47 @@ -4758,28 +4756,7 @@ static void ar9003_hw_set_power_per_rate
48 bool is2ghz = IS_CHAN_2GHZ(chan);
50 ath9k_hw_get_channel_centers(ah, chan, ¢ers);
52 - /* Compute TxPower reduction due to Antenna Gain */
54 - twiceLargestAntenna = pEepData->modalHeader2G.antennaGain;
56 - twiceLargestAntenna = pEepData->modalHeader5G.antennaGain;
58 - twiceLargestAntenna = (int16_t)min((twiceAntennaReduction) -
59 - twiceLargestAntenna, 0);
62 - * scaledPower is the minimum of the user input power level
63 - * and the regulatory allowed power level
65 - maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
67 - if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
68 - maxRegAllowedPower -=
69 - (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
72 - scaledPower = min(powerLimit, maxRegAllowedPower);
73 + scaledPower = powerLimit - antenna_reduction;
76 * Reduce scaled Power by number of chains active to get
77 @@ -4966,7 +4943,6 @@ static inline u8 mcsidx_to_tgtpwridx(uns
78 static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
79 struct ath9k_channel *chan, u16 cfgCtl,
80 u8 twiceAntennaReduction,
81 - u8 twiceMaxRegulatoryPower,
82 u8 powerLimit, bool test)
84 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
85 @@ -5019,7 +4995,6 @@ static void ath9k_hw_ar9300_set_txpower(
86 ar9003_hw_set_power_per_rate_table(ah, chan,
87 targetPowerValT2, cfgCtl,
88 twiceAntennaReduction,
89 - twiceMaxRegulatoryPower,
92 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) {
93 --- a/drivers/net/wireless/ath/ath9k/hw.c
94 +++ b/drivers/net/wireless/ath/ath9k/hw.c
95 @@ -429,7 +429,6 @@ static void ath9k_hw_init_defaults(struc
97 regulatory->country_code = CTRY_DEFAULT;
98 regulatory->power_limit = MAX_RATE_POWER;
99 - regulatory->tp_scale = ATH9K_TP_SCALE_MAX;
101 ah->hw_version.magic = AR5416_MAGIC;
102 ah->hw_version.subvendorid = 0;
103 @@ -1396,9 +1395,7 @@ static bool ath9k_hw_chip_reset(struct a
104 static bool ath9k_hw_channel_change(struct ath_hw *ah,
105 struct ath9k_channel *chan)
107 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
108 struct ath_common *common = ath9k_hw_common(ah);
109 - struct ieee80211_channel *channel = chan->chan;
113 @@ -1423,14 +1420,7 @@ static bool ath9k_hw_channel_change(stru
116 ath9k_hw_set_clockrate(ah);
118 - ah->eep_ops->set_txpower(ah, chan,
119 - ath9k_regd_get_ctl(regulatory, chan),
120 - channel->max_antenna_gain * 2,
121 - channel->max_power * 2,
122 - min((u32) MAX_RATE_POWER,
123 - (u32) regulatory->power_limit), false);
125 + ath9k_hw_apply_txpower(ah, chan);
126 ath9k_hw_rfbus_done(ah);
128 if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan))
129 @@ -2466,23 +2456,56 @@ bool ath9k_hw_disable(struct ath_hw *ah)
131 EXPORT_SYMBOL(ath9k_hw_disable);
133 +static int get_antenna_gain(struct ath_hw *ah, struct ath9k_channel *chan)
135 + enum eeprom_param gain_param;
137 + if (IS_CHAN_2GHZ(chan))
138 + gain_param = EEP_ANTENNA_GAIN_2G;
140 + gain_param = EEP_ANTENNA_GAIN_5G;
142 + return ah->eep_ops->get_eeprom(ah, gain_param);
145 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan)
147 + struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
148 + struct ieee80211_channel *channel;
149 + int chan_pwr, new_pwr, max_gain;
150 + int ant_gain, ant_reduction = 0;
155 + channel = chan->chan;
156 + chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
157 + new_pwr = min_t(int, chan_pwr, reg->power_limit);
158 + max_gain = new_pwr - chan_pwr + channel->max_antenna_gain * 2;
160 + ant_gain = get_antenna_gain(ah, chan);
161 + if (ant_gain > max_gain)
162 + ant_reduction = ant_gain - max_gain;
164 + ah->eep_ops->set_txpower(ah, chan,
165 + ath9k_regd_get_ctl(reg, chan),
166 + ant_reduction, new_pwr, false);
169 void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
171 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
172 + struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
173 struct ath9k_channel *chan = ah->curchan;
174 struct ieee80211_channel *channel = chan->chan;
175 - int reg_pwr = min_t(int, MAX_RATE_POWER, limit);
176 - int chan_pwr = channel->max_power * 2;
178 + reg->power_limit = min_t(int, limit, MAX_RATE_POWER);
180 - reg_pwr = chan_pwr = MAX_RATE_POWER;
181 + channel->max_power = MAX_RATE_POWER / 2;
183 - regulatory->power_limit = reg_pwr;
184 + ath9k_hw_apply_txpower(ah, chan);
186 - ah->eep_ops->set_txpower(ah, chan,
187 - ath9k_regd_get_ctl(regulatory, chan),
188 - channel->max_antenna_gain * 2,
189 - chan_pwr, reg_pwr, test);
191 + channel->max_power = DIV_ROUND_UP(reg->max_power_level, 2);
193 EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
195 --- a/drivers/net/wireless/ath/ath9k/hw.h
196 +++ b/drivers/net/wireless/ath/ath9k/hw.h
197 @@ -389,14 +389,6 @@ enum ath9k_power_mode {
201 -enum ath9k_tp_scale {
202 - ATH9K_TP_SCALE_MAX = 0,
210 SER_REG_MODE_OFF = 0,
212 @@ -964,6 +956,7 @@ void ath9k_hw_htc_resetinit(struct ath_h
214 void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled,
215 u32 *coef_mantissa, u32 *coef_exponent);
216 +void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan);
219 * Code Specific to AR5008, AR9001 or AR9002,
220 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
221 +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
222 @@ -350,6 +350,8 @@ static u32 ath9k_hw_4k_get_eeprom(struct
223 return pModal->antdiv_ctl1;
224 case EEP_TXGAIN_TYPE:
225 return pBase->txGainType;
226 + case EEP_ANTENNA_GAIN_2G:
227 + return pModal->antennaGainCh[0];
231 @@ -462,8 +464,7 @@ static void ath9k_hw_set_4k_power_per_ra
232 struct ath9k_channel *chan,
235 - u16 AntennaReduction,
236 - u16 twiceMaxRegulatoryPower,
237 + u16 antenna_reduction,
240 #define CMP_TEST_GRP \
241 @@ -472,20 +473,16 @@ static void ath9k_hw_set_4k_power_per_ra
242 || (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \
243 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))
245 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
247 - int16_t twiceLargestAntenna;
248 u16 twiceMinEdgePower;
249 u16 twiceMaxEdgePower = MAX_RATE_POWER;
250 - u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
251 + u16 scaledPower = 0, minCtlPower;
255 struct chan_centers centers;
256 struct cal_ctl_data_4k *rep;
257 struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
258 - static const u16 tpScaleReductionTable[5] =
259 - { 0, 3, 6, 9, MAX_RATE_POWER };
260 struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
263 @@ -503,19 +500,7 @@ static void ath9k_hw_set_4k_power_per_ra
265 ath9k_hw_get_channel_centers(ah, chan, ¢ers);
267 - twiceLargestAntenna = pEepData->modalHeader.antennaGainCh[0];
268 - twiceLargestAntenna = (int16_t)min(AntennaReduction -
269 - twiceLargestAntenna, 0);
271 - maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
272 - if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
273 - maxRegAllowedPower -=
274 - (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
277 - scaledPower = min(powerLimit, maxRegAllowedPower);
278 - scaledPower = max((u16)0, scaledPower);
280 + scaledPower = powerLimit - antenna_reduction;
281 numCtlModes = ARRAY_SIZE(ctlModesFor11g) - SUB_NUM_CTL_MODES_AT_2G_40;
282 pCtlMode = ctlModesFor11g;
284 @@ -671,7 +656,6 @@ static void ath9k_hw_4k_set_txpower(stru
285 struct ath9k_channel *chan,
287 u8 twiceAntennaReduction,
288 - u8 twiceMaxRegulatoryPower,
289 u8 powerLimit, bool test)
291 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
292 @@ -691,7 +675,6 @@ static void ath9k_hw_4k_set_txpower(stru
293 ath9k_hw_set_4k_power_per_rate_table(ah, chan,
294 &ratesArray[0], cfgCtl,
295 twiceAntennaReduction,
296 - twiceMaxRegulatoryPower,
299 ath9k_hw_set_4k_power_cal_table(ah, chan);
300 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
301 +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
302 @@ -336,6 +336,9 @@ static u32 ath9k_hw_ar9287_get_eeprom(st
303 return pBase->tempSensSlopePalOn;
306 + case EEP_ANTENNA_GAIN_2G:
307 + return max_t(u8, pModal->antennaGainCh[0],
308 + pModal->antennaGainCh[1]);
312 @@ -554,8 +557,7 @@ static void ath9k_hw_set_ar9287_power_pe
313 struct ath9k_channel *chan,
316 - u16 AntennaReduction,
317 - u16 twiceMaxRegulatoryPower,
318 + u16 antenna_reduction,
322 @@ -569,12 +571,8 @@ static void ath9k_hw_set_ar9287_power_pe
323 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6
324 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10
326 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
327 u16 twiceMaxEdgePower = MAX_RATE_POWER;
328 - static const u16 tpScaleReductionTable[5] =
329 - { 0, 3, 6, 9, MAX_RATE_POWER };
331 - int16_t twiceLargestAntenna;
332 struct cal_ctl_data_ar9287 *rep;
333 struct cal_target_power_leg targetPowerOfdm = {0, {0, 0, 0, 0} },
334 targetPowerCck = {0, {0, 0, 0, 0} };
335 @@ -582,7 +580,7 @@ static void ath9k_hw_set_ar9287_power_pe
336 targetPowerCckExt = {0, {0, 0, 0, 0} };
337 struct cal_target_power_ht targetPowerHt20,
338 targetPowerHt40 = {0, {0, 0, 0, 0} };
339 - u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
340 + u16 scaledPower = 0, minCtlPower;
341 static const u16 ctlModesFor11g[] = {
342 CTL_11B, CTL_11G, CTL_2GHT20,
343 CTL_11B_EXT, CTL_11G_EXT, CTL_2GHT40
344 @@ -597,24 +595,7 @@ static void ath9k_hw_set_ar9287_power_pe
345 tx_chainmask = ah->txchainmask;
347 ath9k_hw_get_channel_centers(ah, chan, ¢ers);
349 - /* Compute TxPower reduction due to Antenna Gain */
350 - twiceLargestAntenna = max(pEepData->modalHeader.antennaGainCh[0],
351 - pEepData->modalHeader.antennaGainCh[1]);
352 - twiceLargestAntenna = (int16_t)min((AntennaReduction) -
353 - twiceLargestAntenna, 0);
356 - * scaledPower is the minimum of the user input power level
357 - * and the regulatory allowed power level.
359 - maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
361 - if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX)
362 - maxRegAllowedPower -=
363 - (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
365 - scaledPower = min(powerLimit, maxRegAllowedPower);
366 + scaledPower = powerLimit - antenna_reduction;
369 * Reduce scaled Power by number of chains active
370 @@ -815,7 +796,6 @@ static void ath9k_hw_set_ar9287_power_pe
371 static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah,
372 struct ath9k_channel *chan, u16 cfgCtl,
373 u8 twiceAntennaReduction,
374 - u8 twiceMaxRegulatoryPower,
375 u8 powerLimit, bool test)
377 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
378 @@ -834,7 +814,6 @@ static void ath9k_hw_ar9287_set_txpower(
379 ath9k_hw_set_ar9287_power_per_rate_table(ah, chan,
380 &ratesArray[0], cfgCtl,
381 twiceAntennaReduction,
382 - twiceMaxRegulatoryPower,
385 ath9k_hw_set_ar9287_power_cal_table(ah, chan);
386 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
387 +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
388 @@ -400,6 +400,7 @@ static u32 ath9k_hw_def_get_eeprom(struc
389 struct ar5416_eeprom_def *eep = &ah->eeprom.def;
390 struct modal_eep_header *pModal = eep->modalHeader;
391 struct base_eep_header *pBase = &eep->baseEepHeader;
396 @@ -467,6 +468,14 @@ static u32 ath9k_hw_def_get_eeprom(struc
397 return pBase->pwr_table_offset;
399 return AR5416_PWR_TABLE_OFFSET_DB;
400 + case EEP_ANTENNA_GAIN_2G:
403 + case EEP_ANTENNA_GAIN_5G:
404 + return max_t(u8, max_t(u8,
405 + pModal[band].antennaGainCh[0],
406 + pModal[band].antennaGainCh[1]),
407 + pModal[band].antennaGainCh[2]);
411 @@ -986,21 +995,15 @@ static void ath9k_hw_set_def_power_per_r
412 struct ath9k_channel *chan,
415 - u16 AntennaReduction,
416 - u16 twiceMaxRegulatoryPower,
417 + u16 antenna_reduction,
420 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
421 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */
423 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
424 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
425 u16 twiceMaxEdgePower = MAX_RATE_POWER;
426 - static const u16 tpScaleReductionTable[5] =
427 - { 0, 3, 6, 9, MAX_RATE_POWER };
430 - int16_t twiceLargestAntenna;
431 struct cal_ctl_data *rep;
432 struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
434 @@ -1012,7 +1015,7 @@ static void ath9k_hw_set_def_power_per_r
435 struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = {
438 - u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
439 + u16 scaledPower = 0, minCtlPower;
440 static const u16 ctlModesFor11a[] = {
441 CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
443 @@ -1031,27 +1034,7 @@ static void ath9k_hw_set_def_power_per_r
445 ath9k_hw_get_channel_centers(ah, chan, ¢ers);
447 - twiceLargestAntenna = max(
448 - pEepData->modalHeader
449 - [IS_CHAN_2GHZ(chan)].antennaGainCh[0],
450 - pEepData->modalHeader
451 - [IS_CHAN_2GHZ(chan)].antennaGainCh[1]);
453 - twiceLargestAntenna = max((u8)twiceLargestAntenna,
454 - pEepData->modalHeader
455 - [IS_CHAN_2GHZ(chan)].antennaGainCh[2]);
457 - twiceLargestAntenna = (int16_t)min(AntennaReduction -
458 - twiceLargestAntenna, 0);
460 - maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
462 - if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
463 - maxRegAllowedPower -=
464 - (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
467 - scaledPower = min(powerLimit, maxRegAllowedPower);
468 + scaledPower = powerLimit - antenna_reduction;
470 switch (ar5416_get_ntxchains(tx_chainmask)) {
472 @@ -1256,7 +1239,6 @@ static void ath9k_hw_def_set_txpower(str
473 struct ath9k_channel *chan,
475 u8 twiceAntennaReduction,
476 - u8 twiceMaxRegulatoryPower,
477 u8 powerLimit, bool test)
479 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
480 @@ -1278,7 +1260,6 @@ static void ath9k_hw_def_set_txpower(str
481 ath9k_hw_set_def_power_per_rate_table(ah, chan,
482 &ratesArray[0], cfgCtl,
483 twiceAntennaReduction,
484 - twiceMaxRegulatoryPower,
487 ath9k_hw_set_def_power_cal_table(ah, chan);
488 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
489 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
490 @@ -763,10 +763,8 @@ static void ar5008_hw_set_channel_regs(s
491 static int ar5008_hw_process_ini(struct ath_hw *ah,
492 struct ath9k_channel *chan)
494 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
495 struct ath_common *common = ath9k_hw_common(ah);
496 int i, regWrites = 0;
497 - struct ieee80211_channel *channel = chan->chan;
498 u32 modesIndex, freqIndex;
500 switch (chan->chanmode) {
501 @@ -903,14 +901,7 @@ static int ar5008_hw_process_ini(struct
502 ar5008_hw_set_channel_regs(ah, chan);
503 ar5008_hw_init_chain_masks(ah);
507 - ah->eep_ops->set_txpower(ah, chan,
508 - ath9k_regd_get_ctl(regulatory, chan),
509 - channel->max_antenna_gain * 2,
510 - channel->max_power * 2,
511 - min((u32) MAX_RATE_POWER,
512 - (u32) regulatory->power_limit), false);
513 + ath9k_hw_apply_txpower(ah, chan);
515 /* Write analog registers */
516 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
517 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
518 +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
521 void ar9003_paprd_enable(struct ath_hw *ah, bool val)
523 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
524 struct ath9k_channel *chan = ah->curchan;
525 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
527 @@ -54,13 +53,7 @@ void ar9003_paprd_enable(struct ath_hw *
530 ah->paprd_table_write_done = true;
532 - ah->eep_ops->set_txpower(ah, chan,
533 - ath9k_regd_get_ctl(regulatory, chan),
534 - chan->chan->max_antenna_gain * 2,
535 - chan->chan->max_power * 2,
536 - min((u32) MAX_RATE_POWER,
537 - (u32) regulatory->power_limit), false);
538 + ath9k_hw_apply_txpower(ah, chan);
541 REG_RMW_FIELD(ah, AR_PHY_PAPRD_CTRL0_B0,
542 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
543 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
544 @@ -628,9 +628,7 @@ static void ar9003_hw_prog_ini(struct at
545 static int ar9003_hw_process_ini(struct ath_hw *ah,
546 struct ath9k_channel *chan)
548 - struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
549 unsigned int regWrites = 0, i;
550 - struct ieee80211_channel *channel = chan->chan;
553 switch (chan->chanmode) {
554 @@ -683,14 +681,7 @@ static int ar9003_hw_process_ini(struct
555 ar9003_hw_override_ini(ah);
556 ar9003_hw_set_channel_regs(ah, chan);
557 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
560 - ah->eep_ops->set_txpower(ah, chan,
561 - ath9k_regd_get_ctl(regulatory, chan),
562 - channel->max_antenna_gain * 2,
563 - channel->max_power * 2,
564 - min((u32) MAX_RATE_POWER,
565 - (u32) regulatory->power_limit), false);
566 + ath9k_hw_apply_txpower(ah, chan);
570 --- a/drivers/net/wireless/ath/ath9k/common.c
571 +++ b/drivers/net/wireless/ath/ath9k/common.c
572 @@ -161,10 +161,12 @@ EXPORT_SYMBOL(ath9k_cmn_count_streams);
573 void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
574 u16 new_txpow, u16 *txpower)
576 - if (cur_txpow != new_txpow) {
577 + struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
579 + if (reg->power_limit != new_txpow) {
580 ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
581 /* read back in case value is clamped */
582 - *txpower = ath9k_hw_regulatory(ah)->power_limit;
583 + *txpower = reg->max_power_level;
586 EXPORT_SYMBOL(ath9k_cmn_update_txpow);
587 --- a/drivers/net/wireless/ath/ath9k/eeprom.h
588 +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
589 @@ -253,7 +253,9 @@ enum eeprom_param {
593 - EEP_CHAIN_MASK_REDUCE
594 + EEP_CHAIN_MASK_REDUCE,
595 + EEP_ANTENNA_GAIN_2G,
596 + EEP_ANTENNA_GAIN_5G
600 @@ -657,8 +659,7 @@ struct eeprom_ops {
601 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
602 void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
603 u16 cfgCtl, u8 twiceAntennaReduction,
604 - u8 twiceMaxRegulatoryPower, u8 powerLimit,
606 + u8 powerLimit, bool test);
607 u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
610 --- a/drivers/net/wireless/ath/ath9k/init.c
611 +++ b/drivers/net/wireless/ath/ath9k/init.c
612 @@ -626,7 +626,6 @@ static void ath9k_init_band_txpower(stru
613 struct ieee80211_supported_band *sband;
614 struct ieee80211_channel *chan;
615 struct ath_hw *ah = sc->sc_ah;
616 - struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
619 sband = &sc->sbands[band];
620 @@ -635,7 +634,6 @@ static void ath9k_init_band_txpower(stru
621 ah->curchan = &ah->channels[chan->hw_value];
622 ath9k_cmn_update_ichannel(ah->curchan, chan, NL80211_CHAN_HT20);
623 ath9k_hw_set_txpowerlimit(ah, MAX_RATE_POWER, true);
624 - chan->max_power = reg->max_power_level / 2;