Skip to contentSkip to conversation

thermal: of-thermal: allow setting trip_temp on hardware

PATCH Superseded Wei Ni 1 participant 1 message Mar 16, 2016

Subsystems (2)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Wei Ni

author
#0 lore raw

PATCH v8 7/14 thermal: of-thermal: allow setting trip_temp on hardware

In current of-thermal, the .set_trip_temp only support to set trip_temp for SW. But some sensors support to set trip_temp on hardware, so that can trigger interrupt, shutdown or any other events.
This patch adds .set_trip_temp() callback in thermal_zone_of_device_ops{}, so that the sensor device can use it to set trip_temp on hardware.

---
 drivers/thermal/of-thermal.c | 8 ++++++++
 include/linux/thermal.h      | 1 +
 2 files changed, 9 insertions(+)
drivers/thermal/of-thermal.c +8 -0
index 5a515f8677ec..57828841b6e6 100644
@@ -331,6 +331,14 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
 	if (trip >= data->ntrips || trip < 0)
 		return -EDOM;
 
+	if (data->ops->set_trip_temp) {
+		int ret;
+
+		ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);
+		if (ret)
+			return ret;
+	}
+
 	/* thermal framework should take care of data->mask & (1 << trip) */
 	data->trips[trip].temperature = temp;
 
include/linux/thermal.h +1 -0
index 9c481991fdc7..fcaab873b94f 100644
@@ -338,6 +338,7 @@ struct thermal_zone_of_device_ops {
 	int (*get_temp)(void *, int *);
 	int (*get_trend)(void *, long *);
 	int (*set_emul_temp)(void *, int);
+	int (*set_trip_temp)(void *, int, int);
 };
 
 /**
Signature · 1 line
1.9.1