rt2800: add chipset revision RT5390R support
authorAnisse Astier <anisse@astier.eu>
Mon, 23 Apr 2012 10:33:11 +0000 (12:33 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 23 Apr 2012 19:37:42 +0000 (15:37 -0400)
About 70% of the chips with revision RT5390R initialize incorrectly, using
the auxiliary antenna instead of the main one. The net result is that
signal reception is very poor (no AP further than 1M).

This chipset differs from RT5390 and RT5390F by its support of hardware
antenna diversity. Therefore antenna selection should be done
differently, by disabling software features and previously selected
antenna.

This changeset does just that, and makes all RT5390R work properly.

This is based on Ralink's 2012_03_22_RT5572_Linux_STA_v2.6.0.0_DPO
driver.

Signed-off-by: Anisse Astier <anisse@astier.eu>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800.h
drivers/net/wireless/rt2x00/rt2800lib.c

index 1c4d75004627af70db6e11b037c2f51fde2d5fe4..d91f4f628f655a11268cefe84ac5069f0f8e387e 100644 (file)
@@ -83,6 +83,7 @@
 #define REV_RT3090E                    0x0211
 #define REV_RT3390E                    0x0211
 #define REV_RT5390F                    0x0502
+#define REV_RT5390R                    0x1502
 
 /*
  * Signal information.
index bd1980202f19a5eae9bb33f449479884e27531dd..1cd16b416024c1d4b002633f704fd4df931a4d6b 100644 (file)
@@ -3356,6 +3356,13 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
                        rt2800_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);
                }
 
+               /* This chip has hardware antenna diversity*/
+               if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390R)) {
+                       rt2800_bbp_write(rt2x00dev, 150, 0); /* Disable Antenna Software OFDM */
+                       rt2800_bbp_write(rt2x00dev, 151, 0); /* Disable Antenna Software CCK */
+                       rt2800_bbp_write(rt2x00dev, 154, 0); /* Clear previously selected antenna */
+               }
+
                rt2800_bbp_read(rt2x00dev, 152, &value);
                if (ant == 0)
                        rt2x00_set_field8(&value, BBP152_RX_DEFAULT_ANT, 1);
@@ -4291,6 +4298,11 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
                rt2x00dev->default_ant.rx = ANTENNA_A;
        }
 
+       if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390R)) {
+               rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */
+               rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */
+       }
+
        /*
         * Determine external LNA informations.
         */