blob: dbb5c3f61e3147a74edae595ceaea150a611579d [file] [log] [blame]
From c4f870c030edebe27120d87364a213c9f8f7089c Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Thu, 13 Jul 2023 15:50:00 +0800
Subject: [PATCH 03/21] wifi: mt76: mt7915: move temperature margin check to
mt7915_thermal_temp_store()
Originally, we would reduce the 10-degree margin to the restore
temperature, but the user would not be aware of this when setting it.
Moving the margin reduction to the user setting check allows the user to
clearly understand that there is a 10-degree difference between the
restore and trigger temperature.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
---
mt7915/init.c | 7 ++++---
mt7915/mcu.c | 3 +--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mt7915/init.c b/mt7915/init.c
index 888dbf82..3b352fe9 100644
--- a/mt7915/init.c
+++ b/mt7915/init.c
@@ -84,12 +84,13 @@ static ssize_t mt7915_thermal_temp_store(struct device *dev,
mutex_lock(&phy->dev->mt76.mutex);
val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 60, 130);
+ /* add a safety margin ~10 */
if ((i - 1 == MT7915_CRIT_TEMP_IDX &&
- val > phy->throttle_temp[MT7915_MAX_TEMP_IDX]) ||
+ val > phy->throttle_temp[MT7915_MAX_TEMP_IDX] - 10) ||
(i - 1 == MT7915_MAX_TEMP_IDX &&
- val < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
+ val - 10 < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
dev_err(phy->dev->mt76.dev,
- "temp1_max shall be greater than temp1_crit.");
+ "temp1_max shall be 10 degrees greater than temp1_crit.");
mutex_unlock(&phy->dev->mt76.mutex);
return -EINVAL;
}
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index 9774bcce..dcf8782a 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -3226,8 +3226,7 @@ int mt7915_mcu_set_thermal_protect(struct mt7915_phy *phy)
/* set high-temperature trigger threshold */
req.ctrl.ctrl_id = THERMAL_PROTECT_ENABLE;
- /* add a safety margin ~10 */
- req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10);
+ req.restore_temp = cpu_to_le32(phy->throttle_temp[0]);
req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]);
req.sustain_time = cpu_to_le16(10);
--
2.18.0