blob: 4576a2c522fd5c7f80c798bd9dd9539e33f305b4 [file] [log] [blame]
developer42c7a432024-07-12 14:39:29 +08001From 9fd80f6b724ba3f7272da8856e3b3d07d04dadb8 Mon Sep 17 00:00:00 2001
developereb155692024-01-11 14:08:37 +08002From: Howard Hsu <howard-yh.hsu@mediatek.com>
3Date: Thu, 21 Dec 2023 20:35:36 +0800
developer42c7a432024-07-12 14:39:29 +08004Subject: [PATCH 1041/1041] wifi: mt76: mt7915: support thermal recal debug
developera20cdc22024-05-31 18:57:31 +08005 commnad
developereb155692024-01-11 14:08:37 +08006
7Add thermal recal debug command:
8$ echo val > debugfs/thermal_recal
9
10The val can be the following values:
110 = disable
121 = enable
132 = manual trigger
14
15Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
16---
17 mt76_connac_mcu.h | 1 +
18 mt7915/mcu.c | 15 +++++++++++++++
19 mt7915/mt7915.h | 1 +
20 mt7915/mtk_debugfs.c | 18 ++++++++++++++++++
21 4 files changed, 35 insertions(+)
22
23diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer42c7a432024-07-12 14:39:29 +080024index 8b7fe87..c34c6e6 100644
developereb155692024-01-11 14:08:37 +080025--- a/mt76_connac_mcu.h
26+++ b/mt76_connac_mcu.h
developer42c7a432024-07-12 14:39:29 +080027@@ -1234,6 +1234,7 @@ enum {
developereb155692024-01-11 14:08:37 +080028 MCU_EXT_CMD_RED_ENABLE = 0x68,
developer753619c2024-02-22 13:42:45 +080029 MCU_EXT_CMD_PKT_BUDGET_CTRL = 0x6c,
developerdc9eeae2024-04-08 14:36:46 +080030 MCU_EXT_CMD_CP_SUPPORT = 0x75,
developereb155692024-01-11 14:08:37 +080031+ MCU_EXT_CMD_THERMAL_DEBUG = 0x79,
32 MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
33 MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
34 MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
35diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer42c7a432024-07-12 14:39:29 +080036index 297ded7..b66e5ea 100644
developereb155692024-01-11 14:08:37 +080037--- a/mt7915/mcu.c
38+++ b/mt7915/mcu.c
developer42c7a432024-07-12 14:39:29 +080039@@ -5356,3 +5356,18 @@ void mt7915_mcu_scs_sta_poll(struct work_struct *work)
40 if (scs_enable_flag)
developereb155692024-01-11 14:08:37 +080041 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->scs_work, HZ);
42 }
developer42c7a432024-07-12 14:39:29 +080043+
developereb155692024-01-11 14:08:37 +080044+int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action)
45+{
46+ struct {
47+ u8 mode;
48+ u8 action;
49+ u8 rsv[2];
50+ } req = {
51+ .mode = mode,
52+ .action = action,
53+ };
54+
55+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_DEBUG), &req,
56+ sizeof(req), true);
57+}
58diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer42c7a432024-07-12 14:39:29 +080059index 6b27be9..496ccd9 100644
developereb155692024-01-11 14:08:37 +080060--- a/mt7915/mt7915.h
61+++ b/mt7915/mt7915.h
developer42c7a432024-07-12 14:39:29 +080062@@ -835,6 +835,7 @@ int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool w
developereb155692024-01-11 14:08:37 +080063 int mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val);
64 int mt7915_mcu_set_scs_en(struct mt7915_phy *phy, u8 enable);
65 void mt7915_mcu_scs_sta_poll(struct work_struct *work);
66+int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action);
67
68 #ifdef MTK_DEBUG
69 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
70diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
developer42c7a432024-07-12 14:39:29 +080071index e60dc85..0677495 100644
developereb155692024-01-11 14:08:37 +080072--- a/mt7915/mtk_debugfs.c
73+++ b/mt7915/mtk_debugfs.c
developera46f6132024-03-26 14:09:54 +080074@@ -3843,6 +3843,22 @@ mt7915_scs_enable_set(void *data, u64 val)
developereb155692024-01-11 14:08:37 +080075 DEFINE_DEBUGFS_ATTRIBUTE(fops_scs_enable, NULL,
76 mt7915_scs_enable_set, "%lld\n");
77
78+static int
79+mt7915_thermal_recal_set(void *data, u64 val)
80+{
81+#define THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER 2
82+#define THERMAL_DEBUG_MODE_RECAL 1
83+ struct mt7915_dev *dev = data;
84+
85+ if (val > THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER)
86+ return -EINVAL;
87+
88+ return mt7915_mcu_thermal_debug(dev, THERMAL_DEBUG_MODE_RECAL, val);
89+}
90+
91+DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL,
92+ mt7915_thermal_recal_set, "%llu\n");
93+
94 int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
95 {
96 struct mt7915_dev *dev = phy->dev;
developera46f6132024-03-26 14:09:54 +080097@@ -3936,6 +3952,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
developereb155692024-01-11 14:08:37 +080098 &fops_sw_aci);
99 debugfs_create_file("sr_enable", 0200, dir, phy, &fops_sr_enable);
100 debugfs_create_file("scs_enable", 0200, dir, phy, &fops_scs_enable);
101+ debugfs_create_file("thermal_recal", 0200, dir, dev, &fops_thermal_recal);
102+
103 return 0;
104 }
105 #endif
106--
1072.18.0
108