developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 1 | From 85865dc300bbe3bc8ef98907a145e8a9875858af Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Thu, 12 Oct 2023 16:17:33 +0800 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 048/116] mtk: wifi: mt76: testmode: add kite testmode support |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | Add Kite testmode support |
| 7 | 1. avoid entering connac 2 testmode flow in kite |
| 8 | 2. refactor prek implementation for handling chip difference |
| 9 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 11 | --- |
| 12 | mt7996/eeprom.c | 63 +++++++++++++----------------- |
| 13 | mt7996/eeprom.h | 81 +++++++++++++++++++++++++++------------ |
| 14 | mt7996/mcu.c | 48 ++++++++++++++--------- |
| 15 | mt7996/mt7996.h | 18 ++++++++- |
| 16 | mt7996/testmode.c | 97 ++++++++++++++++++++++++++++------------------- |
| 17 | testmode.c | 11 ++++-- |
| 18 | 6 files changed, 198 insertions(+), 120 deletions(-) |
| 19 | |
| 20 | diff --git a/mt7996/eeprom.c b/mt7996/eeprom.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 21 | index acf5bc1..215d81e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 22 | --- a/mt7996/eeprom.c |
| 23 | +++ b/mt7996/eeprom.c |
| 24 | @@ -29,12 +29,39 @@ const struct ieee80211_channel dpd_5g_skip_ch_list[] = { |
| 25 | CHAN5G(96, 5480) |
| 26 | }; |
| 27 | |
| 28 | +const struct ieee80211_channel dpd_5g_ch_list_bw80[] = { |
| 29 | + CHAN5G(42, 5210), |
| 30 | + CHAN5G(58, 5290), |
| 31 | + CHAN5G(106, 5530), |
| 32 | + CHAN5G(122, 5610), |
| 33 | + CHAN5G(138, 5690), |
| 34 | + CHAN5G(155, 5775), |
| 35 | + CHAN5G(171, 5855) |
| 36 | +}; |
| 37 | + |
| 38 | const struct ieee80211_channel dpd_5g_ch_list_bw160[] = { |
| 39 | CHAN5G(50, 5250), |
| 40 | CHAN5G(114, 5570), |
| 41 | CHAN5G(163, 5815) |
| 42 | }; |
| 43 | |
| 44 | +const struct ieee80211_channel dpd_6g_ch_list_bw80[] = { |
| 45 | + CHAN6G(7, 5985), |
| 46 | + CHAN6G(23, 6065), |
| 47 | + CHAN6G(39, 6145), |
| 48 | + CHAN6G(55, 6225), |
| 49 | + CHAN6G(71, 6305), |
| 50 | + CHAN6G(87, 6385), |
| 51 | + CHAN6G(103, 6465), |
| 52 | + CHAN6G(119, 6545), |
| 53 | + CHAN6G(135, 6625), |
| 54 | + CHAN6G(151, 6705), |
| 55 | + CHAN6G(167, 6785), |
| 56 | + CHAN6G(183, 6865), |
| 57 | + CHAN6G(199, 6945), |
| 58 | + CHAN6G(215, 7025) |
| 59 | +}; |
| 60 | + |
| 61 | const struct ieee80211_channel dpd_6g_ch_list_bw160[] = { |
| 62 | CHAN6G(15, 6025), |
| 63 | CHAN6G(47, 6185), |
| 64 | @@ -54,12 +81,6 @@ const struct ieee80211_channel dpd_6g_ch_list_bw320[] = { |
| 65 | CHAN6G(191, 6905) |
| 66 | }; |
| 67 | |
| 68 | -const u32 dpd_2g_bw20_ch_num = ARRAY_SIZE(dpd_2g_ch_list_bw20); |
| 69 | -const u32 dpd_5g_skip_ch_num = ARRAY_SIZE(dpd_5g_skip_ch_list); |
| 70 | -const u32 dpd_5g_bw160_ch_num = ARRAY_SIZE(dpd_5g_ch_list_bw160); |
| 71 | -const u32 dpd_6g_bw160_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw160); |
| 72 | -const u32 dpd_6g_bw320_ch_num = ARRAY_SIZE(dpd_6g_ch_list_bw320); |
| 73 | - |
| 74 | static int mt7996_check_eeprom(struct mt7996_dev *dev) |
| 75 | { |
| 76 | u8 *eeprom = dev->mt76.eeprom.data; |
| 77 | @@ -159,36 +180,6 @@ const char *mt7996_eeprom_name(struct mt7996_dev *dev) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | -int |
| 82 | -mt7996_get_dpd_per_band_size(struct mt7996_dev *dev, enum nl80211_band band) |
| 83 | -{ |
| 84 | - /* handle different sku */ |
| 85 | - static const u8 band_to_idx[] = { |
| 86 | - [NL80211_BAND_2GHZ] = MT_BAND0, |
| 87 | - [NL80211_BAND_5GHZ] = MT_BAND1, |
| 88 | - [NL80211_BAND_6GHZ] = MT_BAND2, |
| 89 | - }; |
| 90 | - struct mt7996_phy *phy = __mt7996_phy(dev, band_to_idx[band]); |
| 91 | - struct mt76_phy *mphy; |
| 92 | - int dpd_size; |
| 93 | - |
| 94 | - if (!phy) |
| 95 | - return 0; |
| 96 | - |
| 97 | - mphy = phy->mt76; |
| 98 | - |
| 99 | - if (band == NL80211_BAND_2GHZ) |
| 100 | - dpd_size = dpd_2g_bw20_ch_num * DPD_PER_CH_BW20_SIZE; |
| 101 | - else if (band == NL80211_BAND_5GHZ) |
| 102 | - dpd_size = (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) * |
| 103 | - DPD_PER_CH_BW20_SIZE + dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE; |
| 104 | - else |
| 105 | - dpd_size = mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE + |
| 106 | - (dpd_6g_bw160_ch_num + dpd_6g_bw320_ch_num) * DPD_PER_CH_GT_BW20_SIZE; |
| 107 | - |
| 108 | - return dpd_size; |
| 109 | -} |
| 110 | - |
| 111 | static int |
| 112 | mt7996_eeprom_load_bin(struct mt7996_dev *dev) |
| 113 | { |
| 114 | diff --git a/mt7996/eeprom.h b/mt7996/eeprom.h |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 115 | index 9a15b44..fa9c31e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 116 | --- a/mt7996/eeprom.h |
| 117 | +++ b/mt7996/eeprom.h |
| 118 | @@ -45,36 +45,69 @@ enum mt7996_eeprom_field { |
| 119 | #define MT_EE_WIFI_CAL_DPD GENMASK(5, 3) |
| 120 | |
| 121 | #define MT_EE_CAL_UNIT 1024 |
| 122 | -#define MT_EE_CAL_GROUP_SIZE_2G (4 * MT_EE_CAL_UNIT) |
| 123 | -#define MT_EE_CAL_GROUP_SIZE_5G (45 * MT_EE_CAL_UNIT) |
| 124 | -#define MT_EE_CAL_GROUP_SIZE_6G (125 * MT_EE_CAL_UNIT) |
| 125 | -#define MT_EE_CAL_ADCDCOC_SIZE_2G (4 * 4) |
| 126 | -#define MT_EE_CAL_ADCDCOC_SIZE_5G (4 * 4) |
| 127 | -#define MT_EE_CAL_ADCDCOC_SIZE_6G (4 * 5) |
| 128 | -#define MT_EE_CAL_GROUP_SIZE (MT_EE_CAL_GROUP_SIZE_2G + \ |
| 129 | - MT_EE_CAL_GROUP_SIZE_5G + \ |
| 130 | - MT_EE_CAL_GROUP_SIZE_6G + \ |
| 131 | - MT_EE_CAL_ADCDCOC_SIZE_2G + \ |
| 132 | - MT_EE_CAL_ADCDCOC_SIZE_5G + \ |
| 133 | - MT_EE_CAL_ADCDCOC_SIZE_6G) |
| 134 | - |
| 135 | -#define DPD_PER_CH_LEGACY_SIZE (4 * MT_EE_CAL_UNIT) |
| 136 | -#define DPD_PER_CH_MEM_SIZE (13 * MT_EE_CAL_UNIT) |
| 137 | -#define DPD_PER_CH_OTFG0_SIZE (2 * MT_EE_CAL_UNIT) |
| 138 | -#define DPD_PER_CH_BW20_SIZE (DPD_PER_CH_LEGACY_SIZE + DPD_PER_CH_OTFG0_SIZE) |
| 139 | -#define DPD_PER_CH_GT_BW20_SIZE (DPD_PER_CH_MEM_SIZE + DPD_PER_CH_OTFG0_SIZE) |
| 140 | -#define MT_EE_CAL_DPD_SIZE (780 * MT_EE_CAL_UNIT) |
| 141 | + |
| 142 | +enum mt7996_prek_rev { |
| 143 | + GROUP_SIZE_2G, |
| 144 | + GROUP_SIZE_5G, |
| 145 | + GROUP_SIZE_6G, |
| 146 | + ADCDCOC_SIZE_2G, |
| 147 | + ADCDCOC_SIZE_5G, |
| 148 | + ADCDCOC_SIZE_6G, |
| 149 | + DPD_LEGACY_SIZE, |
| 150 | + DPD_MEM_SIZE, |
| 151 | + DPD_OTFG0_SIZE, |
| 152 | +}; |
| 153 | + |
| 154 | +static const u32 mt7996_prek_rev[] = { |
| 155 | + [GROUP_SIZE_2G] = 4 * MT_EE_CAL_UNIT, |
| 156 | + [GROUP_SIZE_5G] = 45 * MT_EE_CAL_UNIT, |
| 157 | + [GROUP_SIZE_6G] = 125 * MT_EE_CAL_UNIT, |
| 158 | + [ADCDCOC_SIZE_2G] = 4 * 4, |
| 159 | + [ADCDCOC_SIZE_5G] = 4 * 4, |
| 160 | + [ADCDCOC_SIZE_6G] = 4 * 5, |
| 161 | + [DPD_LEGACY_SIZE] = 4 * MT_EE_CAL_UNIT, |
| 162 | + [DPD_MEM_SIZE] = 13 * MT_EE_CAL_UNIT, |
| 163 | + [DPD_OTFG0_SIZE] = 2 * MT_EE_CAL_UNIT, |
| 164 | +}; |
| 165 | + |
| 166 | +/* kite 2/5g config */ |
| 167 | +static const u32 mt7992_prek_rev[] = { |
| 168 | + [GROUP_SIZE_2G] = 4 * MT_EE_CAL_UNIT, |
| 169 | + [GROUP_SIZE_5G] = 110 * MT_EE_CAL_UNIT, |
| 170 | + [GROUP_SIZE_6G] = 0, |
| 171 | + [ADCDCOC_SIZE_2G] = 4 * 4, |
| 172 | + [ADCDCOC_SIZE_5G] = 4 * 5, |
| 173 | + [ADCDCOC_SIZE_6G] = 0, |
| 174 | + [DPD_LEGACY_SIZE] = 5 * MT_EE_CAL_UNIT, |
| 175 | + [DPD_MEM_SIZE] = 16 * MT_EE_CAL_UNIT, |
| 176 | + [DPD_OTFG0_SIZE] = 2 * MT_EE_CAL_UNIT, |
| 177 | +}; |
| 178 | |
| 179 | extern const struct ieee80211_channel dpd_2g_ch_list_bw20[]; |
| 180 | -extern const u32 dpd_2g_bw20_ch_num; |
| 181 | extern const struct ieee80211_channel dpd_5g_skip_ch_list[]; |
| 182 | -extern const u32 dpd_5g_skip_ch_num; |
| 183 | +extern const struct ieee80211_channel dpd_5g_ch_list_bw80[]; |
| 184 | extern const struct ieee80211_channel dpd_5g_ch_list_bw160[]; |
| 185 | -extern const u32 dpd_5g_bw160_ch_num; |
| 186 | +extern const struct ieee80211_channel dpd_6g_ch_list_bw80[]; |
| 187 | extern const struct ieee80211_channel dpd_6g_ch_list_bw160[]; |
| 188 | -extern const u32 dpd_6g_bw160_ch_num; |
| 189 | extern const struct ieee80211_channel dpd_6g_ch_list_bw320[]; |
| 190 | -extern const u32 dpd_6g_bw320_ch_num; |
| 191 | + |
| 192 | +#define PREK(id) (dev->prek.rev[(id)]) |
| 193 | +#define DPD_CH_NUM(_type) (dev->prek.dpd_ch_num[DPD_CH_NUM_##_type]) |
| 194 | +#define MT_EE_CAL_GROUP_SIZE (PREK(GROUP_SIZE_2G) + PREK(GROUP_SIZE_5G) + \ |
| 195 | + PREK(GROUP_SIZE_6G) + PREK(ADCDCOC_SIZE_2G) + \ |
| 196 | + PREK(ADCDCOC_SIZE_5G) + PREK(ADCDCOC_SIZE_6G)) |
| 197 | +#define DPD_PER_CH_BW20_SIZE (PREK(DPD_LEGACY_SIZE) + PREK(DPD_OTFG0_SIZE)) |
| 198 | +#define DPD_PER_CH_GT_BW20_SIZE (PREK(DPD_MEM_SIZE) + PREK(DPD_OTFG0_SIZE)) |
| 199 | +#define MT_EE_CAL_DPD_SIZE_2G (DPD_CH_NUM(BW20_2G) * DPD_PER_CH_BW20_SIZE) |
| 200 | +#define MT_EE_CAL_DPD_SIZE_5G (DPD_CH_NUM(BW20_5G) * DPD_PER_CH_BW20_SIZE + \ |
| 201 | + DPD_CH_NUM(BW80_5G) * DPD_PER_CH_GT_BW20_SIZE + \ |
| 202 | + DPD_CH_NUM(BW160_5G) * DPD_PER_CH_GT_BW20_SIZE) |
| 203 | +#define MT_EE_CAL_DPD_SIZE_6G (DPD_CH_NUM(BW20_6G) * DPD_PER_CH_BW20_SIZE + \ |
| 204 | + DPD_CH_NUM(BW80_6G) * DPD_PER_CH_GT_BW20_SIZE + \ |
| 205 | + DPD_CH_NUM(BW160_6G) * DPD_PER_CH_GT_BW20_SIZE + \ |
| 206 | + DPD_CH_NUM(BW320_6G) * DPD_PER_CH_GT_BW20_SIZE) |
| 207 | +#define MT_EE_CAL_DPD_SIZE (MT_EE_CAL_DPD_SIZE_2G + MT_EE_CAL_DPD_SIZE_5G + \ |
| 208 | + MT_EE_CAL_DPD_SIZE_6G) |
| 209 | |
| 210 | #define RF_DPD_FLAT_CAL BIT(28) |
| 211 | #define RF_PRE_CAL BIT(29) |
| 212 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 213 | index 6f08161..528bce8 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 214 | --- a/mt7996/mcu.c |
| 215 | +++ b/mt7996/mcu.c |
| 216 | @@ -3735,13 +3735,11 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy) |
| 217 | enum nl80211_chan_width bw = chandef->width; |
| 218 | const struct ieee80211_channel *chan_list; |
| 219 | u32 cal_id, chan_list_size, base_offset = 0, offs = MT_EE_DO_PRE_CAL; |
| 220 | - u32 dpd_size_2g, dpd_size_5g, per_chan_size = DPD_PER_CH_BW20_SIZE; |
| 221 | + u32 per_chan_size = DPD_PER_CH_BW20_SIZE; |
| 222 | u16 channel = ieee80211_frequency_to_channel(chandef->center_freq1); |
| 223 | u8 dpd_mask, *cal = dev->cal, *eeprom = dev->mt76.eeprom.data; |
| 224 | int idx, i, ret; |
| 225 | - |
| 226 | - dpd_size_2g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_2GHZ); |
| 227 | - dpd_size_5g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_5GHZ); |
| 228 | + bool has_skip_ch = (band == NL80211_BAND_5GHZ); |
| 229 | |
| 230 | switch (band) { |
| 231 | case NL80211_BAND_2GHZ: |
| 232 | @@ -3757,27 +3755,35 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy) |
| 233 | return 0; |
| 234 | cal_id = RF_DPD_FLAT_CAL; |
| 235 | chan_list = dpd_2g_ch_list_bw20; |
| 236 | - chan_list_size = dpd_2g_bw20_ch_num; |
| 237 | + chan_list_size = DPD_CH_NUM(BW20_2G); |
| 238 | break; |
| 239 | case NL80211_BAND_5GHZ: |
| 240 | dpd_mask = MT_EE_WIFI_CAL_DPD_5G; |
| 241 | cal_id = RF_DPD_FLAT_5G_CAL; |
| 242 | chan_list = mphy->sband_5g.sband.channels; |
| 243 | chan_list_size = mphy->sband_5g.sband.n_channels; |
| 244 | - base_offset += dpd_size_2g; |
| 245 | + base_offset += MT_EE_CAL_DPD_SIZE_2G; |
| 246 | if (bw == NL80211_CHAN_WIDTH_160) { |
| 247 | - base_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) * |
| 248 | - DPD_PER_CH_BW20_SIZE; |
| 249 | + base_offset += DPD_CH_NUM(BW20_5G) * DPD_PER_CH_BW20_SIZE + |
| 250 | + DPD_CH_NUM(BW80_5G) * DPD_PER_CH_GT_BW20_SIZE; |
| 251 | per_chan_size = DPD_PER_CH_GT_BW20_SIZE; |
| 252 | cal_id = RF_DPD_FLAT_5G_MEM_CAL; |
| 253 | chan_list = dpd_5g_ch_list_bw160; |
| 254 | - chan_list_size = dpd_5g_bw160_ch_num; |
| 255 | + chan_list_size = DPD_CH_NUM(BW160_5G); |
| 256 | + has_skip_ch = false; |
| 257 | + } else if (is_mt7992(&dev->mt76) && bw == NL80211_CHAN_WIDTH_80) { |
| 258 | + base_offset += DPD_CH_NUM(BW20_5G) * DPD_PER_CH_BW20_SIZE; |
| 259 | + per_chan_size = DPD_PER_CH_GT_BW20_SIZE; |
| 260 | + cal_id = RF_DPD_FLAT_5G_MEM_CAL; |
| 261 | + chan_list = dpd_5g_ch_list_bw80; |
| 262 | + chan_list_size = DPD_CH_NUM(BW80_5G); |
| 263 | + has_skip_ch = false; |
| 264 | } else if (bw > NL80211_CHAN_WIDTH_20) { |
| 265 | /* apply (center channel - 2)'s dpd cal data for bw 40/80 channels */ |
| 266 | channel -= 2; |
| 267 | } |
| 268 | if (channel >= dpd_5g_skip_ch_list[0].hw_value && |
| 269 | - channel <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value) |
| 270 | + channel <= dpd_5g_skip_ch_list[DPD_CH_NUM(BW20_5G_SKIP) - 1].hw_value) |
| 271 | return 0; |
| 272 | break; |
| 273 | case NL80211_BAND_6GHZ: |
| 274 | @@ -3785,20 +3791,27 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy) |
| 275 | cal_id = RF_DPD_FLAT_6G_CAL; |
| 276 | chan_list = mphy->sband_6g.sband.channels; |
| 277 | chan_list_size = mphy->sband_6g.sband.n_channels; |
| 278 | - base_offset += dpd_size_2g + dpd_size_5g; |
| 279 | + base_offset += MT_EE_CAL_DPD_SIZE_2G + MT_EE_CAL_DPD_SIZE_5G; |
| 280 | if (bw == NL80211_CHAN_WIDTH_160) { |
| 281 | base_offset += mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE; |
| 282 | per_chan_size = DPD_PER_CH_GT_BW20_SIZE; |
| 283 | cal_id = RF_DPD_FLAT_6G_MEM_CAL; |
| 284 | chan_list = dpd_6g_ch_list_bw160; |
| 285 | - chan_list_size = dpd_6g_bw160_ch_num; |
| 286 | - } else if (bw == NL80211_CHAN_WIDTH_320) { |
| 287 | + chan_list_size = DPD_CH_NUM(BW160_6G); |
| 288 | + } else if (is_mt7996(&dev->mt76) && bw == NL80211_CHAN_WIDTH_320) { |
| 289 | base_offset += mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE + |
| 290 | - dpd_6g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE; |
| 291 | + DPD_CH_NUM(BW80_6G) * DPD_PER_CH_GT_BW20_SIZE + |
| 292 | + DPD_CH_NUM(BW160_6G) * DPD_PER_CH_GT_BW20_SIZE; |
| 293 | per_chan_size = DPD_PER_CH_GT_BW20_SIZE; |
| 294 | cal_id = RF_DPD_FLAT_6G_MEM_CAL; |
| 295 | chan_list = dpd_6g_ch_list_bw320; |
| 296 | - chan_list_size = dpd_6g_bw320_ch_num; |
| 297 | + chan_list_size = DPD_CH_NUM(BW320_6G); |
| 298 | + } else if (is_mt7992(&dev->mt76) && bw == NL80211_CHAN_WIDTH_80) { |
| 299 | + base_offset += mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE; |
| 300 | + per_chan_size = DPD_PER_CH_GT_BW20_SIZE; |
| 301 | + cal_id = RF_DPD_FLAT_6G_MEM_CAL; |
| 302 | + chan_list = dpd_6g_ch_list_bw80; |
| 303 | + chan_list_size = DPD_CH_NUM(BW80_6G); |
| 304 | } else if (bw > NL80211_CHAN_WIDTH_20) { |
| 305 | /* apply (center channel - 2)'s dpd cal data for bw 40/80 channels */ |
| 306 | channel -= 2; |
| 307 | @@ -3818,9 +3831,8 @@ int mt7996_mcu_apply_tx_dpd(struct mt7996_phy *phy) |
| 308 | if (idx == chan_list_size) |
| 309 | return -EINVAL; |
| 310 | |
| 311 | - if (band == NL80211_BAND_5GHZ && bw != NL80211_CHAN_WIDTH_160 && |
| 312 | - channel > dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value) |
| 313 | - idx -= dpd_5g_skip_ch_num; |
| 314 | + if (has_skip_ch && channel > dpd_5g_skip_ch_list[DPD_CH_NUM(BW20_5G_SKIP) - 1].hw_value) |
| 315 | + idx -= DPD_CH_NUM(BW20_5G_SKIP); |
| 316 | |
| 317 | cal += MT_EE_CAL_GROUP_SIZE + base_offset + idx * per_chan_size; |
| 318 | |
| 319 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 320 | index 7f7a622..0ebeb24 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 321 | --- a/mt7996/mt7996.h |
| 322 | +++ b/mt7996/mt7996.h |
| 323 | @@ -194,6 +194,19 @@ struct mt7996_twt_flow { |
| 324 | |
| 325 | DECLARE_EWMA(avg_signal, 10, 8) |
| 326 | |
| 327 | +enum mt7996_dpd_ch_num { |
| 328 | + DPD_CH_NUM_BW20_2G, |
| 329 | + DPD_CH_NUM_BW20_5G, |
| 330 | + DPD_CH_NUM_BW20_5G_SKIP, |
| 331 | + DPD_CH_NUM_BW80_5G, |
| 332 | + DPD_CH_NUM_BW160_5G, |
| 333 | + DPD_CH_NUM_BW20_6G, |
| 334 | + DPD_CH_NUM_BW80_6G, |
| 335 | + DPD_CH_NUM_BW160_6G, |
| 336 | + DPD_CH_NUM_BW320_6G, |
| 337 | + DPD_CH_NUM_TYPE_MAX, |
| 338 | +}; |
| 339 | + |
| 340 | struct mt7996_sta { |
| 341 | struct mt76_wcid wcid; /* must be first */ |
| 342 | |
| 343 | @@ -463,6 +476,10 @@ struct mt7996_dev { |
| 344 | |
| 345 | void *cal; |
| 346 | u32 cur_prek_offset; |
| 347 | + struct { |
| 348 | + const u32 *rev; |
| 349 | + u8 dpd_ch_num[DPD_CH_NUM_TYPE_MAX]; |
| 350 | + } prek; |
| 351 | |
| 352 | struct { |
| 353 | u16 table_mask; |
| 354 | @@ -599,7 +616,6 @@ int mt7996_eeprom_parse_hw_cap(struct mt7996_dev *dev, struct mt7996_phy *phy); |
| 355 | int mt7996_eeprom_get_target_power(struct mt7996_dev *dev, |
| 356 | struct ieee80211_channel *chan); |
| 357 | s8 mt7996_eeprom_get_power_delta(struct mt7996_dev *dev, int band); |
| 358 | -int mt7996_get_dpd_per_band_size(struct mt7996_dev *dev, enum nl80211_band band); |
| 359 | int mt7996_dma_init(struct mt7996_dev *dev); |
| 360 | void mt7996_dma_reset(struct mt7996_dev *dev, bool force); |
| 361 | void mt7996_dma_prefetch(struct mt7996_dev *dev); |
| 362 | diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 363 | index 95d3bde..9fa4edc 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 364 | --- a/mt7996/testmode.c |
| 365 | +++ b/mt7996/testmode.c |
| 366 | @@ -434,7 +434,7 @@ mt7996_tm_set_tx_cont(struct mt7996_phy *phy, bool en) |
| 367 | static int |
| 368 | mt7996_tm_group_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 369 | { |
| 370 | - u8 *eeprom; |
| 371 | + u8 *eeprom, do_precal; |
| 372 | u32 i, group_size, dpd_size, size, offs, *pre_cal; |
| 373 | int ret = 0; |
| 374 | struct mt7996_dev *dev = phy->dev; |
| 375 | @@ -462,6 +462,9 @@ mt7996_tm_group_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 376 | dpd_size = MT_EE_CAL_DPD_SIZE; |
| 377 | size = group_size + dpd_size; |
| 378 | offs = MT_EE_DO_PRE_CAL; |
| 379 | + do_precal = (MT_EE_WIFI_CAL_GROUP_2G * !!PREK(GROUP_SIZE_2G)) | |
| 380 | + (MT_EE_WIFI_CAL_GROUP_5G * !!PREK(GROUP_SIZE_5G)) | |
| 381 | + (MT_EE_WIFI_CAL_GROUP_6G * !!PREK(GROUP_SIZE_6G)); |
| 382 | |
| 383 | switch (state) { |
| 384 | case MT76_TM_STATE_GROUP_PREK: |
| 385 | @@ -476,13 +479,10 @@ mt7996_tm_group_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 386 | wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == group_size, |
| 387 | 30 * HZ); |
| 388 | |
| 389 | - if (ret) { |
| 390 | + if (ret) |
| 391 | dev_err(dev->mt76.dev, "Group Pre-cal: mcu send msg failed!\n"); |
| 392 | - return ret; |
| 393 | - } |
| 394 | - |
| 395 | - if (!ret) |
| 396 | - eeprom[offs] |= MT_EE_WIFI_CAL_GROUP; |
| 397 | + else |
| 398 | + eeprom[offs] |= do_precal; |
| 399 | break; |
| 400 | case MT76_TM_STATE_GROUP_PREK_DUMP: |
| 401 | pre_cal = (u32 *)dev->cal; |
| 402 | @@ -520,10 +520,12 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req, |
| 403 | struct mt76_phy *mphy = phy->mt76; |
| 404 | struct cfg80211_chan_def chandef_backup, *chandef = &mphy->chandef; |
| 405 | struct ieee80211_channel chan_backup; |
| 406 | - int i, ret; |
| 407 | + int i, ret, skip_ch_num = DPD_CH_NUM(BW20_5G_SKIP); |
| 408 | |
| 409 | if (!chan_list) |
| 410 | return -EOPNOTSUPP; |
| 411 | + if (!channel_size) |
| 412 | + return 0; |
| 413 | |
| 414 | req->rf_test.op.rf.param.cal_param.func_data = cpu_to_le32(func_data); |
| 415 | |
| 416 | @@ -533,7 +535,7 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req, |
| 417 | for (i = 0; i < channel_size; i++) { |
| 418 | if (chan_list[i].band == NL80211_BAND_5GHZ && |
| 419 | chan_list[i].hw_value >= dpd_5g_skip_ch_list[0].hw_value && |
| 420 | - chan_list[i].hw_value <= dpd_5g_skip_ch_list[dpd_5g_skip_ch_num - 1].hw_value) |
| 421 | + chan_list[i].hw_value <= dpd_5g_skip_ch_list[skip_ch_num - 1].hw_value) |
| 422 | continue; |
| 423 | |
| 424 | memcpy(chandef->chan, &chan_list[i], sizeof(struct ieee80211_channel)); |
| 425 | @@ -602,11 +604,11 @@ mt7996_tm_dpd_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 426 | switch (state) { |
| 427 | case MT76_TM_STATE_DPD_2G: |
| 428 | ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_2g_ch_list_bw20, |
| 429 | - dpd_2g_bw20_ch_num, |
| 430 | + DPD_CH_NUM(BW20_2G), |
| 431 | NL80211_CHAN_WIDTH_20, RF_DPD_FLAT_CAL); |
| 432 | - wait_on_prek_offset += dpd_2g_bw20_ch_num * DPD_PER_CH_BW20_SIZE; |
| 433 | - wait_event_timeout(mdev->mcu.wait, |
| 434 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 435 | + wait_on_prek_offset += DPD_CH_NUM(BW20_2G) * DPD_PER_CH_BW20_SIZE; |
| 436 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 437 | + 30 * HZ); |
| 438 | |
| 439 | do_precal = MT_EE_WIFI_CAL_DPD_2G; |
| 440 | break; |
| 441 | @@ -617,18 +619,27 @@ mt7996_tm_dpd_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 442 | NL80211_CHAN_WIDTH_20, RF_DPD_FLAT_5G_CAL); |
| 443 | if (ret) |
| 444 | return ret; |
| 445 | - wait_on_prek_offset += (mphy->sband_5g.sband.n_channels - dpd_5g_skip_ch_num) * |
| 446 | - DPD_PER_CH_BW20_SIZE; |
| 447 | - wait_event_timeout(mdev->mcu.wait, |
| 448 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 449 | + wait_on_prek_offset += DPD_CH_NUM(BW20_5G) * DPD_PER_CH_BW20_SIZE; |
| 450 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 451 | + 30 * HZ); |
| 452 | + |
| 453 | + /* 5g channel bw80 calibration */ |
| 454 | + ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_5g_ch_list_bw80, |
| 455 | + DPD_CH_NUM(BW80_5G), |
| 456 | + NL80211_CHAN_WIDTH_80, RF_DPD_FLAT_5G_MEM_CAL); |
| 457 | + if (ret) |
| 458 | + return ret; |
| 459 | + wait_on_prek_offset += DPD_CH_NUM(BW80_5G) * DPD_PER_CH_GT_BW20_SIZE; |
| 460 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 461 | + 30 * HZ); |
| 462 | |
| 463 | /* 5g channel bw160 calibration */ |
| 464 | ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_5g_ch_list_bw160, |
| 465 | - dpd_5g_bw160_ch_num, |
| 466 | + DPD_CH_NUM(BW160_5G), |
| 467 | NL80211_CHAN_WIDTH_160, RF_DPD_FLAT_5G_MEM_CAL); |
| 468 | - wait_on_prek_offset += dpd_5g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE; |
| 469 | - wait_event_timeout(mdev->mcu.wait, |
| 470 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 471 | + wait_on_prek_offset += DPD_CH_NUM(BW160_5G) * DPD_PER_CH_GT_BW20_SIZE; |
| 472 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 473 | + 30 * HZ); |
| 474 | |
| 475 | do_precal = MT_EE_WIFI_CAL_DPD_5G; |
| 476 | break; |
| 477 | @@ -639,27 +650,37 @@ mt7996_tm_dpd_prek(struct mt7996_phy *phy, enum mt76_testmode_state state) |
| 478 | NL80211_CHAN_WIDTH_20, RF_DPD_FLAT_6G_CAL); |
| 479 | if (ret) |
| 480 | return ret; |
| 481 | - wait_on_prek_offset += mphy->sband_6g.sband.n_channels * DPD_PER_CH_BW20_SIZE; |
| 482 | - wait_event_timeout(mdev->mcu.wait, |
| 483 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 484 | + wait_on_prek_offset += DPD_CH_NUM(BW20_6G) * DPD_PER_CH_BW20_SIZE; |
| 485 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 486 | + 30 * HZ); |
| 487 | + |
| 488 | + /* 6g channel bw80 calibration */ |
| 489 | + ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_6g_ch_list_bw80, |
| 490 | + DPD_CH_NUM(BW80_6G), |
| 491 | + NL80211_CHAN_WIDTH_80, RF_DPD_FLAT_6G_MEM_CAL); |
| 492 | + if (ret) |
| 493 | + return ret; |
| 494 | + wait_on_prek_offset += DPD_CH_NUM(BW80_6G) * DPD_PER_CH_GT_BW20_SIZE; |
| 495 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 496 | + 30 * HZ); |
| 497 | |
| 498 | /* 6g channel bw160 calibration */ |
| 499 | ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_6g_ch_list_bw160, |
| 500 | - dpd_6g_bw160_ch_num, |
| 501 | + DPD_CH_NUM(BW160_6G), |
| 502 | NL80211_CHAN_WIDTH_160, RF_DPD_FLAT_6G_MEM_CAL); |
| 503 | if (ret) |
| 504 | return ret; |
| 505 | - wait_on_prek_offset += dpd_6g_bw160_ch_num * DPD_PER_CH_GT_BW20_SIZE; |
| 506 | - wait_event_timeout(mdev->mcu.wait, |
| 507 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 508 | + wait_on_prek_offset += DPD_CH_NUM(BW160_6G) * DPD_PER_CH_GT_BW20_SIZE; |
| 509 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 510 | + 30 * HZ); |
| 511 | |
| 512 | /* 6g channel bw320 calibration */ |
| 513 | ret = mt7996_tm_dpd_prek_send_req(phy, &req, dpd_6g_ch_list_bw320, |
| 514 | - dpd_6g_bw320_ch_num, |
| 515 | + DPD_CH_NUM(BW320_6G), |
| 516 | NL80211_CHAN_WIDTH_320, RF_DPD_FLAT_6G_MEM_CAL); |
| 517 | - wait_on_prek_offset += dpd_6g_bw320_ch_num * DPD_PER_CH_GT_BW20_SIZE; |
| 518 | - wait_event_timeout(mdev->mcu.wait, |
| 519 | - dev->cur_prek_offset == wait_on_prek_offset, 30 * HZ); |
| 520 | + wait_on_prek_offset += DPD_CH_NUM(BW320_6G) * DPD_PER_CH_GT_BW20_SIZE; |
| 521 | + wait_event_timeout(mdev->mcu.wait, dev->cur_prek_offset == wait_on_prek_offset, |
| 522 | + 30 * HZ); |
| 523 | |
| 524 | do_precal = MT_EE_WIFI_CAL_DPD_6G; |
| 525 | break; |
| 526 | @@ -732,9 +753,9 @@ mt7996_tm_dump_precal(struct mt76_phy *mphy, struct sk_buff *msg, int flag, int |
| 527 | eeprom = dev->mt76.eeprom.data; |
| 528 | offs = MT_EE_DO_PRE_CAL; |
| 529 | |
| 530 | - dpd_size_2g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_2GHZ); |
| 531 | - dpd_size_5g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_5GHZ); |
| 532 | - dpd_size_6g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_6GHZ); |
| 533 | + dpd_size_2g = MT_EE_CAL_DPD_SIZE_2G; |
| 534 | + dpd_size_5g = MT_EE_CAL_DPD_SIZE_5G; |
| 535 | + dpd_size_6g = MT_EE_CAL_DPD_SIZE_6G; |
| 536 | |
| 537 | switch (type) { |
| 538 | case PREK_SYNC_ALL: |
| 539 | @@ -810,9 +831,9 @@ mt7996_tm_re_cal_event(struct mt7996_dev *dev, struct mt7996_tm_rf_test_result * |
| 540 | u8 *pre_cal; |
| 541 | |
| 542 | pre_cal = dev->cal; |
| 543 | - dpd_size_2g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_2GHZ); |
| 544 | - dpd_size_5g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_5GHZ); |
| 545 | - dpd_size_6g = mt7996_get_dpd_per_band_size(dev, NL80211_BAND_6GHZ); |
| 546 | + dpd_size_2g = MT_EE_CAL_DPD_SIZE_2G; |
| 547 | + dpd_size_5g = MT_EE_CAL_DPD_SIZE_5G; |
| 548 | + dpd_size_6g = MT_EE_CAL_DPD_SIZE_6G; |
| 549 | |
| 550 | cal_idx = le32_to_cpu(data->cal_idx); |
| 551 | cal_type = le32_to_cpu(data->cal_type); |
| 552 | diff --git a/testmode.c b/testmode.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 553 | index b9f7109..2dd184e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 554 | --- a/testmode.c |
| 555 | +++ b/testmode.c |
| 556 | @@ -37,6 +37,11 @@ const struct nla_policy mt76_tm_policy[NUM_MT76_TM_ATTRS] = { |
| 557 | }; |
| 558 | EXPORT_SYMBOL_GPL(mt76_tm_policy); |
| 559 | |
| 560 | +static inline bool mt76_testmode_offload(struct mt76_dev *dev) |
| 561 | +{ |
| 562 | + return is_mt7996(dev) || is_mt7992(dev); |
| 563 | +} |
| 564 | + |
| 565 | void mt76_testmode_tx_pending(struct mt76_phy *phy) |
| 566 | { |
| 567 | struct mt76_testmode_data *td = &phy->test; |
| 568 | @@ -197,7 +202,7 @@ mt76_testmode_tx_init(struct mt76_phy *phy) |
| 569 | u8 max_nss = hweight8(phy->antenna_mask); |
| 570 | int ret; |
| 571 | |
| 572 | - if (is_mt7996(phy->dev)) |
| 573 | + if (mt76_testmode_offload(phy->dev)) |
| 574 | return 0; |
| 575 | |
| 576 | ret = mt76_testmode_alloc_skb(phy, td->tx_mpdu_len); |
| 577 | @@ -293,7 +298,7 @@ mt76_testmode_tx_start(struct mt76_phy *phy) |
| 578 | td->tx_done = 0; |
| 579 | td->tx_pending = td->tx_count; |
| 580 | |
| 581 | - if (!is_mt7996(dev)) |
| 582 | + if (!mt76_testmode_offload(dev)) |
| 583 | mt76_worker_schedule(&dev->tx_worker); |
| 584 | } |
| 585 | |
| 586 | @@ -303,7 +308,7 @@ mt76_testmode_tx_stop(struct mt76_phy *phy) |
| 587 | struct mt76_testmode_data *td = &phy->test; |
| 588 | struct mt76_dev *dev = phy->dev; |
| 589 | |
| 590 | - if (is_mt7996(dev) && dev->test_ops->tx_stop) { |
| 591 | + if (mt76_testmode_offload(dev) && dev->test_ops->tx_stop) { |
| 592 | dev->test_ops->tx_stop(phy); |
| 593 | return; |
| 594 | } |
| 595 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame^] | 596 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 597 | |