blob: 6aef19c873cdb04366cc4b68b7ecb5ea45d2e738 [file] [log] [blame]
developer1a173672023-12-21 14:49:33 +08001From 5186827e8a40a71363aa2c7cc3aef1fafae3665f Mon Sep 17 00:00:00 2001
developer70180b02023-11-14 17:01:47 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Tue, 31 Oct 2023 16:29:13 +0800
developer1a173672023-12-21 14:49:33 +08004Subject: [PATCH 55/76] wifi: mt76: testmode: add cheetah support
developer70180b02023-11-14 17:01:47 +08005
6Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
7---
8 mt7915/eeprom.c | 3 +--
9 mt7915/eeprom.h | 12 ++++++++++++
10 mt7915/mcu.c | 21 +++++++++++++++++++--
11 mt7915/testmode.c | 9 +++++----
12 4 files changed, 37 insertions(+), 8 deletions(-)
13
14diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
developer1a173672023-12-21 14:49:33 +080015index b96776d..c8ea1d9 100644
developer70180b02023-11-14 17:01:47 +080016--- a/mt7915/eeprom.c
17+++ b/mt7915/eeprom.c
18@@ -39,8 +39,7 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)
19 if (!dev->flash_mode || !val)
20 return 0;
21
22- size = mt7915_get_cal_group_size(dev) +
23- (is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2);
24+ size = mt7915_get_cal_group_size(dev) + mt7915_get_cal_dpd_size(dev);
25
26 dev->cal = devm_kzalloc(mdev->dev, size, GFP_KERNEL);
27 if (!dev->cal)
28diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h
29index a1ab05a..99101f9 100644
30--- a/mt7915/eeprom.h
31+++ b/mt7915/eeprom.h
32@@ -52,6 +52,7 @@ enum mt7915_eeprom_field {
33 #define MT_EE_CAL_GROUP_SIZE_7916_6G (94 * MT_EE_CAL_UNIT + 16)
34 #define MT_EE_CAL_DPD_SIZE_V1 (54 * MT_EE_CAL_UNIT)
35 #define MT_EE_CAL_DPD_SIZE_V2 (300 * MT_EE_CAL_UNIT)
36+#define MT_EE_CAL_DPD_SIZE_V2_7981 (102 * MT_EE_CAL_UNIT) /* no 6g dpd data */
37
38 #define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
39 #define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
40@@ -192,6 +193,17 @@ mt7915_get_cal_group_size(struct mt7915_dev *dev)
41 }
42 }
43
44+static inline u32
45+mt7915_get_cal_dpd_size(struct mt7915_dev *dev)
46+{
47+ if (is_mt7915(&dev->mt76))
48+ return MT_EE_CAL_DPD_SIZE_V1;
49+ else if (is_mt7981(&dev->mt76))
50+ return MT_EE_CAL_DPD_SIZE_V2_7981;
51+ else
52+ return MT_EE_CAL_DPD_SIZE_V2;
53+}
54+
55 extern const u8 mt7915_sku_group_len[MAX_SKU_RATE_GROUP_NUM];
56
57 #endif
58diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer1a173672023-12-21 14:49:33 +080059index ac015ab..2b41feb 100644
developer70180b02023-11-14 17:01:47 +080060--- a/mt7915/mcu.c
61+++ b/mt7915/mcu.c
developer1a173672023-12-21 14:49:33 +080062@@ -3040,13 +3040,30 @@ static int mt7915_dpd_freq_idx(struct mt7915_dev *dev, u16 freq, u8 bw)
developer70180b02023-11-14 17:01:47 +080063 /* 5G BW160 */
64 5250, 5570, 5815
65 };
66+ const u16 freq_list_v2_7981[] = {
67+ /* 5G BW20 */
68+ 5180, 5200, 5220, 5240,
69+ 5260, 5280, 5300, 5320,
70+ 5500, 5520, 5540, 5560,
71+ 5580, 5600, 5620, 5640,
72+ 5660, 5680, 5700, 5720,
73+ 5745, 5765, 5785, 5805,
74+ 5825, 5845, 5865, 5885,
75+ /* 5G BW160 */
76+ 5250, 5570, 5815
77+ };
78 const u16 *freq_list = freq_list_v1;
79 int n_freqs = ARRAY_SIZE(freq_list_v1);
80 int idx;
81
82 if (!is_mt7915(&dev->mt76)) {
83- freq_list = freq_list_v2;
84- n_freqs = ARRAY_SIZE(freq_list_v2);
85+ if (is_mt7981(&dev->mt76)) {
86+ freq_list = freq_list_v2_7981;
87+ n_freqs = ARRAY_SIZE(freq_list_v2_7981);
88+ } else {
89+ freq_list = freq_list_v2;
90+ n_freqs = ARRAY_SIZE(freq_list_v2);
91+ }
92 }
93
94 if (freq < 4000) {
95diff --git a/mt7915/testmode.c b/mt7915/testmode.c
developer1a173672023-12-21 14:49:33 +080096index faf6014..ecd6271 100644
developer70180b02023-11-14 17:01:47 +080097--- a/mt7915/testmode.c
98+++ b/mt7915/testmode.c
developer1a173672023-12-21 14:49:33 +080099@@ -2151,7 +2151,7 @@ mt7915_tm_group_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
developer70180b02023-11-14 17:01:47 +0800100 eeprom = mdev->eeprom.data;
101 dev->cur_prek_offset = 0;
102 group_size = mt7915_get_cal_group_size(dev);
103- dpd_size = is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2;
104+ dpd_size = mt7915_get_cal_dpd_size(dev);
105 size = group_size + dpd_size;
106 offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2;
107
developer1a173672023-12-21 14:49:33 +0800108@@ -2233,11 +2233,11 @@ mt7915_tm_dpd_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
developer70180b02023-11-14 17:01:47 +0800109 eeprom = mdev->eeprom.data;
110 dev->cur_prek_offset = 0;
111 group_size = mt7915_get_cal_group_size(dev);
112+ dpd_size = mt7915_get_cal_dpd_size(dev);
113 dev->dpd_chan_num_2g = hweight32(DPD_2G_CH_BW20_BITMAP_0);
114 if (is_mt7915(&dev->mt76)) {
115 dev->dpd_chan_num_5g = hweight32(DPD_5G_CH_BW20_BITMAP_7915_0);
116 dev->dpd_chan_num_6g = 0;
117- dpd_size = MT_EE_CAL_DPD_SIZE_V1;
118 offs = MT_EE_DO_PRE_CAL;
119 } else {
120 dev->dpd_chan_num_5g = hweight32(DPD_5G_CH_BW20_BITMAP_0) +
developer1a173672023-12-21 14:49:33 +0800121@@ -2246,7 +2246,8 @@ mt7915_tm_dpd_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
developer70180b02023-11-14 17:01:47 +0800122 dev->dpd_chan_num_6g = hweight32(DPD_6G_CH_BW20_BITMAP_0) +
123 hweight32(DPD_6G_CH_BW20_BITMAP_1) +
124 ARRAY_SIZE(bw160_6g_freq);
125- dpd_size = MT_EE_CAL_DPD_SIZE_V2;
126+ if (is_mt7981(&dev->mt76))
127+ dev->dpd_chan_num_6g = 0;
128 offs = MT_EE_DO_PRE_CAL_V2;
129 }
130 size = group_size + dpd_size;
developer1a173672023-12-21 14:49:33 +0800131@@ -2711,7 +2712,7 @@ mt7915_tm_dump_precal(struct mt76_phy *mphy, struct sk_buff *msg, int flag, int
developer70180b02023-11-14 17:01:47 +0800132 }
133
134 group_size = mt7915_get_cal_group_size(dev);
135- dpd_size = is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2;
136+ dpd_size = mt7915_get_cal_dpd_size(dev);
137 dpd_per_chan_size = is_mt7915(&dev->mt76) ? 2 : 3;
138 total_size = group_size + dpd_size;
139 pre_cal = dev->cal;
140--
1412.18.0
142