Initial Contribution
msm-2.6.38: tag AU_LINUX_ANDROID_GINGERBREAD.02.03.04.00.142
Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 0b1c82a..e0d8ef7 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -188,6 +188,12 @@
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:
@@ -198,6 +204,34 @@
}
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_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -220,6 +254,30 @@
}
static ssize_t
+trip_point_temp_set(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct thermal_zone_device *tz = to_thermal_zone(dev);
+ int trip, ret;
+ long temperature;
+
+ if (!tz->ops->set_trip_temp)
+ return -EPERM;
+
+ if (!sscanf(attr->attr.name, "trip_point_%d_temp", &trip))
+ return -EINVAL;
+
+ if (!sscanf(buf, "%ld", &temperature))
+ return -EINVAL;
+
+ ret = tz->ops->set_trip_temp(tz, trip, temperature);
+ if (ret)
+ return ret;
+
+ return count;
+}
+
+static ssize_t
passive_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -287,30 +345,54 @@
passive_store);
static struct device_attribute trip_point_attrs[] = {
- __ATTR(trip_point_0_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_0_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_1_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_1_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_2_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_2_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_3_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_3_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_4_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_4_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_5_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_5_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_6_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_6_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_7_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_7_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_8_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_8_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_9_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_9_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_10_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_10_temp, 0444, trip_point_temp_show, NULL),
- __ATTR(trip_point_11_type, 0444, trip_point_type_show, NULL),
- __ATTR(trip_point_11_temp, 0444, trip_point_temp_show, NULL),
+ __ATTR(trip_point_0_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_0_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_1_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_1_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_2_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_2_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_3_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_3_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_4_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_4_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_5_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_5_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_6_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_6_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_7_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_7_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_8_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_8_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_9_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_9_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_10_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_10_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
+ __ATTR(trip_point_11_type, 0644, trip_point_type_show,
+ trip_point_type_activate),
+ __ATTR(trip_point_11_temp, 0644, trip_point_temp_show,
+ trip_point_temp_set),
};
#define TRIP_POINT_ATTR_ADD(_dev, _index, result) \
@@ -992,6 +1074,29 @@
if (tz->ops->notify)
tz->ops->notify(tz, count, trip_type);
break;
+ case THERMAL_TRIP_CONFIGURABLE_HI:
+ if (temp >= trip_temp)
+ if (tz->ops->notify)
+ tz->ops->notify(tz, count, trip_type);
+ break;
+ case THERMAL_TRIP_CONFIGURABLE_LOW:
+ if (temp <= trip_temp)
+ if (tz->ops->notify)
+ tz->ops->notify(tz, count, trip_type);
+ break;
+ case THERMAL_TRIP_CRITICAL_LOW:
+ if (temp <= trip_temp) {
+ if (tz->ops->notify)
+ ret = tz->ops->notify(tz, count,
+ trip_type);
+ if (!ret) {
+ printk(KERN_EMERG
+ "Critical temperature reached (%ld C), \
+ shutting down.\n", temp/1000);
+ orderly_poweroff(true);
+ }
+ }
+ break;
case THERMAL_TRIP_ACTIVE:
list_for_each_entry(instance, &tz->cooling_devices,
node) {