blob: c26296c0029a53a00423c10ef9986070ccd3dfdf [file] [log] [blame]
From 245a524ed07deb346a60a8390ba9e10a8f3e14ea Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Thu, 21 Dec 2023 20:35:36 +0800
Subject: [PATCH] wifi: mt76: mt7915: support thermal recal debug commnad
Add thermal recal debug command:
$ echo val > debugfs/thermal_recal
The val can be the following values:
0 = disable
1 = enable
2 = manual trigger
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
---
mt76_connac_mcu.h | 1 +
mt7915/mcu.c | 15 +++++++++++++++
mt7915/mt7915.h | 1 +
mt7915/mtk_debugfs.c | 18 ++++++++++++++++++
4 files changed, 35 insertions(+)
diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
index 6d60a20..bb491c2 100644
--- a/mt76_connac_mcu.h
+++ b/mt76_connac_mcu.h
@@ -1220,6 +1220,7 @@ enum {
MCU_EXT_CMD_CAL_CACHE = 0x67,
MCU_EXT_CMD_RED_ENABLE = 0x68,
MCU_EXT_CMD_PKT_BUDGET_CTRL = 0x6c,
+ MCU_EXT_CMD_THERMAL_DEBUG = 0x79,
MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
MCU_EXT_CMD_SET_RDD_PATTERN = 0x7d,
MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index 01c0d5d..3b50877 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -5345,3 +5345,18 @@ void mt7915_mcu_scs_sta_poll(struct work_struct *work)
if (scs_enable_flag)
ieee80211_queue_delayed_work(mt76_hw(dev), &dev->scs_work, HZ);
}
+
+int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action)
+{
+ struct {
+ u8 mode;
+ u8 action;
+ u8 rsv[2];
+ } req = {
+ .mode = mode,
+ .action = action,
+ };
+
+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_DEBUG), &req,
+ sizeof(req), true);
+}
diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
index 05a3bd5..38a9db4 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -802,6 +802,7 @@ int mt7915_mcu_ipi_hist_scan(struct mt7915_phy *phy, void *data, u8 mode, bool w
int mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val);
int mt7915_mcu_set_scs_en(struct mt7915_phy *phy, u8 enable);
void mt7915_mcu_scs_sta_poll(struct work_struct *work);
+int mt7915_mcu_thermal_debug(struct mt7915_dev *dev, u8 mode, u8 action);
#ifdef MTK_DEBUG
int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
index 64e9d59..9da6328 100644
--- a/mt7915/mtk_debugfs.c
+++ b/mt7915/mtk_debugfs.c
@@ -3820,6 +3820,22 @@ mt7915_scs_enable_set(void *data, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(fops_scs_enable, NULL,
mt7915_scs_enable_set, "%lld\n");
+static int
+mt7915_thermal_recal_set(void *data, u64 val)
+{
+#define THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER 2
+#define THERMAL_DEBUG_MODE_RECAL 1
+ struct mt7915_dev *dev = data;
+
+ if (val > THERMAL_DEBUG_OPERATION_MANUAL_TRIGGER)
+ return -EINVAL;
+
+ return mt7915_mcu_thermal_debug(dev, THERMAL_DEBUG_MODE_RECAL, val);
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_recal, NULL,
+ mt7915_thermal_recal_set, "%llu\n");
+
int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
{
struct mt7915_dev *dev = phy->dev;
@@ -3913,6 +3929,8 @@ int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
&fops_sw_aci);
debugfs_create_file("sr_enable", 0200, dir, phy, &fops_sr_enable);
debugfs_create_file("scs_enable", 0200, dir, phy, &fops_scs_enable);
+ debugfs_create_file("thermal_recal", 0200, dir, dev, &fops_thermal_recal);
+
return 0;
}
#endif
--
2.18.0