[source] mac80211: rt2x00: add incomplete support for external PA on MT7620

LEDE Commits lede-commits at lists.infradead.org
Mon Apr 24 07:35:41 PDT 2017


dangole pushed a commit to source.git, branch master:
https://git.lede-project.org/61cfc8075b615c231cf6349b3708d0a7e073613e

commit 61cfc8075b615c231cf6349b3708d0a7e073613e
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Mon Apr 24 01:44:29 2017 +0200

    mac80211: rt2x00: add incomplete support for external PA on MT7620
    
    Do as the vendor driver does -- however, some devices apparently
    patched support for external PA into the driver similar to how it was
    done on Rt3352, using EEPROM_NIC_CONF1 rather than EEPROM_NIC_CONF2,
    hence we check for both fields. Somehow the vendor driver also no
    longer offers the option of only one of the TX paths having an external
    PA (which was probably to weird to ever be implemented in practise,
    though it doesn't seem like a particularly bad idea to me). Do the same
    in rt2x00 and enable support for external PA on both TX paths whenever
    it is set for TX0 in EEPROM.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 ...x00-add-support-for-external-PA-on-MT7620.patch | 125 +++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/package/kernel/mac80211/patches/650-rt2x00-add-support-for-external-PA-on-MT7620.patch b/package/kernel/mac80211/patches/650-rt2x00-add-support-for-external-PA-on-MT7620.patch
new file mode 100644
index 0000000..b224861
--- /dev/null
+++ b/package/kernel/mac80211/patches/650-rt2x00-add-support-for-external-PA-on-MT7620.patch
@@ -0,0 +1,125 @@
+From 9782a7f7488443568fa4d6088b73c9aff7eb8510 Mon Sep 17 00:00:00 2001
+From: Daniel Golle <daniel at makrotopia.org>
+Date: Wed, 19 Apr 2017 16:14:53 +0200
+Subject: [PATCH] rt2x00: add support for external PA on MT7620
+To: Stanislaw Gruszka <sgruszka at redhat.com>
+Cc: Helmut Schaa <helmut.schaa at googlemail.com>,
+    linux-wireless at vger.kernel.org,
+    Kalle Valo <kvalo at codeaurora.org>
+
+Signed-off-by: Daniel Golle <daniel at makrotopia.org>
+---
+ drivers/net/wireless/ralink/rt2x00/rt2800.h    |  1 +
+ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 70 +++++++++++++++++++++++++-
+ 2 files changed, 70 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800.h b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+index 6a8c93fb6a43..df0cefe44171 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
+@@ -2732,6 +2732,7 @@ enum rt2800_eeprom_word {
+ #define EEPROM_NIC_CONF2_RX_STREAM	FIELD16(0x000f)
+ #define EEPROM_NIC_CONF2_TX_STREAM	FIELD16(0x00f0)
+ #define EEPROM_NIC_CONF2_CRYSTAL	FIELD16(0x0600)
++#define EEPROM_NIC_CONF2_EXTERNAL_PA	FIELD16(0xc000)
+ 
+ /*
+  * EEPROM LNA
+diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+index c06db547b0a4..db431c9544e2 100644
+--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+@@ -3834,6 +3834,61 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
+ 		rt2800_iq_calibrate(rt2x00dev, rf->channel);
+ 	}
+ 
++	if (rt2x00_rt(rt2x00dev, RT6352)) {
++		if (test_bit(CAPABILITY_EXTERNAL_PA_TX0,
++			     &rt2x00dev->cap_flags)) {
++			rt2x00_warn(rt2x00dev, "Using incomplete support for " \
++					       "external PA\n");
++			rt2800_register_read(rt2x00dev, RF_CONTROL3, &reg);
++			reg |= 0x00000101;
++			rt2800_register_write(rt2x00dev, RF_CONTROL3, reg);
++
++			rt2800_register_read(rt2x00dev, RF_BYPASS3, &reg);
++			reg |= 0x00000101;
++			rt2800_register_write(rt2x00dev, RF_BYPASS3, reg);
++
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 43, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 43, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 44, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 44, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 45, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 45, 0x73);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 46, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 46, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 47, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 47, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 48, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 48, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 49, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 49, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 54, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 54, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 55, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 55, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 56, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 56, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 57, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 57, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 58, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 58, 0x27);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 59, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 59, 0xC8);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 60, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 60, 0xA4);
++			rt2800_rfcsr_write_bank(rt2x00dev, 4, 61, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 6, 61, 0x05);
++			rt2800_rfcsr_write_bank(rt2x00dev, 5, 05, 0x00);
++			rt2800_rfcsr_write_bank(rt2x00dev, 7, 05, 0x00);
++
++			rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT,
++					      0x36303636);
++			rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN,
++					      0x6C6C6B6C);
++			rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN,
++					      0x6C6C6B6C);
++		}
++	}
++
+ 	rt2800_bbp_read(rt2x00dev, 4, &bbp);
+ 	rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
+ 	rt2800_bbp_write(rt2x00dev, 4, bbp);
+@@ -8796,7 +8851,8 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
+ 	 */
+ 	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
+ 
+-	if (rt2x00_rt(rt2x00dev, RT3352)) {
++	if (rt2x00_rt(rt2x00dev, RT3352) ||
++	    rt2x00_rt(rt2x00dev, RT6352)) {
+ 		if (rt2x00_get_field16(eeprom,
+ 		    EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
+ 		    __set_bit(CAPABILITY_EXTERNAL_PA_TX0,
+@@ -8807,6 +8863,18 @@ static int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
+ 			      &rt2x00dev->cap_flags);
+ 	}
+ 
++	rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF2, &eeprom);
++
++	if (rt2x00_rt(rt2x00dev, RT6352) && eeprom != 0 && eeprom != 0xffff) {
++		if (rt2x00_get_field16(eeprom,
++		    EEPROM_NIC_CONF2_EXTERNAL_PA)) {
++		    __set_bit(CAPABILITY_EXTERNAL_PA_TX0,
++			      &rt2x00dev->cap_flags);
++		    __set_bit(CAPABILITY_EXTERNAL_PA_TX1,
++			      &rt2x00dev->cap_flags);
++		}
++	}
++
+ 	return 0;
+ }
+ 
+-- 
+2.12.2
+



More information about the lede-commits mailing list