blob: dcd5544599d977f65d80fec40032b28d0810426c [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From 5c0d266ff3446fe53d2fa9203e930350607ab7dc Mon Sep 17 00:00:00 2001
2From: Howard Hsu <howard-yh.hsu@mediatek.com>
3Date: Thu, 4 Jan 2024 19:53:37 +0800
4Subject: [PATCH 080/116] mtk: wifi: mt76: mt7996: support thermal recal debug
5 command
6
7Add support thermal recal debug command.
8
9Usage:
10$ echo val > debugfs/thermal_recal
11
12The val can be the following values:
130 = disable
141 = enable
152 = manual trigger
16
17CR-Id: WCNCR00261410
18Change-Id: Ief064633dd7ab0faeb298ac3902ca1b399e70365
19Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
20---
21 mt76_connac_mcu.h | 1 +
22 mt7996/mt7996.h | 1 +
23 mt7996/mtk_debugfs.c | 17 +++++++++++++++++
24 mt7996/mtk_mcu.c | 21 +++++++++++++++++++++
25 4 files changed, 40 insertions(+)
26
27diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
28index 12fdc6e12..151183d08 100644
29--- a/mt76_connac_mcu.h
30+++ b/mt76_connac_mcu.h
31@@ -1285,6 +1285,7 @@ enum {
32 MCU_UNI_CMD_TESTMODE_TRX_PARAM = 0x42,
33 MCU_UNI_CMD_TESTMODE_CTRL = 0x46,
34 MCU_UNI_CMD_PRECAL_RESULT = 0x47,
35+ MCU_UNI_CMD_THERMAL_CAL = 0x4c,
36 MCU_UNI_CMD_RRO = 0x57,
37 MCU_UNI_CMD_OFFCH_SCAN_CTRL = 0x58,
38 MCU_UNI_CMD_PER_STA_INFO = 0x6d,
39diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
40index 3069e9070..69bcf78f5 100644
41--- a/mt7996/mt7996.h
42+++ b/mt7996/mt7996.h
43@@ -1032,6 +1032,7 @@ void mt7996_mcu_set_cert(struct mt7996_phy *phy, u8 type);
44 void mt7996_tm_update_channel(struct mt7996_phy *phy);
45
46 int mt7996_mcu_set_vow_drr_dbg(struct mt7996_dev *dev, u32 val);
47+int mt7996_mcu_thermal_debug(struct mt7996_dev *dev, u8 mode, u8 action);
48 #endif
49
50 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
51diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
52index ee72c0e51..ddb4a7ca2 100644
53--- a/mt7996/mtk_debugfs.c
54+++ b/mt7996/mtk_debugfs.c
55@@ -3212,6 +3212,22 @@ out:
56 DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_enable, mt7996_thermal_enable_get,
57 mt7996_thermal_enable_set, "%lld\n");
58
59+static int
60+mt7996_thermal_recal_set(void *data, u64 val)
61+{
62+#define THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER 2
63+#define THERMAL_DEBUG_MODE_RECAL 1
64+ struct mt7996_dev *dev = data;
65+
66+ if (val > THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER)
67+ return -EINVAL;
68+
69+ return mt7996_mcu_thermal_debug(dev, THERMAL_DEBUG_MODE_RECAL, val);
70+}
71+
72+DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL,
73+ mt7996_thermal_recal_set, "%llu\n");
74+
75 int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
76 {
77 struct mt7996_dev *dev = phy->dev;
78@@ -3320,6 +3336,7 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
79 }
80
81 debugfs_create_file("thermal_enable", 0600, dir, phy, &fops_thermal_enable);
82+ debugfs_create_file("thermal_recal", 0200, dir, dev, &fops_thermal_recal);
83
84 return 0;
85 }
86diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c
87index aed32e982..aa44b4710 100644
88--- a/mt7996/mtk_mcu.c
89+++ b/mt7996/mtk_mcu.c
90@@ -1342,4 +1342,25 @@ int mt7996_mcu_set_vow_drr_dbg(struct mt7996_dev *dev, u32 val)
91 sizeof(req), true);
92 }
93
94+int mt7996_mcu_thermal_debug(struct mt7996_dev *dev, u8 mode, u8 action)
95+{
96+ struct {
97+ u8 __rsv1[4];
98+
99+ __le16 tag;
100+ __le16 len;
101+
102+ u8 mode;
103+ u8 action;
104+ u8 __rsv2[2];
105+ } __packed req = {
106+ .tag = cpu_to_le16(mode),
107+ .len = cpu_to_le16(sizeof(req) - 4),
108+ .mode = mode,
109+ .action = action,
110+ };
111+
112+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(THERMAL_CAL), &req,
113+ sizeof(req), true);
114+}
115 #endif
116--
1172.39.2
118