blob: 160462df712f2eeda7862a7e2d7c7cd29eff3574 [file] [log] [blame]
developer30d39c22022-12-16 10:29:49 +08001From 25975e49e92f2a8d9b74efbfe3f5fb838689c872 Mon Sep 17 00:00:00 2001
developer51f6fcf2022-12-14 17:08:01 +08002From: Howard Hsu <howard-yh.hsu@mediatek.com>
3Date: Mon, 12 Dec 2022 11:30:37 +0800
developer30d39c22022-12-16 10:29:49 +08004Subject: [PATCH 3/6] wifi: mt76: mt7915: rework mt7915_thermal_temp_store()
developer51f6fcf2022-12-14 17:08:01 +08005
6Call mt7915_mcu_set_thermal_protect() through
7mt7915_thermal_temp_store() to update firmware trigger/restore temp
8directly.
9
10Fixes: 02ee68b95d81 ("mt76: mt7915: add control knobs for thermal throttling")
11Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
12Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
13---
14 mt7915/init.c | 18 ++++++++++++++++--
15 mt7915/mt7915.h | 3 +++
16 2 files changed, 19 insertions(+), 2 deletions(-)
17
18diff --git a/mt7915/init.c b/mt7915/init.c
19index df3a35d5..98655e4d 100644
20--- a/mt7915/init.c
21+++ b/mt7915/init.c
22@@ -83,9 +83,23 @@ static ssize_t mt7915_thermal_temp_store(struct device *dev,
23
24 mutex_lock(&phy->dev->mt76.mutex);
25 val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 60, 130);
26+
27+ if ((i - 1 == MT7915_CRIT_TEMP_IDX &&
28+ val > phy->throttle_temp[MT7915_MAX_TEMP_IDX]) ||
29+ (i - 1 == MT7915_MAX_TEMP_IDX &&
30+ val < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
31+ dev_err(phy->dev->mt76.dev,
32+ "temp1_max shall be greater than temp1_crit.");
33+ return -EINVAL;
34+ }
35+
36 phy->throttle_temp[i - 1] = val;
37 mutex_unlock(&phy->dev->mt76.mutex);
38
39+ ret = mt7915_mcu_set_thermal_protect(phy);
40+ if (ret)
41+ return ret;
42+
43 return count;
44 }
45
46@@ -195,8 +209,8 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)
47 return PTR_ERR(hwmon);
48
49 /* initialize critical/maximum high temperature */
50- phy->throttle_temp[0] = 110;
51- phy->throttle_temp[1] = 120;
52+ phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = 110;
53+ phy->throttle_temp[MT7915_MAX_TEMP_IDX] = 120;
54
55 return 0;
56 }
57diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
58index 855779f8..e58650bb 100644
59--- a/mt7915/mt7915.h
60+++ b/mt7915/mt7915.h
61@@ -70,6 +70,9 @@
62
63 #define MT7915_WED_RX_TOKEN_SIZE 12288
64
65+#define MT7915_CRIT_TEMP_IDX 0
66+#define MT7915_MAX_TEMP_IDX 1
67+
68 struct mt7915_vif;
69 struct mt7915_sta;
70 struct mt7915_dfs_pulse;
71--
developer30d39c22022-12-16 10:29:49 +0800722.25.1
developer51f6fcf2022-12-14 17:08:01 +080073