diff options
author | Siddartha Mohanadoss <smohanad@codeaurora.org> | 2010-12-06 22:49:26 -0800 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:08:17 -0700 |
commit | 0637fa244fff60c961668a29c67c0e0310d2a95e (patch) | |
tree | 7a71750bbbfca4f7c6da80265cca8f04918b8d81 /drivers/thermal | |
parent | 9b7489584281df171c56ea3ae37c1e3710dd2095 (diff) |
thermal: thermal_sys: Add support for configurable trip points.
Add functionality for configurable hi, low and critical low.
Change the trip point attributes to allow userspace clients
with root access to set temperature for configurable hi and
low temperature.
Change-Id: I25c9c3bcfd58e44da5369187d1095559062f1860
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
Signed-off-by: David Brown <davidb@codeaurora.org>
Conflicts:
drivers/thermal/thermal_core.c
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d9e525cc9c1c..f392eb8fccd5 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -431,15 +431,21 @@ static void handle_critical_trips(struct thermal_zone_device *tz, tz->ops->get_trip_temp(tz, trip, &trip_temp); /* If we have not crossed the trip_temp, we do not care. */ - if (trip_temp <= 0 || tz->temperature < trip_temp) - return; + if (trip_type != THERMAL_TRIP_CRITICAL_LOW && + trip_type != THERMAL_TRIP_CONFIGURABLE_LOW) { + if (tz->temperature < trip_temp) + return; + } else + if (tz->temperature >= trip_temp) + return; trace_thermal_zone_trip(tz, trip, trip_type); if (tz->ops->notify) tz->ops->notify(tz, trip, trip_type); - if (trip_type == THERMAL_TRIP_CRITICAL) { + if (trip_type == THERMAL_TRIP_CRITICAL || + trip_type == THERMAL_TRIP_CRITICAL_LOW) { dev_emerg(&tz->device, "critical temperature reached(%d C),shutting down\n", tz->temperature / 1000); @@ -453,7 +459,10 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip) tz->ops->get_trip_type(tz, trip, &type); - if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT) + if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT || + type == THERMAL_TRIP_CONFIGURABLE_HI || + type == THERMAL_TRIP_CONFIGURABLE_LOW || + type == THERMAL_TRIP_CRITICAL_LOW) handle_critical_trips(tz, trip, type); else handle_non_critical_trips(tz, trip, type); @@ -649,6 +658,12 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "critical\n"); case THERMAL_TRIP_HOT: return sprintf(buf, "hot\n"); + case THERMAL_TRIP_CONFIGURABLE_HI: + return sprintf(buf, "configurable_hi\n"); + case THERMAL_TRIP_CONFIGURABLE_LOW: + return sprintf(buf, "configurable_low\n"); + case THERMAL_TRIP_CRITICAL_LOW: + return sprintf(buf, "critical_low\n"); case THERMAL_TRIP_PASSIVE: return sprintf(buf, "passive\n"); case THERMAL_TRIP_ACTIVE: @@ -659,6 +674,34 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr, } static ssize_t +trip_point_type_activate(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + int trip, result; + + if (!tz->ops->activate_trip_type) + return -EPERM; + + if (!sscanf(attr->attr.name, "trip_point_%d_type", &trip)) + return -EINVAL; + + if (!strncmp(buf, "enabled", sizeof("enabled"))) + result = tz->ops->activate_trip_type(tz, trip, + THERMAL_TRIP_ACTIVATION_ENABLED); + else if (!strncmp(buf, "disabled", sizeof("disabled"))) + result = tz->ops->activate_trip_type(tz, trip, + THERMAL_TRIP_ACTIVATION_DISABLED); + else + result = -EINVAL; + + if (result) + return result; + + return count; +} + +static ssize_t trip_point_temp_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -1670,8 +1713,9 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) sysfs_attr_init(&tz->trip_type_attrs[indx].attr.attr); tz->trip_type_attrs[indx].attr.attr.name = tz->trip_type_attrs[indx].name; - tz->trip_type_attrs[indx].attr.attr.mode = S_IRUGO; + tz->trip_type_attrs[indx].attr.attr.mode = S_IRUGO | S_IWUSR; tz->trip_type_attrs[indx].attr.show = trip_point_type_show; + tz->trip_type_attrs[indx].attr.store = trip_point_type_activate; device_create_file(&tz->device, &tz->trip_type_attrs[indx].attr); |