mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7915: add thermal zone device registration
Register the mt7915 phy as a thermal zone sensor using devm_thermal_of_zone_register() so that device tree thermal-zones nodes can reference the Wi-Fi chip as a temperature source. This allows the kernel thermal governor to control external cooling devices such as PWM fans based on Wi-Fi chip temperature. Registration is non-fatal: -ENODEV is returned when no thermal-sensors DT property references this device, which is the expected case on platforms without a thermal zone configured. Signed-off-by: Ryan Leung <[email protected]> Link: https://patch.msgid.link/20260719-mt7915-thermal-zone-device-registration-v2-1-0eac68c2741e@protonmail.com Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
491d786c1b
commit
fd25371901
@@ -177,6 +177,25 @@ static const struct thermal_cooling_device_ops mt7915_thermal_ops = {
|
||||
.set_cur_state = mt7915_thermal_set_cur_throttle_state,
|
||||
};
|
||||
|
||||
static int mt7915_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||
{
|
||||
struct mt7915_phy *phy = thermal_zone_device_priv(tz);
|
||||
int val;
|
||||
|
||||
mutex_lock(&phy->dev->mt76.mutex);
|
||||
val = mt7915_mcu_get_temperature(phy);
|
||||
mutex_unlock(&phy->dev->mt76.mutex);
|
||||
if (val < 0)
|
||||
return val;
|
||||
|
||||
*temp = val * 1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct thermal_zone_device_ops mt7915_tz_ops = {
|
||||
.get_temp = mt7915_thermal_get_temp,
|
||||
};
|
||||
|
||||
static void mt7915_unregister_thermal(struct mt7915_phy *phy)
|
||||
{
|
||||
struct wiphy *wiphy = phy->mt76->hw->wiphy;
|
||||
@@ -213,6 +232,17 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)
|
||||
phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = MT7915_CRIT_TEMP;
|
||||
phy->throttle_temp[MT7915_MAX_TEMP_IDX] = MT7915_MAX_TEMP;
|
||||
|
||||
phy->tzone = devm_thermal_of_zone_register(phy->dev->mt76.dev,
|
||||
phy->mt76->band_idx, phy,
|
||||
&mt7915_tz_ops);
|
||||
if (IS_ERR(phy->tzone)) {
|
||||
if (PTR_ERR(phy->tzone) != -ENODEV)
|
||||
dev_warn(phy->dev->mt76.dev,
|
||||
"failed to register thermal zone: %ld\n",
|
||||
PTR_ERR(phy->tzone));
|
||||
phy->tzone = NULL;
|
||||
}
|
||||
|
||||
if (!IS_REACHABLE(CONFIG_HWMON))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@ struct mt7915_phy {
|
||||
|
||||
struct ieee80211_vif *monitor_vif;
|
||||
|
||||
struct thermal_zone_device *tzone;
|
||||
struct thermal_cooling_device *cdev;
|
||||
u8 cdev_state;
|
||||
u8 throttle_state;
|
||||
|
||||
Reference in New Issue
Block a user