blob: b7d2df3bc302570e184877de9c38e70ac4ce1a00 [file] [log] [blame]
developer33907d42022-09-19 14:33:58 +08001From c0238eeeaec21b5f1e0087bec4b6306d3c5aed53 Mon Sep 17 00:00:00 2001
developer8ec491f2022-08-22 19:48:44 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Wed, 17 Aug 2022 13:40:24 +0800
developer33907d42022-09-19 14:33:58 +08004Subject: [PATCH] mt76: mt7915: add fw_version dump
developer8ec491f2022-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
developer33907d42022-09-19 14:33:58 +080013index e4a248a1..b5453d35 100644
developer8ec491f2022-08-22 19:48:44 +080014--- a/mt76.h
15+++ b/mt76.h
developer33907d42022-09-19 14:33:58 +080016@@ -837,6 +837,10 @@ struct mt76_dev {
developer8ec491f2022-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
developer33907d42022-09-19 14:33:58 +080028index ed6c9ebb..be2a2de1 100644
developer8ec491f2022-08-22 19:48:44 +080029--- a/mt76_connac_mcu.c
30+++ b/mt76_connac_mcu.c
developer33907d42022-09-19 14:33:58 +080031@@ -2889,6 +2889,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
32 sizeof(dev->hw->wiphy->fw_version),
33 "%.10s-%.15s", hdr->fw_ver, hdr->build_date);
developer8ec491f2022-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)
developer33907d42022-09-19 14:33:58 +080041@@ -2914,6 +2917,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer8ec491f2022-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);
developer33907d42022-09-19 14:33:58 +080051@@ -2984,6 +2990,9 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
developer8ec491f2022-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
developer33907d42022-09-19 14:33:58 +080062index 222268fc..ef0c27d2 100644
developer8ec491f2022-08-22 19:48:44 +080063--- a/mt7915/mtk_debugfs.c
64+++ b/mt7915/mtk_debugfs.c
65@@ -2721,6 +2721,22 @@ static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
66 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;
developer33907d42022-09-19 14:33:58 +080073+ seq_printf(s, "Version: 2.2.5.0\n");
developer8ec491f2022-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
88@@ -2952,6 +2968,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
89
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--
developer27b55252022-09-05 19:09:45 +0800992.18.0
developer8ec491f2022-08-22 19:48:44 +0800100