blob: 638abb77441abf13ab097f681ac0b279205a5bbe [file] [log] [blame]
developer7af0f762023-05-22 15:16:16 +08001From 64d91a2c5c82e023639c032c8dde34da2d125628 Mon Sep 17 00:00:00 2001
developer45fae412022-08-22 19:48:44 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Wed, 17 Aug 2022 13:40:24 +0800
developer7af0f762023-05-22 15:16:16 +08004Subject: [PATCH 1008/1033] wifi: mt76: mt7915: add fw_version dump
developer45fae412022-08-22 19:48:44 +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
developer7af0f762023-05-22 15:16:16 +080013index a8f26a8..3425159 100644
developer45fae412022-08-22 19:48:44 +080014--- a/mt76.h
15+++ b/mt76.h
developer7af0f762023-05-22 15:16:16 +080016@@ -849,6 +849,10 @@ struct mt76_dev {
developer45fae412022-08-22 19:48:44 +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
developer7af0f762023-05-22 15:16:16 +080028index 732a4e6..1cdef36 100644
developer45fae412022-08-22 19:48:44 +080029--- a/mt76_connac_mcu.c
30+++ b/mt76_connac_mcu.c
developer7af0f762023-05-22 15:16:16 +080031@@ -2976,6 +2976,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer4b170522022-09-19 14:33:58 +080032 sizeof(dev->hw->wiphy->fw_version),
33 "%.10s-%.15s", hdr->fw_ver, hdr->build_date);
developer45fae412022-08-22 19:48:44 +080034
35+ dev->wm_hdr = devm_kzalloc(dev->dev, sizeof(*hdr), GFP_KERNEL);
36+ memcpy(dev->wm_hdr, hdr, sizeof(*hdr));
37+
38 release_firmware(fw);
39
40 if (!fw_wa)
developer7af0f762023-05-22 15:16:16 +080041@@ -3001,6 +3004,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer45fae412022-08-22 19:48:44 +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);
developer7af0f762023-05-22 15:16:16 +080051@@ -3071,6 +3077,9 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
developer45fae412022-08-22 19:48:44 +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
developer7af0f762023-05-22 15:16:16 +080062index fc148d4..c6cec57 100644
developer45fae412022-08-22 19:48:44 +080063--- a/mt7915/mtk_debugfs.c
64+++ b/mt7915/mtk_debugfs.c
developer60a3d662023-02-07 15:24:34 +080065@@ -2799,6 +2799,22 @@ static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
developer45fae412022-08-22 19:48:44 +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;
developer7af0f762023-05-22 15:16:16 +080073+ seq_printf(s, "Version: 2.2.11.0\n");
developer45fae412022-08-22 19:48:44 +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
developer8effbd32023-04-17 15:57:28 +080088@@ -3635,6 +3651,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developer45fae412022-08-22 19:48:44 +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--
developer8effbd32023-04-17 15:57:28 +0800992.18.0
developer45fae412022-08-22 19:48:44 +0800100