ath9k: Add information about AR9285 diversity
PATCH 1/5 ath9k: Add information about AR9285 diversity
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/antenna.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/net/wireless/ath/ath9k/antenna.c +39 -0
@@ -16,6 +16,45 @@#include "ath9k.h" +/* +* AR9285 +* ====== +* +* EEPROM has 2 4-bit fields containing the card configuration. +* +* antdiv_ctl1: +* ------------ +* bb_enable_ant_div_lnadiv : 1 +* bb_ant_div_alt_gaintb : 1 +* bb_ant_div_main_gaintb : 1 +* bb_enable_ant_fast_div : 1 +* +* antdiv_ctl2: +* ----------- +* bb_ant_div_alt_lnaconf : 2 +* bb_ant_div_main_lnaconf : 2 +* +* The EEPROM bits are used as follows: +* ------------------------------------ +* +* bb_enable_ant_div_lnadiv - Enable LNA path rx antenna diversity/combining. +* Set in AR_PHY_MULTICHAIN_GAIN_CTL. +* +* bb_ant_div_[alt/main]_gaintb - 0 -> Antenna config Alt/Main uses gaintable 0 +* 1 -> Antenna config Alt/Main uses gaintable 1 +* Set in AR_PHY_MULTICHAIN_GAIN_CTL. +* +* bb_enable_ant_fast_div - Enable fast antenna diversity. +* Set in AR_PHY_CCK_DETECT. +* +* bb_ant_div_[alt/main]_lnaconf - Alt/Main LNA diversity/combining input config. +* Set in AR_PHY_MULTICHAIN_GAIN_CTL. +* 10=LNA1 +* 01=LNA2 +* 11=LNA1+LNA2 +* 00=LNA1-LNA2 +*/ +static inline bool ath_is_alt_ant_ratio_better (int alt_ratio,int maxdelta,int mindelta,int main_rssi_avg,int alt_rssi_avg,int pkt_count)
Signature · 1 line
1.8.3.3
PATCH 2/5 ath9k: Print LNA combining mode during init
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/hw.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +9 -15
@@ -2559,34 +2559,28 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)if (AR_SREV_9287_11_OR_LATER (ah) ||AR_SREV_9271 (ah)) pCap->hw_caps |=ATH9K_HW_CAP_SGI_20 ; -if (AR_SREV_9285 (ah)) +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 )) +if ((ant_div_ctl1 &0x1 ) && ((ant_div_ctl1 >>3 ) &0x1 )) { pCap->hw_caps |=ATH9K_HW_CAP_ANT_DIV_COMB ; +ath_info (common,"Enable LNA combining\n" ); + } } + } +if (AR_SREV_9300_20_OR_LATER (ah)) {if (ah->eep_ops->get_eeprom (ah,EEP_CHAIN_MASK_REDUCE )) pCap->hw_caps |=ATH9K_HW_CAP_APM ; } -if (AR_SREV_9330 (ah) ||AR_SREV_9485 (ah) ||AR_SREV_9565 (ah)) { ant_div_ctl1 = ah->eep_ops->get_eeprom (ah,EEP_ANT_DIV_CTL1 ); -/* -* enable the diversity-combining algorithm only when -* both enable_lna_div and enable_fast_div are set -* Table for Diversity -* ant_div_alt_lnaconf bit 0-1 -* ant_div_main_lnaconf bit 2-3 -* ant_div_alt_gaintb bit 4 -* ant_div_main_gaintb bit 5 -* enable_ant_div_lnadiv bit 6 -* enable_ant_fast_div bit 7 -*/ -if ((ant_div_ctl1 >>0x6 ) ==0x3 ) +if ((ant_div_ctl1 >>0x6 ) ==0x3 ) { pCap->hw_caps |=ATH9K_HW_CAP_ANT_DIV_COMB ; +ath_info (common,"Enable LNA combining\n" ); + } }if (ath9k_hw_dfs_tested (ah))
Signature · 1 line
1.8.3.3
PATCH 3/5 ath9k: Cleanup BT/WLAN RX diversity
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
For single-chain WLAN+BT cards, the BT antenna can be used for WLAN RX when the BT interface is disabled. Rename the modparam "antenna_diversity" to "bt_ant_diversity" to clarify this.
Also, there is no need to check if btcoex is disabled to enable WLAN/BT RX diversity.
--- drivers/net/wireless/ath/ath.h | 2 +- drivers/net/wireless/ath/ath9k/antenna.c | 2 +- drivers/net/wireless/ath/ath9k/debug.c | 32 ++++++++++++++++---------------- drivers/net/wireless/ath/ath9k/init.c | 30 +++++++++++++++++++++++------- 4 files changed, 41 insertions(+), 25 deletions(-)
drivers/net/wireless/ath/ath.h +1 -1
@@ -159,7 +159,7 @@ struct ath_common {bool btcoex_enabled;bool disable_ani; -bool antenna_diversity; +bool bt_ant_diversity; }; struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
drivers/net/wireless/ath/ath9k/antenna.c +1 -1
@@ -831,6 +831,6 @@ void ath_ant_comb_update(struct ath_softc *sc)ath9k_hw_antdiv_comb_conf_set (ah, &div_ant_conf); -if (common->antenna_diversity) +if (common->bt_ant_diversity)ath9k_hw_antctrl_shared_chain_lnadiv (ah, true); }
drivers/net/wireless/ath/ath9k/debug.c +16 -16
@@ -270,25 +270,25 @@ static const struct file_operations fops_ani = { .llseek = default_llseek, }; -static ssize_t read_file_ant_diversity (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t read_file_bt_ant_diversity (struct file *file,char __user *user_buf, +size_t count,loff_t *ppos) {struct ath_softc *sc = file->private_data;struct ath_common *common =ath9k_hw_common (sc->sc_ah);char buf[32 ];unsigned int len; - len =sprintf (buf,"%d\n" , common->antenna_diversity); + len =sprintf (buf,"%d\n" , common->bt_ant_diversity);return simple_read_from_buffer (user_buf, count, ppos, buf, len); } -static ssize_t write_file_ant_diversity (struct file *file, -const char __user *user_buf, -size_t count,loff_t *ppos) +static ssize_t write_file_bt_ant_diversity (struct file *file, +const char __user *user_buf, +size_t count,loff_t *ppos) {struct ath_softc *sc = file->private_data;struct ath_common *common =ath9k_hw_common (sc->sc_ah); -unsigned long antenna_diversity; +unsigned long bt_ant_diversity;char buf[32 ];ssize_t len;
@@ -300,22 +300,22 @@ static ssize_t write_file_ant_diversity(struct file *file, goto exit; buf[len] ='\0' ; -if (kstrtoul (buf,0 , &antenna_diversity)) +if (kstrtoul (buf,0 , &bt_ant_diversity))return -EINVAL ; - common->antenna_diversity = !!antenna_diversity; + common->bt_ant_diversity = !!bt_ant_diversity;ath9k_ps_wakeup (sc);ath_ant_comb_update (sc); -ath_dbg (common,CONFIG ,"Antenna diversity: %d\n" , - common->antenna_diversity); +ath_dbg (common,CONFIG ,"BT/WLAN RX Antenna diversity: %d\n" , + common->bt_ant_diversity);ath9k_ps_restore (sc); exit:return count; } -static const struct file_operations fops_ant_diversity = { - .read = read_file_ant_diversity, - .write = write_file_ant_diversity, +static const struct file_operations fops_bt_ant_diversity = { + .read = read_file_bt_ant_diversity, + .write = write_file_bt_ant_diversity, .open = simple_open, .owner =THIS_MODULE , .llseek = default_llseek,
@@ -1814,8 +1814,8 @@ int ath9k_init_debug(struct ath_hw *ah) sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);debugfs_create_u32 ("gpio_val" ,S_IRUSR |S_IWUSR , sc->debug.debugfs_phy, &sc->sc_ah->gpio_val); -debugfs_create_file ("diversity" ,S_IRUSR |S_IWUSR , - sc->debug.debugfs_phy, sc, &fops_ant_diversity); +debugfs_create_file ("bt_ant_diversity" ,S_IRUSR |S_IWUSR , + sc->debug.debugfs_phy, sc, &fops_bt_ant_diversity);#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT debugfs_create_file ("btcoex" ,S_IRUSR , sc->debug.debugfs_phy, sc, &fops_btcoex);
drivers/net/wireless/ath/ath9k/init.c +23 -7
@@ -53,9 +53,9 @@ static int ath9k_btcoex_enable;module_param_named (btcoex_enable, ath9k_btcoex_enable, int,0444 );MODULE_PARM_DESC (btcoex_enable,"Enable wifi-BT coexistence" ); -static int ath9k_enable_diversity; -module_param_named (enable_diversity, ath9k_enable_diversity, int,0444 ); -MODULE_PARM_DESC (enable_diversity,"Enable Antenna diversity for AR9565" ); +static int ath9k_bt_ant_diversity; +module_param_named (bt_antenna_diversity, ath9k_bt_ant_diversity, int,0444 ); +MODULE_PARM_DESC (bt_antenna_diversity,"Use BT antenna for WLAN RX diversity" );bool is_ath9k_unloaded;/* We use the hw_value as an index into our private channel structure */
@@ -631,11 +631,27 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,ath9k_init_platform (sc);/* -* Enable Antenna diversity only when BTCOEX is disabled -* and the user manually requests the feature. +* Enable WLAN RX Antenna diversity for WLAN/BT combo +* chips only when the user manually requests the feature. +* +* The BT antenna can be used for WLAN RX when the +* BT interface is disabled. Currently, there is no +* mechanism in the kernel to pass such information +* between the WLAN and BT subsystems. The user has +* to make sure that the BT card is disabled when enabling +* WLAN RX diversity. +* +* Cards which can use this feature are: +* +* WB225 - AR9485 + AR3012 +* WB335 - AR9565 (WLAN+BT Combo SoC). +* +* Diversity combining is available for WB225 and WB335. +* WB195 which is a AR9285 + AR3011 card doesn't have +* this feature. */ -if (!common->btcoex_enabled && ath9k_enable_diversity) - common->antenna_diversity =1 ; +if (ath9k_bt_ant_diversity) + common->bt_ant_diversity =1 ;spin_lock_init (&common->cc_lock);
Signature · 1 line
1.8.3.3
PATCH 4/5 ath9k: Add a HW capability for WLAN/BT RX diversity
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/ath9k.h | 9 +++++---- drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/init.c | 13 +++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +5 -4
@@ -624,10 +624,11 @@ void ath_ant_comb_update(struct ath_softc *sc);/* Main driver core */ /********************/ -#define ATH9K_PCI_CUS198 0x0001 -#define ATH9K_PCI_CUS230 0x0002 -#define ATH9K_PCI_CUS217 0x0004 -#define ATH9K_PCI_WOW 0x0008 +#define ATH9K_PCI_CUS198 0x0001 +#define ATH9K_PCI_CUS230 0x0002 +#define ATH9K_PCI_CUS217 0x0004 +#define ATH9K_PCI_WOW 0x0008 +#define ATH9K_PCI_BT_ANT_DIV 0x0010/* * Default cache line size, in bytes.
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -248,6 +248,7 @@ enum ath9k_hw_caps {ATH9K_HW_WOW_DEVICE_CAPABLE =BIT (17 ),ATH9K_HW_CAP_PAPRD =BIT (18 ),ATH9K_HW_CAP_FCC_BAND_SWITCH =BIT (19 ), + ATH9K_HW_CAP_BT_ANT_DIV = BIT(20), };/*
drivers/net/wireless/ath/ath9k/init.c +11 -2
@@ -516,6 +516,7 @@ static void ath9k_init_misc(struct ath_softc *sc)static void ath9k_init_platform (struct ath_softc *sc) {struct ath_hw *ah = sc->sc_ah; +struct ath9k_hw_capabilities *pCap = &ah->caps;struct ath_common *common =ath9k_hw_common (ah);if (common->bus_ops->ath_bus_type !=ATH_PCI )
@@ -529,8 +530,14 @@ static void ath9k_init_platform(struct ath_softc *sc)ath_info (common,"Set parameters for %s\n" , (sc->driver_data &ATH9K_PCI_CUS198 ) ?"CUS198" :"CUS230" ); - }else if (sc->driver_data &ATH9K_PCI_CUS217 ) { + } + +if (sc->driver_data &ATH9K_PCI_CUS217 )ath_info (common,"CUS217 card detected\n" ); + +if (sc->driver_data &ATH9K_PCI_BT_ANT_DIV ) { + pCap->hw_caps |=ATH9K_HW_CAP_BT_ANT_DIV ; +ath_info (common,"Enable BT/WLAN RX diversity\n" ); } }
@@ -583,6 +590,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) {struct ath9k_platform_data *pdata = sc->dev->platform_data; +struct ath9k_hw_capabilities *pCap;struct ath_hw *ah =NULL ;struct ath_common *common;int ret =0 , i;
@@ -600,6 +608,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, ah->reg_ops.rmw = ath9k_reg_rmw;atomic_set (&ah->intr_ref_cnt,-1 ); sc->sc_ah = ah; + pCap = &ah->caps; sc->dfs_detector =dfs_pattern_detector_init (ah,NL80211_DFS_UNSET );
@@ -650,7 +659,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,* WB195 which is a AR9285 + AR3011 card doesn't have * this feature. */ -if (ath9k_bt_ant_diversity) +if (ath9k_bt_ant_diversity && (pCap->hw_caps &ATH9K_HW_CAP_BT_ANT_DIV )) common->bt_ant_diversity =1 ;spin_lock_init (&common->cc_lock);
Signature · 1 line
1.8.3.3
PATCH 5/5 ath9k: Add PCI IDs that support WLAN/BT RX diversity
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath9k/pci.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/pci.c +10 -6
@@ -40,29 +40,29 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { 0x0032, PCI_VENDOR_ID_AZWAVE, 0x2086), - .driver_data = ATH9K_PCI_CUS198 }, + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ATHEROS ,0x0032 ,PCI_VENDOR_ID_AZWAVE , 0x1237), - .driver_data = ATH9K_PCI_CUS198 }, + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x0032, PCI_VENDOR_ID_AZWAVE, 0x2126), - .driver_data = ATH9K_PCI_CUS198 }, + .driver_data = ATH9K_PCI_CUS198 | ATH9K_PCI_BT_ANT_DIV }, /* PCI-E CUS230 */ { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x0032, PCI_VENDOR_ID_AZWAVE, 0x2152), - .driver_data = ATH9K_PCI_CUS230 }, + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV }, { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS, 0x0032, PCI_VENDOR_ID_FOXCONN, 0xE075), - .driver_data = ATH9K_PCI_CUS230 }, + .driver_data = ATH9K_PCI_CUS230 | ATH9K_PCI_BT_ANT_DIV }, { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E AR9485 */ { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E AR9580 */
@@ -138,7 +138,11 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { { PCI_VDEVICE(ATHEROS, 0x0034) }, /* PCI-E AR9462 */ { PCI_VDEVICE(ATHEROS, 0x0037) }, /* PCI-E AR1111/AR9485 */ - { PCI_VDEVICE(ATHEROS, 0x0036) }, /* PCI-E AR9565 */ + +/* PCI-E AR9565 */ + { PCI_VDEVICE(ATHEROS, 0x0036), + .driver_data = ATH9K_PCI_BT_ANT_DIV }, + { 0 } };
Signature · 1 line
1.8.3.3