提交 ce6ad123 编写于 作者: S Shiji Yang 提交者: Daniel Golle

mac80211: fix MT7620 Wi-Fi channel scanning function

During the channel scanning process, the driver will continuously
switch channels. It seems that the full RF calibration step in
rt2800_config_channel() caused the channel scanning function to
timeout. To fix it, move the RF calibration to rt2800_enable_radio()
so that it is only executed once. This commit also includes some
coding format adjustments to follow the Linux recommended style.

Fixes: 2824fa69 ("mac80211: rework MT7620 PA/LNA RF calibration")
Signed-off-by: NShiji Yang <yangshiji66@qq.com>
上级 4c0fdad7
......@@ -3,8 +3,6 @@ Date: Tue, 25 Jul 2023 20:05:06 +0800
Subject: [PATCH] wifi: rt2x00: rework MT7620 PA/LNA RF calibration
1. Move MT7620 PA/LNA calibration code to dedicated functions.
Calibration stage 1 is executed before configuring channels and
stage 2 is executed after configuring channels.
2. For external PA/LNA devices, restore RF and BBP registers before
R-Calibration.
3. Do Rx DCOC calibration again before RXIQ calibration.
......@@ -21,23 +19,13 @@ Subject: [PATCH] wifi: rt2x00: rework MT7620 PA/LNA RF calibration
Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
---
.../net/wireless/ralink/rt2x00/rt2800lib.c | 318 +++++++++++-------
.../net/wireless/ralink/rt2x00/rt2800lib.c | 306 ++++++++++--------
drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 +
2 files changed, 194 insertions(+), 130 deletions(-)
2 files changed, 182 insertions(+), 130 deletions(-)
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -62,6 +62,9 @@ MODULE_PARM_DESC(watchdog, "Enable watch
rt2800_regbusy_read((__dev), H2M_MAILBOX_CSR, \
H2M_MAILBOX_CSR_OWNER, (__reg))
+static void rt6352_init_palna_stage1(struct rt2x00_dev *rt2x00dev);
+static void rt6352_init_palna_stage2(struct rt2x00_dev *rt2x00dev);
+
static inline bool rt2800_is_305x_soc(struct rt2x00_dev *rt2x00dev)
{
/* check for rt2872 on SoC */
@@ -3881,14 +3884,6 @@ static void rt2800_config_channel_rf7620
@@ -3881,14 +3881,6 @@ static void rt2800_config_channel_rf7620
rfcsr |= tx_agc_fc;
rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr);
}
......@@ -52,17 +40,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
}
static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev,
@@ -4151,6 +4146,9 @@ static void rt2800_config_channel(struct
rt2800_txpower_to_dev(rt2x00dev, rf->channel,
info->default_power3);
+ if (rt2x00_rt(rt2x00dev, RT6352))
+ rt6352_init_palna_stage1(rt2x00dev);
+
switch (rt2x00dev->chip.rt) {
case RT3883:
rt3883_bbp_adjust(rt2x00dev, rf);
@@ -4457,89 +4455,65 @@ static void rt2800_config_channel(struct
@@ -4457,89 +4449,63 @@ static void rt2800_config_channel(struct
usleep_range(1000, 1500);
}
......@@ -193,12 +171,10 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ * Otherwise it's difficult to pass the WHQL.
+ */
+ usleep_range(1000, 1500);
+
+ rt6352_init_palna_stage2(rt2x00dev);
}
bbp = rt2800_bbp_read(rt2x00dev, 4);
@@ -5649,43 +5623,6 @@ void rt2800_vco_calibration(struct rt2x0
@@ -5649,43 +5615,6 @@ void rt2800_vco_calibration(struct rt2x0
}
}
rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
......@@ -242,7 +218,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
}
EXPORT_SYMBOL_GPL(rt2800_vco_calibration);
@@ -8650,7 +8587,7 @@ static void rt2800_r_calibration(struct
@@ -8650,7 +8579,7 @@ static void rt2800_r_calibration(struct
rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n");
maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL);
......@@ -251,7 +227,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg);
if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX)))
@@ -10688,30 +10625,151 @@ static void rt2800_init_rfcsr_6352(struc
@@ -10688,30 +10617,143 @@ static void rt2800_init_rfcsr_6352(struc
rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
}
......@@ -266,7 +242,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
- rt2800_loft_iq_calibration(rt2x00dev);
- rt2800_rxiq_calibration(rt2x00dev);
- rt6352_enable_pa_pin(rt2x00dev, 1);
+static void rt6352_init_ext_palna(struct rt2x00_dev *rt2x00dev)
+static void rt2800_init_palna_rt6352(struct rt2x00_dev *rt2x00dev)
+{
+ u32 reg;
+
......@@ -308,9 +284,8 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ }
+
+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
+ rt2x00_has_cap_external_pa(rt2x00dev)) {
+ rt2x00_has_cap_external_pa(rt2x00dev))
+ rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00);
+ }
+
+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
......@@ -333,7 +308,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ }
+}
+
+static void rt6352_restore_rf_bbp(struct rt2x00_dev *rt2x00dev)
+static void rt2800_restore_rf_bbp_rt6352(struct rt2x00_dev *rt2x00dev)
+{
+ if (rt2x00_has_cap_external_pa(rt2x00dev)) {
+ rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0);
......@@ -348,8 +323,7 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ }
+
+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
+ rt2x00_has_cap_external_pa(rt2x00dev))
+ {
+ rt2x00_has_cap_external_pa(rt2x00dev)) {
+ rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
+ rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xB3);
+ rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
......@@ -376,29 +350,23 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ rt2800_bbp_write(rt2x00dev, 82, 0xB6);
+ }
+
+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1
+ && rt2x00_has_cap_external_pa(rt2x00dev)) {
+ if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
+ rt2x00_has_cap_external_pa(rt2x00dev)) {
+ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x3630363A);
+ rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);
+ rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C666C);
+ }
+}
+
+/* MT7620 PA/LNA initialization before switching channels */
+static void rt6352_init_palna_stage1(struct rt2x00_dev *rt2x00dev)
+static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev)
+{
+ if (rt2x00_has_cap_external_pa(rt2x00dev) ||
+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
+ rt6352_enable_pa_pin(rt2x00dev, 0);
+ rt6352_restore_rf_bbp(rt2x00dev);
+ rt2800_restore_rf_bbp_rt6352(rt2x00dev);
+ }
+
+ rt2800_r_calibration(rt2x00dev);
+}
+
+/* MT7620 PA/LNA initialization after switching channels */
+static void rt6352_init_palna_stage2(struct rt2x00_dev *rt2x00dev)
+{
+ rt2800_rf_self_txdc_cal(rt2x00dev);
+ rt2800_rxdcoc_calibration(rt2x00dev);
+ rt2800_bw_filter_calibration(rt2x00dev, true);
......@@ -410,13 +378,24 @@ Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
+ rt2800_rxdcoc_calibration(rt2x00dev);
+ rt2800_rxiq_calibration(rt2x00dev);
+
+ if(rt2x00_has_cap_external_pa(rt2x00dev) ||
+ if (rt2x00_has_cap_external_pa(rt2x00dev) ||
+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
+ rt6352_enable_pa_pin(rt2x00dev, 1);
+ rt6352_init_ext_palna(rt2x00dev);
+ rt2800_init_palna_rt6352(rt2x00dev);
}
}
@@ -10804,6 +10846,10 @@ int rt2800_enable_radio(struct rt2x00_de
rt2800_init_bbp(rt2x00dev);
rt2800_init_rfcsr(rt2x00dev);
+ /* Do calibration and init PA/LNA for RT6352 */
+ if (rt2x00_rt(rt2x00dev, RT6352))
+ rt2800_calibration_rt6352(rt2x00dev);
+
if (rt2x00_is_usb(rt2x00dev) &&
(rt2x00_rt(rt2x00dev, RT3070) ||
rt2x00_rt(rt2x00dev, RT3071) ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -1277,6 +1277,12 @@ rt2x00_has_cap_external_lna_bg(struct rt
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册