blob: 4f3c97ad27b5560c8e8baff7caef84f56af2ac98 [file] [log] [blame]
From 2825cf9ff77fa1065dac5c7a129aad9e8edecdf3 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 edf83c4..9fe0524 100644
--- a/mt7915/init.c
+++ b/mt7915/init.c
@@ -83,12 +83,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 7df2162..6e9970c 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