ath5k: Add tx power calibration support
PATCH 3/3 ath5k: Add tx power calibration support
* Add tx power calibration support
* Add a few tx power limits
* Hardcode default power to 12.5dB
* Disable TPC for now
--- drivers/net/wireless/ath5k/ath5k.h | 35 +- drivers/net/wireless/ath5k/attach.c | 2 + drivers/net/wireless/ath5k/base.c | 13 +- drivers/net/wireless/ath5k/desc.c | 4 + drivers/net/wireless/ath5k/phy.c | 1169 +++++++++++++++++++++++++++++++++-- drivers/net/wireless/ath5k/reg.h | 19 + drivers/net/wireless/ath5k/reset.c | 35 +- 7 files changed, 1180 insertions(+), 97 deletions(-)
drivers/net/wireless/ath5k/ath5k.h +24 -11
@@ -204,9 +204,9 @@#define AR5K_TUNE_CWMAX_11B 1023#define AR5K_TUNE_CWMAX_XR 7#define AR5K_TUNE_NOISE_FLOOR -72 -#define AR5K_TUNE_MAX_TXPOWER 60 -#define AR5K_TUNE_DEFAULT_TXPOWER 30 -#define AR5K_TUNE_TPC_TXPOWER true +#define AR5K_TUNE_MAX_TXPOWER 63 +#define AR5K_TUNE_DEFAULT_TXPOWER 25 +#define AR5K_TUNE_TPC_TXPOWER false#define AR5K_TUNE_ANT_DIVERSITY true#define AR5K_TUNE_HWTXTRIES 4
@@ -551,11 +551,11 @@ enum ath5k_pkt_type {*/ #define AR5K_TXPOWER_OFDM (_r, _v) ( \ ((0 & 1) << ((_v) + 6)) | \ - (((ah->ah_txpower.txp_rates[(_r)]) & 0x3f) << (_v)) \ + (((ah->ah_txpower.txp_rates_power_table[(_r)]) & 0x3f) << (_v)) \ )#define AR5K_TXPOWER_CCK (_r, _v) ( \ - (ah->ah_txpower.txp_rates[(_r)] & 0x3f) << (_v) \ + (ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v) \ )/*
@@ -1085,13 +1085,25 @@ struct ath5k_hw {struct ath5k_gain ah_gain;u8 ah_offset[AR5K_MAX_RF_BANKS ]; +struct { -u16 txp_pcdac[AR5K_EEPROM_POWER_TABLE_SIZE ]; -u16 txp_rates[AR5K_MAX_RATES ]; -s16 txp_min; -s16 txp_max; +/* Temporary tables used for interpolation */ +u8 tmpL[AR5K_EEPROM_N_PD_GAINS ] + [AR5K_EEPROM_POWER_TABLE_SIZE ]; +u8 tmpR[AR5K_EEPROM_N_PD_GAINS ] + [AR5K_EEPROM_POWER_TABLE_SIZE ]; +u8 txp_pd_table[AR5K_EEPROM_POWER_TABLE_SIZE *2 ]; +u16 txp_rates_power_table[AR5K_MAX_RATES ]; +u8 txp_min_idx;bool txp_tpc; +/* Values in 0.25dB units */ +s16 txp_min_pwr; +s16 txp_max_pwr; +s16 txp_offset;s16 txp_ofdm; +/* Values in dB units */ +s16 txp_cck_ofdm_pwr_delta; +s16 txp_cck_ofdm_gainf_delta; } ah_txpower;struct {
@@ -1155,6 +1167,7 @@ extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_l/* EEPROM access functions */ extern int ath5k_eeprom_init (struct ath5k_hw *ah); +extern void ath5k_eeprom_detach (struct ath5k_hw *ah);extern int ath5k_eeprom_read_mac (struct ath5k_hw *ah,u8 *mac);extern bool ath5k_eeprom_is_hb63 (struct ath5k_hw *ah);
@@ -1250,8 +1263,8 @@ extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant);extern unsigned int ath5k_hw_get_def_antenna (struct ath5k_hw *ah);extern int ath5k_hw_phy_disable (struct ath5k_hw *ah);/* TX power setup */ -extern int ath5k_hw_txpower (struct ath5k_hw *ah,struct ieee80211_channel *channel,unsigned int txpower); -extern int ath5k_hw_set_txpower_limit (struct ath5k_hw *ah,unsigned int power); +extern int ath5k_hw_txpower (struct ath5k_hw *ah,struct ieee80211_channel *channel,u8 ee_mode,u8 txpower); +extern int ath5k_hw_set_txpower_limit (struct ath5k_hw *ah,u8 ee_mode,u8 txpower);/* * Functions used internaly
drivers/net/wireless/ath5k/attach.c +2 -0
@@ -342,6 +342,8 @@ void ath5k_hw_detach(struct ath5k_hw *ah)if (ah->ah_rf_banks !=NULL )kfree (ah->ah_rf_banks); +ath5k_eeprom_detach (ah); +/* assume interrupts are down */ kfree (ah); }
drivers/net/wireless/ath5k/base.c +7 -6
@@ -521,6 +521,7 @@ ath5k_pci_probe(struct pci_dev *pdev,IEEE80211_HW_NOISE_DBM ; hw->wiphy->interface_modes = +BIT (NL80211_IFTYPE_AP )|BIT (NL80211_IFTYPE_STATION ) |BIT (NL80211_IFTYPE_ADHOC ) |BIT (NL80211_IFTYPE_MESH_POINT );
@@ -1221,6 +1222,9 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) pktlen = skb->len; +/* FIXME: If we are in g mode and rate is a CCK rate +* subtract ah->ah_txpower.txp_cck_ofdm_pwr_delta +* from tx power (value is in dB units already) */ if (info->control.hw_key) { keyidx = info->control.hw_key->hw_key_idx; pktlen += info->control.hw_key->icv_len;
@@ -2049,6 +2053,9 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) antenna = sc->bsent &4 ?2 :1 ; } +/* FIXME: If we are in g mode and rate is a CCK rate +* subtract ah->ah_txpower.txp_cck_ofdm_pwr_delta +* from tx power (value is in dB units already) */ ds->ds_data = bf->skbaddr; ret = ah->ah_setup_tx_desc(ah, ds, skb->len, ieee80211_get_hdrlen_from_skb(skb),
@@ -2748,12 +2755,6 @@ ath5k_reset(struct ath5k_softc *sc, bool stop, bool change_channel) goto err; } -/* -* This is needed only to setup initial state -* but it's best done after a reset. -*/ -ath5k_hw_set_txpower_limit (sc->ah,0 ); - ret =ath5k_rx_start (sc);if (ret) {ATH5K_ERR (sc,"can't start recv logic\n" );
drivers/net/wireless/ath5k/desc.c +4 -0
@@ -194,6 +194,10 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,return -EINVAL ; } + tx_power += ah->ah_txpower.txp_offset; +if (tx_power >AR5K_TUNE_MAX_TXPOWER ) + tx_power =AR5K_TUNE_MAX_TXPOWER ; +/* Clear descriptor */ memset (&desc->ud.ds_tx5212,0 ,sizeof (struct ath5k_hw_5212_tx_desc ));
drivers/net/wireless/ath5k/phy.c +1103 -66
1,235 lines not on this page · raw message
drivers/net/wireless/ath5k/reg.h +19 -0
@@ -1554,6 +1554,19 @@/*===5212 Specific PCU registers===*/ /* +* Transmit power control register +*/ +#define AR5K_TPC 0x80e8 +#define AR5K_TPC_ACK 0x0000003f/* ack frames */ +#define AR5K_TPC_ACK_S 0 +#define AR5K_TPC_CTS 0x00003f00/* cts frames */ +#define AR5K_TPC_CTS_S 8 +#define AR5K_TPC_CHIRP 0x003f0000/* chirp frames */ +#define AR5K_TPC_CHIRP_S 16 +#define AR5K_TPC_DOPPLER 0x0f000000/* doppler chirp span */ +#define AR5K_TPC_DOPPLER_S 24 + +/* * XR (eXtended Range) mode register */ #define AR5K_XRMODE 0x80c0/* Register Address */
@@ -2550,6 +2563,12 @@#define AR5K_PHY_TPC_RG1 0xa258#define AR5K_PHY_TPC_RG1_NUM_PD_GAIN 0x0000c000#define AR5K_PHY_TPC_RG1_NUM_PD_GAIN_S 14 +#define AR5K_PHY_TPC_RG1_PDGAIN_1 0x00030000 +#define AR5K_PHY_TPC_RG1_PDGAIN_1_S 16 +#define AR5K_PHY_TPC_RG1_PDGAIN_2 0x000c0000 +#define AR5K_PHY_TPC_RG1_PDGAIN_2_S 18 +#define AR5K_PHY_TPC_RG1_PDGAIN_3 0x00300000 +#define AR5K_PHY_TPC_RG1_PDGAIN_3_S 20#define AR5K_PHY_TPC_RG5 0xa26C#define AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP 0x0000000F
drivers/net/wireless/ath5k/reset.c +21 -14
@@ -664,29 +664,35 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 *ant, u8 ee_mode) { struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; +s16 cck_ofdm_pwr_delta; -/* Set CCK to OFDM power delta */ -if (ah->ah_phy_revision >=AR5K_SREV_PHY_5212A ) { -int16_t cck_ofdm_pwr_delta; - -/* Adjust power delta for channel 14 */ -if (channel->center_freq ==2484 ) - cck_ofdm_pwr_delta = - ((ee->ee_cck_ofdm_power_delta - - ee->ee_scaled_cck_delta) *2 ) /10 ; -else - cck_ofdm_pwr_delta = - (ee->ee_cck_ofdm_power_delta *2 ) /10 ; +/* Adjust power delta for channel 14 */ +if (channel->center_freq ==2484 ) + cck_ofdm_pwr_delta = + ((ee->ee_cck_ofdm_power_delta - + ee->ee_scaled_cck_delta) *2 ) /10 ; +else + cck_ofdm_pwr_delta = + (ee->ee_cck_ofdm_power_delta *2 ) /10 ; +/* Set CCK to OFDM power delta on tx power +* adjustment register */ +if (ah->ah_phy_revision >=AR5K_SREV_PHY_5212A ) {if (channel->hw_value ==CHANNEL_G )ath5k_hw_reg_write (ah, -AR5K_REG_SM ((ee->ee_cck_ofdm_power_delta *-1 ), +AR5K_REG_SM ((ee->ee_cck_ofdm_gain_delta *-1 ),AR5K_PHY_TX_PWR_ADJ_CCK_GAIN_DELTA ) |AR5K_REG_SM ((cck_ofdm_pwr_delta *-1 ),AR5K_PHY_TX_PWR_ADJ_CCK_PCDAC_INDEX ),AR5K_PHY_TX_PWR_ADJ );else ath5k_hw_reg_write (ah,0 ,AR5K_PHY_TX_PWR_ADJ ); + }else { +/* For older revs we scale power on sw during tx power +* setup */ + ah->ah_txpower.txp_cck_ofdm_pwr_delta = cck_ofdm_pwr_delta; + ah->ah_txpower.txp_cck_ofdm_gainf_delta = + ee->ee_cck_ofdm_gain_delta; }/* Set antenna idle switch table */
@@ -994,7 +1000,8 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,/* * Set TX power (FIXME) */ - ret =ath5k_hw_txpower (ah, channel,AR5K_TUNE_DEFAULT_TXPOWER ); + ret =ath5k_hw_txpower (ah, channel, ee_mode, +AR5K_TUNE_DEFAULT_TXPOWER );if (ret)return ret;
Quoted 4 lines · Nick Kossifidis
* Add tx power calibration support
* Add a few tx power limits
* Hardcode default power to 12.5dB
* Disable TPC for now
...
drivers/net/wireless/ath5k/base.c ath5k_pci_probe(struct pci_dev *pdev, · line 527
Quoted 12 lines
drivers/net/wireless/ath5k/base.c +1
-0@@ -521,6 +521,7 @@ ath5k_pci_probe(struct pci_dev *pdev,IEEE80211_HW_NOISE_DBM ; hw->wiphy->interface_modes = +BIT (NL80211_IFTYPE_AP )|BIT (NL80211_IFTYPE_STATION ) |BIT (NL80211_IFTYPE_ADHOC ) |BIT (NL80211_IFTYPE_MESH_POINT );
Is this a typo or wrongly amended commit :)?
2009/3/10 Jiri Slaby <[email protected]>:
Quoted 9 lines · Nick Kossifidis
Quoted 5 lines
=C2=A0* Add tx power calibration support
=C2=A0* Add a few tx power limits
=C2=A0* Hardcode default power to 12.5dB
=C2=A0* Disable TPC for now...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/net/wireless/ath5k/base.c +0
-0@@ -521,6 +521,7 @@ ath5k_pci_probe(struct pci_dev *pdev,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
IEEE80211_HW_NOISE_DBM;
Quoted 3 lines
Quoted 3 lines
=C2=A0 =C2=A0 =C2=A0 =C2=A0hw->wiphy->interface_modes =3D
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BIT(NL80211_IFTYP=
E_AP)|
Quoted 1 line
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BIT(NL80211_I=
=46TYPE_STATION) |
Quoted 1 line
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BIT(NL80211_I=
=46TYPE_ADHOC) |
Quoted 1 line
Quoted 1 line
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BIT(NL80211_I=
=46TYPE_MESH_POINT);
Quoted 2 lines
Is this a typo or wrongly amended commit :)?
I wanted to do some basic testing for this on a spectrum analyzer so i had to switch it to AP mode and watch the beacons coming out, of course i forgot to remove it :P
--=20
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-) Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html