[][MAC80211][WiFi6][mt76][Add support for cheetah]
[Description]
Add support for cheetah
1. Add cheetah specific eeprom definition
2. Add cheetah 3T3R 2ss handling in mt7915_set_anntena for chainmask
3. Add testmode prek support for cheetah
Testmode RDUT status
1. basic tx/rx: local RDUT pass
2. pre-calibration: local RDUT pass
3. ZWDFS verification: TBD (not sure if ZWDFS is required or not)
4. ebf: local RDUT pass
5. ibf
(a) 2G/5G cal with golden: local RDUT pass
(b) 2G/5G cal with instrument: TBD
[Release-log]
N/A
Change-Id: Ie9291e87ed2df05a5215a511af698bf6e8adc7fe
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8188020
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1043-wifi-mt76-mt7915-add-cheetah-eeprom-related-fix.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1043-wifi-mt76-mt7915-add-cheetah-eeprom-related-fix.patch
new file mode 100644
index 0000000..9ff6874
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1043-wifi-mt76-mt7915-add-cheetah-eeprom-related-fix.patch
@@ -0,0 +1,44 @@
+From 02120d0ab9b6d2f864706c2a0d6583c7b8fc60e8 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Tue, 31 Oct 2023 16:28:52 +0800
+Subject: [PATCH] wifi: mt76: mt7915: add cheetah eeprom related fix
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ mt7915/eeprom.h | 3 ++-
+ mt7915/main.c | 5 +++--
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h
+index 9056d78..a1ab05a 100644
+--- a/mt7915/eeprom.h
++++ b/mt7915/eeprom.h
+@@ -160,7 +160,8 @@ static inline bool
+ mt7915_tssi_enabled(struct mt7915_dev *dev, enum nl80211_band band)
+ {
+ u8 *eep = dev->mt76.eeprom.data;
+- u8 val = eep[MT_EE_WIFI_CONF + 7];
++ u8 offs = is_mt7981(&dev->mt76) ? 8 : 7;
++ u8 val = eep[MT_EE_WIFI_CONF + offs];
+
+ if (band == NL80211_BAND_2GHZ)
+ return val & MT_EE_WIFI_CONF7_TSSI0_2G;
+diff --git a/mt7915/main.c b/mt7915/main.c
+index 797a3b4..9ab93f4 100644
+--- a/mt7915/main.c
++++ b/mt7915/main.c
+@@ -1110,8 +1110,9 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
+
+ phy->mt76->antenna_mask = tx_ant;
+
+- /* handle a variant of mt7916 which has 3T3R but nss2 on 5 GHz band */
+- if (is_mt7916(&dev->mt76) && band && hweight8(tx_ant) == max_nss)
++ /* handle a variant of mt7916/mt7981 which has 3T3R but nss2 on 5 GHz band */
++ if ((is_mt7916(&dev->mt76) || is_mt7981(&dev->mt76)) &&
++ band && hweight8(tx_ant) == max_nss)
+ phy->mt76->chainmask = (dev->chainmask >> chainshift) << chainshift;
+ else
+ phy->mt76->chainmask = tx_ant << (chainshift * band);
+--
+2.18.0
+
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1044-wifi-mt76-testmode-add-cheetah-support.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1044-wifi-mt76-testmode-add-cheetah-support.patch
new file mode 100644
index 0000000..0f53710
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1044-wifi-mt76-testmode-add-cheetah-support.patch
@@ -0,0 +1,142 @@
+From 14b505d62c856f210ce46e831886ae0fab253252 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Tue, 31 Oct 2023 16:29:13 +0800
+Subject: [PATCH] wifi: mt76: testmode: add cheetah support
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ mt7915/eeprom.c | 3 +--
+ mt7915/eeprom.h | 12 ++++++++++++
+ mt7915/mcu.c | 21 +++++++++++++++++++--
+ mt7915/testmode.c | 9 +++++----
+ 4 files changed, 37 insertions(+), 8 deletions(-)
+
+diff --git a/mt7915/eeprom.c b/mt7915/eeprom.c
+index f8166dd..50ed7ba 100644
+--- a/mt7915/eeprom.c
++++ b/mt7915/eeprom.c
+@@ -39,8 +39,7 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev)
+ if (!dev->flash_mode || !val)
+ return 0;
+
+- size = mt7915_get_cal_group_size(dev) +
+- (is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2);
++ size = mt7915_get_cal_group_size(dev) + mt7915_get_cal_dpd_size(dev);
+
+ dev->cal = devm_kzalloc(mdev->dev, size, GFP_KERNEL);
+ if (!dev->cal)
+diff --git a/mt7915/eeprom.h b/mt7915/eeprom.h
+index a1ab05a..99101f9 100644
+--- a/mt7915/eeprom.h
++++ b/mt7915/eeprom.h
+@@ -52,6 +52,7 @@ enum mt7915_eeprom_field {
+ #define MT_EE_CAL_GROUP_SIZE_7916_6G (94 * MT_EE_CAL_UNIT + 16)
+ #define MT_EE_CAL_DPD_SIZE_V1 (54 * MT_EE_CAL_UNIT)
+ #define MT_EE_CAL_DPD_SIZE_V2 (300 * MT_EE_CAL_UNIT)
++#define MT_EE_CAL_DPD_SIZE_V2_7981 (102 * MT_EE_CAL_UNIT) /* no 6g dpd data */
+
+ #define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
+ #define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
+@@ -192,6 +193,17 @@ mt7915_get_cal_group_size(struct mt7915_dev *dev)
+ }
+ }
+
++static inline u32
++mt7915_get_cal_dpd_size(struct mt7915_dev *dev)
++{
++ if (is_mt7915(&dev->mt76))
++ return MT_EE_CAL_DPD_SIZE_V1;
++ else if (is_mt7981(&dev->mt76))
++ return MT_EE_CAL_DPD_SIZE_V2_7981;
++ else
++ return MT_EE_CAL_DPD_SIZE_V2;
++}
++
+ extern const u8 mt7915_sku_group_len[MAX_SKU_RATE_GROUP_NUM];
+
+ #endif
+diff --git a/mt7915/mcu.c b/mt7915/mcu.c
+index cd4f472..492cfcd 100644
+--- a/mt7915/mcu.c
++++ b/mt7915/mcu.c
+@@ -3035,13 +3035,30 @@ static int mt7915_dpd_freq_idx(struct mt7915_dev *dev, u16 freq, u8 bw)
+ /* 5G BW160 */
+ 5250, 5570, 5815
+ };
++ const u16 freq_list_v2_7981[] = {
++ /* 5G BW20 */
++ 5180, 5200, 5220, 5240,
++ 5260, 5280, 5300, 5320,
++ 5500, 5520, 5540, 5560,
++ 5580, 5600, 5620, 5640,
++ 5660, 5680, 5700, 5720,
++ 5745, 5765, 5785, 5805,
++ 5825, 5845, 5865, 5885,
++ /* 5G BW160 */
++ 5250, 5570, 5815
++ };
+ const u16 *freq_list = freq_list_v1;
+ int n_freqs = ARRAY_SIZE(freq_list_v1);
+ int idx;
+
+ if (!is_mt7915(&dev->mt76)) {
+- freq_list = freq_list_v2;
+- n_freqs = ARRAY_SIZE(freq_list_v2);
++ if (is_mt7981(&dev->mt76)) {
++ freq_list = freq_list_v2_7981;
++ n_freqs = ARRAY_SIZE(freq_list_v2_7981);
++ } else {
++ freq_list = freq_list_v2;
++ n_freqs = ARRAY_SIZE(freq_list_v2);
++ }
+ }
+
+ if (freq < 4000) {
+diff --git a/mt7915/testmode.c b/mt7915/testmode.c
+index 5e20cb9..4aa7eb6 100644
+--- a/mt7915/testmode.c
++++ b/mt7915/testmode.c
+@@ -2149,7 +2149,7 @@ mt7915_tm_group_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
+ eeprom = mdev->eeprom.data;
+ dev->cur_prek_offset = 0;
+ group_size = mt7915_get_cal_group_size(dev);
+- dpd_size = is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2;
++ dpd_size = mt7915_get_cal_dpd_size(dev);
+ size = group_size + dpd_size;
+ offs = is_mt7915(&dev->mt76) ? MT_EE_DO_PRE_CAL : MT_EE_DO_PRE_CAL_V2;
+
+@@ -2231,11 +2231,11 @@ mt7915_tm_dpd_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
+ eeprom = mdev->eeprom.data;
+ dev->cur_prek_offset = 0;
+ group_size = mt7915_get_cal_group_size(dev);
++ dpd_size = mt7915_get_cal_dpd_size(dev);
+ dev->dpd_chan_num_2g = hweight32(DPD_2G_CH_BW20_BITMAP_0);
+ if (is_mt7915(&dev->mt76)) {
+ dev->dpd_chan_num_5g = hweight32(DPD_5G_CH_BW20_BITMAP_7915_0);
+ dev->dpd_chan_num_6g = 0;
+- dpd_size = MT_EE_CAL_DPD_SIZE_V1;
+ offs = MT_EE_DO_PRE_CAL;
+ } else {
+ dev->dpd_chan_num_5g = hweight32(DPD_5G_CH_BW20_BITMAP_0) +
+@@ -2244,7 +2244,8 @@ mt7915_tm_dpd_prek(struct mt7915_phy *phy, enum mt76_testmode_state state)
+ dev->dpd_chan_num_6g = hweight32(DPD_6G_CH_BW20_BITMAP_0) +
+ hweight32(DPD_6G_CH_BW20_BITMAP_1) +
+ ARRAY_SIZE(bw160_6g_freq);
+- dpd_size = MT_EE_CAL_DPD_SIZE_V2;
++ if (is_mt7981(&dev->mt76))
++ dev->dpd_chan_num_6g = 0;
+ offs = MT_EE_DO_PRE_CAL_V2;
+ }
+ size = group_size + dpd_size;
+@@ -2707,7 +2708,7 @@ mt7915_tm_dump_precal(struct mt76_phy *mphy, struct sk_buff *msg, int flag, int
+ }
+
+ group_size = mt7915_get_cal_group_size(dev);
+- dpd_size = is_mt7915(&dev->mt76) ? MT_EE_CAL_DPD_SIZE_V1 : MT_EE_CAL_DPD_SIZE_V2;
++ dpd_size = mt7915_get_cal_dpd_size(dev);
+ dpd_per_chan_size = is_mt7915(&dev->mt76) ? 2 : 3;
+ total_size = group_size + dpd_size;
+ pre_cal = dev->cal;
+--
+2.18.0
+