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