1 Implement the power curve interpolation, which is required for
2 proper tx on 2413 and newer RF designs.
4 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
6 --- a/drivers/net/wireless/ath5k/phy.c
7 +++ b/drivers/net/wireless/ath5k/phy.c
9 * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
10 * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
11 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
12 + * Copyright (c) 2008-2009 Felix Fietkau <nbd@openwrt.org>
14 * Permission to use, copy, modify, and distribute this software for any
15 * purpose with or without fee is hereby granted, provided that the above
16 @@ -1438,31 +1439,449 @@ unsigned int ath5k_hw_get_def_antenna(st
20 - * Initialize the tx power table (not fully implemented)
21 + * find the lower and upper index of the values in the table surrounding the target value
23 -static void ath5k_txpower_table(struct ath5k_hw *ah,
24 - struct ieee80211_channel *channel, s16 max_power)
26 +ath5k_get_table_index(const u16 *tbl, unsigned int tbl_sz, u16 target,
27 + unsigned int idx[2])
29 - unsigned int i, min, max, n;
30 - u16 txpower, *rates;
33 - rates = ah->ah_txpower.txp_rates;
34 + if (target < tbl[0]) {
35 + idx[0] = idx[1] = 0;
39 + if (target > tbl[tbl_sz - 1]) {
40 + idx[0] = idx[1] = tbl_sz - 1;
44 + /* look for the surrounding values */
45 + for (ti = tbl; ti < &tbl[tbl_sz - 1]; ti++) {
47 + /* if the value is equal to the target, set lo = hi = index */
48 + if (*ti == target) {
49 + idx[0] = idx[1] = ti - tbl;
53 + /* if the target is between the current value and the next one,
54 + * set lo = cur, hi = lo + 1 */
55 + if (target < ti[1]) {
57 + idx[1] = idx[0] + 1;
63 +/* find the lower and upper frequency info */
65 +ath5k_get_freq_tables(struct ath5k_hw *ah, struct ieee80211_channel *channel,
66 + struct ath5k_chan_pcal_info **pcinfo_l,
67 + struct ath5k_chan_pcal_info **pcinfo_r,
68 + struct ath5k_rate_pcal_info *rates)
70 + struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
71 + struct ath5k_chan_pcal_info *pcinfo;
72 + unsigned int idx_l, idx_r;
74 + unsigned int target = channel->center_freq;
75 + struct ath5k_rate_pcal_info *rpinfo;
77 + if (!(channel->hw_value & CHANNEL_OFDM)) {
78 + pcinfo = ee->ee_pwr_cal_b;
79 + rpinfo = ee->ee_rate_tpwr_b;
80 + mode = AR5K_EEPROM_MODE_11B;
81 + } else if (channel->hw_value & CHANNEL_2GHZ) {
82 + pcinfo = ee->ee_pwr_cal_g;
83 + rpinfo = ee->ee_rate_tpwr_g;
84 + mode = AR5K_EEPROM_MODE_11G;
86 + pcinfo = ee->ee_pwr_cal_a;
87 + rpinfo = ee->ee_rate_tpwr_a;
88 + mode = AR5K_EEPROM_MODE_11A;
90 + max = ee->ee_n_piers[mode] - 1;
92 + if (target < pcinfo[0].freq) {
97 + if (target > pcinfo[max].freq) {
98 + idx_l = idx_r = max;
102 + /* look for the surrounding values */
103 + for (i = 0; i <= max; i++) {
105 + /* if the value is equal to the target, set lo = hi = index */
106 + if (pcinfo[i].freq == target) {
111 + /* if the target is between the current value and the next one,
112 + * set lo = cur, hi = lo + 1 */
113 + if (target < pcinfo[i].freq) {
121 + *pcinfo_l = &pcinfo[idx_l];
122 + *pcinfo_r = &pcinfo[idx_r];
127 + /* rate info minimum values */
128 + rates->freq = channel->center_freq;
129 + rates->target_power_6to24 =
130 + min(rpinfo[idx_l].target_power_6to24,
131 + rpinfo[idx_r].target_power_6to24);
132 + rates->target_power_36 =
133 + min(rpinfo[idx_l].target_power_36,
134 + rpinfo[idx_r].target_power_36);
135 + rates->target_power_48 =
136 + min(rpinfo[idx_l].target_power_48,
137 + rpinfo[idx_r].target_power_48);
138 + rates->target_power_54 =
139 + min(rpinfo[idx_l].target_power_54,
140 + rpinfo[idx_r].target_power_54);
144 +/* Fill the VPD table for all indices between pmin and pmax */
146 +ath5k_fill_vpdtable(s16 pmin, s16 pmax, const s16 *pwr,
147 + const u16 *vpd, unsigned int intercepts,
148 + u16 vpdtable[AR5K_EEPROM_POWER_TABLE_SIZE])
150 + unsigned int idx[2] = { 0, 0 };
151 + s16 cur_pwr = 2 * pmin;
154 + if (intercepts < 2)
157 + for(i = 0; i <= (pmax - pmin); i++) {
158 + ath5k_get_table_index(pwr, intercepts, cur_pwr, idx);
163 + if (idx[0] == intercepts - 1)
164 + idx[0] = intercepts - 2;
166 + if (pwr[idx[0]] == pwr[idx[1]])
167 + vpdtable[i] = vpd[idx[0]];
169 + vpdtable[i] = (((cur_pwr - pwr[idx[0]]) * vpd[idx[1]] +
170 + (pwr[idx[1]] - cur_pwr) * vpd[idx[0]]) /
171 + (pwr[idx[1]] - pwr[idx[0]]));
178 +ath5k_interpolate_signed(u16 ref, u16 ref_l, u16 ref_r, s16 val_l, s16 val_r)
180 + if (ref_l == ref_r)
183 + return ((ref - ref_l)*val_r + (ref_r - ref)*val_l) / (ref_r - ref_l);
187 +ath5k_get_min_power_2413(struct ath5k_chan_pcal_info *pcinfo)
189 + struct ath5k_pdgain_info *pd;
192 + /* backwards - highest pdgain == lowest power */
193 + for (i = AR5K_EEPROM_N_PD_GAINS - 1; i >= 0; i--) {
194 + pd = &pcinfo->rf2413_info.pdgains[i];
198 + return pd->pwr_t4[0];
204 +ath5k_get_max_power_2413(struct ath5k_chan_pcal_info *pcinfo)
206 + struct ath5k_pdgain_info *pd;
209 + /* forwards: lowest pdgain == highest power */
210 + for (i = 0; i < AR5K_EEPROM_N_PD_GAINS; i++) {
211 + pd = &pcinfo->rf2413_info.pdgains[i];
215 + return pd->pwr_t4[pd->n_vpd];
223 +ath5k_txpower_table_2413(struct ath5k_hw *ah, struct ieee80211_channel *ch,
224 + struct ath5k_chan_pcal_info *pcinfo_l,
225 + struct ath5k_chan_pcal_info *pcinfo_r)
227 + struct ath5k_pdgain_info *pd_l, *pd_r;
228 + u16 gain_boundaries[4];
229 + u16 *xpd = ah->ah_txpower.txp_xpd;
231 + s16 pmin_t2[AR5K_EEPROM_N_PD_GAINS];
232 + s16 pmax_t2[AR5K_EEPROM_N_PD_GAINS];
233 + u16 *pdadc_out = ah->ah_txpower.txp_pcdac;
234 + unsigned int gain_overlap;
235 + unsigned int vpd_size, target_idx, max_idx;
236 + unsigned int n_pdadc = 0;
242 + s16 ch_pmin, ch_pmax;
244 + gain_overlap = ath5k_hw_reg_read(ah, AR5K_PHY_TPC_RG5) &
245 + AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP;
247 + /* loop backwards over pdgains (highest pdgain == lowest power) */
248 + for (i = AR5K_EEPROM_N_PD_GAINS - 1; i >= 0; i--) {
249 + pd_l = &pcinfo_l->rf2413_info.pdgains[i];
250 + pd_r = &pcinfo_r->rf2413_info.pdgains[i];
251 + pcdacL = ah->ah_txpower.txp_rfdata.rf2413.pcdacL[n_xpd];
252 + pcdacR = ah->ah_txpower.txp_rfdata.rf2413.pcdacR[n_xpd];
259 + pmin_t2[n_xpd] = min(pd_l->pwr_t4[0], pd_r->pwr_t4[0]) / 2;
260 + pmax_t2[n_xpd] = min(pd_l->pwr_t4[pd_l->n_vpd - 1],
261 + pd_r->pwr_t4[pd_r->n_vpd - 1]) / 2;
263 + if ((u16) (pmax_t2[n_xpd] - pmin_t2[n_xpd]) > 64)
266 + /* fill vpd tables for left and right frequency info */
267 + ath5k_fill_vpdtable(pmin_t2[n_xpd], pmax_t2[n_xpd],
268 + pd_l->pwr_t4, pd_l->vpd, pd_l->n_vpd, pcdacL);
270 + /* check if interpolation is necessary */
271 + if (pcinfo_l == pcinfo_r)
274 + ath5k_fill_vpdtable(pmin_t2[n_xpd], pmax_t2[n_xpd],
275 + pd_r->pwr_t4, pd_r->vpd, pd_r->n_vpd, pcdacR);
277 + /* interpolate pcdac values,
278 + * reuse pcdacL table for interpolation output */
279 + for (j = 0; j < (u16) (pmax_t2[n_xpd] - pmin_t2[n_xpd]); j++) {
280 + pcdacL[j] = ath5k_interpolate_signed(ch->center_freq,
281 + pcinfo_l->freq, pcinfo_r->freq,
282 + (s16) pcdacL[j], (s16) pcdacR[j]);
290 + /* create final table */
291 + for (i = 0, n_pdadc = 0; i < n_xpd; i++) {
292 + pcdacL = ah->ah_txpower.txp_rfdata.rf2413.pcdacL[i];
294 + if (i == n_xpd - 1) {
295 + /* 2 db boundary stretch */
296 + gain_boundaries[i] = pmax_t2[i] + 4;
298 + gain_boundaries[i] = (pmax_t2[i] + pmin_t2[i + 1]) / 2;
301 + if (gain_boundaries[i] > AR5K_TUNE_MAX_TXPOWER)
302 + gain_boundaries[i] = AR5K_TUNE_MAX_TXPOWER;
304 + /* find starting index */
308 + s = (gain_boundaries[i - 1] - pmin_t2[i]) -
311 + if (pcdacL[1] > pcdacL[0])
312 + vpd_step = pcdacL[1] - pcdacL[0];
316 + /* if s is below 0, we need to extrapolate below this pdgain */
317 + while ((s < 0) && (n_pdadc < 128)) {
318 + s16 tmp = pcdacL[0] + s * vpd_step;
319 + pdadc_out[n_pdadc++] = (u16) ((tmp < 0) ? 0 : tmp);
323 + vpd_size = pmax_t2[i] - pmin_t2[i];
324 + target_idx = gain_boundaries[i] + gain_overlap - pmin_t2[i];
325 + max_idx = (target_idx < vpd_size) ? target_idx : vpd_size;
327 + while ((s < (s16) max_idx) && (n_pdadc < 128))
328 + pdadc_out[n_pdadc++] = pcdacL[s++];
330 + /* need to extrapolate above this pdgain? */
331 + if (target_idx <= max_idx)
334 - txpower = AR5K_TUNE_DEFAULT_TXPOWER * 2;
335 - if (max_power > txpower)
336 - txpower = max_power > AR5K_TUNE_MAX_TXPOWER ?
337 - AR5K_TUNE_MAX_TXPOWER : max_power;
338 + if (pcdacL[vpd_size - 1] > pcdacL[vpd_size - 2])
339 + vpd_step = pcdacL[vpd_size - 1] - pcdacL[vpd_size - 2];
343 - for (i = 0; i < AR5K_MAX_RATES; i++)
344 - rates[i] = txpower;
345 + while ((s < (s16) target_idx) && (n_pdadc < 128)) {
346 + int tmp = pcdacL[vpd_size - 1] +
347 + (s - max_idx) * vpd_step;
348 + pdadc_out[n_pdadc++] = (tmp > 127) ? 127 : tmp;
353 - /* XXX setup target powers by rate */
354 + while (i < AR5K_EEPROM_N_PD_GAINS) {
355 + gain_boundaries[i] = gain_boundaries[i - 1];
359 + while (n_pdadc < 128) {
360 + pdadc_out[n_pdadc] = pdadc_out[n_pdadc - 1];
364 + /* select the right xpdgain curves */
365 + reg = ath5k_hw_reg_read(ah, AR5K_PHY_TPC_RG1);
366 + reg &= ~(AR5K_PHY_TPC_RG1_PDGAIN_1 |
367 + AR5K_PHY_TPC_RG1_PDGAIN_2 |
368 + AR5K_PHY_TPC_RG1_PDGAIN_3 |
369 + AR5K_PHY_TPC_RG1_NUM_PD_GAIN);
370 + reg |= AR5K_REG_SM(n_xpd, AR5K_PHY_TPC_RG1_NUM_PD_GAIN);
373 + reg |= AR5K_REG_SM(xpd[2], AR5K_PHY_TPC_RG1_PDGAIN_3);
376 + reg |= AR5K_REG_SM(xpd[1], AR5K_PHY_TPC_RG1_PDGAIN_2);
379 + reg |= AR5K_REG_SM(xpd[0], AR5K_PHY_TPC_RG1_PDGAIN_1);
382 + ath5k_hw_reg_write(ah, reg, AR5K_PHY_TPC_RG1);
385 + * Write TX power values
387 + reg = AR5K_PHY_PDADC_TXPOWER_BASE;
388 + for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
389 + ath5k_hw_reg_write(ah,
390 + ((pdadc_out[4*i + 0] & 0xff) << 0) |
391 + ((pdadc_out[4*i + 1] & 0xff) << 8) |
392 + ((pdadc_out[4*i + 2] & 0xff) << 16) |
393 + ((pdadc_out[4*i + 3] & 0xff) << 24), reg);
397 + ath5k_hw_reg_write(ah,
398 + AR5K_REG_SM(gain_overlap,
399 + AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP) |
400 + AR5K_REG_SM(gain_boundaries[0],
401 + AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_1) |
402 + AR5K_REG_SM(gain_boundaries[1],
403 + AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_2) |
404 + AR5K_REG_SM(gain_boundaries[2],
405 + AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_3) |
406 + AR5K_REG_SM(gain_boundaries[3],
407 + AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_4),
410 + ah->ah_txpower.txp_offset = pmin_t2[0];
412 + /* look up power boundaries for this channel */
413 + ch_pmin = ath5k_get_min_power_2413(pcinfo_l);
414 + ch_pmax = ath5k_get_max_power_2413(pcinfo_l);
416 + if (pcinfo_l != pcinfo_r) {
419 + pwr_r = ath5k_get_min_power_2413(pcinfo_r);
420 + ch_pmin = ath5k_interpolate_signed(ch->center_freq,
421 + pcinfo_l->freq, pcinfo_r->freq,
424 + pwr_r = ath5k_get_max_power_2413(pcinfo_r);
425 + ch_pmax = ath5k_interpolate_signed(ch->center_freq,
426 + pcinfo_l->freq, pcinfo_r->freq,
429 + ah->ah_txpower.txp_min = ch_pmin;
430 + ah->ah_txpower.txp_max = ch_pmax;
436 +ath5k_setup_rate_table(struct ath5k_hw *ah, u16 max_pwr,
437 + struct ath5k_rate_pcal_info *rate_info)
443 + max_pwr = min(max_pwr, (u16) ah->ah_txpower.txp_max);
445 + /* apply rate limits */
446 + rates = ah->ah_txpower.txp_rates;
447 + for (i = 0; i < 5; i++) {
448 + rates[i] = min(max_pwr, rate_info->target_power_6to24);
450 + rates[5] = min(rates[0], rate_info->target_power_36);
451 + rates[6] = min(rates[0], rate_info->target_power_48);
452 + rates[7] = min(rates[0], rate_info->target_power_54);
453 + rates[8] = min(rates[0], rate_info->target_power_6to24);
454 + rates[9] = min(rates[0], rate_info->target_power_36);
455 + rates[10] = min(rates[0], rate_info->target_power_36);
456 + rates[11] = min(rates[0], rate_info->target_power_48);
457 + rates[12] = min(rates[0], rate_info->target_power_48);
458 + rates[13] = min(rates[0], rate_info->target_power_54);
459 + rates[14] = min(rates[0], rate_info->target_power_54);
461 + ah->ah_txpower.txp_tpc = max_pwr;
462 ah->ah_txpower.txp_min = rates[7];
463 - ah->ah_txpower.txp_max = rates[0];
464 - ah->ah_txpower.txp_ofdm = rates[0];
465 + ah->ah_txpower.txp_max = min(ah->ah_txpower.txp_max,
466 + (s16) rate_info->target_power_36);
467 + ah->ah_txpower.txp_ofdm = ah->ah_txpower.txp_max;
471 +ath5k_txpower_table(struct ath5k_hw *ah, struct ieee80211_channel *ch,
472 + struct ath5k_chan_pcal_info *pcinfo_l,
473 + struct ath5k_chan_pcal_info *pcinfo_r,
476 + unsigned int i, min, max, n;
478 - /* Calculate the power table */
479 n = ARRAY_SIZE(ah->ah_txpower.txp_pcdac);
480 min = AR5K_EEPROM_PCDAC_START;
481 max = AR5K_EEPROM_PCDAC_STOP;
482 @@ -1473,51 +1892,64 @@ static void ath5k_txpower_table(struct a
488 + * Write TX power values
490 + for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
491 + ath5k_hw_reg_write(ah,
492 + ((((ah->ah_txpower.txp_pcdac[(i << 1) + 1] << 8) |
493 + 0xff) & 0xffff) << 16) |
494 + (((ah->ah_txpower.txp_pcdac[(i << 1) ] << 8) |
496 + AR5K_PHY_PCDAC_TXPOWER(i));
503 * Set transmition power
505 -int /*O.K. - txpower_table is unimplemented so this doesn't work*/
507 ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel,
508 unsigned int txpower)
510 + struct ath5k_chan_pcal_info *pcinfo_l, *pcinfo_r;
511 + struct ath5k_rate_pcal_info rate_info;
512 bool tpc = ah->ah_txpower.txp_tpc;
515 ATH5K_TRACE(ah->ah_sc);
516 if (txpower > AR5K_TUNE_MAX_TXPOWER) {
517 ATH5K_ERR(ah->ah_sc, "invalid tx power: %u\n", txpower);
522 - * RF2413 for some reason can't
523 - * transmit anything if we call
524 - * this funtion, so we skip it
525 - * until we fix txpower.
527 - * XXX: Assume same for RF2425
530 - if ((ah->ah_radio == AR5K_RF2413) || (ah->ah_radio == AR5K_RF2425))
533 + txpower = AR5K_TUNE_MAX_TXPOWER;
535 /* Reset TX power values */
536 memset(&ah->ah_txpower, 0, sizeof(ah->ah_txpower));
537 ah->ah_txpower.txp_tpc = tpc;
538 + ah->ah_txpower.txp_min = 0;
539 + ah->ah_txpower.txp_max = AR5K_TUNE_MAX_TXPOWER;
541 - /* Initialize TX power table */
542 - ath5k_txpower_table(ah, channel, txpower);
543 + /* find matching frequency info */
544 + ath5k_get_freq_tables(ah, channel, &pcinfo_l, &pcinfo_r, &rate_info);
545 + ath5k_setup_rate_table(ah, txpower, &rate_info);
548 - * Write TX power values
550 - for (i = 0; i < (AR5K_EEPROM_POWER_TABLE_SIZE / 2); i++) {
551 - ath5k_hw_reg_write(ah,
552 - ((((ah->ah_txpower.txp_pcdac[(i << 1) + 1] << 8) | 0xff) & 0xffff) << 16) |
553 - (((ah->ah_txpower.txp_pcdac[(i << 1) ] << 8) | 0xff) & 0xffff),
554 - AR5K_PHY_PCDAC_TXPOWER(i));
555 + /* Initialize TX power table */
556 + switch(ah->ah_radio) {
559 + ath5k_txpower_table_2413(ah, channel, pcinfo_l, pcinfo_r);
562 + /* unimplemented */
565 + /* Default power table */
566 + ath5k_txpower_table(ah, channel, pcinfo_l, pcinfo_r, txpower);
570 ath5k_hw_reg_write(ah, AR5K_TXPOWER_OFDM(3, 24) |
571 @@ -1536,12 +1968,19 @@ ath5k_hw_txpower(struct ath5k_hw *ah, st
572 AR5K_TXPOWER_CCK(13, 16) | AR5K_TXPOWER_CCK(12, 8) |
573 AR5K_TXPOWER_CCK(11, 0), AR5K_PHY_TXPOWER_RATE4);
575 - if (ah->ah_txpower.txp_tpc)
576 + if (ah->ah_txpower.txp_tpc) {
577 ath5k_hw_reg_write(ah, AR5K_PHY_TXPOWER_RATE_MAX_TPC_ENABLE |
578 AR5K_TUNE_MAX_TXPOWER, AR5K_PHY_TXPOWER_RATE_MAX);
581 + ath5k_hw_reg_write(ah,
582 + AR5K_REG_MS(AR5K_TUNE_MAX_TXPOWER, AR5K_TPC_ACK) |
583 + AR5K_REG_MS(AR5K_TUNE_MAX_TXPOWER, AR5K_TPC_CTS) |
584 + AR5K_REG_MS(AR5K_TUNE_MAX_TXPOWER, AR5K_TPC_CHIRP),
587 ath5k_hw_reg_write(ah, AR5K_PHY_TXPOWER_RATE_MAX |
588 AR5K_TUNE_MAX_TXPOWER, AR5K_PHY_TXPOWER_RATE_MAX);
593 --- a/drivers/net/wireless/ath5k/ath5k.h
594 +++ b/drivers/net/wireless/ath5k/ath5k.h
596 #define AR5K_TUNE_CWMAX_11B 1023
597 #define AR5K_TUNE_CWMAX_XR 7
598 #define AR5K_TUNE_NOISE_FLOOR -72
599 -#define AR5K_TUNE_MAX_TXPOWER 60
600 +#define AR5K_TUNE_MAX_TXPOWER 63
601 #define AR5K_TUNE_DEFAULT_TXPOWER 30
602 #define AR5K_TUNE_TPC_TXPOWER true
603 #define AR5K_TUNE_ANT_DIVERSITY true
604 @@ -1085,11 +1085,23 @@ struct ath5k_hw {
605 struct ath5k_gain ah_gain;
606 u8 ah_offset[AR5K_MAX_RF_BANKS];
610 - u16 txp_pcdac[AR5K_EEPROM_POWER_TABLE_SIZE];
613 + /* Temporary PCDAC tables for interpolation */
614 + u16 pcdacL[AR5K_EEPROM_N_PD_GAINS]
615 + [AR5K_EEPROM_POWER_TABLE_SIZE];
616 + u16 pcdacR[AR5K_EEPROM_N_PD_GAINS]
617 + [AR5K_EEPROM_POWER_TABLE_SIZE];
620 + u16 txp_xpd[AR5K_EEPROM_N_XPD_PER_CHANNEL];
621 + u16 txp_pcdac[AR5K_EEPROM_POWER_TABLE_SIZE * 2];
622 u16 txp_rates[AR5K_MAX_RATES];
629 --- a/drivers/net/wireless/ath5k/reg.h
630 +++ b/drivers/net/wireless/ath5k/reg.h
631 @@ -1552,6 +1552,15 @@
634 /*===5212 Specific PCU registers===*/
635 +#define AR5K_TPC 0x80e8
636 +#define AR5K_TPC_ACK 0x0000003f /* ack frames */
637 +#define AR5K_TPC_ACK_S 0
638 +#define AR5K_TPC_CTS 0x00003f00 /* cts frames */
639 +#define AR5K_TPC_CTS_S 8
640 +#define AR5K_TPC_CHIRP 0x003f0000 /* chirp frames */
641 +#define AR5K_TPC_CHIRP_S 16
642 +#define AR5K_TPC_DOPPLER 0x0f000000 /* doppler chirp span */
643 +#define AR5K_TPC_DOPPLER_S 24
646 * XR (eXtended Range) mode register
647 @@ -2550,6 +2559,12 @@
648 #define AR5K_PHY_TPC_RG1 0xa258
649 #define AR5K_PHY_TPC_RG1_NUM_PD_GAIN 0x0000c000
650 #define AR5K_PHY_TPC_RG1_NUM_PD_GAIN_S 14
651 +#define AR5K_PHY_TPC_RG1_PDGAIN_1 0x00030000
652 +#define AR5K_PHY_TPC_RG1_PDGAIN_1_S 16
653 +#define AR5K_PHY_TPC_RG1_PDGAIN_2 0x000c0000
654 +#define AR5K_PHY_TPC_RG1_PDGAIN_2_S 18
655 +#define AR5K_PHY_TPC_RG1_PDGAIN_3 0x00300000
656 +#define AR5K_PHY_TPC_RG1_PDGAIN_3_S 20
658 #define AR5K_PHY_TPC_RG5 0xa26C
659 #define AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP 0x0000000F
660 --- a/drivers/net/wireless/ath5k/desc.c
661 +++ b/drivers/net/wireless/ath5k/desc.c
662 @@ -194,6 +194,10 @@ static int ath5k_hw_setup_4word_tx_desc(
666 + tx_power += ah->ah_txpower.txp_offset;
667 + if (tx_power > AR5K_TUNE_MAX_TXPOWER)
668 + tx_power = AR5K_TUNE_MAX_TXPOWER;
670 /* Clear descriptor */
671 memset(&desc->ud.ds_tx5212, 0, sizeof(struct ath5k_hw_5212_tx_desc));