1 From 2c5aad0f9990724cce48e0a53b66bc0438e4603d Mon Sep 17 00:00:00 2001
2 From: Shiji Yang <yangshiji66@outlook.com>
3 Date: Sun, 22 Dec 2024 17:06:59 +0800
4 Subject: [PATCH 1/4] rt2x00: always calibrate MT7620 when switching channel
6 Perform calibration work after each channel switching operation.
7 This should help improve the rx/tx signal strength for MT7620.
9 Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
11 .../net/wireless/ralink/rt2x00/rt2800lib.c | 24 ++++++++++++++-----
12 1 file changed, 18 insertions(+), 6 deletions(-)
14 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
15 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
16 @@ -5704,6 +5704,9 @@ static void rt2800_config_ps(struct rt2x
20 +static void rt2800_calibration_rt6352_stage1(struct rt2x00_dev *rt2x00dev);
21 +static void rt2800_calibration_rt6352_stage2(struct rt2x00_dev *rt2x00dev);
23 void rt2800_config(struct rt2x00_dev *rt2x00dev,
24 struct rt2x00lib_conf *libconf,
25 const unsigned int flags)
26 @@ -5718,10 +5721,18 @@ void rt2800_config(struct rt2x00_dev *rt
28 rt2800_update_survey(rt2x00dev);
30 + if (rt2x00_rt(rt2x00dev, RT6352) &&
31 + !test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags))
32 + rt2800_calibration_rt6352_stage1(rt2x00dev);
34 rt2800_config_channel(rt2x00dev, libconf->conf,
35 &libconf->rf, &libconf->channel);
36 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan,
37 libconf->conf->power_level);
39 + if (rt2x00_rt(rt2x00dev, RT6352) &&
40 + !test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags))
41 + rt2800_calibration_rt6352_stage2(rt2x00dev);
43 if (flags & IEEE80211_CONF_CHANGE_POWER)
44 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan,
45 @@ -10427,15 +10438,19 @@ static void rt2800_restore_rf_bbp_rt6352
49 -static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev)
50 +static void rt2800_calibration_rt6352_stage1(struct rt2x00_dev *rt2x00dev)
54 if (rt2x00_has_cap_external_pa(rt2x00dev) ||
55 rt2x00_has_cap_external_lna_bg(rt2x00dev))
56 rt2800_restore_rf_bbp_rt6352(rt2x00dev);
58 rt2800_r_calibration(rt2x00dev);
61 +static void rt2800_calibration_rt6352_stage2(struct rt2x00_dev *rt2x00dev)
65 rt2800_rf_self_txdc_cal(rt2x00dev);
66 rt2800_rxdcoc_calibration(rt2x00dev);
67 rt2800_bw_filter_calibration(rt2x00dev, true);
68 @@ -10766,9 +10781,6 @@ static void rt2800_init_rfcsr_6352(struc
70 rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
71 rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
73 - /* Do calibration and init PA/LNA */
74 - rt2800_calibration_rt6352(rt2x00dev);
77 static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)