blob: c28e05f59c91708e706adb66b6e362e7f12c9d78 [file] [log] [blame]
From 9ce78c0a20ff2448496bc7a670df617c7441c011 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 1042/1051] 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 5be93f6a..4e1006db 100644
--- a/mt76_connac_mcu.h
+++ b/mt76_connac_mcu.h
@@ -1224,6 +1224,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 5e1fd3be..c5f60c07 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -5357,3 +5357,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 3c049364..1b2f584f 100644
--- a/mt7915/mt7915.h
+++ b/mt7915/mt7915.h
@@ -816,6 +816,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 4210ecb8..677266ee 100644
--- a/mt7915/mtk_debugfs.c
+++ b/mt7915/mtk_debugfs.c
@@ -3843,6 +3843,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;
@@ -3936,6 +3952,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