blob: 3aa94419665bba118d72e26decfa857aa91d70a3 [file] [log] [blame]
developer66e89bc2024-04-23 14:50:01 +08001From 097d8d847d49f831848e990e60091d10bd9c59a5 Mon Sep 17 00:00:00 2001
2From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Mon, 11 Sep 2023 14:43:07 +0800
4Subject: [PATCH 048/116] mtk: wifi: mt76: testmode: add channel 68 & 96
5
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7
8Add all the channel between 68 & 96 since ibf 5g channel group 3 will use channel 84.
9Also, "mtk: wifi: mt76: testmode: add channel 68 & 96" can be
10merged into to "mtk: wifi: mt76: testmode: add basic testmode support"
11
12CR-Id: WCNCR00274293
13Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
14
15Fix 5g channel list size
16
17CR-Id: WCNCR00274293
18Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
19---
20 mac80211.c | 9 +++++++++
21 mt7996/eeprom.c | 49 +++++++++++++++++++++++++++++++++++++++++++++--
22 mt7996/eeprom.h | 2 ++
23 mt7996/mcu.c | 10 +++++++++-
24 mt7996/testmode.c | 15 ++++++++++++---
25 mt7996/testmode.h | 6 +++---
26 6 files changed, 82 insertions(+), 9 deletions(-)
27
28diff --git a/mac80211.c b/mac80211.c
29index 0590aaf2e..8091a60e0 100644
30--- a/mac80211.c
31+++ b/mac80211.c
32@@ -34,6 +34,15 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
33 CHAN5G(60, 5300),
34 CHAN5G(64, 5320),
35
36+ CHAN5G(68, 5340),
37+ CHAN5G(72, 5360),
38+ CHAN5G(76, 5380),
39+ CHAN5G(80, 5400),
40+ CHAN5G(84, 5420),
41+ CHAN5G(88, 5440),
42+ CHAN5G(92, 5460),
43+ CHAN5G(96, 5480),
44+
45 CHAN5G(100, 5500),
46 CHAN5G(104, 5520),
47 CHAN5G(108, 5540),
48diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c
49index f97d76cc4..acf5bc179 100644
50--- a/mt7996/eeprom.c
51+++ b/mt7996/eeprom.c
52@@ -18,6 +18,17 @@ const struct ieee80211_channel dpd_2g_ch_list_bw20[] = {
53 CHAN2G(11, 2462)
54 };
55
56+const struct ieee80211_channel dpd_5g_skip_ch_list[] = {
57+ CHAN5G(68, 5340),
58+ CHAN5G(72, 5360),
59+ CHAN5G(76, 5380),
60+ CHAN5G(80, 5400),
61+ CHAN5G(84, 5420),
62+ CHAN5G(88, 5440),
63+ CHAN5G(92, 5460),
64+ CHAN5G(96, 5480)
65+};
66+
67 const struct ieee80211_channel dpd_5g_ch_list_bw160[] = {
68 CHAN5G(50, 5250),
69 CHAN5G(114, 5570),
70@@ -44,6 +55,7 @@ const struct ieee80211_channel dpd_6g_ch_list_bw320[] = {
71 };
72
73 const u32 dpd_2g_bw20_ch_num = ARRAY_SIZE(dpd_2g_ch_list_bw20);
74+const u32 dpd_5g_skip_ch_num = ARRAY_SIZE(dpd_5g_skip_ch_list);
75 const u32 dpd_5g_bw160_ch_num = ARRAY_SIZE(dpd_5g_ch_list_bw160);
76 const u32 dpd_6g_bw160_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw160);
77 const u32 dpd_6g_bw320_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw320);
78@@ -168,8 +180,8 @@ mt7996_get_dpd_per_band_size(struct mt7996_dev *dev, enum nl80211_band band)
79 if (band == NL80211_BAND_2GHZ)
80 dpd_size = dpd_2g_bw20_ch_num * DPD_PER_CH_BW20_SIZE;
81 else if (band == NL80211_BAND_5GHZ)
82- dpd_size = mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE +
83- dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE;
84+ dpd_size = (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
85+ DPD_PER_CH_BW20_SIZE + dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE;
86 else
87 dpd_size = mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE +
88 (dpd_6g_bw160_ch_num + dpd_6g_bw320_ch_num) * DPD_PER_CH_GT_BW20_SIZE;
89@@ -431,6 +443,39 @@ out:
90 return ret;
91 }
92
93+static void mt7996_eeprom_init_precal(struct mt7996_dev *dev)
94+{
95+#define MT76_CHANNELS_5GHZ_SIZE 36 /* ARRAY_SIZE(mt76_channels_5ghz) */
96+#define MT76_CHANNELS_6GHZ_SIZE 59 /* ARRAY_SIZE(mt76_channels_6ghz) */
97+
98+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_2G] = ARRAY_SIZE(dpd_2g_ch_list_bw20);
99+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_5G_SKIP] = ARRAY_SIZE(dpd_5g_skip_ch_list);
100+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_5G] = MT76_CHANNELS_5GHZ_SIZE -
101+ DPD_CH_NUM(BW20_5G_SKIP);
102+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_5G] = ARRAY_SIZE(dpd_5g_ch_list_bw160);
103+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_6G] = MT76_CHANNELS_6GHZ_SIZE;
104+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_6G] = ARRAY_SIZE(dpd_6g_ch_list_bw160);
105+
106+ switch (mt76_chip(&dev->mt76)) {
107+ case 0x7990:
108+ dev->prek.rev = mt7996_prek_rev;
109+ /* 5g & 6g bw 80 dpd channel list is not used */
110+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW320_6G] = ARRAY_SIZE(dpd_6g_ch_list_bw320);
111+ break;
112+ case 0x7992:
113+ dev->prek.rev = mt7992_prek_rev;
114+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW80_5G] = ARRAY_SIZE(dpd_5g_ch_list_bw80);
115+ /* 6g is not used in current sku */
116+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW20_6G] = 0;
117+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW80_6G] = 0;
118+ dev->prek.dpd_ch_num[DPD_CH_NUM_BW160_6G] = 0;
119+ break;
120+ default:
121+ dev->prek.rev = mt7996_prek_rev;
122+ break;
123+ }
124+}
125+
126 static int mt7996_eeprom_load_precal(struct mt7996_dev *dev)
127 {
128 struct mt76_dev *mdev = &dev->mt76;
129diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h
130index 03a4fd07d..9a15b4462 100644
131--- a/mt7996/eeprom.h
132+++ b/mt7996/eeprom.h
133@@ -67,6 +67,8 @@ enum mt7996_eeprom_field {
134
135 extern const struct ieee80211_channel dpd_2g_ch_list_bw20[];
136 extern const u32 dpd_2g_bw20_ch_num;
137+extern const struct ieee80211_channel dpd_5g_skip_ch_list[];
138+extern const u32 dpd_5g_skip_ch_num;
139 extern const struct ieee80211_channel dpd_5g_ch_list_bw160[];
140 extern const u32 dpd_5g_bw160_ch_num;
141 extern const struct ieee80211_channel dpd_6g_ch_list_bw160[];
142diff --git a/mt7996/mcu.c b/mt7996/mcu.c
143index 8756a5df8..97bf2969e 100644
144--- a/mt7996/mcu.c
145+++ b/mt7996/mcu.c
146@@ -3766,7 +3766,8 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
147 chan_list_size = mphy->sband_5g.sband.n_channels;
148 base_offset += dpd_size_2g;
149 if (bw == NL80211_CHAN_WIDTH_160) {
150- base_offset += mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE;
151+ base_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
152+ DPD_PER_CH_BW20_SIZE;
153 per_chan_size = DPD_PER_CH_GT_BW20_SIZE;
154 cal_id = RF_DPD_FLAT_5G_MEM_CAL;
155 chan_list = dpd_5g_ch_list_bw160;
156@@ -3775,6 +3776,9 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
157 /* apply (center channel - 2)'s dpd cal data for bw 40/80 channels */
158 channel -= 2;
159 }
160+ if (channel >= dpd_5g_skip_ch_list[0].hw_value &&
161+ channel <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
162+ return 0;
163 break;
164 case NL80211_BAND_6GHZ:
165 dpd_mask = MT_EE_WIFI_CAL_DPD_6G;
166@@ -3814,6 +3818,10 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy)
167 if (idx == chan_list_size)
168 return -EINVAL;
169
170+ if (band == NL80211_BAND_5GHZ && bw != NL80211_CHAN_WIDTH_160 &&
171+ channel > dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
172+ idx -= dpd_5g_skip_ch_num;
173+
174 cal += MT_EE_CAL_GROUP_SIZE + base_offset + idx * per_chan_size;
175
176 for (i = 0; i < per_chan_size / MT_EE_CAL_UNIT; i++) {
177diff --git a/mt7996/testmode.c b/mt7996/testmode.c
178index 5cec1eef6..95d3bde03 100644
179--- a/mt7996/testmode.c
180+++ b/mt7996/testmode.c
181@@ -531,6 +531,11 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req,
182 memcpy(&chandef_backup, chandef, sizeof(struct cfg80211_chan_def));
183
184 for (i = 0; i < channel_size; i++) {
185+ if (chan_list[i].band == NL80211_BAND_5GHZ &&
186+ chan_list[i].hw_value >= dpd_5g_skip_ch_list[0].hw_value &&
187+ chan_list[i].hw_value <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value)
188+ continue;
189+
190 memcpy(chandef->chan, &chan_list[i], sizeof(struct ieee80211_channel));
191 chandef->width = width;
192
193@@ -612,7 +617,8 @@ mt7996_tm_dpd_prek(struct mt7996_phy *phy, enum mt76_testmode_state state)
194 NL80211_CHAN_WIDTH_20, RF_DPD_FLAT_5G_CAL);
195 if (ret)
196 return ret;
197- wait_on_prek_offset += mphy->sband_5g.sband.n_channels * DPD_PER_CH_BW20_SIZE;
198+ wait_on_prek_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) *
199+ DPD_PER_CH_BW20_SIZE;
200 wait_event_timeout(mdev->mcu.wait,
201 dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ);
202
203@@ -868,6 +874,7 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
204 const struct ieee80211_channel *chan = mphy->sband_5g.sband.channels;
205 u32 bitmap, i, offset, width_mhz, size = mphy->sband_5g.sband.n_channels;
206 u16 first_control = 0, control_chan = chandef->chan->hw_value;
207+ bool not_first;
208
209 bitmap = mt7996_tm_bw_mapping(chandef->width, BW_MAP_NL_TO_CONTROL_BITMAP_5G);
210 if (!bitmap)
211@@ -877,7 +884,9 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
212 offset = width_mhz / 10 - 2;
213
214 for (i = 0; i < size; i++) {
215- if (!((1 << i) & bitmap))
216+ not_first = (chandef->width != NL80211_CHAN_WIDTH_160) ?
217+ (i % bitmap) : (i >= 32) || !((1 << i) & bitmap);
218+ if (not_first)
219 continue;
220
221 if (control_chan >= chan[i].hw_value)
222@@ -886,7 +895,7 @@ mt7996_tm_get_center_chan(struct mt7996_phy *phy, struct cfg80211_chan_def *chan
223 break;
224 }
225
226- if (i == size || first_control == 0)
227+ if (first_control == 0)
228 return control_chan;
229
230 return first_control + offset;
231diff --git a/mt7996/testmode.h b/mt7996/testmode.h
232index f97ccb267..ba1767aed 100644
233--- a/mt7996/testmode.h
234+++ b/mt7996/testmode.h
235@@ -38,9 +38,9 @@ enum {
236 BF_CDBW_8080MHZ,
237 };
238
239-#define FIRST_CONTROL_CHAN_BITMAP_BW40 0x5555555
240-#define FIRST_CONTROL_CHAN_BITMAP_BW80 0x111111
241-#define FIRST_CONTROL_CHAN_BITMAP_BW160 0x100101
242+#define FIRST_CONTROL_CHAN_BITMAP_BW40 2
243+#define FIRST_CONTROL_CHAN_BITMAP_BW80 4
244+#define FIRST_CONTROL_CHAN_BITMAP_BW160 0x10010101
245
246 enum bw_mapping_method {
247 BW_MAP_NL_TO_FW,
248--
2492.39.2
250