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
@@ -265,6 +265,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
@@ -2052,6 +2052,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;
@@ -2276,6 +2277,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 | 39 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/ar9002_phy.h | 2 + drivers/net/wireless/ath/ath9k/hw-ops.h | 14 +++++++++ drivers/net/wireless/ath/ath9k/hw.h | 10 +++++++ 4 files changed, 65 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_phy.c +39 -0
@@ -513,9 +513,43 @@ static void ar9002_hw_set_nf_limits(struct ath_hw *ah) } } +static void ar9002_hw_ant_div_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 ; +} + +static void ar9002_hw_ant_div_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); +} +void ar9002_hw_attach_phy_ops (struct ath_hw *ah) {struct ath_hw_private_ops *priv_ops =ath9k_hw_private_ops (ah); +struct ath_hw_ops *ops =ath9k_hw_ops (ah); priv_ops->set_rf_regs =NULL ; priv_ops->rf_alloc_ext_banks =NULL ;
@@ -526,5 +560,10 @@ void ar9002_hw_attach_phy_ops(struct ath_hw *ah) priv_ops->compute_pll_control = ar9002_hw_compute_pll_control; priv_ops->do_getnf = ar9002_hw_do_getnf; +if (AR_SREV_9285 (ah)) { + ops->ant_div_comb_conf_get = ar9002_hw_ant_div_comb_conf_get; + ops->ant_div_comb_conf_set = ar9002_hw_ant_div_comb_conf_set; + } +ar9002_hw_set_nf_limits (ah); }
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-ops.h +14 -0
@@ -139,6 +139,20 @@ static inline void ath9k_hw_ani_monitor(struct ath_hw *ah,ath9k_hw_ops (ah)->ani_monitor (ah, chan); } +static inline void ath9k_hw_antdiv_comb_conf_get (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf) +{ +if (ath9k_hw_ops (ah)->ant_div_comb_conf_get) +ath9k_hw_ops (ah)->ant_div_comb_conf_get (ah, antconf); +} + +static inline void ath9k_hw_antdiv_comb_conf_set (struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf) +{ +if (ath9k_hw_ops (ah)->ant_div_comb_conf_set) +ath9k_hw_ops (ah)->ant_div_comb_conf_set (ah, antconf); +} +/* Private hardware call ops */ /* PHY ops */
drivers/net/wireless/ath/ath9k/hw.h +10 -0
@@ -489,6 +489,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 *
@@ -627,6 +633,10 @@ struct ath_hw_ops {void (*ani_proc_mib_event)(struct ath_hw *ah);void (*ani_monitor)(struct ath_hw *ah,struct ath9k_channel *chan); +void (*ant_div_comb_conf_get)(struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf); +void (*ant_div_comb_conf_set)(struct ath_hw *ah, +struct ath_hw_antcomb_conf *antconf); };struct ath_nf_limits {
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 | 5 + drivers/net/wireless/ath/ath9k/recv.c | 531 ++++++++++++++++++++++++++++++++ 3 files changed, 592 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +56 -0
@@ -488,6 +488,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 */ /********************/
@@ -604,6 +658,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 +5 -0
@@ -531,6 +531,11 @@ 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 ) { +memset (&sc->ant_comb,0 ,sizeof (struct ath_ant_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 +531 -0
543 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 12 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.
Signed-off-by Vasanthakumar Thiagarajan <[email protected]>drivers/net/wireless/ath/ath9k/init.c +0
-0
drivers/net/wireless/ath/ath9k/init.c static void ath9k_init_misc(struct ath_softc *sc) · line 536
Quoted 6 lines
drivers/net/wireless/ath/ath9k/init.c +3
-0@@ -531,6 +531,11 @@ 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) { + memset(&sc->ant_comb, 0, sizeof(struct ath_ant_comb));
I do not believe this memset is required since we kzalloc()'d the ah struct.
Quoted 10 lines
drivers/net/wireless/ath/ath9k/init.c +2
-0+ 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 +0
-0
drivers/net/wireless/ath/ath9k/recv.c static void ath9k_rx_skb_postprocess(struct ath_common *common, · line 1078
Quoted 6 lines
drivers/net/wireless/ath/ath9k/recv.c +3
-0@@ -1073,6 +1073,534 @@ static void ath9k_rx_skb_postprocess(struct ath_common *common, rxs->flag &= ~RX_FLAG_DECRYPTED; } +/* Antenna diversity and combining */ +static void ath_ant_comb_scan (struct ath_softc *sc,struct ath_rx_status *rs) +{
<-- snip -->
drivers/net/wireless/ath/ath9k/recv.c static void ath9k_rx_skb_postprocess(struct ath_common *common, · line 1133
Quoted 1 line
drivers/net/wireless/ath/ath9k/recv.c +1
-0+ ath9k_hw_antdiv_comb_conf_get(sc->sc_ah, &div_ant_conf);
<-- snip -->
drivers/net/wireless/ath/ath9k/recv.c static void ath9k_rx_skb_postprocess(struct ath_common *common, · line 1594
Quoted 1 line
drivers/net/wireless/ath/ath9k/recv.c +1
-0+ ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf);
<-- snip -->
drivers/net/wireless/ath/ath9k/recv.c static void ath9k_rx_skb_postprocess(struct ath_common *common, · line 1081
Quoted 1 line
drivers/net/wireless/ath/ath9k/recv.c +1
-0+}
Wow this routine is pretty large. Could you split this up into a few helpers which describe what they do ?
Also notice how this ended up calling ath9k_hw_antdiv_comb_conf_get() and ath9k_hw_antdiv_comb_conf_set(), the only callers of those routines, and this itself is done when:
Quoted 13 lines
drivers/net/wireless/ath/ath9k/recv.c +4
-0+ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) { struct ath_buf *bf;@@ -1210,6 +1738,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) PS_WAIT_FOR_PSPOLL_DATA)))) ath_rx_ps(sc, skb); + if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) + ath_ant_comb_scan(sc, &rs); + ath_rx_send_to_mac80211(hw, sc, skb, rxs);
Quoted 1 line
requeue:
So the call currently really does not require to be abstracted away unless we expect another 1x1 device where it will have its own set of calls, eventually.
Luis
Re: [PATCH 3/3] ath9k: Implement an algorithm for Antenna diversity and combining
Quoted 9 lines · Luis R. Rodriguez
Quoted 6 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.
Signed-off-by Vasanthakumar Thiagarajan <[email protected]>
Quoted 13 lines
drivers/net/wireless/ath/ath9k/init.c static void ath9k_init_misc(struct ath_softc *sc) · line 536
Quoted 11 lines
drivers/net/wireless/ath/ath9k/init.c +3
-0@@ -531,6 +531,11 @@ 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) { + memset(&sc->ant_comb, 0, sizeof(struct ath_ant_comb));I do not believe this memset is required since we kzalloc()'d the ah struct.
that,s true. thanks.
Quoted 3 lines
Wow this routine is pretty large. Could you split this up into a few helpers which describe what they do ?
right, this one is pretty large, let me see if I can split things up.
Quoted 17 lines
Also notice how this ended up calling
ath9k_hw_antdiv_comb_conf_get()andath9k_hw_antdiv_comb_conf_set(), the only callers of those routines, and this itself is done when:Quoted 13 lines
drivers/net/wireless/ath/ath9k/init.c +4
-0+ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) { struct ath_buf *bf;@@ -1210,6 +1738,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) PS_WAIT_FOR_PSPOLL_DATA)))) ath_rx_ps(sc, skb); + if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) + ath_ant_comb_scan(sc, &rs); + ath_rx_send_to_mac80211(hw, sc, skb, rxs);
Quoted 5 lines
Quoted 1 line
requeue:
So the call currently really does not require to be abstracted away unless we expect another 1x1 device where it will have its own set of calls, eventually.
hm, i actually planned not to abstract, not sure how I ended up doing this one. I'll send the next version of this series. thanks.
Vasanth