Skip to contentSkip to conversation

rt2x00: Fix transmit power troubles on some Ralink RT30xx cards

PATCH In review [email protected] 3 participants 6 messages Apr 15, 2013 – Apr 16, 2013 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rt2x00: Fix transmit power troubles on some Ralink RT30xx cards

From: "Alex A. Mihaylov" <[email protected]>

Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Correctly value in EEPROM/EFUSE is one or more for RT3070 and two or more for other RT30xx chips.

Tested on Canyon CNP-WF518N1 usb Wi-Fi dongle and Jorjin WN8020 usb embedded Wi-Fi module.

---
 drivers/net/wireless/rt2x00/rt2800lib.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +6 -2
index a658b4b..92849e5 100644
@@ -4436,6 +4436,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 
 	if (!rt2x00_rt(rt2x00dev, RT5390) &&
 	    !rt2x00_rt(rt2x00dev, RT5392)) {
+		u8 min_gain = rt2x00_rt(rt2x00dev, RT3070) ? 1 : 2;
+
 		rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
 		rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
 		if (rt2x00_rt(rt2x00dev, RT3070) ||
@@ -4446,8 +4448,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 				      &rt2x00dev->cap_flags))
 				rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
 		}
-		rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
-				  drv_data->txmixer_gain_24g);
+		if (drv_data->txmixer_gain_24g >= min_gain) {
+			rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
+					  drv_data->txmixer_gain_24g);
+		}
 		rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
 	}
 
Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 35 lines · On Mon, Apr 15, 2013 at 5:29 AM, <[email protected]> wrote:

From: "Alex A. Mihaylov" <[email protected]>

Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Correctly value in EEPROM/EFUSE is one or more for RT3070 and two or more for other RT30xx chips.

Tested on Canyon CNP-WF518N1 usb Wi-Fi dongle and Jorjin WN8020 usb embedded Wi-Fi module.

---
 drivers/net/wireless/rt2x00/rt2800lib.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +2 -0
index a658b4b..92849e5 100644
@@ -4436,6 +4436,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 
        if (!rt2x00_rt(rt2x00dev, RT5390) &&
            !rt2x00_rt(rt2x00dev, RT5392)) {
+               u8 min_gain = rt2x00_rt(rt2x00dev, RT3070) ? 1 : 2;
+
                rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
                rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
                if (rt2x00_rt(rt2x00dev, RT3070) ||
@@ -4446,8 +4448,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
                                      &rt2x00dev->cap_flags))
                                rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);

drivers/net/wireless/rt2x00/rt2800lib.c static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) · line 4457

Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800lib.c +4 -2
                }
-               rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
-                                 drv_data->txmixer_gain_24g);
+               if (drv_data->txmixer_gain_24g >= min_gain) {
+                       rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
+                                         drv_data->txmixer_gain_24g);
+               }
                rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
        }
 

Could you explain how you have come to this patch?
Is this behavior of the Ralink provided driver that you replicated here, or have you come to this approach in an other way?

---
Gertjan

#2 lore raw

Good day!

Quoted 6 lines
Quoted 5 lines

From: "Alex A. Mihaylov" <[email protected]>
Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Quoted 6 lines

drivers/net/wireless/rt2x00/rt2800lib.c

Quoted 2 lines
drivers/net/wireless/rt2x00/rt2800lib.c +0 -0

Could you explain how you have come to this patch?
Is this behavior of the Ralink provided driver that you replicated here, or have you come to this approach in an other way?

Yes, vendor driver have this code in chips/rt3070.c (function NICInitRT3070RFRegisters) and chips/rt30xx.c (function RT30xxLoadRFNormalModeSetup) files. Look like this:
[skipped]
if (pAd->TxMixerGain24G >= 2)

{
     RFValue &= (~0x7);  /* clean bit [2:0]*/
     RFValue |= pAd->TxMixerGain24G;
}

RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
[skipped]
and have differents only in constants (2 in rt30xx.c and one in tr3070.c). TxPower i messaurment on power detector, connected directly to module.

#3 lore raw
Quoted 26 lines · Alex Mihaylov

Good day!

Quoted 7 lines
Quoted 5 lines

From: "Alex A. Mihaylov" <[email protected]>
Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Quoted 8 lines

drivers/net/wireless/rt2x00/rt2800lib.c

Quoted 3 lines
drivers/net/wireless/rt2x00/rt2800lib.c +0 -0

Could you explain how you have come to this patch?
Is this behavior of the Ralink provided driver that you replicated here, or have you come to this approach in an other way?

Yes, vendor driver have this code in chips/rt3070.c (function NICInitRT3070RFRegisters) and chips/rt30xx.c (function RT30xxLoadRFNormalModeSetup) files.
Look like this:
[skipped]
if (pAd->TxMixerGain24G >= 2)

Quoted 8 lines
{
     RFValue &= (~0x7);  /* clean bit [2:0]*/
     RFValue |= pAd->TxMixerGain24G;
}

RT30xxWriteRFRegister(pAd, RF_R17, RFValue);
[skipped]
and have differents only in constants (2 in rt30xx.c and one in tr3070.c). TxPower i messaurment on power detector, connected directly to module.

OK. Thanks for the explanation. I've found it myself there as well. I'll ack the patch.

--
---
Gertjan

Acked-by on v2 1/1
#4 lore raw
In reply to [email protected]
Quoted 7 lines · On Mon, Apr 15, 2013 at 5:29 AM, <[email protected]> wrote:

From: "Alex A. Mihaylov" <[email protected]>

Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Quoted 8 lines

Correctly value in EEPROM/EFUSE is one or more for RT3070 and two or more for other RT30xx chips.

Tested on Canyon CNP-WF518N1 usb Wi-Fi dongle and Jorjin WN8020 usb embedded Wi-Fi module.

Quoted 33 lines
---
 drivers/net/wireless/rt2x00/rt2800lib.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +6 -3
index a658b4b..92849e5 100644
@@ -4436,6 +4436,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 
        if (!rt2x00_rt(rt2x00dev, RT5390) &&
            !rt2x00_rt(rt2x00dev, RT5392)) {
+               u8 min_gain = rt2x00_rt(rt2x00dev, RT3070) ? 1 : 2;
+
                rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
                rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
                if (rt2x00_rt(rt2x00dev, RT3070) ||
@@ -4446,8 +4448,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
                                      &rt2x00dev->cap_flags))
                                rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
                }
-               rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
-                                 drv_data->txmixer_gain_24g);
+               if (drv_data->txmixer_gain_24g >= min_gain) {
+                       rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
+                                         drv_data->txmixer_gain_24g);
+               }
                rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
        }
 
--

1.8.1.5

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
---
Gertjan

Acked-by on v2 1/1
#5 lore raw
In reply to [email protected]
Quoted 7 lines · On Mon, Apr 15, 2013 at 07:29:35AM +0400, [email protected] wrote:

From: "Alex A. Mihaylov" <[email protected]>

Some cards on Ralink RT30xx chipset not have correctly TX_MIXER_GAIN value in them EEPROM/EFUSE. In this case, we must use default value, but always used EEPROM/EFUSE value. As result we have tranmitt power range from -10dBm to +6dBm instead 0dBm to +16dBm.

Quoted 8 lines

Correctly value in EEPROM/EFUSE is one or more for RT3070 and two or more for other RT30xx chips.

Tested on Canyon CNP-WF518N1 usb Wi-Fi dongle and Jorjin WN8020 usb embedded Wi-Fi module.