linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592
@ 2013-10-03 18:00 Gabor Juhos
  2013-10-03 18:00 ` [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593 Gabor Juhos
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Gabor Juhos @ 2013-10-03 18:00 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos, stable

In commit 3d81535ea5940446510a8a5cee1c6ad23c90c753
(rt2800: 5592: add chip specific vgc calculations)
the rt2800_link_tuner function has been modified to
adjust VGC level for the RT5592 chipset.

On the RT5592 chipset, the VGC level must be adjusted
only if rssi is greater than -65. However the current
code adjusts the VGC value by 0x10 regardless of the
actual chipset if the rssi value is between -80 and
-65.

Fix the broken behaviour by reordering the if-else
statements.

Cc: stable@vger.kernel.org
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index f414978..2690081 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4469,10 +4469,13 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
 
 	vgc = rt2800_get_default_vgc(rt2x00dev);
 
-	if (rt2x00_rt(rt2x00dev, RT5592) && qual->rssi > -65)
-		vgc += 0x20;
-	else if (qual->rssi > -80)
-		vgc += 0x10;
+	if (rt2x00_rt(rt2x00dev, RT5592)) {
+		if (qual->rssi > -65)
+			vgc += 0x20;
+	} else {
+		if (qual->rssi > -80)
+			vgc += 0x10;
+	}
 
 	rt2800_set_vgc(rt2x00dev, qual, vgc);
 }
-- 
1.7.10

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

* [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593
  2013-10-03 18:00 [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Gabor Juhos
@ 2013-10-03 18:00 ` Gabor Juhos
  2013-10-04 14:27   ` [rt2x00-users] " Stanislaw Gruszka
  2013-10-03 18:00 ` [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593 Gabor Juhos
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Gabor Juhos @ 2013-10-03 18:00 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

The Ralink DPO_RT5572_LinuxSTA_2.6.1.3_20121022
reference driver uses different RSSI threshold
and VGC adjustment values for the RT3572 and
RT3593 chipsets.

Update the rt2800_link_tuner function to use the
same values. Also change the comment in the function
to make it more generic.

References:

  RT35xx_ChipAGCAdjust function in chips/rt35xx.c
  RSSI_FOR_MID_LOW_SENSIBILITY constant in include/chip/rtmp_phy.h
  RT3593_R66_MID_LOW_SENS_GET macro in include/chip/rt3593.h
  RT3593_R66_NON_MID_LOW_SEMS_GET macro in include/chips/rt3593.h

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 2690081..a619f2c 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4462,19 +4462,34 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
 
 	if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C))
 		return;
-	/*
-	 * When RSSI is better then -80 increase VGC level with 0x10, except
-	 * for rt5592 chip.
+
+	/* When RSSI is better than a certain threshold, increase VGC
+	 * with a chip specific value in order to improve the balance
+	 * between sensibility and noise isolation.
 	 */
 
 	vgc = rt2800_get_default_vgc(rt2x00dev);
 
-	if (rt2x00_rt(rt2x00dev, RT5592)) {
+	switch (rt2x00dev->chip.rt) {
+	case RT3572:
+	case RT3593:
+		if (qual->rssi > -65) {
+			if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ)
+				vgc += 0x20;
+			else
+				vgc += 0x10;
+		}
+		break;
+
+	case RT5592:
 		if (qual->rssi > -65)
 			vgc += 0x20;
-	} else {
+		break;
+
+	default:
 		if (qual->rssi > -80)
 			vgc += 0x10;
+		break;
 	}
 
 	rt2800_set_vgc(rt2x00dev, qual, vgc);
-- 
1.7.10

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

* [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593
  2013-10-03 18:00 [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Gabor Juhos
  2013-10-03 18:00 ` [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593 Gabor Juhos
@ 2013-10-03 18:00 ` Gabor Juhos
  2013-10-04 14:38   ` [rt2x00-users] " Stanislaw Gruszka
  2013-10-03 18:00 ` [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593 Gabor Juhos
  2013-10-04 14:19 ` [rt2x00-users] [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Stanislaw Gruszka
  3 siblings, 1 reply; 9+ messages in thread
From: Gabor Juhos @ 2013-10-03 18:00 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

Update the rt2800_get_default_vgc function to use the same VGC
values that the DPO_RT5572_LinuxSTA_2.6.1.3_20121022 reference
driver uses.

References:
  RT35xx_ChipAGCAdjust in chips/rt35xx.c
  RT3593_R66_MID_LOW_SENS_GET macro in include/chip/rt3593.h
  RT3593_R66_NON_MID_LOW_SEMS_GET macro in include/chips/rt3593.h

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index a619f2c..55b421f 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4413,6 +4413,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
 		    rt2x00_rt(rt2x00dev, RT3290) ||
 		    rt2x00_rt(rt2x00dev, RT3390) ||
 		    rt2x00_rt(rt2x00dev, RT3572) ||
+		    rt2x00_rt(rt2x00dev, RT3593) ||
 		    rt2x00_rt(rt2x00dev, RT5390) ||
 		    rt2x00_rt(rt2x00dev, RT5392) ||
 		    rt2x00_rt(rt2x00dev, RT5592))
@@ -4422,6 +4423,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
 	} else { /* 5GHZ band */
 		if (rt2x00_rt(rt2x00dev, RT3572))
 			vgc = 0x22 + (rt2x00dev->lna_gain * 5) / 3;
+		else if (rt2x00_rt(rt2x00dev, RT3593))
+			vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3;
 		else if (rt2x00_rt(rt2x00dev, RT5592))
 			vgc = 0x24 + (2 * rt2x00dev->lna_gain);
 		else {
-- 
1.7.10

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

* [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593
  2013-10-03 18:00 [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Gabor Juhos
  2013-10-03 18:00 ` [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593 Gabor Juhos
  2013-10-03 18:00 ` [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593 Gabor Juhos
@ 2013-10-03 18:00 ` Gabor Juhos
  2013-10-04 14:39   ` [rt2x00-users] " Stanislaw Gruszka
  2013-10-04 14:19 ` [rt2x00-users] [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Stanislaw Gruszka
  3 siblings, 1 reply; 9+ messages in thread
From: Gabor Juhos @ 2013-10-03 18:00 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

According to the DPO_RT5572_LinuxSTA_2.6.1.3_20121022
reference driver, programming of the 'BBP 66' register
on the RT3572 and RT3593 chipsets must be done via the
'rt2800_bbp_write_with_rx_chain' function. This ensures
that value is correclty set for all RX chains.

References:
  RT35xx_ChipAGCAdjust and RT35xx_SetAGCInitValue functions
  in chips/rt35xx.c

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 55b421f..f81e943 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4442,11 +4442,17 @@ static inline void rt2800_set_vgc(struct rt2x00_dev *rt2x00dev,
 				  struct link_qual *qual, u8 vgc_level)
 {
 	if (qual->vgc_level != vgc_level) {
-		if (rt2x00_rt(rt2x00dev, RT5592)) {
+		if (rt2x00_rt(rt2x00dev, RT3572) ||
+		    rt2x00_rt(rt2x00dev, RT3593)) {
+			rt2800_bbp_write_with_rx_chain(rt2x00dev, 66,
+						       vgc_level);
+		} else if (rt2x00_rt(rt2x00dev, RT5592)) {
 			rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a);
 			rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, vgc_level);
-		} else
+		} else {
 			rt2800_bbp_write(rt2x00dev, 66, vgc_level);
+		}
+
 		qual->vgc_level = vgc_level;
 		qual->vgc_level_reg = vgc_level;
 	}
-- 
1.7.10

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

* Re: [rt2x00-users] [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592
  2013-10-03 18:00 [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Gabor Juhos
                   ` (2 preceding siblings ...)
  2013-10-03 18:00 ` [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593 Gabor Juhos
@ 2013-10-04 14:19 ` Stanislaw Gruszka
  3 siblings, 0 replies; 9+ messages in thread
From: Stanislaw Gruszka @ 2013-10-04 14:19 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users, stable

On Thu, Oct 03, 2013 at 08:00:40PM +0200, Gabor Juhos wrote:
> In commit 3d81535ea5940446510a8a5cee1c6ad23c90c753
> (rt2800: 5592: add chip specific vgc calculations)
> the rt2800_link_tuner function has been modified to
> adjust VGC level for the RT5592 chipset.
> 
> On the RT5592 chipset, the VGC level must be adjusted
> only if rssi is greater than -65. However the current
> code adjusts the VGC value by 0x10 regardless of the
> actual chipset if the rssi value is between -80 and
> -65.
> 
> Fix the broken behaviour by reordering the if-else
> statements.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

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

* Re: [rt2x00-users] [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593
  2013-10-03 18:00 ` [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593 Gabor Juhos
@ 2013-10-04 14:27   ` Stanislaw Gruszka
  0 siblings, 0 replies; 9+ messages in thread
From: Stanislaw Gruszka @ 2013-10-04 14:27 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users

On Thu, Oct 03, 2013 at 08:00:41PM +0200, Gabor Juhos wrote:
> The Ralink DPO_RT5572_LinuxSTA_2.6.1.3_20121022
> reference driver uses different RSSI threshold
> and VGC adjustment values for the RT3572 and
> RT3593 chipsets.
> 
> Update the rt2800_link_tuner function to use the
> same values. Also change the comment in the function
> to make it more generic.
> 
> References:
> 
>   RT35xx_ChipAGCAdjust function in chips/rt35xx.c
>   RSSI_FOR_MID_LOW_SENSIBILITY constant in include/chip/rtmp_phy.h
>   RT3593_R66_MID_LOW_SENS_GET macro in include/chip/rt3593.h
>   RT3593_R66_NON_MID_LOW_SEMS_GET macro in include/chips/rt3593.h
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

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

* Re: [rt2x00-users] [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593
  2013-10-03 18:00 ` [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593 Gabor Juhos
@ 2013-10-04 14:38   ` Stanislaw Gruszka
  2013-10-04 19:59     ` Gabor Juhos
  0 siblings, 1 reply; 9+ messages in thread
From: Stanislaw Gruszka @ 2013-10-04 14:38 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users

On Thu, Oct 03, 2013 at 08:00:42PM +0200, Gabor Juhos wrote:
> Update the rt2800_get_default_vgc function to use the same VGC
> values that the DPO_RT5572_LinuxSTA_2.6.1.3_20121022 reference
> driver uses.
> 
> References:
>   RT35xx_ChipAGCAdjust in chips/rt35xx.c
>   RT3593_R66_MID_LOW_SENS_GET macro in include/chip/rt3593.h
>   RT3593_R66_NON_MID_LOW_SEMS_GET macro in include/chips/rt3593.h
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

> @@ -4422,6 +4423,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
>  	} else { /* 5GHZ band */
>  		if (rt2x00_rt(rt2x00dev, RT3572))
>  			vgc = 0x22 + (rt2x00dev->lna_gain * 5) / 3;

Looks RT3572 values should be also changed ? According to:

                if (pAd->CommonCfg.BBPCurrentBW == BW_20)
                {
                        R66 = 0x32 + (lanGain*5) / 3;
                        if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
                                R66 += 0x10;
                }
                else
                {
                        R66 = 0x3A + (lanGain*5)/3;
                        if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
                                R66 += 0x10;
                }       


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

* Re: [rt2x00-users] [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593
  2013-10-03 18:00 ` [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593 Gabor Juhos
@ 2013-10-04 14:39   ` Stanislaw Gruszka
  0 siblings, 0 replies; 9+ messages in thread
From: Stanislaw Gruszka @ 2013-10-04 14:39 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users

On Thu, Oct 03, 2013 at 08:00:43PM +0200, Gabor Juhos wrote:
> According to the DPO_RT5572_LinuxSTA_2.6.1.3_20121022
> reference driver, programming of the 'BBP 66' register
> on the RT3572 and RT3593 chipsets must be done via the
> 'rt2800_bbp_write_with_rx_chain' function. This ensures
> that value is correclty set for all RX chains.
> 
> References:
>   RT35xx_ChipAGCAdjust and RT35xx_SetAGCInitValue functions
>   in chips/rt35xx.c
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>

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

* Re: [rt2x00-users] [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593
  2013-10-04 14:38   ` [rt2x00-users] " Stanislaw Gruszka
@ 2013-10-04 19:59     ` Gabor Juhos
  0 siblings, 0 replies; 9+ messages in thread
From: Gabor Juhos @ 2013-10-04 19:59 UTC (permalink / raw)
  To: Stanislaw Gruszka; +Cc: John Linville, linux-wireless, users

2013.10.04. 16:38 keltezéssel, Stanislaw Gruszka írta:
> On Thu, Oct 03, 2013 at 08:00:42PM +0200, Gabor Juhos wrote:
>> Update the rt2800_get_default_vgc function to use the same VGC
>> values that the DPO_RT5572_LinuxSTA_2.6.1.3_20121022 reference
>> driver uses.
>>
>> References:
>>   RT35xx_ChipAGCAdjust in chips/rt35xx.c
>>   RT3593_R66_MID_LOW_SENS_GET macro in include/chip/rt3593.h
>>   RT3593_R66_NON_MID_LOW_SEMS_GET macro in include/chips/rt3593.h
>>
>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> 
> Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
> 
>> @@ -4422,6 +4423,8 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
>>  	} else { /* 5GHZ band */
>>  		if (rt2x00_rt(rt2x00dev, RT3572))
>>  			vgc = 0x22 + (rt2x00dev->lna_gain * 5) / 3;
> 
> Looks RT3572 values should be also changed ? According to:
> 
>                 if (pAd->CommonCfg.BBPCurrentBW == BW_20)
>                 {
>                         R66 = 0x32 + (lanGain*5) / 3;
>                         if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
>                                 R66 += 0x10;
>                 }
>                 else
>                 {
>                         R66 = 0x3A + (lanGain*5)/3;
>                         if (Rssi > RSSI_FOR_MID_LOW_SENSIBILITY)
>                                 R66 += 0x10;
>                 }       

Yes. I even created a patch for that, but I forgot to add that into the series.
Will send that separately.

-Gabor

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

end of thread, other threads:[~2013-10-04 19:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 18:00 [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Gabor Juhos
2013-10-03 18:00 ` [PATCH v2 2/4] rt2x00: rt2800lib: fix VGC adjustment for RT3572 and RT3593 Gabor Juhos
2013-10-04 14:27   ` [rt2x00-users] " Stanislaw Gruszka
2013-10-03 18:00 ` [PATCH v2 3/4] rt2x00: rt2800lib: fix default VGC values for RT3593 Gabor Juhos
2013-10-04 14:38   ` [rt2x00-users] " Stanislaw Gruszka
2013-10-04 19:59     ` Gabor Juhos
2013-10-03 18:00 ` [PATCH v2 4/4] rt2x00: rt2800lib: fix VGC programming for RT3572 and RT3593 Gabor Juhos
2013-10-04 14:39   ` [rt2x00-users] " Stanislaw Gruszka
2013-10-04 14:19 ` [rt2x00-users] [PATCH v2 1/4] rt2x00: rt2800lib: fix VGC adjustment for RT5592 Stanislaw Gruszka

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).