blob: e617d92ff974f705b3a7d134a0c6b3e07381a00c [file] [log] [blame]
developera43cc482023-04-17 15:57:28 +08001From cdeb1fb2bbd41993968676db9f1087c358c46dd6 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
developera43cc482023-04-17 15:57:28 +08004Subject: [PATCH 1008/1032] wifi: 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
developera43cc482023-04-17 15:57:28 +080013index ffa9595..c75f316 100644
developer8ec491f2022-08-22 19:48:44 +080014--- a/mt76.h
15+++ b/mt76.h
developera43cc482023-04-17 15:57:28 +080016@@ -848,6 +848,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
developera43cc482023-04-17 15:57:28 +080028index b0dcc5a..856b289 100644
developer8ec491f2022-08-22 19:48:44 +080029--- a/mt76_connac_mcu.c
30+++ b/mt76_connac_mcu.c
developer78848c62023-04-06 13:44:00 +080031@@ -2969,6 +2969,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm,
developer33907d42022-09-19 14:33:58 +080032 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)
developer78848c62023-04-06 13:44:00 +080041@@ -2994,6 +2997,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);
developer78848c62023-04-06 13:44:00 +080051@@ -3064,6 +3070,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
developera43cc482023-04-17 15:57:28 +080062index fc148d4..99e7c88 100644
developer8ec491f2022-08-22 19:48:44 +080063--- a/mt7915/mtk_debugfs.c
64+++ b/mt7915/mtk_debugfs.c
developerf3f5d9b2023-02-07 15:24:34 +080065@@ -2799,6 +2799,22 @@ static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
developer8ec491f2022-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;
developer81e9eb72023-03-14 14:09:34 +080073+ seq_printf(s, "Version: 2.2.10.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
developera43cc482023-04-17 15:57:28 +080088@@ -3635,6 +3651,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developer8ec491f2022-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--
developera43cc482023-04-17 15:57:28 +0800992.18.0
developer8ec491f2022-08-22 19:48:44 +0800100