From 412fcf3d4400f84551f3ead0514834c62d94a251 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 17 Sep 2022 20:11:12 +0100 Subject: [PATCH] mac80211: rt2x00: replace patches with v3 of pending series See also patchwork for submission progress: https://patchwork.kernel.org/project/linux-wireless/cover/cover.1663445157.git.daniel@makrotopia.org/ Signed-off-by: Daniel Golle --- ...define-RF5592-in-init_eeprom-routine.patch | 52 ++++ ...2-rt2x00-add-throughput-LED-trigger.patch} | 42 +++- ...define-RF5592-in-init_eeprom-routine.patch | 46 ---- ...d-support-for-external-PA-on-MT7620.patch} | 45 ++-- ...ove-up-and-reuse-busy-wait-functions.patch | 178 ++++++++++++++ ...RF-self-TXDC-calibration-for-MT7620.patch} | 50 ++-- ...rt2x00-add-r-calibration-for-MT7620.patch} | 85 ++++--- ...0-add-RXDCOC-calibration-for-MT7620.patch} | 62 ++--- ...x00-add-RXIQ-calibration-for-MT7620.patch} | 223 +++++++++--------- ...-run-Rt5592-IQ-calibration-on-MT7620.patch | 52 ++++ ...-add-TX-LOFT-calibration-for-MT7620.patch} | 108 +++++---- ...00-move-helper-functions-up-in-file.patch} | 42 +++- ...HT20-HT40-bandwidth-switch-on-MT7620.patch | 56 +++++ ...t-TX_SW_CFG1-MAC-register-for-MT7620.patch | 52 ++++ ...t-VGC-gain-for-both-chains-of-MT7620.patch | 50 ++++ ...-rt2x00-set-SoC-wmac-clock-register.patch} | 40 +++- ...ectly-set-BBP-register-86-for-MT7620.patch | 79 +++++++ .../602-rt2x00-introduce-rt2x00eeprom.patch | 8 +- ...0-rt2x00-change-led-polarity-from-OF.patch | 2 +- .../611-rt2x00-add-AP+STA-support.patch | 2 +- ...-run-Rt5592-IQ-calibration-on-MT7620.patch | 35 --- ...HT20-HT40-bandwidth-switch-on-MT7620.patch | 40 ---- ...ct-TX_SW_CFG1-MAC-register-for-MT762.patch | 35 --- ...t-VGC-gain-for-both-chains-of-MT7620.patch | 34 --- ...ectly-set-BBP-register-86-for-MT7620.patch | 36 --- ...t-support-for-external-LNA-on-MT7620.patch | 6 +- ...-differentiate-based-on-SoC-CHIP_VER.patch | 22 +- 27 files changed, 938 insertions(+), 544 deletions(-) create mode 100644 package/kernel/mac80211/patches/rt2x00/001-rt2x00-define-RF5592-in-init_eeprom-routine.patch rename package/kernel/mac80211/patches/rt2x00/{612-rt2x00-add-throughput-LED-trigger.patch => 002-rt2x00-add-throughput-LED-trigger.patch} (54%) delete mode 100644 package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch rename package/kernel/mac80211/patches/rt2x00/{650-rt2x00-add-support-for-external-PA-on-MT7620.patch => 003-rt2x00-add-support-for-external-PA-on-MT7620.patch} (72%) create mode 100644 package/kernel/mac80211/patches/rt2x00/004-rt2x00-move-up-and-reuse-busy-wait-functions.patch rename package/kernel/mac80211/patches/rt2x00/{982-rt2x00-add-RF-self-TXDC-calibration.patch => 005-rt2x00-add-RF-self-TXDC-calibration-for-MT7620.patch} (64%) rename package/kernel/mac80211/patches/rt2x00/{983-rt2x00-add-r-calibration.patch => 006-rt2x00-add-r-calibration-for-MT7620.patch} (72%) rename package/kernel/mac80211/patches/rt2x00/{984-rt2x00-add-RXDCOC-calibration.patch => 007-rt2x00-add-RXDCOC-calibration-for-MT7620.patch} (63%) rename package/kernel/mac80211/patches/rt2x00/{985-rt2x00-add-RXIQ-calibration.patch => 008-rt2x00-add-RXIQ-calibration-for-MT7620.patch} (72%) create mode 100644 package/kernel/mac80211/patches/rt2x00/009-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch rename package/kernel/mac80211/patches/rt2x00/{987-rt2x00-add-TX-LOFT-calibration.patch => 010-rt2x00-add-TX-LOFT-calibration-for-MT7620.patch} (92%) rename package/kernel/mac80211/patches/rt2x00/{988-rt2x00-move-helper-functions-up-in-file.patch => 011-rt2x00-move-helper-functions-up-in-file.patch} (59%) create mode 100644 package/kernel/mac80211/patches/rt2x00/012-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch create mode 100644 package/kernel/mac80211/patches/rt2x00/013-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT7620.patch create mode 100644 package/kernel/mac80211/patches/rt2x00/014-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch rename package/kernel/mac80211/patches/rt2x00/{992-rt2x00-set-SoC-wmac-clock-register.patch => 015-rt2x00-set-SoC-wmac-clock-register.patch} (51%) create mode 100644 package/kernel/mac80211/patches/rt2x00/016-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch delete mode 100644 package/kernel/mac80211/patches/rt2x00/986-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch delete mode 100644 package/kernel/mac80211/patches/rt2x00/989-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch delete mode 100644 package/kernel/mac80211/patches/rt2x00/990-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT762.patch delete mode 100644 package/kernel/mac80211/patches/rt2x00/991-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch delete mode 100644 package/kernel/mac80211/patches/rt2x00/993-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch diff --git a/package/kernel/mac80211/patches/rt2x00/001-rt2x00-define-RF5592-in-init_eeprom-routine.patch b/package/kernel/mac80211/patches/rt2x00/001-rt2x00-define-RF5592-in-init_eeprom-routine.patch new file mode 100644 index 0000000000..351e24a4d5 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/001-rt2x00-define-RF5592-in-init_eeprom-routine.patch @@ -0,0 +1,52 @@ +From patchwork Sat Sep 17 20:26:27 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979242 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:26:27 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 01/16] rt2x00: define RF5592 in init_eeprom routine +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +From: Tomislav Požega + +Fix incorrect RF value encoded in EEPROM on devices with Ralink Rt5592 +PCIe radio (a single chip 2T2R 802.11abgn solution). + +Signed-off-by: Tomislav Požega +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -9435,6 +9435,8 @@ static int rt2800_init_eeprom(struct rt2 + rf = RF3853; + else if (rt2x00_rt(rt2x00dev, RT5350)) + rf = RF5350; ++ else if (rt2x00_rt(rt2x00dev, RT5592)) ++ rf = RF5592; + else + rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); + diff --git a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch b/package/kernel/mac80211/patches/rt2x00/002-rt2x00-add-throughput-LED-trigger.patch similarity index 54% rename from package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch rename to package/kernel/mac80211/patches/rt2x00/002-rt2x00-add-throughput-LED-trigger.patch index c9cada6dbd..02d1f7a2e5 100644 --- a/package/kernel/mac80211/patches/rt2x00/612-rt2x00-add-throughput-LED-trigger.patch +++ b/package/kernel/mac80211/patches/rt2x00/002-rt2x00-add-throughput-LED-trigger.patch @@ -1,16 +1,31 @@ -From 208be6e22eba13408a0a3eb4c02256bc9ddfaf48 Mon Sep 17 00:00:00 2001 +From patchwork Sat Sep 17 20:26:40 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979243 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:26:40 +0100 From: Daniel Golle -Date: Mon, 16 Dec 2019 20:47:06 +0100 -Subject: [PATCH 02/16] rt2x00: add throughput LED trigger -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 02/16] rt2x00: add throughput LED trigger +Message-ID: + <73f5ba4134e621462a26186449400cf0c1ac1730.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: David Bauer @@ -20,13 +35,14 @@ was limited to a single VAP. Tested-by: Christoph Krapp Signed-off-by: David Bauer +Acked-by: Stanislaw Gruszka --- drivers/net/wireless/ralink/rt2x00/rt2x00dev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1125,6 +1125,19 @@ static void rt2x00lib_remove_hw(struct r +@@ -1093,6 +1093,19 @@ static void rt2x00lib_remove_hw(struct r kfree(rt2x00dev->spec.channels_info); } @@ -46,7 +62,7 @@ Signed-off-by: David Bauer static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) { struct hw_mode_spec *spec = &rt2x00dev->spec; -@@ -1206,6 +1219,11 @@ static int rt2x00lib_probe_hw(struct rt2 +@@ -1174,6 +1187,11 @@ static int rt2x00lib_probe_hw(struct rt2 #undef RT2X00_TASKLET_INIT diff --git a/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch b/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch deleted file mode 100644 index df4aab0d95..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/002-rt2x00-define-RF5592-in-init_eeprom-routine.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 15eed6b853b7e06f08632ef3cbe6cc42ac3eb858 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Thu, 27 Dec 2018 15:05:26 +0100 -Subject: [PATCH 01/16] rt2x00: define RF5592 in init_eeprom routine -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -From: Tomislav Požega - -This patch fixes following crash on Linksys EA2750 during 5GHz wifi -init: - -[ 7.955153] rt2800pci 0000:01:00.0: card - bus=0x1, slot = 0x0 irq=4 -[ 7.962259] rt2800pci 0000:01:00.0: loaded eeprom from mtd device "Factory" -[ 7.969435] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5592, rev 0222 detected -[ 7.977348] ieee80211 phy0: rt2800_init_eeprom: Error - Invalid RF chipset 0x0000 detected -[ 7.985793] ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device -[ 7.993569] CPU 0 Unable to handle kernel paging request at virtual address 00000024, epc == 800c8f54, ra == 80249ff8 -[ 8.004408] Oops[#1]: - -Signed-off-by: Tomislav Požega ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -9435,6 +9435,8 @@ static int rt2800_init_eeprom(struct rt2 - rf = RF3853; - else if (rt2x00_rt(rt2x00dev, RT5350)) - rf = RF5350; -+ else if (rt2x00_rt(rt2x00dev, RT5592)) -+ rf = RF5592; - else - rf = rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RF_TYPE); - diff --git a/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/003-rt2x00-add-support-for-external-PA-on-MT7620.patch similarity index 72% rename from package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch rename to package/kernel/mac80211/patches/rt2x00/003-rt2x00-add-support-for-external-PA-on-MT7620.patch index fe023cf77a..216f583063 100644 --- a/package/kernel/mac80211/patches/rt2x00/650-rt2x00-add-support-for-external-PA-on-MT7620.patch +++ b/package/kernel/mac80211/patches/rt2x00/003-rt2x00-add-support-for-external-PA-on-MT7620.patch @@ -1,25 +1,38 @@ -From 8dcdb02e3ad5f3d384c071e0a36670bb342bab35 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Wed, 19 Apr 2017 16:14:53 +0200 -Subject: [PATCH 03/16] rt2x00: add support for external PA on MT7620 +From patchwork Sat Sep 17 20:26:55 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979244 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:26:55 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 03/16] rt2x00: add support for external PA on MT7620 +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org Implement support for external PA connected to MT7620A. Signed-off-by: Tomislav Požega [pozega.tomislav@gmail.com: use chanreg and dccal helpers.] Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- drivers/net/wireless/ralink/rt2x00/rt2800.h | 1 + .../net/wireless/ralink/rt2x00/rt2800lib.c | 52 ++++++++++++++++++- @@ -37,7 +50,7 @@ Signed-off-by: Daniel Golle * EEPROM LNA --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4369,6 +4369,43 @@ static void rt2800_config_channel(struct +@@ -4368,6 +4368,43 @@ static void rt2800_config_channel(struct rt2800_iq_calibrate(rt2x00dev, rf->channel); } @@ -81,7 +94,7 @@ Signed-off-by: Daniel Golle bbp = rt2800_bbp_read(rt2x00dev, 4); rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf)); rt2800_bbp_write(rt2x00dev, 4, bbp); -@@ -9578,7 +9615,8 @@ static int rt2800_init_eeprom(struct rt2 +@@ -9566,7 +9603,8 @@ static int rt2800_init_eeprom(struct rt2 */ eeprom = rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1); @@ -91,7 +104,7 @@ Signed-off-by: Daniel Golle if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352)) __set_bit(CAPABILITY_EXTERNAL_PA_TX0, -@@ -9589,6 +9627,18 @@ static int rt2800_init_eeprom(struct rt2 +@@ -9577,6 +9615,18 @@ static int rt2800_init_eeprom(struct rt2 &rt2x00dev->cap_flags); } diff --git a/package/kernel/mac80211/patches/rt2x00/004-rt2x00-move-up-and-reuse-busy-wait-functions.patch b/package/kernel/mac80211/patches/rt2x00/004-rt2x00-move-up-and-reuse-busy-wait-functions.patch new file mode 100644 index 0000000000..da453074a1 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/004-rt2x00-move-up-and-reuse-busy-wait-functions.patch @@ -0,0 +1,178 @@ +From patchwork Sat Sep 17 20:27:10 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979245 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:27:10 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 04/16] rt2x00: move up and reuse busy wait functions +Message-ID: + <3fdb9dc15e76a9f9c1948b4a3a1308a7a5677bb8.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +Move bbp_ready and rf_ready busy wait functions up in the code so they +can more easily be used. Allow specifying register mask in rf_ready +function which is useful for calibration routines which will be added +in follow-up commits. + +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + .../net/wireless/ralink/rt2x00/rt2800lib.c | 99 +++++++++---------- + 1 file changed, 46 insertions(+), 53 deletions(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -2143,6 +2143,48 @@ void rt2800_config_erp(struct rt2x00_dev + } + EXPORT_SYMBOL_GPL(rt2800_config_erp); + ++static int rt2800_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev, ++ const struct rt2x00_field32 mask) ++{ ++ unsigned int i; ++ u32 reg; ++ ++ for (i = 0; i < REGISTER_BUSY_COUNT; i++) { ++ reg = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); ++ if (!rt2x00_get_field32(reg, mask)) ++ return 0; ++ ++ udelay(REGISTER_BUSY_DELAY); ++ } ++ ++ rt2x00_err(rt2x00dev, "BBP/RF register access failed, aborting\n"); ++ return -EACCES; ++} ++ ++static int rt2800_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) ++{ ++ unsigned int i; ++ u8 value; ++ ++ /* ++ * BBP was enabled after firmware was loaded, ++ * but we need to reactivate it now. ++ */ ++ rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); ++ rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); ++ msleep(1); ++ ++ for (i = 0; i < REGISTER_BUSY_COUNT; i++) { ++ value = rt2800_bbp_read(rt2x00dev, 0); ++ if ((value != 0xff) && (value != 0x00)) ++ return 0; ++ udelay(REGISTER_BUSY_DELAY); ++ } ++ ++ rt2x00_err(rt2x00dev, "BBP register access failed, aborting\n"); ++ return -EACCES; ++} ++ + static void rt2800_config_3572bt_ant(struct rt2x00_dev *rt2x00dev) + { + u32 reg; +@@ -3799,10 +3841,9 @@ static void rt2800_config_alc(struct rt2 + struct ieee80211_channel *chan, + int power_level) { + u16 eeprom, target_power, max_power; +- u32 mac_sys_ctrl, mac_status; ++ u32 mac_sys_ctrl; + u32 reg; + u8 bbp; +- int i; + + /* hardware unit is 0.5dBm, limited to 23.5dBm */ + power_level *= 2; +@@ -3838,16 +3879,8 @@ static void rt2800_config_alc(struct rt2 + /* Disable Tx/Rx */ + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0); + /* Check MAC Tx/Rx idle */ +- for (i = 0; i < 10000; i++) { +- mac_status = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); +- if (mac_status & 0x3) +- usleep_range(50, 200); +- else +- break; +- } +- +- if (i == 10000) +- rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n"); ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY))) ++ rt2x00_warn(rt2x00dev, "RF busy while configuring ALC\n"); + + if (chan->center_freq > 2457) { + bbp = rt2800_bbp_read(rt2x00dev, 30); +@@ -6249,46 +6282,6 @@ static int rt2800_init_registers(struct + return 0; + } + +-static int rt2800_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev) +-{ +- unsigned int i; +- u32 reg; +- +- for (i = 0; i < REGISTER_BUSY_COUNT; i++) { +- reg = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); +- if (!rt2x00_get_field32(reg, MAC_STATUS_CFG_BBP_RF_BUSY)) +- return 0; +- +- udelay(REGISTER_BUSY_DELAY); +- } +- +- rt2x00_err(rt2x00dev, "BBP/RF register access failed, aborting\n"); +- return -EACCES; +-} +- +-static int rt2800_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) +-{ +- unsigned int i; +- u8 value; +- +- /* +- * BBP was enabled after firmware was loaded, +- * but we need to reactivate it now. +- */ +- rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); +- rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); +- msleep(1); +- +- for (i = 0; i < REGISTER_BUSY_COUNT; i++) { +- value = rt2800_bbp_read(rt2x00dev, 0); +- if ((value != 0xff) && (value != 0x00)) +- return 0; +- udelay(REGISTER_BUSY_DELAY); +- } +- +- rt2x00_err(rt2x00dev, "BBP register access failed, aborting\n"); +- return -EACCES; +-} + + static void rt2800_bbp4_mac_if_ctrl(struct rt2x00_dev *rt2x00dev) + { +@@ -9110,7 +9103,7 @@ int rt2800_enable_radio(struct rt2x00_de + /* + * Wait BBP/RF to wake up. + */ +- if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev))) ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY))) + return -EIO; + + /* diff --git a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch b/package/kernel/mac80211/patches/rt2x00/005-rt2x00-add-RF-self-TXDC-calibration-for-MT7620.patch similarity index 64% rename from package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/005-rt2x00-add-RF-self-TXDC-calibration-for-MT7620.patch index ed8a737a4c..4e98d6a375 100644 --- a/package/kernel/mac80211/patches/rt2x00/982-rt2x00-add-RF-self-TXDC-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/005-rt2x00-add-RF-self-TXDC-calibration-for-MT7620.patch @@ -1,32 +1,48 @@ -From 21f2acf0f9e9da35fbdb96ee0aea97b02472030b Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Mon, 8 Jan 2018 13:42:27 +0100 -Subject: [PATCH 04/16] rt2x00: add RF self TXDC calibration for MT7620 +From patchwork Sat Sep 17 20:27:26 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979246 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:27:26 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 05/16] rt2x00: add RF self TXDC calibration for MT7620 +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: Tomislav Požega Add TX self calibration based on mtk driver. Signed-off-by: Tomislav Požega +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- +v2: use ++i instead of i = i + 1 in loops + .../net/wireless/ralink/rt2x00/rt2800lib.c | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8436,6 +8436,53 @@ static void rt2800_init_rfcsr_5592(struc +@@ -8428,6 +8428,53 @@ static void rt2800_init_rfcsr_5592(struc rt2800_led_open_drain_enable(rt2x00dev); } @@ -52,7 +68,7 @@ Signed-off-by: Tomislav Požega + rfb7r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1); + + rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, 0x4); -+ for (i = 0; i < 100; i = i + 1) { ++ for (i = 0; i < 100; ++i) { + usleep_range(50, 100); + rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); + if ((rfvalue & 0x04) != 0x4) @@ -61,7 +77,7 @@ Signed-off-by: Tomislav Požega + rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, rfb5r1_org); + + rt2800_rfcsr_write_bank(rt2x00dev, 7, 1, 0x4); -+ for (i = 0; i < 100; i = i + 1) { ++ for (i = 0; i < 100; ++i) { + usleep_range(50, 100); + rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 7, 1); + if ((rfvalue & 0x04) != 0x4) @@ -80,7 +96,7 @@ Signed-off-by: Tomislav Požega static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, bool set_bw, bool is_ht40) { -@@ -9043,6 +9090,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -9035,6 +9082,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); diff --git a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch b/package/kernel/mac80211/patches/rt2x00/006-rt2x00-add-r-calibration-for-MT7620.patch similarity index 72% rename from package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/006-rt2x00-add-r-calibration-for-MT7620.patch index 569b1083e5..7c69970166 100644 --- a/package/kernel/mac80211/patches/rt2x00/983-rt2x00-add-r-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/006-rt2x00-add-r-calibration-for-MT7620.patch @@ -1,32 +1,60 @@ -From b75efecd6473e6a044d214571c17cad8ae88ed42 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Mon, 8 Jan 2018 13:42:58 +0100 -Subject: [PATCH 05/16] rt2x00: add r calibration for MT7620 +From patchwork Sat Sep 17 20:27:41 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979247 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:27:41 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 06/16] rt2x00: add r calibration for MT7620 +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: Tomislav Požega Add r calibration code as found in mtk driver. Signed-off-by: Tomislav Požega +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 150 ++++++++++++++++++ - 1 file changed, 150 insertions(+) +v2: use rt2800_wait_bbp_rf_ready() + + drivers/net/wireless/ralink/rt2x00/rt2800.h | 2 + + .../net/wireless/ralink/rt2x00/rt2800lib.c | 133 ++++++++++++++++++ + 2 files changed, 135 insertions(+) +--- a/drivers/net/wireless/ralink/rt2x00/rt2800.h ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h +@@ -1016,6 +1016,8 @@ + */ + #define MAC_STATUS_CFG 0x1200 + #define MAC_STATUS_CFG_BBP_RF_BUSY FIELD32(0x00000003) ++#define MAC_STATUS_CFG_BBP_RF_BUSY_TX FIELD32(0x00000001) ++#define MAC_STATUS_CFG_BBP_RF_BUSY_RX FIELD32(0x00000002) + + /* + * PWR_PIN_CFG: --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8483,6 +8483,155 @@ static void rt2800_rf_self_txdc_cal(stru +@@ -8475,6 +8475,138 @@ static void rt2800_rf_self_txdc_cal(stru rt2800_register_write(rt2x00dev, RF_BYPASS2, mac052c); } @@ -54,8 +82,7 @@ Signed-off-by: Tomislav Požega + char d1 = 0, d2 = 0; + u8 rfvalue; + u32 MAC_RF_BYPASS0, MAC_RF_CONTROL0, MAC_PWR_PIN_CFG; -+ u32 maccfg, macstatus; -+ int i; ++ u32 maccfg; + + saverfb0r1 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 1); + saverfb0r34 = rt2800_rfcsr_read_bank(rt2x00dev, 0, 34); @@ -79,30 +106,14 @@ Signed-off-by: Tomislav Požega + maccfg &= (~0x04); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); + -+ for (i = 0; i < 10000; i++) { -+ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macstatus & 0x1) -+ usleep_range(50, 100); -+ else -+ break; -+ } -+ -+ if (i == 10000) ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_TX))) + rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n"); + + maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + maccfg &= (~0x04); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg); + -+ for (i = 0; i < 10000; i++) { -+ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macstatus & 0x2) -+ usleep_range(50, 100); -+ else -+ break; -+ } -+ -+ if (i == 10000) ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX))) + rt2x00_warn(rt2x00dev, "Wait MAC Rx Status to MAX !!!\n"); + + rfvalue = (MAC_RF_BYPASS0 | 0x3004); @@ -182,7 +193,7 @@ Signed-off-by: Tomislav Požega static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, bool set_bw, bool is_ht40) { -@@ -9090,6 +9239,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -9082,6 +9214,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); diff --git a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch b/package/kernel/mac80211/patches/rt2x00/007-rt2x00-add-RXDCOC-calibration-for-MT7620.patch similarity index 63% rename from package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/007-rt2x00-add-RXDCOC-calibration-for-MT7620.patch index fa732c97a6..8da41e875a 100644 --- a/package/kernel/mac80211/patches/rt2x00/984-rt2x00-add-RXDCOC-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/007-rt2x00-add-RXDCOC-calibration-for-MT7620.patch @@ -1,41 +1,54 @@ -From 865823b63f608ac024d326a465ba8fc1a28868cd Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Mon, 8 Jan 2018 13:43:37 +0100 -Subject: [PATCH 06/16] rt2x00: add RXDCOC calibration for MT7620 +From patchwork Sat Sep 17 20:27:56 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979248 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:27:56 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 07/16] rt2x00: add RXDCOC calibration for MT7620 +Message-ID: + <850b30f652e88de30d79e968af4eb47aa5bc2511.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: Tomislav Požega Add RXDCOC calibration code from mtk driver. -Signed-off-by: Daniel Golle -[fixed typo reported by Serge Vasilugin ] Signed-off-by: Tomislav Požega +[fixed typo reported by Serge Vasilugin ] +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 65 +++++++++++++++++++ - 1 file changed, 65 insertions(+) + .../net/wireless/ralink/rt2x00/rt2800lib.c | 60 +++++++++++++++++++ + 1 file changed, 60 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8632,6 +8632,70 @@ static void rt2800_r_calibration(struct +@@ -8607,6 +8607,65 @@ static void rt2800_r_calibration(struct rt2800_register_write(rt2x00dev, PWR_PIN_CFG, MAC_PWR_PIN_CFG); } +static void rt2800_rxdcoc_calibration(struct rt2x00_dev *rt2x00dev) +{ + u8 bbpreg = 0; -+ u32 macvalue = 0, macvalue1 = 0; ++ u32 macvalue = 0; + u8 saverfb0r2, saverfb5r4, saverfb7r4, rfvalue; + int i; + @@ -52,13 +65,8 @@ Signed-off-by: Tomislav Požega + macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x8); + -+ for (i = 0; i < 10000; i++) { -+ macvalue1 = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macvalue1 & 0x1) -+ usleep_range(50, 100); -+ else -+ break; -+ } ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_TX))) ++ rt2x00_warn(rt2x00dev, "RF TX busy in RX RXDCOC calibration\n"); + + saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); + saverfb7r4 = rt2800_rfcsr_read_bank(rt2x00dev, 7, 4); @@ -99,7 +107,7 @@ Signed-off-by: Tomislav Požega static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, bool set_bw, bool is_ht40) { -@@ -9241,6 +9305,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -9216,6 +9275,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_r_calibration(rt2x00dev); rt2800_rf_self_txdc_cal(rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch b/package/kernel/mac80211/patches/rt2x00/008-rt2x00-add-RXIQ-calibration-for-MT7620.patch similarity index 72% rename from package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/008-rt2x00-add-RXIQ-calibration-for-MT7620.patch index 59dbd1f506..dc516da43a 100644 --- a/package/kernel/mac80211/patches/rt2x00/985-rt2x00-add-RXIQ-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/008-rt2x00-add-RXIQ-calibration-for-MT7620.patch @@ -1,19 +1,31 @@ -From 38b78ba60f6759968b19fe183a344a8612fef694 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Mon, 8 Jan 2018 13:43:56 +0100 -Subject: [PATCH 07/16] rt2x00: add RXIQ calibration for MT7620 +From patchwork Sat Sep 17 20:28:10 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979249 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:28:10 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 08/16] rt2x00: add RXIQ calibration for MT7620 +Message-ID: + <033a39a697d51f6df258acea4c33608e0944fe4c.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: Tomislav Požega @@ -21,13 +33,17 @@ Add RXIQ calibration found in mtk driver. With old openwrt builds this gets us ~8Mbps more of RX bandwidth (test with iPA/eLNA layout). Signed-off-by: Tomislav Požega +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 384 ++++++++++++++++++ - 1 file changed, 384 insertions(+) +v2: use rt2800_wait_bbp_rf_ready(), fix indentation + + .../net/wireless/ralink/rt2x00/rt2800lib.c | 375 ++++++++++++++++++ + 1 file changed, 375 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -8696,6 +8696,389 @@ static void rt2800_rxdcoc_calibration(st +@@ -8666,6 +8666,380 @@ static void rt2800_rxdcoc_calibration(st rt2800_rfcsr_write_bank(rt2x00dev, 0, 2, saverfb0r2); } @@ -73,8 +89,8 @@ Signed-off-by: Tomislav Požega + u32 orig_RF_BYPASS1 = 0; + u32 orig_RF_CONTROL3 = 0; + u32 orig_RF_BYPASS3 = 0; -+ u32 macstatus, bbpval1 = 0; -+ u8 rf_vga_table[] = {0x20, 0x21, 0x22, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}; ++ u32 bbpval1 = 0; ++ static const u8 rf_vga_table[] = {0x20, 0x21, 0x22, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f}; + + savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + orig_RF_CONTROL0 = rt2800_register_read(rt2x00dev, RF_CONTROL0); @@ -89,16 +105,8 @@ Signed-off-by: Tomislav Požega + + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x0); + -+ for (i = 0; i < 10000; i++) { -+ macstatus = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macstatus & 0x3) -+ usleep_range(50, 100); -+ else -+ break; -+ } -+ -+ if (i == 10000) -+ rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n"); ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY))) ++ rt2x00_warn(rt2x00dev, "Timeout waiting for MAC status in RXIQ calibration\n"); + + bbpval = bbp4 & (~0x18); + bbpval = bbp4 | 0x00; @@ -223,92 +231,91 @@ Signed-off-by: Tomislav Požega + usleep_range(500, 1500); + + vga_idx = 0; -+ while (vga_idx < 11) { -+ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rf_vga_table[vga_idx]); -+ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rf_vga_table[vga_idx]); -+ -+ rt2800_bbp_dcoc_write(rt2x00dev, 0, 0x93); -+ -+ for (i = 0; i < 10000; i++) { -+ bbpval = rt2800_bbp_read(rt2x00dev, 159); -+ if ((bbpval & 0xff) == 0x93) -+ usleep_range(50, 100); -+ else -+ break; -+ } -+ -+ if ((bbpval & 0xff) == 0x93) { -+ rt2x00_warn(rt2x00dev, "Fatal Error: Calibration doesn't finish"); -+ goto restore_value; -+ } ++ while (vga_idx < 11) { ++ rt2800_rfcsr_write_dccal(rt2x00dev, 3, rf_vga_table[vga_idx]); ++ rt2800_rfcsr_write_dccal(rt2x00dev, 4, rf_vga_table[vga_idx]); + -+ for (i = 0; i < 5; i++) { -+ u32 bbptemp = 0; -+ u8 value = 0; -+ int result = 0; -+ -+ rt2800_bbp_write(rt2x00dev, 158, 0x1e); -+ rt2800_bbp_write(rt2x00dev, 159, i); -+ rt2800_bbp_write(rt2x00dev, 158, 0x22); -+ value = rt2800_bbp_read(rt2x00dev, 159); -+ bbptemp = bbptemp + (value << 24); -+ rt2800_bbp_write(rt2x00dev, 158, 0x21); -+ value = rt2800_bbp_read(rt2x00dev, 159); -+ bbptemp = bbptemp + (value << 16); -+ rt2800_bbp_write(rt2x00dev, 158, 0x20); -+ value = rt2800_bbp_read(rt2x00dev, 159); -+ bbptemp = bbptemp + (value << 8); -+ rt2800_bbp_write(rt2x00dev, 158, 0x1f); -+ value = rt2800_bbp_read(rt2x00dev, 159); -+ bbptemp = bbptemp + value; -+ -+ if (i < 2 && (bbptemp & 0x800000)) -+ result = (bbptemp & 0xffffff) - 0x1000000; -+ else if (i == 4) -+ result = bbptemp; -+ else -+ result = bbptemp; -+ -+ if (i == 0) -+ mi = result / 4096; -+ else if (i == 1) -+ mq = result / 4096; -+ else if (i == 2) -+ si = bbptemp / 4096; -+ else if (i == 3) -+ sq = bbptemp / 4096; -+ else -+ riq = result / 4096; -+ } ++ rt2800_bbp_dcoc_write(rt2x00dev, 0, 0x93); + -+ bbpval1 = si - mi * mi; -+ rt2x00_dbg(rt2x00dev, -+ "RXIQ si=%d, sq=%d, riq=%d, bbpval %d, vga_idx %d", -+ si, sq, riq, bbpval1, vga_idx); -+ -+ if (bbpval1 >= (100 * 100)) ++ for (i = 0; i < 10000; i++) { ++ bbpval = rt2800_bbp_read(rt2x00dev, 159); ++ if ((bbpval & 0xff) == 0x93) ++ usleep_range(50, 100); ++ else + break; ++ } + -+ if (bbpval1 <= 100) -+ vga_idx = vga_idx + 9; -+ else if (bbpval1 <= 158) -+ vga_idx = vga_idx + 8; -+ else if (bbpval1 <= 251) -+ vga_idx = vga_idx + 7; -+ else if (bbpval1 <= 398) -+ vga_idx = vga_idx + 6; -+ else if (bbpval1 <= 630) -+ vga_idx = vga_idx + 5; -+ else if (bbpval1 <= 1000) -+ vga_idx = vga_idx + 4; -+ else if (bbpval1 <= 1584) -+ vga_idx = vga_idx + 3; -+ else if (bbpval1 <= 2511) -+ vga_idx = vga_idx + 2; ++ if ((bbpval & 0xff) == 0x93) { ++ rt2x00_warn(rt2x00dev, "Fatal Error: Calibration doesn't finish"); ++ goto restore_value; ++ } ++ for (i = 0; i < 5; i++) { ++ u32 bbptemp = 0; ++ u8 value = 0; ++ int result = 0; ++ ++ rt2800_bbp_write(rt2x00dev, 158, 0x1e); ++ rt2800_bbp_write(rt2x00dev, 159, i); ++ rt2800_bbp_write(rt2x00dev, 158, 0x22); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 24); ++ rt2800_bbp_write(rt2x00dev, 158, 0x21); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 16); ++ rt2800_bbp_write(rt2x00dev, 158, 0x20); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + (value << 8); ++ rt2800_bbp_write(rt2x00dev, 158, 0x1f); ++ value = rt2800_bbp_read(rt2x00dev, 159); ++ bbptemp = bbptemp + value; ++ ++ if (i < 2 && (bbptemp & 0x800000)) ++ result = (bbptemp & 0xffffff) - 0x1000000; ++ else if (i == 4) ++ result = bbptemp; + else -+ vga_idx = vga_idx + 1; ++ result = bbptemp; ++ ++ if (i == 0) ++ mi = result / 4096; ++ else if (i == 1) ++ mq = result / 4096; ++ else if (i == 2) ++ si = bbptemp / 4096; ++ else if (i == 3) ++ sq = bbptemp / 4096; ++ else ++ riq = result / 4096; + } + ++ bbpval1 = si - mi * mi; ++ rt2x00_dbg(rt2x00dev, ++ "RXIQ si=%d, sq=%d, riq=%d, bbpval %d, vga_idx %d", ++ si, sq, riq, bbpval1, vga_idx); ++ ++ if (bbpval1 >= (100 * 100)) ++ break; ++ ++ if (bbpval1 <= 100) ++ vga_idx = vga_idx + 9; ++ else if (bbpval1 <= 158) ++ vga_idx = vga_idx + 8; ++ else if (bbpval1 <= 251) ++ vga_idx = vga_idx + 7; ++ else if (bbpval1 <= 398) ++ vga_idx = vga_idx + 6; ++ else if (bbpval1 <= 630) ++ vga_idx = vga_idx + 5; ++ else if (bbpval1 <= 1000) ++ vga_idx = vga_idx + 4; ++ else if (bbpval1 <= 1584) ++ vga_idx = vga_idx + 3; ++ else if (bbpval1 <= 2511) ++ vga_idx = vga_idx + 2; ++ else ++ vga_idx = vga_idx + 1; ++ } ++ + sigma_i = rt2800_do_sqrt_accumulation(100 * (si - mi * mi)); + sigma_q = rt2800_do_sqrt_accumulation(100 * (sq - mq * mq)); + r_iq = 10 * (riq - (mi * mq)); @@ -417,7 +424,7 @@ Signed-off-by: Tomislav Požega static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, bool set_bw, bool is_ht40) { -@@ -9308,6 +9691,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -9278,6 +9652,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rxdcoc_calibration(rt2x00dev); rt2800_bw_filter_calibration(rt2x00dev, true); rt2800_bw_filter_calibration(rt2x00dev, false); diff --git a/package/kernel/mac80211/patches/rt2x00/009-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/009-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch new file mode 100644 index 0000000000..6b27f6a705 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/009-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch @@ -0,0 +1,52 @@ +From patchwork Sat Sep 17 20:28:29 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979250 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:28:29 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 09/16] rt2x00: don't run Rt5592 IQ calibration on MT7620 +Message-ID: + <31a1c34ddbd296b82f38c18c9ae7339059215fdc.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +The function rt2800_iq_calibrate is intended for Rt5592 only. +Don't call it for MT7620 which has it's own calibration functions. + +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +--- +v2: test for RT5592 instead of !RT6352 + + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -4398,7 +4398,8 @@ static void rt2800_config_channel(struct + reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); + +- rt2800_iq_calibrate(rt2x00dev, rf->channel); ++ if (rt2x00_rt(rt2x00dev, RT5592)) ++ rt2800_iq_calibrate(rt2x00dev, rf->channel); + } + + if (rt2x00_rt(rt2x00dev, RT6352)) { diff --git a/package/kernel/mac80211/patches/rt2x00/987-rt2x00-add-TX-LOFT-calibration.patch b/package/kernel/mac80211/patches/rt2x00/010-rt2x00-add-TX-LOFT-calibration-for-MT7620.patch similarity index 92% rename from package/kernel/mac80211/patches/rt2x00/987-rt2x00-add-TX-LOFT-calibration.patch rename to package/kernel/mac80211/patches/rt2x00/010-rt2x00-add-TX-LOFT-calibration-for-MT7620.patch index 4ce532be84..bb01ff1dca 100644 --- a/package/kernel/mac80211/patches/rt2x00/987-rt2x00-add-TX-LOFT-calibration.patch +++ b/package/kernel/mac80211/patches/rt2x00/010-rt2x00-add-TX-LOFT-calibration-for-MT7620.patch @@ -1,33 +1,51 @@ -From e02adea15f762d2add77b2b7714706f5c3c2f9c9 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Thu, 11 Jan 2018 19:53:49 +0100 -Subject: [PATCH 09/16] rt2x00: add TX LOFT calibration for MT7620 +From patchwork Sat Sep 17 20:28:43 2022 +Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979251 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:28:43 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 10/16] rt2x00: add TX LOFT calibration for MT7620 +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org From: Tomislav Požega Add TX LOFT calibration from mtk driver. Signed-off-by: Tomislav Požega +Signed-off-by: Daniel Golle --- - .../net/wireless/ralink/rt2x00/rt2800lib.c | 922 ++++++++++++++++++ +v2: use helper functions, make tables static const, remove useless + debug prints +v3: don't export function not used anywhere else +Reported-by: kernel test robot + + .../net/wireless/ralink/rt2x00/rt2800lib.c | 902 ++++++++++++++++++ .../net/wireless/ralink/rt2x00/rt2800lib.h | 10 + - 2 files changed, 932 insertions(+) + 2 files changed, 912 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -9080,6 +9080,927 @@ restore_value: +@@ -9041,6 +9041,907 @@ restore_value: rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, savemacsysctrl); } @@ -298,8 +316,6 @@ Signed-off-by: Tomislav Požega + + for (bidx = 5; bidx >= 0; bidx--) { + for (iorq = 0; iorq <= 1; iorq++) { -+ rt2x00_dbg(rt2x00dev, "\n========================================================\n"); -+ + if (idxf[iorq] == 0x20) { + idx0 = 0x20; + p0 = pf; @@ -357,8 +373,6 @@ Signed-off-by: Tomislav Požega + + for (bidx = 5; bidx >= 1; bidx--) { + for (gop = 0; gop < 2; gop++) { -+ rt2x00_dbg(rt2x00dev, "\n==============================================\n"); -+ + if (gop == 1 || bidx < 4) { + if (gop == 0) + iq_err = gerr; @@ -500,7 +514,7 @@ Signed-off-by: Tomislav Požega + rt2800_rfcsr_write_bank(rt2x00dev, 7, 20, 0x20); +} + -+void rt2800_loft_iq_calibration(struct rt2x00_dev *rt2x00dev) ++static void rt2800_loft_iq_calibration(struct rt2x00_dev *rt2x00dev) +{ + struct rf_reg_pair rf_store[CHAIN_NUM][13]; + u32 macorg1 = 0; @@ -511,7 +525,7 @@ Signed-off-by: Tomislav Požega + u32 orig528 = 0; + u32 orig52c = 0; + -+ u32 savemacsysctrl = 0, mtxcycle = 0; ++ u32 savemacsysctrl = 0; + u32 macvalue = 0; + u32 mac13b8 = 0; + u32 p0 = 0, p1 = 0; @@ -520,11 +534,8 @@ Signed-off-by: Tomislav Požega + u8 rfvalue; + u8 loft_dc_search_result[CHAIN_NUM][RF_ALC_NUM][2]; + u8 ger[CHAIN_NUM], per[CHAIN_NUM]; -+ u8 rf_gain[] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x0c}; -+ u8 rfvga_gain_table[] = {0x24, 0x25, 0x26, 0x27, 0x28, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, -+ 0x31, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3F}; ++ + u8 vga_gain[] = {14, 14}; -+ u8 bbp_2324gain[] = {0x16, 0x14, 0x12, 0x10, 0x0c, 0x08}; + u8 bbp = 0, ch_idx = 0, rf_alc_idx = 0, idx = 0; + u8 bbpr30, rfb0r39, rfb0r42; + u8 bbpr1; @@ -532,6 +543,11 @@ Signed-off-by: Tomislav Požega + u8 bbpr241, bbpr242; + u8 count_step; + ++ static const u8 rf_gain[] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x0c}; ++ static const u8 rfvga_gain_table[] = {0x24, 0x25, 0x26, 0x27, 0x28, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, ++ 0x31, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3F}; ++ static const u8 bbp_2324gain[] = {0x16, 0x14, 0x12, 0x10, 0x0c, 0x08}; ++ + savemacsysctrl = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + macorg1 = rt2800_register_read(rt2x00dev, TX_PIN_CFG); + macorg2 = rt2800_register_read(rt2x00dev, RF_CONTROL0); @@ -546,25 +562,15 @@ Signed-off-by: Tomislav Požega + macvalue &= (~0x04); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); + -+ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { -+ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macvalue & 0x01) -+ usleep_range(50, 100); -+ else -+ break; -+ } ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_TX))) ++ rt2x00_warn(rt2x00dev, "RF TX busy in LOFT IQ calibration\n"); + + macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + macvalue &= (~0x08); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); + -+ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { -+ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macvalue & 0x02) -+ usleep_range(50, 100); -+ else -+ break; -+ } ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX))) ++ rt2x00_warn(rt2x00dev, "RF RX busy in LOFT IQ calibration\n"); + + for (ch_idx = 0; ch_idx < 2; ch_idx++) + rt2800_rf_configstore(rt2x00dev, rf_store, ch_idx); @@ -742,24 +748,16 @@ Signed-off-by: Tomislav Požega + macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + macvalue &= (~0x04); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); -+ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { -+ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macvalue & 0x01) -+ usleep_range(50, 100); -+ else -+ break; -+ } ++ ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_TX))) ++ rt2x00_warn(rt2x00dev, "RF TX busy in LOFT IQ calibration\n"); + + macvalue = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL); + macvalue &= (~0x08); + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, macvalue); -+ for (mtxcycle = 0; mtxcycle < 10000; mtxcycle++) { -+ macvalue = rt2800_register_read(rt2x00dev, MAC_STATUS_CFG); -+ if (macvalue & 0x02) -+ usleep_range(50, 100); -+ else -+ break; -+ } ++ ++ if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX))) ++ rt2x00_warn(rt2x00dev, "RF RX busy in LOFT IQ calibration\n"); + + if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { + rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x00000101); @@ -955,7 +953,7 @@ Signed-off-by: Tomislav Požega static void rt2800_bbp_core_soft_reset(struct rt2x00_dev *rt2x00dev, bool set_bw, bool is_ht40) { -@@ -9692,6 +10613,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -9653,6 +10554,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rxdcoc_calibration(rt2x00dev); rt2800_bw_filter_calibration(rt2x00dev, true); rt2800_bw_filter_calibration(rt2x00dev, false); diff --git a/package/kernel/mac80211/patches/rt2x00/988-rt2x00-move-helper-functions-up-in-file.patch b/package/kernel/mac80211/patches/rt2x00/011-rt2x00-move-helper-functions-up-in-file.patch similarity index 59% rename from package/kernel/mac80211/patches/rt2x00/988-rt2x00-move-helper-functions-up-in-file.patch rename to package/kernel/mac80211/patches/rt2x00/011-rt2x00-move-helper-functions-up-in-file.patch index 7dc37eb826..07a32b17be 100644 --- a/package/kernel/mac80211/patches/rt2x00/988-rt2x00-move-helper-functions-up-in-file.patch +++ b/package/kernel/mac80211/patches/rt2x00/011-rt2x00-move-helper-functions-up-in-file.patch @@ -1,28 +1,44 @@ -From f06bc3d756e7bfdaa03f060ae68797321b2e281a Mon Sep 17 00:00:00 2001 +From patchwork Sat Sep 17 20:28:58 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979252 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:28:58 +0100 From: Daniel Golle -Date: Fri, 16 Sep 2022 20:22:04 +0100 -Subject: [PATCH 10/16] rt2x00: move helper functions up in file -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 11/16] rt2x00: move helper functions up in file +Message-ID: + +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org Move register access helper functions up to the head of the file so they can be used in all functions. Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -199,6 +199,26 @@ static void rt2800_rfcsr_write_dccal(str +@@ -198,6 +198,26 @@ static void rt2800_rfcsr_write_dccal(str rt2800_rfcsr_write_bank(rt2x00dev, 7, reg, value); } @@ -49,7 +65,7 @@ Signed-off-by: Daniel Golle static u8 rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev, const unsigned int word) { -@@ -6955,26 +6975,6 @@ static void rt2800_init_bbp_5592(struct +@@ -6947,26 +6967,6 @@ static void rt2800_init_bbp_5592(struct rt2800_bbp_write(rt2x00dev, 103, 0xc0); } diff --git a/package/kernel/mac80211/patches/rt2x00/012-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/012-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch new file mode 100644 index 0000000000..e989205ba2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/012-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch @@ -0,0 +1,56 @@ +From patchwork Sat Sep 17 20:29:13 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979253 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:29:13 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 12/16] rt2x00: fix HT20/HT40 bandwidth switch on MT7620 +Message-ID: + <1664d89ba149f7b0bcec18b2a2abaedf49654507.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +Add missing configuration of the channel bandwidth filter to the +channel setup function for MT7620. + +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -3855,6 +3855,14 @@ static void rt2800_config_channel_rf7620 + rfcsr |= tx_agc_fc; + rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); + } ++ ++ if (conf_is_ht40(conf)) { ++ rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10); ++ rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f); ++ } else { ++ rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a); ++ rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40); ++ } + } + + static void rt2800_config_alc(struct rt2x00_dev *rt2x00dev, diff --git a/package/kernel/mac80211/patches/rt2x00/013-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/013-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT7620.patch new file mode 100644 index 0000000000..3d7af17b16 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/013-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT7620.patch @@ -0,0 +1,52 @@ +From patchwork Sat Sep 17 20:29:26 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979254 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:29:26 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 13/16] rt2x00: set correct TX_SW_CFG1 MAC register for + MT7620 +Message-ID: + <4be38975ce600a34249e12d09a3cb758c6e71071.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +Set correct TX_SW_CFG1 MAC register as it is done also in v3 of the +vendor driver[1]. + +[1]: https://gitlab.com/dm38/padavan-ng/-/blob/master/trunk/proprietary/rt_wifi/rtpci/3.0.X.X/mt76x2/chips/rt6352.c#L531 +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5966,7 +5966,7 @@ static int rt2800_init_registers(struct + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); + } else if (rt2x00_rt(rt2x00dev, RT6352)) { + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401); +- rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000); ++ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0001); + rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); + rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); + rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); diff --git a/package/kernel/mac80211/patches/rt2x00/014-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/014-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch new file mode 100644 index 0000000000..27b8d92cd2 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/014-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch @@ -0,0 +1,50 @@ +From patchwork Sat Sep 17 20:29:40 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979255 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:29:40 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 14/16] rt2x00: set VGC gain for both chains of MT7620 +Message-ID: + <29e161397e5c9d9399da0fe87d44458aa2b90a78.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +Set bbp66 for all chains of the MT7620. + +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -5743,7 +5743,8 @@ static inline void rt2800_set_vgc(struct + if (qual->vgc_level != vgc_level) { + if (rt2x00_rt(rt2x00dev, RT3572) || + rt2x00_rt(rt2x00dev, RT3593) || +- rt2x00_rt(rt2x00dev, RT3883)) { ++ rt2x00_rt(rt2x00dev, RT3883) || ++ rt2x00_rt(rt2x00dev, RT6352)) { + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, + vgc_level); + } else if (rt2x00_rt(rt2x00dev, RT5592)) { diff --git a/package/kernel/mac80211/patches/rt2x00/992-rt2x00-set-SoC-wmac-clock-register.patch b/package/kernel/mac80211/patches/rt2x00/015-rt2x00-set-SoC-wmac-clock-register.patch similarity index 51% rename from package/kernel/mac80211/patches/rt2x00/992-rt2x00-set-SoC-wmac-clock-register.patch rename to package/kernel/mac80211/patches/rt2x00/015-rt2x00-set-SoC-wmac-clock-register.patch index 194d7d6cfd..3cadc91da6 100644 --- a/package/kernel/mac80211/patches/rt2x00/992-rt2x00-set-SoC-wmac-clock-register.patch +++ b/package/kernel/mac80211/patches/rt2x00/015-rt2x00-set-SoC-wmac-clock-register.patch @@ -1,16 +1,31 @@ -From 6569ed4ba88105d7ee877abba8f22e4965a29856 Mon Sep 17 00:00:00 2001 +From patchwork Sat Sep 17 20:29:55 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979256 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +Date: Sat, 17 Sep 2022 21:29:55 +0100 From: Daniel Golle -Date: Fri, 16 Sep 2022 20:38:20 +0100 -Subject: [PATCH 14/16] rt2x00: set SoC wmac clock register -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 15/16] rt2x00: set SoC wmac clock register +Message-ID: + <3e275d259f476f597dab91a9c395015ef3fe3284.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org Instead of using the default value 33 (pci), set US_CYC_CNT init based on Programming guide: @@ -18,13 +33,14 @@ If available, set chipset bus clock with fallback to cpu clock/3. Reported-by: Serge Vasilugin Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka --- .../net/wireless/ralink/rt2x00/rt2800lib.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -6197,6 +6197,27 @@ static int rt2800_init_registers(struct +@@ -6229,6 +6229,27 @@ static int rt2800_init_registers(struct reg = rt2800_register_read(rt2x00dev, US_CYC_CNT); rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, 125); rt2800_register_write(rt2x00dev, US_CYC_CNT, reg); diff --git a/package/kernel/mac80211/patches/rt2x00/016-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/016-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch new file mode 100644 index 0000000000..5ddbbf1dd6 --- /dev/null +++ b/package/kernel/mac80211/patches/rt2x00/016-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch @@ -0,0 +1,79 @@ +From patchwork Sat Sep 17 20:30:09 2022 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Daniel Golle +X-Patchwork-Id: 12979257 +X-Patchwork-Delegate: kvalo@adurom.com +Return-Path: +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on + aws-us-west-2-korg-lkml-1.web.codeaurora.org +Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) + by smtp.lore.kernel.org (Postfix) with ESMTP id E9118ECAAA1 + for ; + Sat, 17 Sep 2022 20:30:22 +0000 (UTC) +Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand + id S229639AbiIQUaV (ORCPT + ); + Sat, 17 Sep 2022 16:30:21 -0400 +Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53912 "EHLO + lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org + with ESMTP id S229628AbiIQUaT (ORCPT + ); + Sat, 17 Sep 2022 16:30:19 -0400 +Received: from fudo.makrotopia.org (fudo.makrotopia.org + [IPv6:2a07:2ec0:3002::71]) + by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AEA822B27 + for ; + Sat, 17 Sep 2022 13:30:16 -0700 (PDT) +Received: from local + by fudo.makrotopia.org with esmtpsa + (TLS1.3:TLS_AES_256_GCM_SHA384:256) + (Exim 4.96) + (envelope-from ) + id 1oZeS7-0003ra-0k; + Sat, 17 Sep 2022 22:30:15 +0200 +Date: Sat, 17 Sep 2022 21:30:09 +0100 +From: Daniel Golle +To: linux-wireless@vger.kernel.org, Stanislaw Gruszka , + Helmut Schaa +Cc: Kalle Valo , + "David S. Miller" , + Eric Dumazet , + Jakub Kicinski , + Paolo Abeni , + Johannes Berg +Subject: [PATCH v3 16/16] rt2x00: correctly set BBP register 86 for MT7620 +Message-ID: + <257267247ee4fa7ebc6a5d0c4948b3f8119c0d77.1663445157.git.daniel@makrotopia.org> +References: +MIME-Version: 1.0 +Content-Disposition: inline +In-Reply-To: +Precedence: bulk +List-ID: +X-Mailing-List: linux-wireless@vger.kernel.org + +Instead of 0 set the correct value for BBP register 86 for MT7620. + +Reported-by: Serge Vasilugin +Signed-off-by: Daniel Golle +Acked-by: Stanislaw Gruszka +--- + drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c ++++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +@@ -4225,7 +4225,10 @@ static void rt2800_config_channel(struct + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); +- rt2800_bbp_write(rt2x00dev, 86, 0); ++ if (rt2x00_rt(rt2x00dev, RT6352)) ++ rt2800_bbp_write(rt2x00dev, 86, 0x38); ++ else ++ rt2800_bbp_write(rt2x00dev, 86, 0); + } + + if (rf->channel <= 14) { diff --git a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch b/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch index 21ed9882b0..ba16e85510 100644 --- a/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch +++ b/package/kernel/mac80211/patches/rt2x00/602-rt2x00-introduce-rt2x00eeprom.patch @@ -48,7 +48,7 @@ obj-$(CPTCFG_RT2X00_LIB_MMIO) += rt2x00mmio.o --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h -@@ -37,6 +37,8 @@ struct rt2800_drv_data { +@@ -47,6 +47,8 @@ struct rt2800_drv_data { struct ieee80211_sta *wcid_to_sta[STA_IDS_SIZE]; }; @@ -57,7 +57,7 @@ struct rt2800_ops { u32 (*register_read)(struct rt2x00_dev *rt2x00dev, const unsigned int offset); -@@ -135,6 +137,15 @@ static inline int rt2800_read_eeprom(str +@@ -145,6 +147,15 @@ static inline int rt2800_read_eeprom(str { const struct rt2800_ops *rt2800ops = rt2x00dev->ops->drv; @@ -127,7 +127,7 @@ DECLARE_KFIFO_PTR(txstatus_fifo, u32); --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1401,6 +1401,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de +@@ -1419,6 +1419,10 @@ int rt2x00lib_probe_dev(struct rt2x00_de INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep); @@ -138,7 +138,7 @@ /* * Let the driver probe the device to detect the capabilities. */ -@@ -1541,6 +1545,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ +@@ -1559,6 +1563,11 @@ void rt2x00lib_remove_dev(struct rt2x00_ * Free the driver data. */ kfree(rt2x00dev->drv_data); diff --git a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch index d78b76d7f5..acc8a8edb8 100644 --- a/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch +++ b/package/kernel/mac80211/patches/rt2x00/610-rt2x00-change-led-polarity-from-OF.patch @@ -8,7 +8,7 @@ #include "rt2x00.h" #include "rt2800lib.h" -@@ -9549,6 +9550,17 @@ static int rt2800_init_eeprom(struct rt2 +@@ -11131,6 +11132,17 @@ static int rt2800_init_eeprom(struct rt2 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); diff --git a/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch b/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch index 0da9356e0c..5ef5fc8def 100644 --- a/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch +++ b/package/kernel/mac80211/patches/rt2x00/611-rt2x00-add-AP+STA-support.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c -@@ -1340,7 +1340,7 @@ static inline void rt2x00lib_set_if_comb +@@ -1358,7 +1358,7 @@ static inline void rt2x00lib_set_if_comb */ if_limit = &rt2x00dev->if_limits_ap; if_limit->max = rt2x00dev->ops->max_ap_intf; diff --git a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/986-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch deleted file mode 100644 index 0fdbaae6a4..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/986-rt2x00-don-t-run-Rt5592-IQ-calibration-on-MT7620.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 5f921753b95927c964a5061b5b64c310b968ff3e Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Fri, 16 Sep 2022 20:43:14 +0100 -Subject: [PATCH 08/16] rt2x00: don't run Rt5592 IQ calibration on MT7620 -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -The function rt2800_iq_calibrate is intended for Rt5592 only. -Don't call it for MT7620 which has it's own calibration functions. - -Reported-by: Serge Vasilugin -Signed-off-by: Daniel Golle ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4366,7 +4366,8 @@ static void rt2800_config_channel(struct - reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); - -- rt2800_iq_calibrate(rt2x00dev, rf->channel); -+ if (!rt2x00_rt(rt2x00dev, RT6352)) -+ rt2800_iq_calibrate(rt2x00dev, rf->channel); - } - - if (rt2x00_rt(rt2x00dev, RT6352)) { diff --git a/package/kernel/mac80211/patches/rt2x00/989-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/989-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch deleted file mode 100644 index 6472bbc6f1..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/989-rt2x00-fix-HT20-HT40-bandwidth-switch-on-MT7620.patch +++ /dev/null @@ -1,40 +0,0 @@ -From d20eadcb4eac59c5168f48c33836fba32b8cd1ae Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Fri, 16 Sep 2022 20:26:03 +0100 -Subject: [PATCH 11/16] rt2x00: fix HT20/HT40 bandwidth switch on MT7620 -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -Add missing configuration of the channel bandwidth filter to the -channel setup function for MT7620. - -Reported-by: Serge Vasilugin -Signed-off-by: Daniel Golle ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -3814,6 +3814,14 @@ static void rt2800_config_channel_rf7620 - rfcsr |= tx_agc_fc; - rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); - } -+ -+ if (conf_is_ht40(conf)) { -+ rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10); -+ rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f); -+ } else { -+ rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a); -+ rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40); -+ } - } - - static void rt2800_config_alc(struct rt2x00_dev *rt2x00dev, diff --git a/package/kernel/mac80211/patches/rt2x00/990-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT762.patch b/package/kernel/mac80211/patches/rt2x00/990-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT762.patch deleted file mode 100644 index 2ab1ccee23..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/990-rt2x00-set-correct-TX_SW_CFG1-MAC-register-for-MT762.patch +++ /dev/null @@ -1,35 +0,0 @@ -From fa8914fe29543be586e9bbc00c7209e2808f0a13 Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Fri, 16 Sep 2022 20:28:40 +0100 -Subject: [PATCH 12/16] rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -Set correct TX_SW_CFG1 MAC register as it is done also in v3 of the -vendor driver[1]. - -[1]: https://gitlab.com/dm38/padavan-ng/-/blob/master/trunk/proprietary/rt_wifi/rtpci/3.0.X.X/mt76x2/chips/rt6352.c#L531 -Reported-by: Serge Vasilugin -Signed-off-by: Daniel Golle ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5934,7 +5934,7 @@ static int rt2800_init_registers(struct - rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); - } else if (rt2x00_rt(rt2x00dev, RT6352)) { - rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401); -- rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000); -+ rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0001); - rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); - rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x00000000); - rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0); diff --git a/package/kernel/mac80211/patches/rt2x00/991-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/991-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch deleted file mode 100644 index 4d1700b24e..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/991-rt2x00-set-VGC-gain-for-both-chains-of-MT7620.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 5b62ef26e5f17c5cdf19c05e32e2c1da9988480d Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Fri, 16 Sep 2022 20:31:15 +0100 -Subject: [PATCH 13/16] rt2x00: set VGC gain for both chains of MT7620 -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -Set bbp66 for all chains of the MT7620. - -Reported-by: Serge Vasilugin -Signed-off-by: Daniel Golle ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -5711,7 +5711,8 @@ static inline void rt2800_set_vgc(struct - if (qual->vgc_level != vgc_level) { - if (rt2x00_rt(rt2x00dev, RT3572) || - rt2x00_rt(rt2x00dev, RT3593) || -- rt2x00_rt(rt2x00dev, RT3883)) { -+ rt2x00_rt(rt2x00dev, RT3883) || -+ rt2x00_rt(rt2x00dev, RT6352)) { - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, - vgc_level); - } else if (rt2x00_rt(rt2x00dev, RT5592)) { diff --git a/package/kernel/mac80211/patches/rt2x00/993-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/993-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch deleted file mode 100644 index 0b673bcc91..0000000000 --- a/package/kernel/mac80211/patches/rt2x00/993-rt2x00-correctly-set-BBP-register-86-for-MT7620.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 3ae108de9e64e44c724ce150d804c56a4e72ea4e Mon Sep 17 00:00:00 2001 -From: Daniel Golle -Date: Fri, 16 Sep 2022 20:42:11 +0100 -Subject: [PATCH 15/16] rt2x00: correctly set BBP register 86 for MT7620 -To: linux-wireless@vger.kernel.org, - Stanislaw Gruszka , - Helmut Schaa -Cc: Kalle Valo , - David S. Miller , - Eric Dumazet , - Jakub Kicinski , - Paolo Abeni , - Johannes Berg - -Instead of 0 set the correct value for BBP register 86 for MT7620. - -Reported-by: Serge Vasilugin -Signed-off-by: Daniel Golle ---- - drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - ---- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -4193,7 +4193,10 @@ static void rt2800_config_channel(struct - rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); - rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); -- rt2800_bbp_write(rt2x00dev, 86, 0); -+ if (rt2x00_rt(rt2x00dev, RT6352)) -+ rt2800_bbp_write(rt2x00dev, 86, 0x38); -+ else -+ rt2800_bbp_write(rt2x00dev, 86, 0); - } - - if (rf->channel <= 14) { diff --git a/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch b/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch index 3d5849b8b2..deaa03be6c 100644 --- a/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch +++ b/package/kernel/mac80211/patches/rt2x00/994-rt2x00-import-support-for-external-LNA-on-MT7620.patch @@ -52,7 +52,7 @@ Signed-off-by: Daniel Golle static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = { [EEPROM_CHIP_ID] = 0x0000, [EEPROM_VERSION] = 0x0001, -@@ -4436,6 +4454,29 @@ static void rt2800_config_channel(struct +@@ -4469,6 +4487,29 @@ static void rt2800_config_channel(struct rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C6B6C); } @@ -82,7 +82,7 @@ Signed-off-by: Daniel Golle } bbp = rt2800_bbp_read(rt2x00dev, 4); -@@ -10641,6 +10682,7 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10583,6 +10624,7 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); @@ -90,7 +90,7 @@ Signed-off-by: Daniel Golle rt2800_r_calibration(rt2x00dev); rt2800_rf_self_txdc_cal(rt2x00dev); rt2800_rxdcoc_calibration(rt2x00dev); -@@ -10648,6 +10690,22 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10590,6 +10632,22 @@ static void rt2800_init_rfcsr_6352(struc rt2800_bw_filter_calibration(rt2x00dev, false); rt2800_loft_iq_calibration(rt2x00dev); rt2800_rxiq_calibration(rt2x00dev); diff --git a/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch b/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch index de09186618..dab6e05ffd 100644 --- a/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch +++ b/package/kernel/mac80211/patches/rt2x00/996-rt2x00-mt7620-differentiate-based-on-SoC-CHIP_VER.patch @@ -1,6 +1,6 @@ --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h -@@ -1042,6 +1042,11 @@ +@@ -1044,6 +1044,11 @@ #define MIMO_PS_CFG_RX_STBY_POL FIELD32(0x00000010) #define MIMO_PS_CFG_RX_RX_STBY0 FIELD32(0x00000020) @@ -14,7 +14,7 @@ */ --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c -@@ -3736,14 +3736,16 @@ static void rt2800_config_channel_rf7620 +@@ -3778,14 +3778,16 @@ static void rt2800_config_channel_rf7620 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); rt2800_rfcsr_write(rt2x00dev, 19, rfcsr); @@ -39,7 +39,7 @@ rfcsr = rt2800_rfcsr_read(rt2x00dev, 1); rt2x00_set_field8(&rfcsr, RFCSR1_TX2_EN_MT7620, -@@ -3777,18 +3779,23 @@ static void rt2800_config_channel_rf7620 +@@ -3819,18 +3821,23 @@ static void rt2800_config_channel_rf7620 rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x20); } @@ -73,9 +73,9 @@ if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { if (conf_is_ht40(conf)) { -@@ -3896,25 +3903,29 @@ static void rt2800_config_alc(struct rt2 - if (i == 10000) - rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n"); +@@ -3929,25 +3936,29 @@ static void rt2800_config_alc(struct rt2 + if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY))) + rt2x00_warn(rt2x00dev, "RF busy while configuring ALC\n"); - if (chan->center_freq > 2457) { - bbp = rt2800_bbp_read(rt2x00dev, 30); @@ -121,7 +121,7 @@ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, mac_sys_ctrl); rt2800_vco_calibration(rt2x00dev); -@@ -5978,18 +5989,33 @@ static int rt2800_init_registers(struct +@@ -6011,18 +6022,33 @@ static int rt2800_init_registers(struct } else if (rt2x00_rt(rt2x00dev, RT5350)) { rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); } else if (rt2x00_rt(rt2x00dev, RT6352)) { @@ -167,7 +167,7 @@ reg = rt2800_register_read(rt2x00dev, TX_ALC_CFG_1); rt2x00_set_field32(®, TX_ALC_CFG_1_ROS_BUSY_EN, 0); rt2800_register_write(rt2x00dev, TX_ALC_CFG_1, reg); -@@ -7134,14 +7160,16 @@ static void rt2800_init_bbp_6352(struct +@@ -7127,14 +7153,16 @@ static void rt2800_init_bbp_6352(struct rt2800_bbp_write(rt2x00dev, 188, 0x00); rt2800_bbp_write(rt2x00dev, 189, 0x00); @@ -192,7 +192,7 @@ /* BBP for G band GLRT function (BBP_128 ~ BBP_221) */ rt2800_bbp_glrt_write(rt2x00dev, 0, 0x00); -@@ -10466,31 +10494,36 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10408,31 +10436,36 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write(rt2x00dev, 42, 0x5B); rt2800_rfcsr_write(rt2x00dev, 43, 0x00); @@ -254,7 +254,7 @@ /* Initialize RF channel register to default value */ rt2800_rfcsr_write_chanreg(rt2x00dev, 0, 0x03); -@@ -10556,63 +10589,71 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10498,63 +10531,71 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_bank(rt2x00dev, 6, 45, 0xC5); @@ -383,7 +383,7 @@ /* Initialize RF DC calibration register to default value */ rt2800_rfcsr_write_dccal(rt2x00dev, 0, 0x47); -@@ -10675,12 +10716,17 @@ static void rt2800_init_rfcsr_6352(struc +@@ -10617,12 +10658,17 @@ static void rt2800_init_rfcsr_6352(struc rt2800_rfcsr_write_dccal(rt2x00dev, 62, 0x00); rt2800_rfcsr_write_dccal(rt2x00dev, 63, 0x00); -- 2.30.2