ANDROID: GKI: drivers: thermal: Add support for getting trip temperature

Add support for the sensor drivers using of-thermal interface to support
reading the trip temperature from the hardware using a callback. This
can be used in case, when the hardware works on a pre-configured
threshold different from the threshold set by software.

Test: build
Bug: 149945768
Change-Id: Ic5aaf1586b8dcbb3da0dd775718407c257b2064f
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
(cherry picked from commit 8a12149c26)
[hridya: added an extra null pointer check, partial cherry-pick]
Signed-off-by: Hridya Valsaraju <hridya@google.com>
This commit is contained in:
Ram Chandrasekar 2018-02-06 17:12:04 -07:00 committed by Hridya Valsaraju
parent 5a7902fba4
commit 10d3954a78
2 changed files with 14 additions and 1 deletions

View file

@ -407,7 +407,17 @@ static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
if (trip >= data->ntrips || trip < 0)
return -EDOM;
*temp = data->trips[trip].temperature;
if (data->senps && data->senps->ops &&
data->senps->ops->get_trip_temp) {
int ret;
ret = data->senps->ops->get_trip_temp(data->senps->sensor_data,
trip, temp);
if (ret)
return ret;
} else {
*temp = data->trips[trip].temperature;
}
return 0;
}

View file

@ -367,6 +367,8 @@ struct thermal_genl_event {
* temperature.
* @set_trip_temp: a pointer to a function that sets the trip temperature on
* hardware.
* @get_trip_temp: a pointer to a function that gets the trip temperature on
* hardware.
*/
struct thermal_zone_of_device_ops {
int (*get_temp)(void *, int *);
@ -374,6 +376,7 @@ struct thermal_zone_of_device_ops {
int (*set_trips)(void *, int, int);
int (*set_emul_temp)(void *, int);
int (*set_trip_temp)(void *, int, int);
int (*get_trip_temp)(void *, int, int *);
};
/**