linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rt2x00: rt2800lib: fix default VGC values for RT3572 for the 5GHz band
@ 2013-10-04 20:07 Gabor Juhos
  2013-10-05 13:01 ` [rt2x00-users] " Stanislaw Gruszka
  0 siblings, 1 reply; 2+ messages in thread
From: Gabor Juhos @ 2013-10-04 20:07 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, users, Gabor Juhos

The rt2x00 driver uses 0x22 as a default VGC value
in VGC adjustment for the RT3572 chipset. In the
Ralink DPO_RT5572_LinuxSTA_2.6.1.3_20121022 driver,
this value is only used for initialization. During
VGC adjustment, the reference driver uses different
values.

Update the 'rt2800_get_default_vgc' function to
synchronize the values with the reference driver.
Also add the missing AGC initialization code into
the 'rt2800_config_channel' function.

References:
  RT35xx_SetAGCInitValue in chip/rt35xx.c
  RT35xx_ChipAGCAdjust in chip/rt35xx.c

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

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 95c18dc..7508729 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -3310,9 +3310,18 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
 
 	rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
 
-	if (rt2x00_rt(rt2x00dev, RT3572))
+	if (rt2x00_rt(rt2x00dev, RT3572)) {
 		rt2800_rfcsr_write(rt2x00dev, 8, 0x80);
 
+		/* AGC init */
+		if (rf->channel <= 14)
+			reg = 0x1c + (2 * rt2x00dev->lna_gain);
+		else
+			reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3);
+
+		rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
+	}
+
 	if (rt2x00_rt(rt2x00dev, RT3593)) {
 		rt2800_register_read(rt2x00dev, GPIO_CTRL, &reg);
 
@@ -4421,9 +4430,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
 		else
 			vgc = 0x2e + rt2x00dev->lna_gain;
 	} else { /* 5GHZ band */
-		if (rt2x00_rt(rt2x00dev, RT3572))
-			vgc = 0x22 + (rt2x00dev->lna_gain * 5) / 3;
-		else if (rt2x00_rt(rt2x00dev, RT3593))
+		if (rt2x00_rt(rt2x00dev, RT3593))
 			vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3;
 		else if (rt2x00_rt(rt2x00dev, RT5592))
 			vgc = 0x24 + (2 * rt2x00dev->lna_gain);
-- 
1.7.10

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

* Re: [rt2x00-users] [PATCH] rt2x00: rt2800lib: fix default VGC values for RT3572 for the 5GHz band
  2013-10-04 20:07 [PATCH] rt2x00: rt2800lib: fix default VGC values for RT3572 for the 5GHz band Gabor Juhos
@ 2013-10-05 13:01 ` Stanislaw Gruszka
  0 siblings, 0 replies; 2+ messages in thread
From: Stanislaw Gruszka @ 2013-10-05 13:01 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John Linville, linux-wireless, users

On Fri, Oct 04, 2013 at 10:07:09PM +0200, Gabor Juhos wrote:
> The rt2x00 driver uses 0x22 as a default VGC value
> in VGC adjustment for the RT3572 chipset. In the
> Ralink DPO_RT5572_LinuxSTA_2.6.1.3_20121022 driver,
> this value is only used for initialization. During
> VGC adjustment, the reference driver uses different
> values.
> 
> Update the 'rt2800_get_default_vgc' function to
> synchronize the values with the reference driver.
> Also add the missing AGC initialization code into
> the 'rt2800_config_channel' function.
> 
> References:
>   RT35xx_SetAGCInitValue in chip/rt35xx.c
>   RT35xx_ChipAGCAdjust in chip/rt35xx.c
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

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

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

end of thread, other threads:[~2013-10-05 12:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-04 20:07 [PATCH] rt2x00: rt2800lib: fix default VGC values for RT3572 for the 5GHz band Gabor Juhos
2013-10-05 13:01 ` [rt2x00-users] " 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).