[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240122080441.1957022-1-peng.fan@oss.nxp.com>
Date: Mon, 22 Jan 2024 16:04:41 +0800
From: "Peng Fan (OSS)" <peng.fan@....nxp.com>
To: sudeep.holla@....com,
cristian.marussi@....com,
jdelvare@...e.com,
linux@...ck-us.net
Cc: linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org,
Peng Fan <peng.fan@....com>
Subject: [PATCH] hwmon: scmi-hwmon: implement change_mode
From: Peng Fan <peng.fan@....com>
The sensor maybe disabled before kernel boot, so add change_mode
to support configuring the sensor to enabled state.
Signed-off-by: Peng Fan <peng.fan@....com>
---
drivers/hwmon/scmi-hwmon.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index 364199b332c0..f7bd63d52d15 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -151,7 +151,36 @@ static int scmi_hwmon_thermal_get_temp(struct thermal_zone_device *tz,
return ret;
}
+static int scmi_hwmon_thermal_change_mode(struct thermal_zone_device *tz,
+ enum thermal_device_mode new_mode)
+{
+ int ret;
+ u32 config;
+ enum thermal_device_mode cur_mode = THERMAL_DEVICE_DISABLED;
+ struct scmi_thermal_sensor *th_sensor = thermal_zone_device_priv(tz);
+
+ ret = sensor_ops->config_get(th_sensor->ph, th_sensor->info->id,
+ &config);
+ if (ret)
+ return ret;
+
+ if (config & BIT(0))
+ cur_mode = THERMAL_DEVICE_ENABLED;
+
+ if (cur_mode == new_mode)
+ return 0;
+
+ if (new_mode == THERMAL_DEVICE_ENABLED)
+ config |= SCMI_SENS_CFG_SENSOR_ENABLED_MASK;
+ else
+ config &= ~SCMI_SENS_CFG_SENSOR_ENABLED_MASK;
+
+ return sensor_ops->config_set(th_sensor->ph, th_sensor->info->id,
+ config);
+}
+
static const struct thermal_zone_device_ops scmi_hwmon_thermal_ops = {
+ .change_mode = scmi_hwmon_thermal_change_mode,
.get_temp = scmi_hwmon_thermal_get_temp,
};
--
2.37.1
Powered by blists - more mailing lists