[][MAC80211][wifi6][MT76][Add adie id and version in debugfs]

[Description]
Add adie id and version in debugfs.
Usage: cat fw_version
Example output:
adie[0]: id=0x7976 version=0x8a00
adie[1]: id=0x7976 version=0x8a00

[Release-log]
N/A

Change-Id: Iecf7d9e7f1c48e6712435798c3cc6e61252d1b0a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8798192
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1000-wifi-mt76-mt7915-add-mtk-internal-debug-tools-for-mt.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1000-wifi-mt76-mt7915-add-mtk-internal-debug-tools-for-mt.patch
index 95d0dfd..22a3222 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1000-wifi-mt76-mt7915-add-mtk-internal-debug-tools-for-mt.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1000-wifi-mt76-mt7915-add-mtk-internal-debug-tools-for-mt.patch
@@ -1,7 +1,7 @@
-From b4a2df1f096d27e84ab85330ea5069c015891def Mon Sep 17 00:00:00 2001
+From 70f7de3de779dda186c73feecdbd1d72fd367085 Mon Sep 17 00:00:00 2001
 From: Shayne Chen <shayne.chen@mediatek.com>
 Date: Wed, 22 Jun 2022 10:39:47 +0800
-Subject: [PATCH 1000/1049] wifi: mt76: mt7915: add mtk internal debug tools
+Subject: [PATCH 1000/1054] wifi: mt76: mt7915: add mtk internal debug tools
  for mt76
 
 ---
@@ -12,12 +12,13 @@
  mt7915/main.c         |    5 +
  mt7915/mcu.c          |   48 +-
  mt7915/mcu.h          |    4 +
- mt7915/mt7915.h       |   43 +
+ mt7915/mt7915.h       |   56 +
  mt7915/mt7915_debug.h | 1442 ++++++++++++++++
- mt7915/mtk_debugfs.c  | 3743 +++++++++++++++++++++++++++++++++++++++++
+ mt7915/mtk_debugfs.c  | 3750 +++++++++++++++++++++++++++++++++++++++++
  mt7915/mtk_mcu.c      |   51 +
+ mt7915/soc.c          |    7 +
  tools/fwlog.c         |   44 +-
- 12 files changed, 5472 insertions(+), 19 deletions(-)
+ 13 files changed, 5499 insertions(+), 19 deletions(-)
  create mode 100644 mt7915/mt7915_debug.h
  create mode 100644 mt7915/mtk_debugfs.c
  create mode 100644 mt7915/mtk_mcu.c
@@ -232,7 +233,7 @@
  
  	if (dev->relay_fwlog)
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 8e98e5ae..06229ca1 100644
+index 088eb792..428397d7 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
 @@ -282,6 +282,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb,
@@ -394,7 +395,7 @@
  	MCU_WA_PARAM_RED_SETTING = 0x40,
  };
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 874d5318..1418d192 100644
+index 6bee0f9a..ae9d5282 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -9,6 +9,7 @@
@@ -405,7 +406,22 @@
  #define MT7915_MAX_INTERFACES		19
  #define MT7915_WTBL_SIZE		288
  #define MT7916_WTBL_SIZE		544
-@@ -323,6 +324,28 @@ struct mt7915_dev {
+@@ -244,6 +245,14 @@ struct mt7915_phy {
+ #endif
+ };
+ 
++#ifdef MTK_DEBUG
++enum {
++	ADIE0,
++	ADIE1,
++	ADIE_MAX_CNT,
++};
++#endif
++
+ struct mt7915_dev {
+ 	union { /* must be first */
+ 		struct mt76_dev mt76;
+@@ -323,6 +332,33 @@ struct mt7915_dev {
  	void __iomem *dcm;
  	void __iomem *sku;
  
@@ -429,12 +445,17 @@
 +		u8 sku_disable;
 +	} dbg;
 +	const struct mt7915_dbg_reg_desc *dbg_reg;
++
++	struct {
++		u16 id;
++		u16 version;
++	} adie[ADIE_MAX_CNT];
 +#endif
 +
  	bool wmm_pbc_enable;
  	struct work_struct wmm_pbc_work;
- };
-@@ -605,4 +628,24 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+ 	u32 adie_type;
+@@ -606,4 +642,24 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
  			 bool pci, int *irq);
  
@@ -1909,10 +1930,10 @@
 +#endif
 diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
 new file mode 100644
-index 00000000..24ced8f3
+index 00000000..6f71dede
 --- /dev/null
 +++ b/mt7915/mtk_debugfs.c
-@@ -0,0 +1,3743 @@
+@@ -0,0 +1,3750 @@
 +#include<linux/inet.h>
 +#include "mt7915.h"
 +#include "mt7915_debug.h"
@@ -4837,6 +4858,8 @@
 +{
 +	struct mt7915_dev *dev = dev_get_drvdata(s->private);
 +	struct mt76_dev *mdev = NULL;
++	int i;
++
 +	seq_printf(s, "Version: 2.2.16.0\n");
 +
 +	if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state))
@@ -4846,6 +4869,11 @@
 +	seq_printf(s, "Rom Patch Build Time: %.16s\n", mdev->patch_hdr->build_date);
 +	seq_printf(s, "WM Patch Build Time: %.16s\n", mdev->wm_hdr->build_date);
 +	seq_printf(s, "WA Patch Build Time: %.16s\n", mdev->wa_hdr->build_date);
++
++	for (i = 0; i < ADIE_MAX_CNT; i++) {
++		seq_printf(s, "adie[%d]: id=0x%04x version=0x%04x\n",
++			   i, dev->adie[i].id, dev->adie[i].version);
++	}
 +	return 0;
 +}
 +
@@ -5713,6 +5741,24 @@
 +				 MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
 +				 sizeof(req), true);
 +}
+diff --git a/mt7915/soc.c b/mt7915/soc.c
+index fd16ff5a..5afb02f1 100644
+--- a/mt7915/soc.c
++++ b/mt7915/soc.c
+@@ -361,6 +361,13 @@ static int mt798x_wmac_sku_setup(struct mt7915_dev *dev, u32 *adie_type)
+ 	*adie_type = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_main) |
+ 		     (MT_ADIE_CHIP_ID_MASK & adie_ext);
+ 
++#ifdef MTK_DEBUG
++	dev->adie[ADIE0].id = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_main);
++	dev->adie[ADIE0].version = FIELD_GET(MT_ADIE_VERSION_MASK, adie_main);
++	dev->adie[ADIE1].id = FIELD_GET(MT_ADIE_CHIP_ID_MASK, adie_ext);
++	dev->adie[ADIE1].version = FIELD_GET(MT_ADIE_VERSION_MASK, adie_ext);
++#endif
++
+ out:
+ 	mt76_wmac_spi_unlock(dev);
+ 
 diff --git a/tools/fwlog.c b/tools/fwlog.c
 index e5d4a105..3d51d9ec 100644
 --- a/tools/fwlog.c
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1001-wifi-mt76-mt7915-csi-implement-csi-support.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1001-wifi-mt76-mt7915-csi-implement-csi-support.patch
index 25dc2da..8ff4f39 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1001-wifi-mt76-mt7915-csi-implement-csi-support.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1001-wifi-mt76-mt7915-csi-implement-csi-support.patch
@@ -1,7 +1,7 @@
-From eacb5a41b59216ac8a2585fb75bf721e4d559d56 Mon Sep 17 00:00:00 2001
+From b9fb2f28736aaa7f37f96a3b4fe8cdc34fa6fb1f Mon Sep 17 00:00:00 2001
 From: Bo Jiao <Bo.Jiao@mediatek.com>
 Date: Mon, 6 Jun 2022 20:13:02 +0800
-Subject: [PATCH 1001/1049] wifi: mt76: mt7915: csi: implement csi support
+Subject: [PATCH 1001/1054] wifi: mt76: mt7915: csi: implement csi support
 
 ---
  mt76_connac_mcu.h |   2 +
@@ -55,7 +55,7 @@
  mt7915e-$(CONFIG_NL80211_TESTMODE) += testmode.o
  mt7915e-$(CONFIG_MT798X_WMAC) += soc.o
 diff --git a/mt7915/init.c b/mt7915/init.c
-index 6ba98433..e6867548 100644
+index 08e98183..7986f722 100644
 --- a/mt7915/init.c
 +++ b/mt7915/init.c
 @@ -696,6 +696,12 @@ mt7915_register_ext_phy(struct mt7915_dev *dev, struct mt7915_phy *phy)
@@ -71,7 +71,7 @@
  	ret = mt76_register_phy(mphy, true, mt76_rates,
  				ARRAY_SIZE(mt76_rates));
  	if (ret)
-@@ -1173,6 +1179,24 @@ void mt7915_set_stream_he_caps(struct mt7915_phy *phy)
+@@ -1177,6 +1183,24 @@ void mt7915_set_stream_he_caps(struct mt7915_phy *phy)
  	}
  }
  
@@ -96,7 +96,7 @@
  static void mt7915_unregister_ext_phy(struct mt7915_dev *dev)
  {
  	struct mt7915_phy *phy = mt7915_ext_phy(dev);
-@@ -1181,6 +1205,10 @@ static void mt7915_unregister_ext_phy(struct mt7915_dev *dev)
+@@ -1185,6 +1209,10 @@ static void mt7915_unregister_ext_phy(struct mt7915_dev *dev)
  	if (!phy)
  		return;
  
@@ -107,7 +107,7 @@
  	mt7915_unregister_thermal(phy);
  	mt76_unregister_phy(mphy);
  	ieee80211_free_hw(mphy->hw);
-@@ -1193,6 +1221,10 @@ static void mt7915_stop_hardware(struct mt7915_dev *dev)
+@@ -1197,6 +1225,10 @@ static void mt7915_stop_hardware(struct mt7915_dev *dev)
  	mt7915_dma_cleanup(dev);
  	tasklet_disable(&dev->mt76.irq_tasklet);
  
@@ -118,7 +118,7 @@
  	if (is_mt798x(&dev->mt76))
  		mt7986_wmac_disable(dev);
  }
-@@ -1237,6 +1269,12 @@ int mt7915_register_device(struct mt7915_dev *dev)
+@@ -1241,6 +1273,12 @@ int mt7915_register_device(struct mt7915_dev *dev)
  	dev->mt76.test_ops = &mt7915_testmode_ops;
  #endif
  
@@ -458,7 +458,7 @@
 +
  #endif
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 1418d192..e4689d05 100644
+index ae9d5282..dafaa6fa 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -195,6 +195,45 @@ struct mt7915_hif {
@@ -528,8 +528,8 @@
 +#endif
  };
  
- struct mt7915_dev {
-@@ -628,6 +682,12 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+ #ifdef MTK_DEBUG
+@@ -642,6 +696,12 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
  int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
  			 bool pci, int *irq);
  
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1045-wifi-mt76-mt7915-support-scs-feature.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1045-wifi-mt76-mt7915-support-scs-feature.patch
index fd77e42..926ccbf 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1045-wifi-mt76-mt7915-support-scs-feature.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1045-wifi-mt76-mt7915-support-scs-feature.patch
@@ -1,7 +1,7 @@
-From 1ed6238a487b565e854c417df4c45a17f6df1bd8 Mon Sep 17 00:00:00 2001
+From dbb06651b230bfde71393904ea58368eae2861b4 Mon Sep 17 00:00:00 2001
 From: Howard Hsu <howard-yh.hsu@mediatek.com>
 Date: Wed, 6 Dec 2023 08:53:03 +0800
-Subject: [PATCH 1045/1049] wifi: mt76: mt7915: support scs feature
+Subject: [PATCH 1045/1054] wifi: mt76: mt7915: support scs feature
 
 Add support scs feature for connac2 codebase. This commit includes three
 parts.
@@ -61,10 +61,10 @@
  	MCU_EXT_CMD_FW_DBG_CTRL = 0x95,
  	MCU_EXT_CMD_OFFCH_SCAN_CTRL = 0x9a,
 diff --git a/mt7915/init.c b/mt7915/init.c
-index df83ca3c..6eaf7b7a 100644
+index dc13685c..01552454 100644
 --- a/mt7915/init.c
 +++ b/mt7915/init.c
-@@ -1243,6 +1243,7 @@ int mt7915_register_device(struct mt7915_dev *dev)
+@@ -1247,6 +1247,7 @@ int mt7915_register_device(struct mt7915_dev *dev)
  	spin_lock_init(&dev->phy.stats_lock);
  	INIT_WORK(&dev->rc_work, mt7915_mac_sta_rc_work);
  	INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7915_mac_work);
@@ -73,10 +73,10 @@
  	INIT_LIST_HEAD(&dev->twt_list);
  
 diff --git a/mt7915/mac.c b/mt7915/mac.c
-index 53f4c764..1e37ff48 100644
+index 2a247991..58785e1b 100644
 --- a/mt7915/mac.c
 +++ b/mt7915/mac.c
-@@ -1506,6 +1506,8 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
+@@ -1504,6 +1504,8 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
  	if (ext_phy)
  		cancel_delayed_work_sync(&ext_phy->mac_work);
  
@@ -85,7 +85,7 @@
  	mutex_lock(&dev->mt76.mutex);
  	for (i = 0; i < 10; i++) {
  		if (!mt7915_mac_restart(dev))
-@@ -1531,6 +1533,10 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
+@@ -1529,6 +1531,10 @@ mt7915_mac_full_reset(struct mt7915_dev *dev)
  		ieee80211_queue_delayed_work(ext_phy->hw,
  					     &ext_phy->mac_work,
  					     MT7915_WATCHDOG_TIME);
@@ -96,7 +96,7 @@
  }
  
  /* system error recovery */
-@@ -1589,6 +1595,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -1587,6 +1593,7 @@ void mt7915_mac_reset_work(struct work_struct *work)
  		set_bit(MT76_RESET, &phy2->mt76->state);
  		cancel_delayed_work_sync(&phy2->mt76->mac_work);
  	}
@@ -104,7 +104,7 @@
  	mt76_worker_disable(&dev->mt76.tx_worker);
  	mt76_for_each_q_rx(&dev->mt76, i)
  		napi_disable(&dev->mt76.napi[i]);
-@@ -1653,6 +1660,10 @@ void mt7915_mac_reset_work(struct work_struct *work)
+@@ -1651,6 +1658,10 @@ void mt7915_mac_reset_work(struct work_struct *work)
  					     &phy2->mt76->mac_work,
  					     MT7915_WATCHDOG_TIME);
  
@@ -292,7 +292,7 @@
 +};
  #endif
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 45e04afb..05a3bd51 100644
+index c6150c8a..3c049364 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -270,6 +270,15 @@ struct mt7915_air_monitor_ctrl {
@@ -318,17 +318,17 @@
 +	struct mt7915_scs_ctrl scs_ctrl;
  };
  
- struct mt7915_dev {
-@@ -463,6 +473,8 @@ struct mt7915_dev {
- 	const struct mt7915_dbg_reg_desc *dbg_reg;
+ #ifdef MTK_DEBUG
+@@ -476,6 +486,8 @@ struct mt7915_dev {
+ 	} adie[ADIE_MAX_CNT];
  #endif
  
 +	struct delayed_work scs_work;
 +
  	bool wmm_pbc_enable;
  	struct work_struct wmm_pbc_work;
- };
-@@ -788,6 +800,8 @@ int mt7915_mcu_sw_aci_set(struct mt7915_dev *dev, bool val);
+ 	u32 adie_type;
+@@ -802,6 +814,8 @@ int mt7915_mcu_sw_aci_set(struct mt7915_dev *dev, bool val);
  int mt7915_mcu_ipi_hist_ctrl(struct mt7915_phy *phy, void *data, u8 cmd, bool wait_resp);
  int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool wait_resp);
  int mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val);
@@ -338,10 +338,10 @@
  #ifdef MTK_DEBUG
  int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
 diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
-index 69fdb93f..2011fc98 100644
+index 59d89b60..4210ecb8 100644
 --- a/mt7915/mtk_debugfs.c
 +++ b/mt7915/mtk_debugfs.c
-@@ -3813,6 +3813,29 @@ mt7915_sr_enable_set(void *data, u64 val)
+@@ -3820,6 +3820,29 @@ mt7915_sr_enable_set(void *data, u64 val)
  DEFINE_DEBUGFS_ATTRIBUTE(fops_sr_enable, NULL,
  			 mt7915_sr_enable_set, "%llx\n");
  
@@ -371,7 +371,7 @@
  int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
  {
  	struct mt7915_dev *dev = phy->dev;
-@@ -3905,6 +3928,7 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
+@@ -3912,6 +3935,7 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
  	debugfs_create_file("sw_aci", 0600, dir, dev,
  			    &fops_sw_aci);
  	debugfs_create_file("sr_enable", 0200, dir, phy, &fops_sr_enable);
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1049-wifi-mt76-mt7915-support-spatial-reuse-debug-command.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1049-wifi-mt76-mt7915-support-spatial-reuse-debug-command.patch
index 1a411ec..59ad7fb 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/patches/1049-wifi-mt76-mt7915-support-spatial-reuse-debug-command.patch
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1049-wifi-mt76-mt7915-support-spatial-reuse-debug-command.patch
@@ -1,7 +1,7 @@
-From d2e1eed3bc308df82e7866b40c54a7f42934ce66 Mon Sep 17 00:00:00 2001
+From 6907ec2764681762337ec9aab746b81371aa219c Mon Sep 17 00:00:00 2001
 From: Howard Hsu <howard-yh.hsu@mediatek.com>
 Date: Thu, 15 Feb 2024 11:16:16 +0800
-Subject: [PATCH 1049/1049] wifi: mt76: mt7915: support spatial reuse debug
+Subject: [PATCH 1049/1054] wifi: mt76: mt7915: support spatial reuse debug
  commands
 
 Support 3 spatial reuse debug commands:
@@ -232,7 +232,7 @@
  	THERMAL_PROTECT_PARAMETER_CTRL,
  	THERMAL_PROTECT_BASIC_INFO,
 diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
-index 3a596dad..2ec2c77f 100644
+index 34f1a358..47f7d163 100644
 --- a/mt7915/mt7915.h
 +++ b/mt7915/mt7915.h
 @@ -354,6 +354,9 @@ struct mt7915_phy {
@@ -244,12 +244,12 @@
 +#endif
  };
  
- struct mt7915_dev {
+ #ifdef MTK_DEBUG
 diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
-index 1ed7bb2c..e479157f 100644
+index e7588434..bf419265 100644
 --- a/mt7915/mtk_debugfs.c
 +++ b/mt7915/mtk_debugfs.c
-@@ -3802,16 +3802,34 @@ mt7915_sw_aci_set(void *data, u64 val)
+@@ -3809,16 +3809,34 @@ mt7915_sw_aci_set(void *data, u64 val)
  DEFINE_DEBUGFS_ATTRIBUTE(fops_sw_aci, NULL,
  			 mt7915_sw_aci_set, "%llx\n");
  
@@ -287,7 +287,7 @@
  
  static int
  mt7915_scs_enable_set(void *data, u64 val)
-@@ -3852,6 +3870,26 @@ mt7915_thermal_recal_set(void *data, u64 val)
+@@ -3859,6 +3877,26 @@ mt7915_thermal_recal_set(void *data, u64 val)
  DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL,
  			 mt7915_thermal_recal_set, "%llu\n");
  
@@ -314,7 +314,7 @@
  int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
  {
  	struct mt7915_dev *dev = phy->dev;
-@@ -3944,9 +3982,11 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
+@@ -3951,9 +3989,11 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
  				    mt7915_show_eeprom_mode);
  	debugfs_create_file("sw_aci", 0600, dir, dev,
  			    &fops_sw_aci);