[][MAC80211][mt76][Add firmware version dump]

[Description]
Add firmware version dump

[Release-log]
N/A

Change-Id: I9b177af025f4d81502bc876796be78ff232116de
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6389132
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/1009-mt76-mt7915-add-fw_version-dump.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/1009-mt76-mt7915-add-fw_version-dump.patch
new file mode 100644
index 0000000..af4f56d
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/1009-mt76-mt7915-add-fw_version-dump.patch
@@ -0,0 +1,100 @@
+From 611d781ff9e39b474e71a59ec0ea7761a4274456 Mon Sep 17 00:00:00 2001
+From: Evelyn Tsai <evelyn.tsai@mediatek.com>
+Date: Wed, 17 Aug 2022 13:40:24 +0800
+Subject: [PATCH] mt76: mt7915: add fw_version dump
+
+---
+ mt76.h               |  4 ++++
+ mt76_connac_mcu.c    |  9 +++++++++
+ mt7915/mtk_debugfs.c | 19 +++++++++++++++++++
+ 3 files changed, 32 insertions(+)
+
+diff --git a/mt76.h b/mt76.h
+index 8325409a..9a0f0708 100644
+--- a/mt76.h
++++ b/mt76.h
+@@ -803,6 +803,10 @@ struct mt76_dev {
+ 		struct mt76_usb usb;
+ 		struct mt76_sdio sdio;
+ 	};
++
++	struct mt76_connac2_patch_hdr *patch_hdr;
++	struct mt76_connac2_fw_trailer *wm_hdr;
++	struct mt76_connac2_fw_trailer *wa_hdr;
+ };
+ 
+ struct mt76_power_limits {
+diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
+index 261181dc..47b2bce6 100644
+--- a/mt76_connac_mcu.c
++++ b/mt76_connac_mcu.c
+@@ -2883,6 +2883,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
+ 		goto out;
+ 	}
+ 
++	dev->wm_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
++	memcpy(dev->wm_hdr, hdr, sizeof(*hdr));
++
+ 	release_firmware(fw);
+ 
+ 	if (!fw_wa)
+@@ -2908,6 +2911,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
+ 		goto out;
+ 	}
+ 
++	dev->wa_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
++	memcpy(dev->wa_hdr, hdr, sizeof(*hdr));
++
+ 	snprintf(dev->hw->wiphy->fw_version,
+ 		 sizeof(dev->hw->wiphy->fw_version),
+ 		 "%.10s-%.15s", hdr->fw_ver, hdr->build_date);
+@@ -2978,6 +2984,9 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
+ 	dev_info(dev->dev, "HW/SW Version: 0x%x, Build Time: %.16s\n",
+ 		 be32_to_cpu(hdr->hw_sw_ver), hdr->build_date);
+ 
++	dev->patch_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
++	memcpy(dev->patch_hdr, hdr, sizeof(*hdr));
++
+ 	for (i = 0; i < be32_to_cpu(hdr->desc.n_region); i++) {
+ 		struct mt76_connac2_patch_sec *sec;
+ 		u32 len, addr, mode;
+diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
+index 222268fc..cfd0b303 100644
+--- a/mt7915/mtk_debugfs.c
++++ b/mt7915/mtk_debugfs.c
+@@ -2721,6 +2721,22 @@ static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
+ 	return 0;
+ }
+ 
++static int mt7915_dump_version(struct seq_file *s, void *data)
++{
++	struct mt7915_dev *dev = dev_get_drvdata(s->private);
++	struct mt76_dev *mdev = NULL;
++	seq_printf(s, "Version: 2.2.3.0\n");
++
++	if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state))
++		return 0;
++
++	mdev = &dev->mt76;
++	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);
++	return 0;
++}
++
+ /*usage: <en> <num> <len>
+ 	en: BIT(16) 0: sw amsdu  1: hw amsdu
+ 	num: GENMASK(15, 8) range 1-8
+@@ -2952,6 +2968,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
+ 
+ 	debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable);
+ 
++	debugfs_create_devm_seqfile(dev->mt76.dev, "fw_version", dir,
++				    mt7915_dump_version);
++
+ 	return 0;
+ }
+ #endif
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_rom_patch.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_rom_patch.bin
index 1c69d39..7cca92e 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_rom_patch.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_rom_patch.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wa.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wa.bin
index 434e757..f87d182 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wa.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wa.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wm.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wm.bin
index fef6005..777bfac 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wm.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7915_wm.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_rom_patch.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_rom_patch.bin
index 07fe11a..a7c3de2 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_rom_patch.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_rom_patch.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wa.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wa.bin
index 27caa00..3f61a50 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wa.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wa.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wm.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wm.bin
index 7df01ea..f7f7616 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wm.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7916_wm.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch.bin
index 6bb033c..4074aa0 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch_mt7975.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch_mt7975.bin
index 936cfe8..58975ad 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch_mt7975.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_rom_patch_mt7975.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wa.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wa.bin
index 79ec406..0554c0e 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wa.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wa.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm.bin
index 002bece..87a7e3f 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm_mt7975.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm_mt7975.bin
index 972926c..783429b 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm_mt7975.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wm_mt7975.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_0.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_0.bin
index 19d607c..e567237 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_0.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_0.bin
Binary files differ
diff --git a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_1.bin b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_1.bin
index ec3b182..1708121 100644
--- a/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_1.bin
+++ b/autobuild_mac80211_release/package/kernel/mt76/src/firmware/mt7986_wo_1.bin
Binary files differ