blob: c5deee40c22962d2f5f61320c0c02ace00ac0fcf [file] [log] [blame]
From 93cd3c23453725f003318b5556ad09b56e3995a6 Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Thu, 27 Jul 2023 19:35:32 +0800
Subject: [PATCH 071/223] mtk: mt76: mt7996: support enable/disable thermal
protection mechanism
This commit adds a new debugfs thermal_enable to enable/disable thermal
protection mechanism. The purpose of this commit is for autotest to
verify thermal protection mechanism.
[Usage]
Enable thermal protection: echo 1 > thermal_enable
Disable thermal protection: echo 0 > thermal_enable
Please note that if you re-enable thermal protection mechanism, all the
configuration values will be retained from the exising configuration,
rather than using the default values.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
---
mt7996/main.c | 1 +
mt7996/mt7996.h | 1 +
mt7996/mtk_debugfs.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/mt7996/main.c b/mt7996/main.c
index a53eaa55..e5b32d33 100644
--- a/mt7996/main.c
+++ b/mt7996/main.c
@@ -91,6 +91,7 @@ int mt7996_run(struct ieee80211_hw *hw)
#ifdef CONFIG_MTK_DEBUG
phy->sr_enable = true;
phy->enhanced_sr_enable = true;
+ phy->thermal_protection_enable = true;
ret = mt7996_mcu_set_tx_power_ctrl(phy, UNI_TXPOWER_SKU_POWER_LIMIT_CTRL,
dev->dbg.sku_disable ? 0 : phy->sku_limit_en);
diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
index eb9a5634..94735872 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -490,6 +490,7 @@ struct mt7996_phy {
#ifdef CONFIG_MTK_DEBUG
bool sr_enable:1;
bool enhanced_sr_enable:1;
+ bool thermal_protection_enable:1;
#endif
};
diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c
index 4ce4ac0d..196038d4 100644
--- a/mt7996/mtk_debugfs.c
+++ b/mt7996/mtk_debugfs.c
@@ -3127,6 +3127,49 @@ mt7996_show_rro_mib(struct seq_file *s, void *data)
return 0;
}
+static int
+mt7996_thermal_enable_get(void *data, u64 *enable)
+{
+ struct mt7996_phy *phy = data;
+
+ *enable = phy->thermal_protection_enable;
+
+ return 0;
+}
+
+static int
+mt7996_thermal_enable_set(void *data, u64 action)
+{
+ struct mt7996_phy *phy = data;
+ int ret;
+ u8 throttling;
+
+ if (action > 1)
+ return -EINVAL;
+
+ if (!!action == phy->thermal_protection_enable)
+ return 0;
+
+ ret = mt7996_mcu_set_thermal_protect(phy, !!action);
+ if (ret)
+ return ret;
+
+ if (!!!action)
+ goto out;
+
+ throttling = MT7996_THERMAL_THROTTLE_MAX - phy->cdev_state;
+ ret = mt7996_mcu_set_thermal_throttling(phy, throttling);
+ if (ret)
+ return ret;
+
+out:
+ phy->thermal_protection_enable = !!action;
+
+ return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_thermal_enable, mt7996_thermal_enable_get,
+ mt7996_thermal_enable_set, "%lld\n");
+
int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
{
struct mt7996_dev *dev = phy->dev;
@@ -3233,6 +3276,8 @@ int mt7996_mtk_init_debugfs(struct mt7996_phy *phy, struct dentry *dir)
mt7996_show_rro_mib);
}
+ debugfs_create_file("thermal_enable", 0600, dir, phy, &fops_thermal_enable);
+
return 0;
}
--
2.45.2