rt2800: fix LNA gain assignment for MT7620
authorDaniel Golle <daniel@makrotopia.org>
Mon, 17 Apr 2017 19:30:12 +0000 (21:30 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 20 Apr 2017 10:59:59 +0000 (13:59 +0300)
The base value used for MT7620 differs from Rt5392 which resulted in
quite bad RX signal quality. Fix this by using the correct base value as
well as the LNA calibration values for HT20.

Reported-by: Tom Psyborg <pozega.tomislav@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ralink/rt2x00/rt2800lib.c

index ba06ac2d876da2f5ddcfd9cb7bb9da73ac11a1a8..7135519a638c9493c546784669fd582671058272 100644 (file)
@@ -3806,11 +3806,25 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
        }
 
        if (rt2x00_rt(rt2x00dev, RT5592) || rt2x00_rt(rt2x00dev, RT6352)) {
+               reg = 0x10;
+               if (!conf_is_ht40(conf)) {
+                       if (rt2x00_rt(rt2x00dev, RT6352) &&
+                           rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
+                               reg |= 0x5;
+                       } else {
+                               reg |= 0xa;
+                       }
+               }
                rt2800_bbp_write(rt2x00dev, 195, 141);
-               rt2800_bbp_write(rt2x00dev, 196, conf_is_ht40(conf) ? 0x10 : 0x1a);
+               rt2800_bbp_write(rt2x00dev, 196, reg);
 
                /* AGC init */
-               reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2 * rt2x00dev->lna_gain;
+               if (rt2x00_rt(rt2x00dev, RT6352))
+                       reg = 0x04;
+               else
+                       reg = rf->channel <= 14 ? 0x1c : 0x24;
+
+               reg += 2 * rt2x00dev->lna_gain;
                rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
 
                rt2800_iq_calibrate(rt2x00dev, rf->channel);