linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ath9k: Do not enable ANT diversity if ANT control bit is not set
@ 2012-10-30 11:13 Bala Shanmugam
  2012-10-30 13:11 ` Felix Fietkau
  0 siblings, 1 reply; 2+ messages in thread
From: Bala Shanmugam @ 2012-10-30 11:13 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless

RvR test is not good when ANT control bit is not set so
enable ANT diversity only when ANT control bit is set.

Signed-off-by: Bala Shanmugam <bkamatch@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c |   12 +++++++-----
 drivers/net/wireless/ath/ath9k/ar9003_phy.h |    2 ++
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 759f5f5..c93af57 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1340,10 +1340,9 @@ static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
 	regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
 	regval &= (~AR_ANT_DIV_CTRL_ALL);
 	regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
-	regval &= ~AR_PHY_ANT_DIV_LNADIV;
-	regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
 
-	if (enable)
+	if (enable &&
+	    (ant_div_ctl1 & AR_EEP_ANT_DIV_ENABLE))
 		regval |= AR_ANT_DIV_ENABLE;
 
 	REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
@@ -1352,12 +1351,15 @@ static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
 	regval &= ~AR_FAST_DIV_ENABLE;
 	regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
 
-	if (enable)
+	if (enable &&
+	    (ant_div_ctl1 & AR_EEP_FAST_DIV_ENABLE))
 		regval |= AR_FAST_DIV_ENABLE;
 
 	REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
 
-	if (enable) {
+	if (enable &&
+	    (ant_div_ctl1 & (AR_EEP_ANT_DIV_ENABLE |
+			     AR_EEP_FAST_DIV_ENABLE))) {
 		REG_SET_BIT(ah, AR_PHY_MC_GAIN_CTRL,
 			    (1 << AR_PHY_ANT_SW_RX_PROT_S));
 		if (ah->curchan && IS_CHAN_2GHZ(ah->curchan))
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
index 8f58523..b681f27 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
@@ -300,6 +300,8 @@
 #define AR_PHY_ANT_DIV_LNA2                     0x1
 #define AR_PHY_ANT_DIV_LNA1                     0x2
 #define AR_PHY_ANT_DIV_LNA1_PLUS_LNA2           0x3
+#define AR_EEP_ANT_DIV_ENABLE                   0x80
+#define AR_EEP_FAST_DIV_ENABLE                  0x40
 
 #define AR_PHY_EXTCHN_PWRTHR1   (AR_AGC_BASE + 0x2c)
 #define AR_PHY_EXT_CHN_WIN      (AR_AGC_BASE + 0x30)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ath9k: Do not enable ANT diversity if ANT control bit is not set
  2012-10-30 11:13 [PATCH v2] ath9k: Do not enable ANT diversity if ANT control bit is not set Bala Shanmugam
@ 2012-10-30 13:11 ` Felix Fietkau
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Fietkau @ 2012-10-30 13:11 UTC (permalink / raw)
  To: Bala Shanmugam; +Cc: linville, linux-wireless

On 2012-10-30 12:13 PM, Bala Shanmugam wrote:
> RvR test is not good when ANT control bit is not set so
> enable ANT diversity only when ANT control bit is set.
> 
> Signed-off-by: Bala Shanmugam <bkamatch@qca.qualcomm.com>
I don't really like this patch; not only is the description very vague,
but it seems to me that the checks are done at the wrong place.

Further comments below...

> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> @@ -1340,10 +1340,9 @@ static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
>  	regval = REG_READ(ah, AR_PHY_MC_GAIN_CTRL);
>  	regval &= (~AR_ANT_DIV_CTRL_ALL);
>  	regval |= (ant_div_ctl1 & 0x3f) << AR_ANT_DIV_CTRL_ALL_S;
> -	regval &= ~AR_PHY_ANT_DIV_LNADIV;
> -	regval |= ((ant_div_ctl1 >> 6) & 0x1) << AR_PHY_ANT_DIV_LNADIV_S;
>  
> -	if (enable)
> +	if (enable &&
> +	    (ant_div_ctl1 & AR_EEP_ANT_DIV_ENABLE))
>  		regval |= AR_ANT_DIV_ENABLE;
>  
>  	REG_WRITE(ah, AR_PHY_MC_GAIN_CTRL, regval);
The code should check much earlier (preferably somewhere in the eeprom
code) if diversity is available at all, and set a capability
accordingly, so that it doesn't even call this function with
enable==true if no diversity is available.

> @@ -1352,12 +1351,15 @@ static void ar9003_hw_antctrl_shared_chain_lnadiv(struct ath_hw *ah,
>  	regval &= ~AR_FAST_DIV_ENABLE;
>  	regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;
>  
> -	if (enable)
> +	if (enable &&
> +	    (ant_div_ctl1 & AR_EEP_FAST_DIV_ENABLE))
>  		regval |= AR_FAST_DIV_ENABLE;
>  
It would be much simpler to just remove the if statement and the line
below it. This would be equivalent to what you're doing because of this:
  	regval |= ((ant_div_ctl1 >> 7) & 0x1) << AR_FAST_DIV_ENABLE_S;

- Felix

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-30 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-30 11:13 [PATCH v2] ath9k: Do not enable ANT diversity if ANT control bit is not set Bala Shanmugam
2012-10-30 13:11 ` Felix Fietkau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).