[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220601131400.24627-2-quic_manafm@quicinc.com>
Date: Wed, 1 Jun 2022 18:44:00 +0530
From: Manaf Meethalavalappu Pallikunhi <quic_manafm@...cinc.com>
To: "Rafael J . Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>
CC: <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
"Manaf Meethalavalappu Pallikunhi" <quic_manafm@...cinc.com>
Subject: [PATCH 1/1] drivers/thermal/thermal_of: Add critical/hot ops support for thermal_of sensor
The sensor driver which register through thermal_of interface doesn't
have an option to get thermal zone critical, hot trip violation
notification from thermal core.
Add support for these ops in thermal_of interface so that sensor
driver can use these ops.
Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@...cinc.com>
---
drivers/thermal/thermal_of.c | 21 +++++++++++++++++++++
include/linux/thermal.h | 6 ++++++
2 files changed, 27 insertions(+)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index b65d435cb92f..65e1848cb1dd 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -211,6 +211,20 @@ static int of_thermal_change_mode(struct thermal_zone_device *tz,
return data->ops->change_mode(data->sensor_data, mode);
}
+static void of_thermal_hot_notify(struct thermal_zone_device *tz)
+{
+ struct __thermal_zone *data = tz->devdata;
+
+ data->ops->hot(data->sensor_data);
+}
+
+static void of_thermal_critical_notify(struct thermal_zone_device *tz)
+{
+ struct __thermal_zone *data = tz->devdata;
+
+ data->ops->critical(data->sensor_data);
+}
+
static int of_thermal_bind(struct thermal_zone_device *thermal,
struct thermal_cooling_device *cdev)
{
@@ -419,6 +433,11 @@ thermal_zone_of_add_sensor(struct device_node *zone,
if (ops->change_mode)
tzd->ops->change_mode = of_thermal_change_mode;
+ if (ops->hot)
+ tzd->ops->hot = of_thermal_hot_notify;
+
+ if (ops->critical)
+ tzd->ops->critical = of_thermal_critical_notify;
mutex_unlock(&tzd->lock);
return tzd;
@@ -581,6 +600,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
tzd->ops->get_trend = NULL;
tzd->ops->set_emul_temp = NULL;
tzd->ops->change_mode = NULL;
+ tzd->ops->hot = NULL;
+ tzd->ops->critical = NULL;
tz->ops = NULL;
tz->sensor_data = NULL;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 365733b428d8..920f7e5c80bb 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -301,6 +301,10 @@ struct thermal_zone_params {
* hardware.
* @change_mode: a pointer to a function that notifies the thermal zone
* mode change.
+ * @hot: a pointer to a function that notifies the thermal zone
+ * hot trip violation.
+ * @critical: a pointer to a function that notifies the thermal zone
+ * critical trip violation.
*/
struct thermal_zone_of_device_ops {
int (*get_temp)(void *, int *);
@@ -309,6 +313,8 @@ struct thermal_zone_of_device_ops {
int (*set_emul_temp)(void *, int);
int (*set_trip_temp)(void *, int, int);
int (*change_mode) (void *, enum thermal_device_mode);
+ void (*hot)(void *sensor_data);
+ void (*critical)(void *sensor_data);
};
/* Function declarations */
Powered by blists - more mailing lists