ath9k_hw: clean up and fix initial noise floor calibration
PATCH 1/4 ath9k_hw: clean up and fix initial noise floor calibration
On AR9003 the initial noise floor calibration is currently triggered at the end of the reset without allowing the hardware to update the baseband settings. This could potentially make scans in noisy environments a bit more unreliable, so use the same calibration sequence that is used on AR9002.
--- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 5 ++--- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 4 +++- drivers/net/wireless/ath/ath9k/calib.c | 10 ++++++++-- drivers/net/wireless/ath/ath9k/calib.h | 2 +- drivers/net/wireless/ath/ath9k/hw.c | 7 ++----- 5 files changed, 16 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_calib.c +2 -3
@@ -721,7 +721,7 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,*/ ath9k_hw_loadnf (ah, ah->curchan); -ath9k_hw_start_nfcal (ah); +ath9k_hw_start_nfcal (ah, false); }return iscaldone;
@@ -869,8 +869,7 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)ar9002_hw_pa_cal (ah, true);/* Do NF Calibration after DC offset and other calibrations */ -REG_WRITE (ah,AR_PHY_AGC_CONTROL , -REG_READ (ah,AR_PHY_AGC_CONTROL ) |AR_PHY_AGC_CONTROL_NF ); +ath9k_hw_start_nfcal (ah, true); ah->cal_list = ah->cal_list_last = ah->cal_list_curr =NULL ;
drivers/net/wireless/ath/ath9k/ar9003_calib.c +3 -1
@@ -156,7 +156,7 @@ static bool ar9003_hw_calibrate(struct ath_hw *ah,ath9k_hw_loadnf (ah, ah->curchan);/* start NF calibration, without updating BB NF register */ -ath9k_hw_start_nfcal (ah); +ath9k_hw_start_nfcal (ah, false); }return iscaldone;
@@ -762,6 +762,8 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah,/* Revert chainmasks to their original values before NF cal */ ar9003_hw_set_chain_masks (ah, ah->rxchainmask, ah->txchainmask); +ath9k_hw_start_nfcal (ah, true); +/* Initialize list pointers */ ah->cal_list = ah->cal_list_last = ah->cal_list_curr =NULL ;
drivers/net/wireless/ath/ath9k/calib.c +8 -2
@@ -158,12 +158,18 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah) }EXPORT_SYMBOL (ath9k_hw_reset_calvalid); -void ath9k_hw_start_nfcal (struct ath_hw *ah) +void ath9k_hw_start_nfcal (struct ath_hw *ah,bool update) {REG_SET_BIT (ah,AR_PHY_AGC_CONTROL ,AR_PHY_AGC_CONTROL_ENABLE_NF ); -REG_SET_BIT (ah,AR_PHY_AGC_CONTROL , + +if (update) +REG_CLR_BIT (ah,AR_PHY_AGC_CONTROL ,AR_PHY_AGC_CONTROL_NO_UPDATE_NF ); +else +REG_SET_BIT (ah,AR_PHY_AGC_CONTROL , +AR_PHY_AGC_CONTROL_NO_UPDATE_NF ); +REG_SET_BIT (ah,AR_PHY_AGC_CONTROL ,AR_PHY_AGC_CONTROL_NF ); }
drivers/net/wireless/ath/ath9k/calib.h +1 -1
@@ -108,7 +108,7 @@ struct ath9k_pacal_info{ };bool ath9k_hw_reset_calvalid (struct ath_hw *ah); -void ath9k_hw_start_nfcal (struct ath_hw *ah); +void ath9k_hw_start_nfcal (struct ath_hw *ah,bool update);void ath9k_hw_loadnf (struct ath_hw *ah,struct ath9k_channel *chan);int16_t ath9k_hw_getnf (struct ath_hw *ah,struct ath9k_channel *chan);
drivers/net/wireless/ath/ath9k/hw.c +2 -5
@@ -1256,7 +1256,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,if (ath9k_hw_channel_change (ah, chan)) {ath9k_hw_loadnf (ah, ah->curchan); -ath9k_hw_start_nfcal (ah); +ath9k_hw_start_nfcal (ah, true);return 0 ; } }
@@ -1461,11 +1461,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,if (ah->btcoex_hw.enabled)ath9k_hw_btcoex_enable (ah); -if (AR_SREV_9300_20_OR_LATER (ah)) { -ath9k_hw_loadnf (ah, curchan); -ath9k_hw_start_nfcal (ah); +if (AR_SREV_9300_20_OR_LATER (ah))ar9003_hw_bb_watchdog_config (ah); - }return 0 ; }
Signature · 1 line
1.6.4.2
PATCH 2/4 ath9k_hw: fix periodic noise floor calibration on AR9003
The periodic noise floor calibration is broken on this chip family, because it keeps triggering a software-filtered noise floor calibration, but never reads the result before uploading the history buffer value to the hardware.
Fix this with a call to ath9k_hw_getnf(), just like on AR9002.
--- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_calib.c +6 -0
@@ -149,6 +149,12 @@ static bool ar9003_hw_calibrate(struct ath_hw *ah,/* Do NF cal only at longer intervals */ if (longcal) {/* +* Get the value from the previous NF cal and update +* history buffer. +*/ +ath9k_hw_getnf (ah, chan); + +/* * Load the NF from history buffer of the current channel. * NF is slow time-variant, so it is OK to use a historical * value.
Signature · 1 line
1.6.4.2
PATCH 3/4 ath9k: fix a crash in the PA predistortion apply function
When updating the PAPRD table in hardware, PAPRD itself needs to be disabled first, otherwise the hardware can throw a data bus error, which upsets at least some platforms.
--- drivers/net/wireless/ath/ath9k/main.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +1 -0
@@ -239,6 +239,7 @@ static void ath_paprd_activate(struct ath_softc *sc)return ;ath9k_ps_wakeup (sc); +ar9003_paprd_enable (ah, false);for (chain =0 ; chain <AR9300_MAX_CHAINS ; chain++) {if (!(ah->caps.tx_chainmask &BIT (chain)))continue ;
Signature · 1 line
1.6.4.2
PATCH 4/4 ath9k_hw: fix analog shift register writes on AR9003
Writes to the analog shift registers, which are issues by the initval programming function, require a 100 usec delay (similar to AR9002, but in a different register range).
--- drivers/net/wireless/ath/ath9k/ar9003_phy.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/ar9003_phy.c +5 -1
@@ -542,7 +542,11 @@ static void ar9003_hw_prog_ini(struct ath_hw *ah,u32 reg =INI_RA (iniArr, i,0 );u32 val =INI_RA (iniArr, i, column); -REG_WRITE (ah, reg, val); +if (reg >=0x16000 && reg <0x17000 ) +ath9k_hw_analog_shift_regwrite (ah, reg, val); +else +REG_WRITE (ah, reg, val); +DO_DELAY (regWrites); } }
Signature · 1 line
1.6.4.2
Re: [PATCH 4/4] ath9k_hw: fix analog shift register writes on AR9003
Quoted 5 lines · Felix Fietkau
Writes to the analog shift registers, which are issues by the initval programming function, require a 100 usec delay (similar to AR9002, but in a different register range).
Signed-off-by Felix Fietkau <[email protected]>
For all 4
Luis