2011-04-28 14:23:11

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

From: Mohammed Shafi Shajakhan <[email protected]>

*These are purely RFC/RFT patches, none of them are tested.
once tested we will send it as patches.
*This patch set adds Antenna diversity support for AR9485, previously
antenna diversity is only supported in AR9285
*The basic antenna diversity algorithm remains the same
*slight change in the diversity field in eeprom
*introduction of main/alt gain table and lna1_lna2 delta fields
*initially set LNA1 for main antenna
*introduction of diversity group
*based on diversity group, fast diversity bias parmaters and
lna1_lna2_delta varies
*implement an API to take the decision of swapping main/ALT LNA's
for AR9485
*configure fast diversity bias based on diversity group

Mohammed Shafi Shajakhan (9):
ath9k_hw: make antenna diversity modules chip specific
ath9k_hw: enable Antenna diversity for AR9485
ath9k_hw: define registers/macros to support Antenna diversity
ath9k_hw: config diversity based on eeprom contents
ath9k_hw: define modules to get/set Antenna diversity paramaters
ath9k_hw: define antenna diversity group
ath9k: Implement an API to swap main/ALT LNA's
ath9k: configure fast_div_bias based on diversity group
ath9k: make sure main_rssi is positive

drivers/net/wireless/ath/ath9k/ar9002_mac.c | 2 +
drivers/net/wireless/ath/ath9k/ar9002_phy.c | 10 +-
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 50 +++++-
drivers/net/wireless/ath/ath9k/ar9003_mac.c | 2 +
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 44 +++++
drivers/net/wireless/ath/ath9k/ar9003_phy.h | 31 +++-
drivers/net/wireless/ath/ath9k/ath9k.h | 1 -
drivers/net/wireless/ath/ath9k/hw-ops.h | 12 ++
drivers/net/wireless/ath/ath9k/hw.c | 16 ++
drivers/net/wireless/ath/ath9k/hw.h | 23 ++-
drivers/net/wireless/ath/ath9k/recv.c | 211 ++++++++++++++++++------
11 files changed, 337 insertions(+), 65 deletions(-)



2011-04-28 14:23:18

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 1/9] ath9k_hw: make antenna diversity modules chip specific

From: Mohammed Shafi Shajakhan <[email protected]>

this is necessary to support Antenna diversity and combining in new chip
sets such as AR9485, previously Antenna diversity support is available
only in AR9285

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ar9002_mac.c | 2 ++
drivers/net/wireless/ath/ath9k/ar9002_phy.c | 8 ++++----
drivers/net/wireless/ath/ath9k/hw-ops.h | 12 ++++++++++++
drivers/net/wireless/ath/ath9k/hw.h | 15 +++++++++++----
4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
index c338efb..106714d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
@@ -458,4 +458,6 @@ void ar9002_hw_attach_mac_ops(struct ath_hw *ah)
ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
ops->set_clrdmask = ar9002_hw_set_clrdmask;
+ ops->antdiv_comb_conf_get = ar9002_hw_antdiv_comb_conf_get;
+ ops->antdiv_comb_conf_set = ar9002_hw_antdiv_comb_conf_set;
}
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 7d68d61..aa2d08a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -533,7 +533,7 @@ 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,
+void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
struct ath_hw_antcomb_conf *antconf)
{
u32 regval;
@@ -546,9 +546,9 @@ void ath9k_hw_antdiv_comb_conf_get(struct ath_hw *ah,
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);
+EXPORT_SYMBOL(ar9002_hw_antdiv_comb_conf_get);

-void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah,
+void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah,
struct ath_hw_antcomb_conf *antconf)
{
u32 regval;
@@ -566,4 +566,4 @@ void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah,

REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
}
-EXPORT_SYMBOL(ath9k_hw_antdiv_comb_conf_set);
+EXPORT_SYMBOL(ar9002_hw_antdiv_comb_conf_set);
diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h
index 9dd90a8..199d697 100644
--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
+++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
@@ -127,6 +127,18 @@ static inline void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, bool val)
ath9k_hw_ops(ah)->set_clrdmask(ah, ds, val);
}

+static inline void ath9k_hw_antdiv_comb_conf_get(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf)
+{
+ ath9k_hw_ops(ah)->antdiv_comb_conf_get(ah, antconf);
+}
+
+static inline void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf)
+{
+ ath9k_hw_ops(ah)->antdiv_comb_conf_set(ah, antconf);
+}
+
/* Private hardware call ops */

/* PHY ops */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 6a028bd..48420df 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -628,6 +628,11 @@ struct ath_hw_ops {
void (*set11n_burstduration)(struct ath_hw *ah, void *ds,
u32 burstDuration);
void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
+ void (*antdiv_comb_conf_get)(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);
+ void (*antdiv_comb_conf_set)(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);
+
};

struct ath_nf_limits {
@@ -901,10 +906,6 @@ 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);
@@ -975,6 +976,12 @@ void ar9002_hw_enable_async_fifo(struct ath_hw *ah);
void ar9002_hw_update_async_fifo(struct ath_hw *ah);
void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);

+/* Antenna diversity/combining */
+void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);
+void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);
+
/*
* Code specific to AR9003, we stuff these here to avoid callbacks
* for older families
--
1.7.0.4


2011-04-28 14:23:35

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

From: Mohammed Shafi Shajakhan <[email protected]>

* enable LNA-diversity, fast-diversity based on the value read from
EEPROM content
* if antenna diversity/combining is supported set LNA1 for the main
antenna and LNA2 for the alternate antenna based on the new diversity
algorithm

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 50 +++++++++++++++++++++---
1 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index fb892e5..d43e62c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3500,6 +3500,8 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
{
int chain;
+ u32 regval;
+ u32 ant_div_ctl1;
static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
AR_PHY_SWITCH_CHAIN_0,
AR_PHY_SWITCH_CHAIN_1,
@@ -3525,13 +3527,49 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)

if (AR_SREV_9485(ah)) {
value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
- REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_CTRL_ALL,
- value);
- REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE,
- value >> 6);
- REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE,
- value >> 7);
+ /*
+ * main_lnaconf, alt_lnaconf, main_tb, alt_tb
+ * are the fields present
+ */
+ regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
+ regval &= (~AR_ANT_DIV_CTRL_ALL);
+ regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
+ /* enable_lnadiv */
+ regval &= (~AR_PHY_9485_ANT_DIV_LNADIV);
+ regval |= ((value >> 6) & 0x1) <<
+ AR_PHY_9485_ANT_DIV_LNADIV_S;
+ REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
+
+ /*enable fast_div */
+ regval = REG_READ(ah, AR_PHY_CCK_DETECT);
+ regval &= (~AR_BBB_SIG_DETECT_ANT_FAST_DIV);
+ regval |= ((value >> 7) & 0x1) <<
+ AR_BBB_SIG_DETECT_ANT_FAST_DIV_S;
+ REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
+ ant_div_ctl1 =
+ ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
+ /* check whether antenna diversity is enabled */
+ if ((ant_div_ctl1 >> 0x6) == 0x3) {
+ regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
+ /*
+ * clear bits 25-30 main_lnaconf, alt_lnaconf,
+ * main_tb, alt_tb
+ */
+ regval &= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
+ AR_PHY_9485_ANT_DIV_ALT_LNACONF |
+ AR_PHY_9485_ANT_DIV_ALT_GAINTB |
+ AR_PHY_9485_ANT_DIV_MAIN_GAINTB));
+ /* by default use LNA1 for the main antenna */
+ regval |= (AR_PHY_9485_ANT_DIV_LNA1 <<
+ AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S);
+ regval |= (AR_PHY_9485_ANT_DIV_LNA2 <<
+ AR_PHY_9485_ANT_DIV_ALT_LNACONF_S);
+ REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
+ }
+
+
}
+
}

static void ar9003_hw_drive_strength_apply(struct ath_hw *ah)
--
1.7.0.4


2011-04-29 04:52:44

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

On Thursday 28 April 2011 11:42 PM, Luis R. Rodriguez wrote:
> On Thu, Apr 28, 2011 at 11:12 AM, Luis R. Rodriguez
> <[email protected]> wrote:
>
>> On Thu, Apr 28, 2011 at 7:22 AM, Mohammed Shafi Shajakhan
>> <[email protected]> wrote:
>>
>>> From: Mohammed Shafi Shajakhan<[email protected]>
>>>
>>> *These are purely RFC/RFT patches, none of them are tested.
>>> once tested we will send it as patches.
>>> *This patch set adds Antenna diversity support for AR9485, previously
>>> antenna diversity is only supported in AR9285
>>> *The basic antenna diversity algorithm remains the same
>>> *slight change in the diversity field in eeprom
>>> *introduction of main/alt gain table and lna1_lna2 delta fields
>>> *initially set LNA1 for main antenna
>>> *introduction of diversity group
>>> *based on diversity group, fast diversity bias parmaters and
>>> lna1_lna2_delta varies
>>> *implement an API to take the decision of swapping main/ALT LNA's
>>> for AR9485
>>> *configure fast diversity bias based on diversity group
>>>
>> Apart from my one comment:
>>
>> Reviewed-by: Luis R. Rodriguez<[email protected]>
>>
> Oh yeah and great job on your patch split!
>
thanks!
> Luis
>

2011-04-29 04:53:46

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 3/9] ath9k_hw: define registers/macros to support Antenna diversity

On Friday 29 April 2011 09:50 AM, Vasanth Thiagarajan wrote:
> On Thu, Apr 28, 2011 at 07:52:53PM +0530, Mohammed Shafi Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> define few registers and macros to configure/enable Antenna diversity
>> parameters in AR9485
>>
>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>> ---
>> drivers/net/wireless/ath/ath9k/ar9003_phy.h | 31 ++++++++++++++++++++++++--
>> drivers/net/wireless/ath/ath9k/hw.h | 3 ++
>> 2 files changed, 31 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
>> index 2a0d5cb..c4f409f 100644
>> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
>> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
>> @@ -245,6 +245,9 @@
>> */
>> #define AR_BBB_BASE 0x9d00
>>
>> +#define AR_BBB_SIG_DETECT_ANT_FAST_DIV 0x00002000
>> +#define AR_BBB_SIG_DETECT_ANT_FAST_DIV_S 13
>> +
>> /*
>> * AGC Register Map
>> */
>> @@ -261,12 +264,37 @@
>> #define AR_PHY_EXT_CCA0 (AR_AGC_BASE + 0x20)
>> #define AR_PHY_RESTART (AR_AGC_BASE + 0x24)
>>
>> +/*
>> + * Antenna Diversity settings
>> + */
>> #define AR_PHY_MC_GAIN_CTRL (AR_AGC_BASE + 0x28)
>> #define AR_ANT_DIV_CTRL_ALL 0x7e000000
>> #define AR_ANT_DIV_CTRL_ALL_S 25
>> #define AR_ANT_DIV_ENABLE 0x1000000
>> #define AR_ANT_DIV_ENABLE_S 24
>>
>> +#define AR_PHY_CCK_DETECT (AR_AGC_BASE + 0x1c0)
>> +#define AR_FAST_DIV_ENABLE 0x2000
>> +#define AR_FAST_DIV_ENABLE_S 13
>>
> This can be in the original place as it is in order with the
> register offset. This way we can avoid any possible duplication/bug
> in register definition.
>
Ok Vasanth, I will revert it back.

thanks,
shafi
> Vasanth
> .
>
>

2011-04-28 14:23:23

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 2/9] ath9k_hw: enable Antenna diversity for AR9485

From: Mohammed Shafi Shajakhan <[email protected]>

read antenna diversity and combining information from the EEPROM.
Enable antenna diversity/combining feature only when both LNA
diversity and fast diversity are supported

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/hw.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index e99e319..47d3881 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2014,6 +2014,22 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
}


+ if (AR_SREV_9485(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)
+ pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
+ }

if (AR_SREV_9485_10(ah)) {
pCap->pcie_lcr_extsync_en = true;
--
1.7.0.4


2011-04-28 14:24:00

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 8/9] ath9k: configure fast_div_bias based on diversity group

From: Mohammed Shafi Shajakhan <[email protected]>

configure fast diversity bias based on the antenna diversity group and
based on main/alt LNA configurations. also configure main antenna and
alternate antenna to gain-table 0 for diversity group 2(AR9485)

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/recv.c | 174 +++++++++++++++++++++++++--------
1 files changed, 131 insertions(+), 43 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 337e018..4710830 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1315,49 +1315,138 @@ static void ath_select_ant_div_from_quick_scan(struct ath_ant_comb *antcomb,
}
}

-static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf)
+static void ath_ant_div_conf_fast_divbias(struct ath_hw_antcomb_conf *ant_conf,
+ struct ath_ant_comb *antcomb, int alt_ratio)
{
- /* Adjust the fast_div_bias based on main and alt lna conf */
- switch ((ant_conf->main_lna_conf << 4) | ant_conf->alt_lna_conf) {
- case (0x01): /* A-B LNA2 */
- ant_conf->fast_div_bias = 0x3b;
- break;
- case (0x02): /* A-B LNA1 */
- ant_conf->fast_div_bias = 0x3d;
- break;
- case (0x03): /* A-B A+B */
- ant_conf->fast_div_bias = 0x1;
- break;
- case (0x10): /* LNA2 A-B */
- ant_conf->fast_div_bias = 0x7;
- break;
- case (0x12): /* LNA2 LNA1 */
- ant_conf->fast_div_bias = 0x2;
- break;
- case (0x13): /* LNA2 A+B */
- ant_conf->fast_div_bias = 0x7;
- break;
- case (0x20): /* LNA1 A-B */
- ant_conf->fast_div_bias = 0x6;
- break;
- case (0x21): /* LNA1 LNA2 */
- ant_conf->fast_div_bias = 0x0;
- break;
- case (0x23): /* LNA1 A+B */
- ant_conf->fast_div_bias = 0x6;
- break;
- case (0x30): /* A+B A-B */
- ant_conf->fast_div_bias = 0x1;
- break;
- case (0x31): /* A+B LNA2 */
- ant_conf->fast_div_bias = 0x3b;
- break;
- case (0x32): /* A+B LNA1 */
- ant_conf->fast_div_bias = 0x3d;
- break;
- default:
- break;
+ if (ant_conf->div_group == 0) {
+ /* Adjust the fast_div_bias based on main and alt lna conf */
+ switch ((ant_conf->main_lna_conf << 4) |
+ ant_conf->alt_lna_conf) {
+ case (0x01): /* A-B LNA2 */
+ ant_conf->fast_div_bias = 0x3b;
+ break;
+ case (0x02): /* A-B LNA1 */
+ ant_conf->fast_div_bias = 0x3d;
+ break;
+ case (0x03): /* A-B A+B */
+ ant_conf->fast_div_bias = 0x1;
+ break;
+ case (0x10): /* LNA2 A-B */
+ ant_conf->fast_div_bias = 0x7;
+ break;
+ case (0x12): /* LNA2 LNA1 */
+ ant_conf->fast_div_bias = 0x2;
+ break;
+ case (0x13): /* LNA2 A+B */
+ ant_conf->fast_div_bias = 0x7;
+ break;
+ case (0x20): /* LNA1 A-B */
+ ant_conf->fast_div_bias = 0x6;
+ break;
+ case (0x21): /* LNA1 LNA2 */
+ ant_conf->fast_div_bias = 0x0;
+ break;
+ case (0x23): /* LNA1 A+B */
+ ant_conf->fast_div_bias = 0x6;
+ break;
+ case (0x30): /* A+B A-B */
+ ant_conf->fast_div_bias = 0x1;
+ break;
+ case (0x31): /* A+B LNA2 */
+ ant_conf->fast_div_bias = 0x3b;
+ break;
+ case (0x32): /* A+B LNA1 */
+ ant_conf->fast_div_bias = 0x3d;
+ break;
+ default:
+ break;
+ }
+ } else if (ant_conf->div_group == 2) {
+ /* Adjust the fast_div_bias based on main and alt_lna_conf */
+ switch ((ant_conf->main_lna_conf << 4) |
+ ant_conf->alt_lna_conf) {
+ case (0x01): /* A-B LNA2 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x02): /* A-B LNA1 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x03): /* A-B A+B */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x10): /* LNA2 A-B */
+ if (!(antcomb->scan) &&
+ (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
+ ant_conf->fast_div_bias = 0x1;
+ else
+ ant_conf->fast_div_bias = 0x2;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x12): /* LNA2 LNA1 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x13): /* LNA2 A+B */
+ if (!(antcomb->scan) &&
+ (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
+ ant_conf->fast_div_bias = 0x1;
+ else
+ ant_conf->fast_div_bias = 0x2;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x20): /* LNA1 A-B */
+ if (!(antcomb->scan) &&
+ (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
+ ant_conf->fast_div_bias = 0x1;
+ else
+ ant_conf->fast_div_bias = 0x2;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x21): /* LNA1 LNA2 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x23): /* LNA1 A+B */
+ if (!(antcomb->scan) &&
+ (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO))
+ ant_conf->fast_div_bias = 0x1;
+ else
+ ant_conf->fast_div_bias = 0x2;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x30): /* A+B A-B */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x31): /* A+B LNA2 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ case (0x32): /* A+B LNA1 */
+ ant_conf->fast_div_bias = 0x1;
+ ant_conf->main_gaintb = 0;
+ ant_conf->alt_gaintb = 0;
+ break;
+ default:
+ break;
+ }
+
}
+
}

/* Antenna diversity and combining */
@@ -1583,8 +1672,7 @@ static void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
antcomb->quick_scan_cnt++;

div_comb_done:
- ath_ant_div_conf_fast_divbias(&div_ant_conf);
-
+ ath_ant_div_conf_fast_divbias(&div_ant_conf, antcomb, alt_ratio);
ath9k_hw_antdiv_comb_conf_set(sc->sc_ah, &div_ant_conf);

antcomb->scan_start_time = jiffies;
--
1.7.0.4


2011-04-28 14:23:48

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 6/9] ath9k_hw: define antenna diversity group

From: Mohammed Shafi Shajakhan <[email protected]>

AR9285 belongs to diversity group 0 and AR9485 belongs to diversity
group 2. Based on the diversity group we configure certain antenna
diversity paramaters such as lna1_lna2_delta and fast diversity
bias values. For AR9485 we have some gain table paramter which
selects the gain table 0/1 for main and alternate antenna

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ar9002_phy.c | 2 ++
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 2 ++
drivers/net/wireless/ath/ath9k/ath9k.h | 1 -
drivers/net/wireless/ath/ath9k/hw.h | 1 +
drivers/net/wireless/ath/ath9k/recv.c | 2 +-
5 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index aa2d08a..ff32864 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -545,6 +545,8 @@ void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
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;
+ antconf->lna1_lna2_delta = -3;
+ antconf->div_group = 0;
}
EXPORT_SYMBOL(ar9002_hw_antdiv_comb_conf_get);

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 8f580cd..1c6c9ac 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1348,6 +1348,8 @@ void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah,
AR_PHY_9485_ANT_DIV_ALT_LNACONF_S;
antconf->fast_div_bias = (regval & AR_PHY_9485_ANT_FAST_DIV_BIAS) >>
AR_PHY_9485_ANT_FAST_DIV_BIAS_S;
+ antconf->lna1_lna2_delta = -9;
+ antconf->div_group = 2;
}
EXPORT_SYMBOL(ar9003_hw_antdiv_comb_conf_get);

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 0312aa0..3e7f4a4 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -484,7 +484,6 @@ static inline void ath_deinit_leds(struct ath_softc *sc)
#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
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 7035f2d..8603b9f 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -479,6 +479,7 @@ struct ath_hw_antcomb_conf {
u8 main_gaintb;
u8 alt_gaintb;
int lna1_lna2_delta;
+ u8 div_group;
};

/**
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index c5b7cbe..53ff570 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1440,7 +1440,7 @@ static void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
}

if ((alt_rssi_avg < (main_rssi_avg +
- ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA)))
+ div_ant_conf.lna1_lna2_delta)))
goto div_comb_done;
}

--
1.7.0.4


2011-04-28 17:39:50

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

On Thu, Apr 28, 2011 at 07:22:54AM -0700, Mohammed Shajakhan wrote:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> * enable LNA-diversity, fast-diversity based on the value read from
> EEPROM content
> * if antenna diversity/combining is supported set LNA1 for the main
> antenna and LNA2 for the alternate antenna based on the new diversity
> algorithm

The commit log does not mention this is specifically only for
AR9485. Adding this can help reviewers / distributions.

Luis

2011-04-29 06:49:30

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

On Friday 29 April 2011 10:13 AM, Vasanth Thiagarajan wrote:
> On Thu, Apr 28, 2011 at 07:52:54PM +0530, Mohammed Shafi Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> * enable LNA-diversity, fast-diversity based on the value read from
>> EEPROM content
>> * if antenna diversity/combining is supported set LNA1 for the main
>> antenna and LNA2 for the alternate antenna based on the new diversity
>> algorithm
>>
>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>> ---
>> drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 50 +++++++++++++++++++++---
>> 1 files changed, 44 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> index fb892e5..d43e62c 100644
>> --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> @@ -3500,6 +3500,8 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
>> static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
>> {
>> int chain;
>> + u32 regval;
>> + u32 ant_div_ctl1;
>> static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
>> AR_PHY_SWITCH_CHAIN_0,
>> AR_PHY_SWITCH_CHAIN_1,
>> @@ -3525,13 +3527,49 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
>>
>> if (AR_SREV_9485(ah)) {
>> value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
>> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_CTRL_ALL,
>> - value);
>> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE,
>> - value>> 6);
>> - REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE,
>> - value>> 7);
>> + /*
>> + * main_lnaconf, alt_lnaconf, main_tb, alt_tb
>> + * are the fields present
>> + */
>> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
>> + regval&= (~AR_ANT_DIV_CTRL_ALL);
>> + regval |= (value& 0x3f)<< AR_ANT_DIV_CTRL_ALL_S;
>> + /* enable_lnadiv */
>> + regval&= (~AR_PHY_9485_ANT_DIV_LNADIV);
>> + regval |= ((value>> 6)& 0x1)<<
>> + AR_PHY_9485_ANT_DIV_LNADIV_S;
>> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
>> +
>> + /*enable fast_div */
>> + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
>> + regval&= (~AR_BBB_SIG_DETECT_ANT_FAST_DIV);
>> + regval |= ((value>> 7)& 0x1)<<
>> + AR_BBB_SIG_DETECT_ANT_FAST_DIV_S;
>> + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
>>
> Can these be simplified with REG_RMW()?.
>
>> + ant_div_ctl1 =
>> + ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
>> + /* check whether antenna diversity is enabled */
>> + if ((ant_div_ctl1>> 0x6) == 0x3) {
>> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
>> + /*
>> + * clear bits 25-30 main_lnaconf, alt_lnaconf,
>> + * main_tb, alt_tb
>> + */
>> + regval&= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
>> + AR_PHY_9485_ANT_DIV_ALT_LNACONF |
>> + AR_PHY_9485_ANT_DIV_ALT_GAINTB |
>> + AR_PHY_9485_ANT_DIV_MAIN_GAINTB));
>> + /* by default use LNA1 for the main antenna */
>> + regval |= (AR_PHY_9485_ANT_DIV_LNA1<<
>> + AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S);
>> + regval |= (AR_PHY_9485_ANT_DIV_LNA2<<
>> + AR_PHY_9485_ANT_DIV_ALT_LNACONF_S);
>> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
>>
> same here.
>
Vasanth, as you had said it can be further optimized and few macros are
redundant. Thanks a lot for the review.

regards,
shafi
> Vasanth
> .
>
>

2011-04-29 06:34:11

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

On Friday 29 April 2011 10:13 AM, Vasanth Thiagarajan wrote:
> On Thu, Apr 28, 2011 at 07:52:54PM +0530, Mohammed Shafi Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> * enable LNA-diversity, fast-diversity based on the value read from
>> EEPROM content
>> * if antenna diversity/combining is supported set LNA1 for the main
>> antenna and LNA2 for the alternate antenna based on the new diversity
>> algorithm
>>
>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>> ---
>> drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 50 +++++++++++++++++++++---
>> 1 files changed, 44 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> index fb892e5..d43e62c 100644
>> --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
>> @@ -3500,6 +3500,8 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
>> static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
>> {
>> int chain;
>> + u32 regval;
>> + u32 ant_div_ctl1;
>> static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
>> AR_PHY_SWITCH_CHAIN_0,
>> AR_PHY_SWITCH_CHAIN_1,
>> @@ -3525,13 +3527,49 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
>>
>> if (AR_SREV_9485(ah)) {
>> value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
>> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_CTRL_ALL,
>> - value);
>> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE,
>> - value>> 6);
>> - REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE,
>> - value>> 7);
>> + /*
>> + * main_lnaconf, alt_lnaconf, main_tb, alt_tb
>> + * are the fields present
>> + */
>> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
>> + regval&= (~AR_ANT_DIV_CTRL_ALL);
>> + regval |= (value& 0x3f)<< AR_ANT_DIV_CTRL_ALL_S;
>> + /* enable_lnadiv */
>> + regval&= (~AR_PHY_9485_ANT_DIV_LNADIV);
>> + regval |= ((value>> 6)& 0x1)<<
>> + AR_PHY_9485_ANT_DIV_LNADIV_S;
>> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
>> +
>> + /*enable fast_div */
>> + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
>> + regval&= (~AR_BBB_SIG_DETECT_ANT_FAST_DIV);
>> + regval |= ((value>> 7)& 0x1)<<
>> + AR_BBB_SIG_DETECT_ANT_FAST_DIV_S;
>> + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
>>
> Can these be simplified with REG_RMW()?.
>
Vasanth, I will check into that.

thanks,
shafi
>> + ant_div_ctl1 =
>> + ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
>> + /* check whether antenna diversity is enabled */
>> + if ((ant_div_ctl1>> 0x6) == 0x3) {
>> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
>> + /*
>> + * clear bits 25-30 main_lnaconf, alt_lnaconf,
>> + * main_tb, alt_tb
>> + */
>> + regval&= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
>> + AR_PHY_9485_ANT_DIV_ALT_LNACONF |
>> + AR_PHY_9485_ANT_DIV_ALT_GAINTB |
>> + AR_PHY_9485_ANT_DIV_MAIN_GAINTB));
>> + /* by default use LNA1 for the main antenna */
>> + regval |= (AR_PHY_9485_ANT_DIV_LNA1<<
>> + AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S);
>> + regval |= (AR_PHY_9485_ANT_DIV_LNA2<<
>> + AR_PHY_9485_ANT_DIV_ALT_LNACONF_S);
>> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
>>
> same here.
>
> Vasanth
> .
>
>

2011-04-28 18:12:54

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

On Thu, Apr 28, 2011 at 7:22 AM, Mohammed Shafi Shajakhan
<[email protected]> wrote:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> *These are purely RFC/RFT patches, none of them are tested.
>  once tested we will send it as patches.
> *This patch set adds Antenna diversity support for AR9485, previously
>  antenna diversity is only supported in AR9285
> *The basic antenna diversity algorithm remains the same
> *slight change in the diversity field in eeprom
> *introduction of main/alt gain table and lna1_lna2 delta fields
> *initially set LNA1 for main antenna
> *introduction of diversity group
> *based on diversity group, fast diversity bias parmaters and
> lna1_lna2_delta varies
> *implement an API to take the decision of swapping main/ALT LNA's
> for AR9485
> *configure fast diversity bias based on diversity group

Apart from my one comment:

Reviewed-by: Luis R. Rodriguez <[email protected]>

Luis

2011-04-29 04:52:16

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

On Thursday 28 April 2011 11:09 PM, Luis Rodriguez wrote:
> On Thu, Apr 28, 2011 at 07:22:54AM -0700, Mohammed Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> * enable LNA-diversity, fast-diversity based on the value read from
>> EEPROM content
>> * if antenna diversity/combining is supported set LNA1 for the main
>> antenna and LNA2 for the alternate antenna based on the new diversity
>> algorithm
>>
> The commit log does not mention this is specifically only for
> AR9485. Adding this can help reviewers / distributions.
>
Ok Luis, I will address that.

thanks,
shafi
> Luis
> .
>
>

2011-04-29 05:21:28

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 1/9] ath9k_hw: make antenna diversity modules chip specific

On Friday 29 April 2011 09:40 AM, Vasanth Thiagarajan wrote:
> On Thu, Apr 28, 2011 at 07:52:51PM +0530, Mohammed Shafi Shajakhan wrote:
>
>> From: Mohammed Shafi Shajakhan<[email protected]>
>>
>> this is necessary to support Antenna diversity and combining in new chip
>> sets such as AR9485, previously Antenna diversity support is available
>> only in AR9285
>>
>> Signed-off-by: Mohammed Shafi Shajakhan<[email protected]>
>> ---
>> drivers/net/wireless/ath/ath9k/ar9002_mac.c | 2 ++
>> drivers/net/wireless/ath/ath9k/ar9002_phy.c | 8 ++++----
>> drivers/net/wireless/ath/ath9k/hw-ops.h | 12 ++++++++++++
>> drivers/net/wireless/ath/ath9k/hw.h | 15 +++++++++++----
>> 4 files changed, 29 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
>> index c338efb..106714d 100644
>> --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
>> +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
>> @@ -458,4 +458,6 @@ void ar9002_hw_attach_mac_ops(struct ath_hw *ah)
>> ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
>> ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
>> ops->set_clrdmask = ar9002_hw_set_clrdmask;
>> + ops->antdiv_comb_conf_get = ar9002_hw_antdiv_comb_conf_get;
>> + ops->antdiv_comb_conf_set = ar9002_hw_antdiv_comb_conf_set;
>>
> This should be part of phy_ops.
>
Ok I will move it to phy_ops.

thanks,
shafi

> Vasanth
>
> .
>
>

Subject: Re: [RFC/RFT 1/9] ath9k_hw: make antenna diversity modules chip specific

On Thu, Apr 28, 2011 at 07:52:51PM +0530, Mohammed Shafi Shajakhan wrote:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> this is necessary to support Antenna diversity and combining in new chip
> sets such as AR9485, previously Antenna diversity support is available
> only in AR9285
>
> Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
> ---
> drivers/net/wireless/ath/ath9k/ar9002_mac.c | 2 ++
> drivers/net/wireless/ath/ath9k/ar9002_phy.c | 8 ++++----
> drivers/net/wireless/ath/ath9k/hw-ops.h | 12 ++++++++++++
> drivers/net/wireless/ath/ath9k/hw.h | 15 +++++++++++----
> 4 files changed, 29 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
> index c338efb..106714d 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
> @@ -458,4 +458,6 @@ void ar9002_hw_attach_mac_ops(struct ath_hw *ah)
> ops->clr11n_aggr = ar9002_hw_clr11n_aggr;
> ops->set11n_burstduration = ar9002_hw_set11n_burstduration;
> ops->set_clrdmask = ar9002_hw_set_clrdmask;
> + ops->antdiv_comb_conf_get = ar9002_hw_antdiv_comb_conf_get;
> + ops->antdiv_comb_conf_set = ar9002_hw_antdiv_comb_conf_set;

This should be part of phy_ops.

Vasanth


2011-04-28 14:23:54

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 7/9] ath9k: Implement an API to swap main/ALT LNA's

From: Mohammed Shafi Shajakhan <[email protected]>

for the diversity group 2(AR9485) we swap the LNA's of main/ALT antenna
based on alternate antenna's rssi average in comparision with main
antenna's rssi, while for AR9285(antenna diversity group 0)we still
follow the older method of looking at the packet count in alternate
antenna

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/recv.c | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 53ff570..337e018 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -28,6 +28,33 @@ static inline bool ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta,
(alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
}

+static inline bool ath_ant_div_comb_alt_check(u8 div_group, int alt_ratio,
+ int curr_main_set, int curr_alt_set,
+ int alt_rssi_avg, int main_rssi_avg)
+{
+ bool result = false;
+ switch (div_group) {
+ case 0:
+ if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
+ result = true;
+ break;
+ case 1:
+ if ((((curr_main_set == ATH_ANT_DIV_COMB_LNA2) &&
+ (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) &&
+ (alt_rssi_avg >= (main_rssi_avg - 5))) ||
+ ((curr_main_set == ATH_ANT_DIV_COMB_LNA1) &&
+ (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) &&
+ (alt_rssi_avg >= (main_rssi_avg - 2)))) &&
+ (alt_rssi_avg >= 4))
+ result = true;
+ else
+ result = false;
+ break;
+ }
+
+ return result;
+}
+
static inline bool ath9k_check_auto_sleep(struct ath_softc *sc)
{
return sc->ps_enabled &&
@@ -1411,7 +1438,9 @@ static void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
}

if (!antcomb->scan) {
- if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
+ if (ath_ant_div_comb_alt_check(div_ant_conf.div_group,
+ alt_ratio, curr_main_set, curr_alt_set,
+ alt_rssi_avg, main_rssi_avg)) {
if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
/* Switch main and alt LNA */
div_ant_conf.main_lna_conf =
--
1.7.0.4


Subject: Re: [RFC/RFT 4/9] ath9k_hw: config diversity based on eeprom contents

On Thu, Apr 28, 2011 at 07:52:54PM +0530, Mohammed Shafi Shajakhan wrote:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> * enable LNA-diversity, fast-diversity based on the value read from
> EEPROM content
> * if antenna diversity/combining is supported set LNA1 for the main
> antenna and LNA2 for the alternate antenna based on the new diversity
> algorithm
>
> Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
> ---
> drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 50 +++++++++++++++++++++---
> 1 files changed, 44 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> index fb892e5..d43e62c 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> @@ -3500,6 +3500,8 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
> static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
> {
> int chain;
> + u32 regval;
> + u32 ant_div_ctl1;
> static const u32 switch_chain_reg[AR9300_MAX_CHAINS] = {
> AR_PHY_SWITCH_CHAIN_0,
> AR_PHY_SWITCH_CHAIN_1,
> @@ -3525,13 +3527,49 @@ static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
>
> if (AR_SREV_9485(ah)) {
> value = ath9k_hw_ar9300_get_eeprom(ah, EEP_ANT_DIV_CTL1);
> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_CTRL_ALL,
> - value);
> - REG_RMW_FIELD(ah, AR_PHY_MC_GAIN_CTRL, AR_ANT_DIV_ENABLE,
> - value >> 6);
> - REG_RMW_FIELD(ah, AR_PHY_CCK_DETECT, AR_FAST_DIV_ENABLE,
> - value >> 7);
> + /*
> + * main_lnaconf, alt_lnaconf, main_tb, alt_tb
> + * are the fields present
> + */
> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
> + regval &= (~AR_ANT_DIV_CTRL_ALL);
> + regval |= (value & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
> + /* enable_lnadiv */
> + regval &= (~AR_PHY_9485_ANT_DIV_LNADIV);
> + regval |= ((value >> 6) & 0x1) <<
> + AR_PHY_9485_ANT_DIV_LNADIV_S;
> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
> +
> + /*enable fast_div */
> + regval = REG_READ(ah, AR_PHY_CCK_DETECT);
> + regval &= (~AR_BBB_SIG_DETECT_ANT_FAST_DIV);
> + regval |= ((value >> 7) & 0x1) <<
> + AR_BBB_SIG_DETECT_ANT_FAST_DIV_S;
> + REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);

Can these be simplified with REG_RMW()?.
> + ant_div_ctl1 =
> + ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
> + /* check whether antenna diversity is enabled */
> + if ((ant_div_ctl1 >> 0x6) == 0x3) {
> + regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
> + /*
> + * clear bits 25-30 main_lnaconf, alt_lnaconf,
> + * main_tb, alt_tb
> + */
> + regval &= (~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
> + AR_PHY_9485_ANT_DIV_ALT_LNACONF |
> + AR_PHY_9485_ANT_DIV_ALT_GAINTB |
> + AR_PHY_9485_ANT_DIV_MAIN_GAINTB));
> + /* by default use LNA1 for the main antenna */
> + regval |= (AR_PHY_9485_ANT_DIV_LNA1 <<
> + AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S);
> + regval |= (AR_PHY_9485_ANT_DIV_LNA2 <<
> + AR_PHY_9485_ANT_DIV_ALT_LNACONF_S);
> + REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);

same here.

Vasanth

2011-04-28 18:13:12

by Luis R. Rodriguez

[permalink] [raw]
Subject: Re: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

On Thu, Apr 28, 2011 at 11:12 AM, Luis R. Rodriguez
<[email protected]> wrote:
> On Thu, Apr 28, 2011 at 7:22 AM, Mohammed Shafi Shajakhan
> <[email protected]> wrote:
>> From: Mohammed Shafi Shajakhan <[email protected]>
>>
>> *These are purely RFC/RFT patches, none of them are tested.
>>  once tested we will send it as patches.
>> *This patch set adds Antenna diversity support for AR9485, previously
>>  antenna diversity is only supported in AR9285
>> *The basic antenna diversity algorithm remains the same
>> *slight change in the diversity field in eeprom
>> *introduction of main/alt gain table and lna1_lna2 delta fields
>> *initially set LNA1 for main antenna
>> *introduction of diversity group
>> *based on diversity group, fast diversity bias parmaters and
>> lna1_lna2_delta varies
>> *implement an API to take the decision of swapping main/ALT LNA's
>> for AR9485
>> *configure fast diversity bias based on diversity group
>
> Apart from my one comment:
>
> Reviewed-by: Luis R. Rodriguez <[email protected]>

Oh yeah and great job on your patch split!

Luis

2011-04-28 14:23:41

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 5/9] ath9k_hw: define modules to get/set Antenna diversity paramaters

From: Mohammed Shafi Shajakhan <[email protected]>

these are the two important modules that will be called by the antenna
diversity algorithm module in the rx. this will continuosly configure
the hardware based on the current diversity status obtained
from the algorithm

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ar9003_mac.c | 2 +
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 42 +++++++++++++++++++++++++++
drivers/net/wireless/ath/ath9k/hw.h | 4 ++
3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index c1264d6..e2ed2a1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -520,6 +520,8 @@ void ar9003_hw_attach_mac_ops(struct ath_hw *hw)
ops->clr11n_aggr = ar9003_hw_clr11n_aggr;
ops->set11n_burstduration = ar9003_hw_set11n_burstduration;
ops->set_clrdmask = ar9003_hw_set_clrdmask;
+ ops->antdiv_comb_conf_get = ar9003_hw_antdiv_comb_conf_get;
+ ops->antdiv_comb_conf_set = ar9003_hw_antdiv_comb_conf_set;
}

void ath9k_hw_set_rx_bufsize(struct ath_hw *ah, u16 buf_size)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index c83be2d..8f580cd 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1335,3 +1335,45 @@ void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah)
"==== BB update: done ====\n\n");
}
EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info);
+
+void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf)
+{
+ u32 regval;
+
+ regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
+ antconf->main_lna_conf = (regval & AR_PHY_9485_ANT_DIV_MAIN_LNACONF) >>
+ AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S;
+ antconf->alt_lna_conf = (regval & AR_PHY_9485_ANT_DIV_ALT_LNACONF) >>
+ AR_PHY_9485_ANT_DIV_ALT_LNACONF_S;
+ antconf->fast_div_bias = (regval & AR_PHY_9485_ANT_FAST_DIV_BIAS) >>
+ AR_PHY_9485_ANT_FAST_DIV_BIAS_S;
+}
+EXPORT_SYMBOL(ar9003_hw_antdiv_comb_conf_get);
+
+void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf)
+{
+ u32 regval;
+
+ regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
+ regval &= ~(AR_PHY_9485_ANT_DIV_MAIN_LNACONF |
+ AR_PHY_9485_ANT_DIV_ALT_LNACONF |
+ AR_PHY_9485_ANT_FAST_DIV_BIAS |
+ AR_PHY_9485_ANT_DIV_MAIN_GAINTB |
+ AR_PHY_9485_ANT_DIV_ALT_GAINTB);
+ regval |= ((antconf->main_lna_conf <<
+ AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S)
+ & AR_PHY_9485_ANT_DIV_MAIN_LNACONF);
+ regval |= ((antconf->alt_lna_conf << AR_PHY_9485_ANT_DIV_ALT_LNACONF_S)
+ & AR_PHY_9485_ANT_DIV_ALT_LNACONF);
+ regval |= ((antconf->fast_div_bias << AR_PHY_9485_ANT_FAST_DIV_BIAS_S)
+ & AR_PHY_9485_ANT_FAST_DIV_BIAS);
+ regval |= ((antconf->main_gaintb << AR_PHY_9485_ANT_DIV_MAIN_GAINTB_S)
+ & AR_PHY_9485_ANT_DIV_MAIN_GAINTB);
+ regval |= ((antconf->alt_gaintb << AR_PHY_9485_ANT_DIV_ALT_GAINTB_S)
+ & AR_PHY_9485_ANT_DIV_ALT_GAINTB);
+
+ REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
+}
+EXPORT_SYMBOL(ar9003_hw_antdiv_comb_conf_set);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 096f75b..7035f2d 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -984,6 +984,10 @@ void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
struct ath_hw_antcomb_conf *antconf);
void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah,
struct ath_hw_antcomb_conf *antconf);
+void ar9003_hw_antdiv_comb_conf_get(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);
+void ar9003_hw_antdiv_comb_conf_set(struct ath_hw *ah,
+ struct ath_hw_antcomb_conf *antconf);

/*
* Code specific to AR9003, we stuff these here to avoid callbacks
--
1.7.0.4


Subject: Re: [RFC/RFT 3/9] ath9k_hw: define registers/macros to support Antenna diversity

On Thu, Apr 28, 2011 at 07:52:53PM +0530, Mohammed Shafi Shajakhan wrote:
> From: Mohammed Shafi Shajakhan <[email protected]>
>
> define few registers and macros to configure/enable Antenna diversity
> parameters in AR9485
>
> Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
> ---
> drivers/net/wireless/ath/ath9k/ar9003_phy.h | 31 ++++++++++++++++++++++++--
> drivers/net/wireless/ath/ath9k/hw.h | 3 ++
> 2 files changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
> index 2a0d5cb..c4f409f 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
> @@ -245,6 +245,9 @@
> */
> #define AR_BBB_BASE 0x9d00
>
> +#define AR_BBB_SIG_DETECT_ANT_FAST_DIV 0x00002000
> +#define AR_BBB_SIG_DETECT_ANT_FAST_DIV_S 13
> +
> /*
> * AGC Register Map
> */
> @@ -261,12 +264,37 @@
> #define AR_PHY_EXT_CCA0 (AR_AGC_BASE + 0x20)
> #define AR_PHY_RESTART (AR_AGC_BASE + 0x24)
>
> +/*
> + * Antenna Diversity settings
> + */
> #define AR_PHY_MC_GAIN_CTRL (AR_AGC_BASE + 0x28)
> #define AR_ANT_DIV_CTRL_ALL 0x7e000000
> #define AR_ANT_DIV_CTRL_ALL_S 25
> #define AR_ANT_DIV_ENABLE 0x1000000
> #define AR_ANT_DIV_ENABLE_S 24
>
> +#define AR_PHY_CCK_DETECT (AR_AGC_BASE + 0x1c0)
> +#define AR_FAST_DIV_ENABLE 0x2000
> +#define AR_FAST_DIV_ENABLE_S 13

This can be in the original place as it is in order with the
register offset. This way we can avoid any possible duplication/bug
in register definition.

Vasanth

2011-04-28 14:23:30

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 3/9] ath9k_hw: define registers/macros to support Antenna diversity

From: Mohammed Shafi Shajakhan <[email protected]>

define few registers and macros to configure/enable Antenna diversity
parameters in AR9485

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/ar9003_phy.h | 31 ++++++++++++++++++++++++--
drivers/net/wireless/ath/ath9k/hw.h | 3 ++
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index 2a0d5cb..c4f409f 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -245,6 +245,9 @@
*/
#define AR_BBB_BASE 0x9d00

+#define AR_BBB_SIG_DETECT_ANT_FAST_DIV 0x00002000
+#define AR_BBB_SIG_DETECT_ANT_FAST_DIV_S 13
+
/*
* AGC Register Map
*/
@@ -261,12 +264,37 @@
#define AR_PHY_EXT_CCA0 (AR_AGC_BASE + 0x20)
#define AR_PHY_RESTART (AR_AGC_BASE + 0x24)

+/*
+ * Antenna Diversity settings
+ */
#define AR_PHY_MC_GAIN_CTRL (AR_AGC_BASE + 0x28)
#define AR_ANT_DIV_CTRL_ALL 0x7e000000
#define AR_ANT_DIV_CTRL_ALL_S 25
#define AR_ANT_DIV_ENABLE 0x1000000
#define AR_ANT_DIV_ENABLE_S 24

+#define AR_PHY_CCK_DETECT (AR_AGC_BASE + 0x1c0)
+#define AR_FAST_DIV_ENABLE 0x2000
+#define AR_FAST_DIV_ENABLE_S 13
+
+#define AR_PHY_9485_ANT_FAST_DIV_BIAS 0x00007e00
+#define AR_PHY_9485_ANT_DIV_LNADIV 0x01000000
+#define AR_PHY_9485_ANT_DIV_ALT_LNACONF 0x06000000
+#define AR_PHY_9485_ANT_DIV_MAIN_LNACONF 0x18000000
+#define AR_PHY_9485_ANT_DIV_ALT_GAINTB 0x20000000
+#define AR_PHY_9485_ANT_DIV_MAIN_GAINTB 0x40000000
+#define AR_PHY_9485_ANT_DIV_LNADIV_S 24
+#define AR_PHY_9485_ANT_DIV_ALT_LNACONF_S 25
+#define AR_PHY_9485_ANT_DIV_MAIN_LNACONF_S 27
+#define AR_PHY_9485_ANT_DIV_ALT_GAINTB_S 29
+#define AR_PHY_9485_ANT_DIV_MAIN_GAINTB_S 30
+#define AR_PHY_9485_ANT_FAST_DIV_BIAS_S 9
+
+#define AR_PHY_9485_ANT_DIV_LNA1_MINUS_LNA2 0x0
+#define AR_PHY_9485_ANT_DIV_LNA2 0x1
+#define AR_PHY_9485_ANT_DIV_LNA1 0x2
+#define AR_PHY_9485_ANT_DIV_LNA1_PLUS_LNA2 0x3
+
#define AR_PHY_EXTCHN_PWRTHR1 (AR_AGC_BASE + 0x2c)
#define AR_PHY_EXT_CHN_WIN (AR_AGC_BASE + 0x30)
#define AR_PHY_20_40_DET_THR (AR_AGC_BASE + 0x34)
@@ -278,9 +306,6 @@
#define AR_PHY_RSSI_0 (AR_AGC_BASE + 0x180)
#define AR_PHY_SPUR_CCK_REP0 (AR_AGC_BASE + 0x184)

-#define AR_PHY_CCK_DETECT (AR_AGC_BASE + 0x1c0)
-#define AR_FAST_DIV_ENABLE 0x2000
-#define AR_FAST_DIV_ENABLE_S 13

#define AR_PHY_DAG_CTRLCCK (AR_AGC_BASE + 0x1c4)
#define AR_PHY_IQCORR_CTRL_CCK (AR_AGC_BASE + 0x1c8)
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 48420df..096f75b 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -476,6 +476,9 @@ struct ath_hw_antcomb_conf {
u8 main_lna_conf;
u8 alt_lna_conf;
u8 fast_div_bias;
+ u8 main_gaintb;
+ u8 alt_gaintb;
+ int lna1_lna2_delta;
};

/**
--
1.7.0.4


2011-04-28 14:24:06

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: [RFC/RFT 9/9] ath9k: make sure main_rssi is positive

From: Mohammed Shafi Shajakhan <[email protected]>

some times the rssi control descriptor for the main antenna may be
negative like that of alternate antenna, hence before incrementing
packet counts/rssi of main/alternate antenna make sure both main_rssi
and alt_rssi are positive only. this avoids wrong selection of antenna
due to diversity

Signed-off-by: Mohammed Shafi Shajakhan <[email protected]>
---
drivers/net/wireless/ath/ath9k/recv.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 4710830..2441085 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -1466,8 +1466,8 @@ static void ath_ant_comb_scan(struct ath_softc *sc, struct ath_rx_status *rs)
main_ant_conf = (rs->rs_rssi_ctl2 >> ATH_ANT_RX_MAIN_SHIFT) &
ATH_ANT_RX_MASK;

- /* Record packet only when alt_rssi is positive */
- if (alt_rssi > 0) {
+ /* Record packet only when both main_rssi and alt_rssi is positive */
+ if (main_rssi > 0 && alt_rssi > 0) {
antcomb->total_pkt_count++;
antcomb->main_total_rssi += main_rssi;
antcomb->alt_total_rssi += alt_rssi;
--
1.7.0.4


2011-05-12 17:00:57

by John W. Linville

[permalink] [raw]
Subject: Re: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

On Fri, Apr 29, 2011 at 10:22:39AM +0530, Mohammed Shafi wrote:
> On Thursday 28 April 2011 11:42 PM, Luis R. Rodriguez wrote:
> >On Thu, Apr 28, 2011 at 11:12 AM, Luis R. Rodriguez
> ><[email protected]> wrote:
> >>On Thu, Apr 28, 2011 at 7:22 AM, Mohammed Shafi Shajakhan
> >><[email protected]> wrote:
> >>>From: Mohammed Shafi Shajakhan<[email protected]>
> >>>
> >>>*These are purely RFC/RFT patches, none of them are tested.
> >>> once tested we will send it as patches.
> >>>*This patch set adds Antenna diversity support for AR9485, previously
> >>> antenna diversity is only supported in AR9285
> >>>*The basic antenna diversity algorithm remains the same
> >>>*slight change in the diversity field in eeprom
> >>>*introduction of main/alt gain table and lna1_lna2 delta fields
> >>>*initially set LNA1 for main antenna
> >>>*introduction of diversity group
> >>>*based on diversity group, fast diversity bias parmaters and
> >>>lna1_lna2_delta varies
> >>>*implement an API to take the decision of swapping main/ALT LNA's
> >>>for AR9485
> >>>*configure fast diversity bias based on diversity group
> >>Apart from my one comment:
> >>
> >>Reviewed-by: Luis R. Rodriguez<[email protected]>
> >Oh yeah and great job on your patch split!
> thanks!
> > Luis

This series was posted RFC -- do you want it merged now?

--
John W. Linville Someday the world will need a hero, and you
[email protected] might be all we have. Be ready.

2011-05-13 04:22:39

by Mohammed Shafi Shajakhan

[permalink] [raw]
Subject: Re: [RFC/RFT 0/9] ath9k: Add Antenna diversity support for AR9485

On Thursday 12 May 2011 10:29 PM, John W. Linville wrote:
> On Fri, Apr 29, 2011 at 10:22:39AM +0530, Mohammed Shafi wrote:
>> On Thursday 28 April 2011 11:42 PM, Luis R. Rodriguez wrote:
>>> On Thu, Apr 28, 2011 at 11:12 AM, Luis R. Rodriguez
>>> <[email protected]> wrote:
>>>> On Thu, Apr 28, 2011 at 7:22 AM, Mohammed Shafi Shajakhan
>>>> <[email protected]> wrote:
>>>>> From: Mohammed Shafi Shajakhan<[email protected]>
>>>>>
>>>>> *These are purely RFC/RFT patches, none of them are tested.
>>>>> once tested we will send it as patches.
>>>>> *This patch set adds Antenna diversity support for AR9485, previously
>>>>> antenna diversity is only supported in AR9285
>>>>> *The basic antenna diversity algorithm remains the same
>>>>> *slight change in the diversity field in eeprom
>>>>> *introduction of main/alt gain table and lna1_lna2 delta fields
>>>>> *initially set LNA1 for main antenna
>>>>> *introduction of diversity group
>>>>> *based on diversity group, fast diversity bias parmaters and
>>>>> lna1_lna2_delta varies
>>>>> *implement an API to take the decision of swapping main/ALT LNA's
>>>>> for AR9485
>>>>> *configure fast diversity bias based on diversity group
>>>> Apart from my one comment:
>>>>
>>>> Reviewed-by: Luis R. Rodriguez<[email protected]>
>>> Oh yeah and great job on your patch split!
>> thanks!
>>> Luis
>
> This series was posted RFC -- do you want it merged now?

John, today I will send the complete patch set, I am almost done with
the testing.

>