developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 1 | From 3eaaa3c218dd75d14dea44f903e5d689ac9dd994 Mon Sep 17 00:00:00 2001 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Wed, 17 Aug 2022 13:40:24 +0800 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 4 | Subject: [PATCH 1009/1009] mt76: mt7915: add fw_version dump |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | mt76.h | 4 ++++ |
| 8 | mt76_connac_mcu.c | 9 +++++++++ |
| 9 | mt7915/mtk_debugfs.c | 19 +++++++++++++++++++ |
| 10 | 3 files changed, 32 insertions(+) |
| 11 | |
| 12 | diff --git a/mt76.h b/mt76.h |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 13 | index aef60066..fac1dfb7 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 14 | --- a/mt76.h |
| 15 | +++ b/mt76.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 16 | @@ -823,6 +823,10 @@ struct mt76_dev { |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 17 | 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 { |
| 27 | diff --git a/mt76_connac_mcu.c b/mt76_connac_mcu.c |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 28 | index ed6c9ebb..be2a2de1 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 29 | --- a/mt76_connac_mcu.c |
| 30 | +++ b/mt76_connac_mcu.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 31 | @@ -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); |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 34 | |
| 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) |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 41 | @@ -2914,6 +2917,9 @@ int mt76_connac2_load_ram(struct mt76_dev *dev, const char *fw_wm, |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 42 | 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); |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 51 | @@ -2984,6 +2990,9 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name) |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 52 | 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; |
| 61 | diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 62 | index e24b4d78..9de5b0f6 100644 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 63 | --- 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; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 73 | + seq_printf(s, "Version: 2.2.6.0\n"); |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 74 | + |
| 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 |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 88 | @@ -2954,6 +2970,9 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 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 | -- |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 99 | 2.25.1 |
developer | 8ec491f | 2022-08-22 19:48:44 +0800 | [diff] [blame] | 100 | |