ath9k_hw: Add capability flag for Antenna diversity and combining feature
PATCH 1/3 ath9k_hw: Add capability flag for Antenna diversity and combining feature
This is enabled only for ar9285.
--- drivers/net/wireless/ath/ath9k/eeprom.h | 2 ++ drivers/net/wireless/ath/ath9k/eeprom_4k.c | 4 ++++ drivers/net/wireless/ath/ath9k/hw.c | 9 +++++++++ drivers/net/wireless/ath/ath9k/hw.h | 1 + 4 files changed, 16 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/eeprom.h +2 -0
@@ -266,6 +266,8 @@ enum eeprom_param {EEP_INTERNAL_REGULATOR ,EEP_SWREG ,EEP_PAPRD , +EEP_MODAL_VER , + EEP_ANT_DIV_CTL1, }; enum ar5416_rates {
drivers/net/wireless/ath/ath9k/eeprom_4k.c +4 -0
@@ -213,6 +213,10 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,return 0 ;case EEP_PWR_TABLE_OFFSET :return AR5416_PWR_TABLE_OFFSET_DB ; +case EEP_MODAL_VER : +return pModal->version; +case EEP_ANT_DIV_CTL1 : +return pModal->antdiv_ctl1;default :return 0 ; }
drivers/net/wireless/ath/ath9k/hw.c +9 -0
@@ -2056,6 +2056,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;u16 capField =0 , eeval; +u8 ant_div_ctl1; eeval = ah->eep_ops->get_eeprom (ah,EEP_REG_0 ); regulatory->current_rd = eeval;
@@ -2280,6 +2281,14 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)if (AR_SREV_9287_10_OR_LATER (ah) ||AR_SREV_9271 (ah)) pCap->hw_caps |=ATH9K_HW_CAP_SGI_20 ; +if (AR_SREV_9285 (ah)) +if (ah->eep_ops->get_eeprom (ah,EEP_MODAL_VER ) >=3 ) { + ant_div_ctl1 = + ah->eep_ops->get_eeprom (ah,EEP_ANT_DIV_CTL1 ); +if ((ant_div_ctl1 &0x1 ) && ((ant_div_ctl1 >>3 ) &0x1 )) + pCap->hw_caps |=ATH9K_HW_CAP_ANT_DIV_COMB ; + } +return 0 ; }
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -204,6 +204,7 @@ enum ath9k_hw_caps {ATH9K_HW_CAP_FASTCLOCK =BIT (20 ),ATH9K_HW_CAP_SGI_20 =BIT (21 ),ATH9K_HW_CAP_PAPRD =BIT (22 ), + ATH9K_HW_CAP_ANT_DIV_COMB = BIT(23), }; struct ath9k_hw_capabilities {
Signature · 1 line
1.7.0.4
PATCH 2/3 ath9k_hw: Add functions to get/set antenna diversity configuration
--- drivers/net/wireless/ath/ath9k/ar9002_phy.c | 35 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/ar9002_phy.h | 2 + drivers/net/wireless/ath/ath9k/hw.h | 10 +++++++ 3 files changed, 47 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_phy.c +35 -0
@@ -530,3 +530,38 @@ void ar9002_hw_attach_phy_ops(struct ath_hw *ah)ar9002_hw_set_nf_limits (ah); } + +void ath9k_hw_antdiv_comb_conf_get (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf) +{ +u32 regval; + + regval =REG_READ (ah,AR_PHY_MULTICHAIN_GAIN_CTL ); + antconf->main_lna_conf = (regval &AR_PHY_9285_ANT_DIV_MAIN_LNACONF ) >> +AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S ; + antconf->alt_lna_conf = (regval &AR_PHY_9285_ANT_DIV_ALT_LNACONF ) >> +AR_PHY_9285_ANT_DIV_ALT_LNACONF_S ; + antconf->fast_div_bias = (regval &AR_PHY_9285_FAST_DIV_BIAS ) >> +AR_PHY_9285_FAST_DIV_BIAS_S ; +} +EXPORT_SYMBOL (ath9k_hw_antdiv_comb_conf_get); + +void ath9k_hw_antdiv_comb_conf_set (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf) +{ +u32 regval; + + regval =REG_READ (ah,AR_PHY_MULTICHAIN_GAIN_CTL ); + regval &= ~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF | +AR_PHY_9285_ANT_DIV_ALT_LNACONF | +AR_PHY_9285_FAST_DIV_BIAS ); + regval |= ((antconf->main_lna_conf <<AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S ) + &AR_PHY_9285_ANT_DIV_MAIN_LNACONF ); + regval |= ((antconf->alt_lna_conf <<AR_PHY_9285_ANT_DIV_ALT_LNACONF_S ) + &AR_PHY_9285_ANT_DIV_ALT_LNACONF ); + regval |= ((antconf->fast_div_bias <<AR_PHY_9285_FAST_DIV_BIAS_S ) + &AR_PHY_9285_FAST_DIV_BIAS ); + +REG_WRITE (ah,AR_PHY_MULTICHAIN_GAIN_CTL , regval); +} +EXPORT_SYMBOL (ath9k_hw_antdiv_comb_conf_set);
drivers/net/wireless/ath/ath9k/ar9002_phy.h +2 -0
@@ -302,6 +302,8 @@#define AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE 0x80000000#define AR_PHY_MULTICHAIN_GAIN_CTL 0x99ac +#define AR_PHY_9285_FAST_DIV_BIAS 0x00007E00 +#define AR_PHY_9285_FAST_DIV_BIAS_S 9#define AR_PHY_9285_ANT_DIV_CTL_ALL 0x7f000000#define AR_PHY_9285_ANT_DIV_CTL 0x01000000#define AR_PHY_9285_ANT_DIV_CTL_S 24
drivers/net/wireless/ath/ath9k/hw.h +10 -0
@@ -496,6 +496,12 @@ struct ath_gen_timer_table { } timer_mask; }; +struct ath_hw_antcomb_conf { +u8 main_lna_conf; +u8 alt_lna_conf; +u8 fast_div_bias; +}; +/** * struct ath_hw_private_ops - callbacks used internally by hardware code *
@@ -889,6 +895,10 @@ void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio,void ath9k_hw_set_gpio (struct ath_hw *ah,u32 gpio,u32 val);u32 ath9k_hw_getdefantenna (struct ath_hw *ah);void ath9k_hw_setantenna (struct ath_hw *ah,u32 antenna); +void ath9k_hw_antdiv_comb_conf_get (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf); +void ath9k_hw_antdiv_comb_conf_set (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf);/* General Operation */ bool ath9k_hw_wait (struct ath_hw *ah,u32 reg,u32 mask,u32 val,u32 timeout);
Signature · 1 line
1.7.0.4
PATCH 3/3 ath9k: Implement an algorithm for Antenna diversity and combining
In reply to Vasanthakumar ThiagarajanThis algorithm chooses the best main and alt lna out of LNA1, LNA2, LNA1+LNA2 and LNA1-LNA2 to improve rx for single chain chips(AR9285). This would greatly improve rx when there is only one antenna is connected with AR9285.
--- drivers/net/wireless/ath/ath9k/ath9k.h | 56 ++++ drivers/net/wireless/ath/ath9k/init.c | 3 + drivers/net/wireless/ath/ath9k/recv.c | 545 ++++++++++++++++++++++++++++++++ 3 files changed, 604 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +56 -0
@@ -481,6 +481,60 @@ struct ath_led {void ath_init_leds (struct ath_softc *sc);void ath_deinit_leds (struct ath_softc *sc); +/* Antenna diversity/combining */ +#define ATH_ANT_RX_CURRENT_SHIFT 4 +#define ATH_ANT_RX_MAIN_SHIFT 2 +#define ATH_ANT_RX_MASK 0x3 + +#define ATH_ANT_DIV_COMB_SHORT_SCAN_INTR 50 +#define ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT 0x100 +#define ATH_ANT_DIV_COMB_MAX_PKTCOUNT 0x200 +#define ATH_ANT_DIV_COMB_INIT_COUNT 95 +#define ATH_ANT_DIV_COMB_MAX_COUNT 100 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO 30 +#define ATH_ANT_DIV_COMB_ALT_ANT_RATIO2 20 + +#define ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA -3 +#define ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA -1 +#define ATH_ANT_DIV_COMB_LNA1_DELTA_HI -4 +#define ATH_ANT_DIV_COMB_LNA1_DELTA_MID -2 +#define ATH_ANT_DIV_COMB_LNA1_DELTA_LOW 2 + +enum ath9k_ant_div_comb_lna_conf { +ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2 , +ATH_ANT_DIV_COMB_LNA2 , +ATH_ANT_DIV_COMB_LNA1 , +ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2 , +}; + +struct ath_ant_comb { +u16 count; +u16 total_pkt_count; +bool scan; +bool scan_not_start; +int main_total_rssi; +int alt_total_rssi; +int alt_recv_cnt; +int main_recv_cnt; +int rssi_lna1; +int rssi_lna2; +int rssi_add; +int rssi_sub; +int rssi_first; +int rssi_second; +int rssi_third; +bool alt_good; +int quick_scan_cnt; +int main_conf; +enum ath9k_ant_div_comb_lna_conf first_quick_scan_conf; +enum ath9k_ant_div_comb_lna_conf second_quick_scan_conf; +int first_bias; +int second_bias; +bool first_ratio; +bool second_ratio; +unsigned long scan_start_time; +}; +/********************/ /* Main driver core */ /********************/
@@ -597,6 +651,8 @@ struct ath_softc {struct ath_btcoex btcoex;struct ath_descdma txsdma; + +struct ath_ant_comb ant_comb; };struct ath_wiphy {
drivers/net/wireless/ath/ath9k/init.c +3 -0
@@ -531,6 +531,9 @@ static void ath9k_init_misc(struct ath_softc *sc) sc->beacon.bslot[i] =NULL ; sc->beacon.bslot_aphy[i] =NULL ; } + +if (sc->sc_ah->caps.hw_caps &ATH9K_HW_CAP_ANT_DIV_COMB ) + sc->ant_comb.count =ATH_ANT_DIV_COMB_INIT_COUNT ; } static int ath9k_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
drivers/net/wireless/ath/ath9k/recv.c +545 -0
563 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH 3/3] ath9k: Implement an algorithm for Antenna diversity and combining
Quoted 5 lines · Vasanthakumar Thiagarajan
This algorithm chooses the best main and alt lna out of LNA1, LNA2, LNA1+LNA2 and LNA1-LNA2 to improve rx for single chain chips(AR9285). This would greatly improve rx when there is only one antenna is connected with AR9285.
Quoted 7 lines
Signed-off-by Vasanthakumar Thiagarajan <[email protected]>--- drivers/net/wireless/ath/ath9k/ath9k.h | 56 ++++ drivers/net/wireless/ath/ath9k/init.c | 3 + drivers/net/wireless/ath/ath9k/recv.c | 545 ++++++++++++++++++++++++++++++++ 3 files changed, 604 insertions(+), 0 deletions(-)
These patches are V2, sorry forgot to mention.
Vasanth