blob: 638abb77441abf13ab097f681ac0b279205a5bbe [file] [log] [blame]
developerbbd45e12023-05-19 08:22:06 +08001From 64d91a2c5c82e023639c032c8dde34da2d125628 Mon Sep 17 00:00:00 2001
developer5ce5b052022-08-17 14:30:50 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Wed, 17 Aug 2022 13:40:24 +0800
developerbbd45e12023-05-19 08:22:06 +08004Subject: [PATCH 1008/1033] wifi: mt76: mt7915: add fw_version dump
developer5ce5b052022-08-17 14:30:50 +08005
6---
7 mt76.h | 4 ++++
8 mt76_connac_mcu.c | 9 +++++++++
9 mt7915/mtk_debugfs.c | 19 +++++++++++++++++++
10 3 files changed, 32 insertions(+)
11
12diff --git a/mt76.h b/mt76.h
developerbbd45e12023-05-19 08:22:06 +080013index a8f26a8..3425159 100644
developer5ce5b052022-08-17 14:30:50 +080014--- a/mt76.h
15+++ b/mt76.h
developerbbd45e12023-05-19 08:22:06 +080016@@ -849,6 +849,10 @@ struct mt76_dev {
developer5ce5b052022-08-17 14:30:50 +080017 struct mt76_usb usb;
18 struct mt76_sdio sdio;
19 };
20+
21+ struct mt76_connac2_patch_hdr *patch_hdr;
22+ struct mt76_connac2_fw_trailer *wm_hdr;
23+ struct mt76_connac2_fw_trailer *wa_hdr;
24 };
25
26 struct mt76_power_limits {
27diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c
developerbbd45e12023-05-19 08:22:06 +080028index 732a4e6..1cdef36 100644
developer5ce5b052022-08-17 14:30:50 +080029--- a/mt76_connac_mcu.c
30+++ b/mt76_connac_mcu.c
developerbbd45e12023-05-19 08:22:06 +080031@@ -2976,6 +2976,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer3c443fd2022-09-19 10:45:38 +080032 sizeof(dev->hw->wiphy->fw_version),
33 "%.10s-%.15s", hdr->fw_ver, hdr->build_date);
developer5ce5b052022-08-17 14:30:50 +080034
35+ dev->wm_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
36+ memcpy(dev->wm_hdr, hdr, sizeof(*hdr));
37+
developer3c443fd2022-09-19 10:45:38 +080038 release_firmware(fw);
39
40 if (!fw_wa)
developerbbd45e12023-05-19 08:22:06 +080041@@ -3001,6 +3004,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer5ce5b052022-08-17 14:30:50 +080042 goto out;
43 }
44
45+ dev->wa_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
46+ memcpy(dev->wa_hdr, hdr, sizeof(*hdr));
47+
48 snprintf(dev->hw->wiphy->fw_version,
49 sizeof(dev->hw->wiphy->fw_version),
50 "%.10s-%.15s", hdr->fw_ver, hdr->build_date);
developerbbd45e12023-05-19 08:22:06 +080051@@ -3071,6 +3077,9 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
developer5ce5b052022-08-17 14:30:50 +080052 dev_info(dev->dev, "HW/SW Version: 0x%x, Build Time: %.16s\n",
53 be32_to_cpu(hdr->hw_sw_ver), hdr->build_date);
54
55+ dev->patch_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
56+ memcpy(dev->patch_hdr, hdr, sizeof(*hdr));
57+
58 for (i = 0; i < be32_to_cpu(hdr->desc.n_region); i++) {
59 struct mt76_connac2_patch_sec *sec;
60 u32 len, addr, mode;
61diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
developerbbd45e12023-05-19 08:22:06 +080062index fc148d4..c6cec57 100644
developer5ce5b052022-08-17 14:30:50 +080063--- a/mt7915/mtk_debugfs.c
64+++ b/mt7915/mtk_debugfs.c
developerc04f5402023-02-03 09:22:26 +080065@@ -2799,6 +2799,22 @@ static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
developer5ce5b052022-08-17 14:30:50 +080066 return 0;
67 }
68
69+static int mt7915_dump_version(struct seq_file *s, void *data)
70+{
71+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
72+ struct mt76_dev *mdev = NULL;
developerbbd45e12023-05-19 08:22:06 +080073+ seq_printf(s, "Version: 2.2.11.0\n");
developer5ce5b052022-08-17 14:30:50 +080074+
75+ if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state))
76+ return 0;
77+
78+ mdev = &dev->mt76;
79+ seq_printf(s, "Rom Patch Build Time: %.16s\n", mdev->patch_hdr->build_date);
80+ seq_printf(s, "WM Patch Build Time: %.16s\n", mdev->wm_hdr->build_date);
81+ seq_printf(s, "WA Patch Build Time: %.16s\n", mdev->wa_hdr->build_date);
82+ return 0;
83+}
84+
85 /*usage: <en> <num> <len>
86 en: BIT(16) 0: sw amsdu 1: hw amsdu
87 num: GENMASK(15, 8) range 1-8
developer2324aa22023-04-12 11:30:15 +080088@@ -3635,6 +3651,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developer5ce5b052022-08-17 14:30:50 +080089
90 debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable);
91
92+ debugfs_create_devm_seqfile(dev->mt76.dev, "fw_version", dir,
93+ mt7915_dump_version);
94+
95 return 0;
96 }
97 #endif
98--
developer2324aa22023-04-12 11:30:15 +0800992.18.0
developer5ce5b052022-08-17 14:30:50 +0800100