developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame^] | 1 | From 728ee842b9f9819251e4dd4a2779ee337b003321 Mon Sep 17 00:00:00 2001 |
developer | 51f6fcf | 2022-12-14 17:08:01 +0800 | [diff] [blame] | 2 | From: Howard Hsu <howard-yh.hsu@mediatek.com> |
| 3 | Date: Mon, 12 Dec 2022 11:30:37 +0800 |
developer | 30d39c2 | 2022-12-16 10:29:49 +0800 | [diff] [blame] | 4 | Subject: [PATCH 3/6] wifi: mt76: mt7915: rework mt7915_thermal_temp_store() |
developer | 51f6fcf | 2022-12-14 17:08:01 +0800 | [diff] [blame] | 5 | |
| 6 | Call mt7915_mcu_set_thermal_protect() through |
| 7 | mt7915_thermal_temp_store() to update firmware trigger/restore temp |
| 8 | directly. |
| 9 | |
| 10 | Fixes: 02ee68b95d81 ("mt76: mt7915: add control knobs for thermal throttling") |
| 11 | Reviewed-by: Ryder Lee <ryder.lee@mediatek.com> |
| 12 | Signed-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 | |
| 18 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame^] | 19 | index df3a35d..98655e4 100644 |
developer | 51f6fcf | 2022-12-14 17:08:01 +0800 | [diff] [blame] | 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 | } |
| 57 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame^] | 58 | index 855779f..e58650b 100644 |
developer | 51f6fcf | 2022-12-14 17:08:01 +0800 | [diff] [blame] | 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 | -- |
developer | 699cda2 | 2022-12-17 15:21:57 +0800 | [diff] [blame^] | 72 | 2.36.1 |
developer | 51f6fcf | 2022-12-14 17:08:01 +0800 | [diff] [blame] | 73 | |