UPSTREAM: thermal: of-thermal: allow setting trip_temp on hardware
authorWei Ni <wni@nvidia.com>
Tue, 29 Mar 2016 10:29:17 +0000 (18:29 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 31 Mar 2016 07:10:04 +0000 (15:10 +0800)
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.

Change-Id: I879ea144a9ac21a5032dd885118887b4942c96cf
Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
(cherry picked from git.kernel.org next/linux-next.git master
 commit 60f9ce3ada53498409d51da06502392884933f89)

drivers/thermal/of-thermal.c
include/linux/thermal.h

index 5a515f8677ec5bb6699af73dd83df38467d94015..57828841b6e6ac03c1ed5773d9281b07638fbf0f 100644 (file)
@@ -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;
 
index 9c481991fdc7ea602bce3ccdb5b5d99d9bb2a781..fcaab873b94f9a3b51f2f46a8d02b0b3b57589db 100644 (file)
@@ -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);
 };
 
 /**