History

ath9k_hw: extend ath9k_hw_set_txpowerlimit to test channel txpower

ath9k_hw_set_txpowerlimit gets an extra boolean parameter that - if set - causes the rate txpower table and the regulatory limit to be calculated and stored, without changing hardware registers.

Felix Fietkau committed 16 years ago

Commit de40f311 parent 6b7b6cf11 files · +79 −58Browse files

Unified · Split

11 files
  1. drivers/net/wireless/ath/ath9k/ar5008_phy.c +1 −1
  2. drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +14 −6
  3. drivers/net/wireless/ath/ath9k/ar9003_phy.c +1 −1
  4. drivers/net/wireless/ath/ath9k/eeprom.h +2 −1
  5. drivers/net/wireless/ath/ath9k/eeprom_4k.c +7 −2
  6. drivers/net/wireless/ath/ath9k/eeprom_9287.c +15 −12
  7. drivers/net/wireless/ath/ath9k/eeprom_def.c +33 −29
  8. drivers/net/wireless/ath/ath9k/htc_drv_main.c +1 −1
  9. drivers/net/wireless/ath/ath9k/hw.c +3 −3
  10. drivers/net/wireless/ath/ath9k/hw.h +1 −1
  11. drivers/net/wireless/ath/ath9k/main.c +1 −1
drivers/net/wireless/ath/ath9k/ar5008_phy.c+1−1
@@ -873,7 +873,7 @@ static int ar5008_hw_process_ini(struct ath_hw *ah, · 872 unmodified lines
873873 channel->max_antenna_gain * 2,
874874 channel->max_power * 2,
875875 min((u32) MAX_RATE_POWER,
876− (u32) regulatory->power_limit));
876+ (u32) regulatory->power_limit), false);
877877
878878 /* Write analog registers */
879879 if (!ath9k_hw_set_rf_regs(ah, chan, freqIndex)) {
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c+14−6
@@ -2131,7 +2131,7 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, · 2130 unmodified lines
21312131 struct ath9k_channel *chan, u16 cfgCtl,
21322132 u8 twiceAntennaReduction,
21332133 u8 twiceMaxRegulatoryPower,
2134− u8 powerLimit)
2134+ u8 powerLimit, bool test)
21352135 {
21362136 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
21372137 struct ath_common *common = ath9k_hw_common(ah);
@@ -2145,7 +2145,16 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, · 7 unmodified lines
21452145 twiceMaxRegulatoryPower,
21462146 powerLimit);
21472147
2148− while (i < ar9300RateSize) {
2148+ regulatory->max_power_level = 0;
2149+ for (i = 0; i < ar9300RateSize; i++) {
2150+ if (targetPowerValT2[i] > regulatory->max_power_level)
2151+ regulatory->max_power_level = targetPowerValT2[i];
2152+ }
2153+
2154+ if (test)
2155+ return;
2156+
2157+ for (i = 0; i < ar9300RateSize; i++) {
21492158 ath_print(common, ATH_DBG_EEPROM,
21502159 "TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
21512160 i++;
@@ -2160,9 +2169,6 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, · 8 unmodified lines
21602169 i++;
21612170 }
21622171
2163− /* Write target power array to registers */
2164− ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
2165−
21662172 /*
21672173 * This is the TX power we send back to driver core,
21682174 * and it can use to pass to userspace to display our
@@ -2181,8 +2187,10 @@ static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah, · 12 unmodified lines
21812187 i = ALL_TARGET_HT20_0_8_16; /* ht20 */
21822188
21832189 ah->txpower_limit = targetPowerValT2[i];
2184− regulatory->max_power_level = ratesArray[i];
2190+ regulatory->max_power_level = targetPowerValT2[i];
21852191
2192+ /* Write target power array to registers */
2193+ ar9003_hw_tx_power_regwrite(ah, targetPowerValT2);
21862194 ar9003_hw_calibration_apply(ah, chan->channel);
21872195 }
21882196
drivers/net/wireless/ath/ath9k/ar9003_phy.c+1−1
@@ -614,7 +614,7 @@ static int ar9003_hw_process_ini(struct ath_hw *ah, · 613 unmodified lines
614614 channel->max_antenna_gain * 2,
615615 channel->max_power * 2,
616616 min((u32) MAX_RATE_POWER,
617− (u32) regulatory->power_limit));
617+ (u32) regulatory->power_limit), false);
618618
619619 return 0;
620620 }
drivers/net/wireless/ath/ath9k/eeprom.h+2−1
@@ -680,7 +680,8 @@ struct eeprom_ops { · 679 unmodified lines
680680 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
681681 void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
682682 u16 cfgCtl, u8 twiceAntennaReduction,
683− u8 twiceMaxRegulatoryPower, u8 powerLimit);
683+ u8 twiceMaxRegulatoryPower, u8 powerLimit,
684+ bool test);
684685 u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
685686 };
686687
drivers/net/wireless/ath/ath9k/eeprom_4k.c+7−2
@@ -726,7 +726,7 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah, · 725 unmodified lines
726726 u16 cfgCtl,
727727 u8 twiceAntennaReduction,
728728 u8 twiceMaxRegulatoryPower,
729− u8 powerLimit)
729+ u8 powerLimit, bool test)
730730 {
731731 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
732732 struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
@@ -751,15 +751,20 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah, · 18 unmodified lines
751751
752752 ath9k_hw_set_4k_power_cal_table(ah, chan, &txPowerIndexOffset);
753753
754+ regulatory->max_power_level = 0;
754755 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
755756 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
756757 if (ratesArray[i] > AR5416_MAX_RATE_POWER)
757758 ratesArray[i] = AR5416_MAX_RATE_POWER;
759+
760+ if (ratesArray[i] > regulatory->max_power_level)
761+ regulatory->max_power_level = ratesArray[i];
758762 }
759763
764+ if (test)
765+ return;
760766
761767 /* Update regulatory */
762−
763768 i = rate6mb;
764769 if (IS_CHAN_HT40(chan))
765770 i = rateHt40_0;
drivers/net/wireless/ath/ath9k/eeprom_9287.c+15−12
@@ -853,7 +853,7 @@ static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah, · 852 unmodified lines
853853 struct ath9k_channel *chan, u16 cfgCtl,
854854 u8 twiceAntennaReduction,
855855 u8 twiceMaxRegulatoryPower,
856− u8 powerLimit)
856+ u8 powerLimit, bool test)
857857 {
858858 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
859859 struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
@@ -877,12 +877,26 @@ static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah, · 17 unmodified lines
877877
878878 ath9k_hw_set_ar9287_power_cal_table(ah, chan, &txPowerIndexOffset);
879879
880+ regulatory->max_power_level = 0;
880881 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
881882 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
882883 if (ratesArray[i] > AR9287_MAX_RATE_POWER)
883884 ratesArray[i] = AR9287_MAX_RATE_POWER;
885+
886+ if (ratesArray[i] > regulatory->max_power_level)
887+ regulatory->max_power_level = ratesArray[i];
884888 }
885889
890+ if (test)
891+ return;
892+
893+ if (IS_CHAN_2GHZ(chan))
894+ i = rate1l;
895+ else
896+ i = rate6mb;
897+
898+ regulatory->max_power_level = ratesArray[i];
899+
886900 if (AR_SREV_9280_20_OR_LATER(ah)) {
887901 for (i = 0; i < Ar5416RateSize; i++)
888902 ratesArray[i] -= AR9287_PWR_TABLE_OFFSET_DB * 2;
@@ -971,17 +985,6 @@ static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah, · 82 unmodified lines
971985 | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
972986 | ATH9K_POW_SM(ratesArray[rateDupCck], 0));
973987 }
974−
975− if (IS_CHAN_2GHZ(chan))
976− i = rate1l;
977− else
978− i = rate6mb;
979−
980− if (AR_SREV_9280_20_OR_LATER(ah))
981− regulatory->max_power_level =
982− ratesArray[i] + AR9287_PWR_TABLE_OFFSET_DB * 2;
983− else
984− regulatory->max_power_level = ratesArray[i];
985988 }
986989
987990 static void ath9k_hw_ar9287_set_addac(struct ath_hw *ah,
drivers/net/wireless/ath/ath9k/eeprom_def.c+33−29
@@ -1258,7 +1258,7 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah, · 1257 unmodified lines
12581258 u16 cfgCtl,
12591259 u8 twiceAntennaReduction,
12601260 u8 twiceMaxRegulatoryPower,
1261− u8 powerLimit)
1261+ u8 powerLimit, bool test)
12621262 {
12631263 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
12641264 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
@@ -1285,12 +1285,44 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah, · 20 unmodified lines
12851285
12861286 ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset);
12871287
1288+ regulatory->max_power_level = 0;
12881289 for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
12891290 ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
12901291 if (ratesArray[i] > AR5416_MAX_RATE_POWER)
12911292 ratesArray[i] = AR5416_MAX_RATE_POWER;
1293+ if (ratesArray[i] > regulatory->max_power_level)
1294+ regulatory->max_power_level = ratesArray[i];
12921295 }
12931296
1297+ if (!test) {
1298+ i = rate6mb;
1299+
1300+ if (IS_CHAN_HT40(chan))
1301+ i = rateHt40_0;
1302+ else if (IS_CHAN_HT20(chan))
1303+ i = rateHt20_0;
1304+
1305+ regulatory->max_power_level = ratesArray[i];
1306+ }
1307+
1308+ switch(ar5416_get_ntxchains(ah->txchainmask)) {
1309+ case 1:
1310+ break;
1311+ case 2:
1312+ regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
1313+ break;
1314+ case 3:
1315+ regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
1316+ break;
1317+ default:
1318+ ath_print(ath9k_hw_common(ah), ATH_DBG_EEPROM,
1319+ "Invalid chainmask configuration\n");
1320+ break;
1321+ }
1322+
1323+ if (test)
1324+ return;
1325+
12941326 if (AR_SREV_9280_20_OR_LATER(ah)) {
12951327 for (i = 0; i < Ar5416RateSize; i++) {
12961328 int8_t pwr_table_offset;
@@ -1387,34 +1419,6 @@ static void ath9k_hw_def_set_txpower(struct ath_hw *ah, · 90 unmodified lines
13871419 REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
13881420 ATH9K_POW_SM(pModal->pwrDecreaseFor3Chain, 6)
13891421 | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
1390−
1391− i = rate6mb;
1392−
1393− if (IS_CHAN_HT40(chan))
1394− i = rateHt40_0;
1395− else if (IS_CHAN_HT20(chan))
1396− i = rateHt20_0;
1397−
1398− if (AR_SREV_9280_20_OR_LATER(ah))
1399− regulatory->max_power_level =
1400− ratesArray[i] + AR5416_PWR_TABLE_OFFSET_DB * 2;
1401− else
1402− regulatory->max_power_level = ratesArray[i];
1403−
1404− switch(ar5416_get_ntxchains(ah->txchainmask)) {
1405− case 1:
1406− break;
1407− case 2:
1408− regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
1409− break;
1410− case 3:
1411− regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
1412− break;
1413− default:
1414− ath_print(ath9k_hw_common(ah), ATH_DBG_EEPROM,
1415− "Invalid chainmask configuration\n");
1416− break;
1417− }
14181422 }
14191423
14201424 static u8 ath9k_hw_def_get_num_ant_config(struct ath_hw *ah,
drivers/net/wireless/ath/ath9k/htc_drv_main.c+1−1
@@ -29,7 +29,7 @@ static void ath_update_txpow(struct ath9k_htc_priv *priv) · 28 unmodified lines
2929 struct ath_hw *ah = priv->ah;
3030
3131 if (priv->curtxpow != priv->txpowlimit) {
32− ath9k_hw_set_txpowerlimit(ah, priv->txpowlimit);
32+ ath9k_hw_set_txpowerlimit(ah, priv->txpowlimit, false);
3333 /* read back in case value is clamped */
3434 priv->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
3535 }
drivers/net/wireless/ath/ath9k/hw.c+3−3
@@ -1166,7 +1166,7 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah, · 1165 unmodified lines
11661166 channel->max_antenna_gain * 2,
11671167 channel->max_power * 2,
11681168 min((u32) MAX_RATE_POWER,
1169− (u32) regulatory->power_limit));
1169+ (u32) regulatory->power_limit), false);
11701170
11711171 ath9k_hw_rfbus_done(ah);
11721172
@@ -2165,7 +2165,7 @@ bool ath9k_hw_disable(struct ath_hw *ah) · 992 unmodified lines
21652165 }
21662166 EXPORT_SYMBOL(ath9k_hw_disable);
21672167
2168−void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
2168+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
21692169 {
21702170 struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
21712171 struct ath9k_channel *chan = ah->curchan;
@@ -2178,7 +2178,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit) · 6 unmodified lines
21782178 channel->max_antenna_gain * 2,
21792179 channel->max_power * 2,
21802180 min((u32) MAX_RATE_POWER,
2181− (u32) regulatory->power_limit));
2181+ (u32) regulatory->power_limit), test);
21822182 }
21832183 EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
21842184
drivers/net/wireless/ath/ath9k/hw.h+1−1
@@ -860,7 +860,7 @@ u32 ath9k_hw_getrxfilter(struct ath_hw *ah); · 859 unmodified lines
860860 void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
861861 bool ath9k_hw_phy_disable(struct ath_hw *ah);
862862 bool ath9k_hw_disable(struct ath_hw *ah);
863−void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
863+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
864864 void ath9k_hw_setopmode(struct ath_hw *ah);
865865 void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
866866 void ath9k_hw_setbssidmask(struct ath_hw *ah);
drivers/net/wireless/ath/ath9k/main.c+1−1
@@ -23,7 +23,7 @@ static void ath_update_txpow(struct ath_softc *sc) · 22 unmodified lines
2323 struct ath_hw *ah = sc->sc_ah;
2424
2525 if (sc->curtxpow != sc->config.txpowlimit) {
26− ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit);
26+ ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false);
2727 /* read back in case value is clamped */
2828 sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit;
2929 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t