drivers: thermal: Add support to disable a thermal zone by default
Certain thermal zone rules has to be enabled based on usecases. These
usecases will demand a certain thermal zone be disabled by default and
those rules will be enabled by user space daemons.
Add support for a new device tree property, which will keep the thermal
zone disabled by default.
Change-Id: I59b542aa551ad4d414e0c87c4a58ec0aa1c9901f
Signed-off-by: Ram Chandrasekar <rkumbako@codeaurora.org>
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 9f675cd..101e51b 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -80,6 +80,7 @@
* @polling_delay: zone polling interval
* @slope: slope of the temperature adjustment curve
* @offset: offset of the temperature adjustment curve
+ * @default_disable: Keep the thermal zone disabled by default
* @tzd: thermal zone device pointer for this sensor
* @ntrips: number of trip points
* @trips: an array of trip points (0..ntrips - 1)
@@ -96,6 +97,7 @@
int slope;
int offset;
struct thermal_zone_device *tzd;
+ bool default_disable;
/* trip data */
int ntrips;
@@ -710,6 +712,7 @@
for_each_available_child_of_node(np, child) {
struct of_phandle_args sensor_specs;
int ret, id;
+ struct __thermal_zone *tz;
/* For now, thermal framework supports only 1 sensor per zone */
ret = of_parse_phandle_with_args(child, "thermal-sensors",
@@ -733,7 +736,10 @@
if (!IS_ERR(tzd)) {
if (!first_tzd)
first_tzd = tzd;
- tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
+ tz = tzd->devdata;
+ if (!tz->default_disable)
+ tzd->ops->set_mode(tzd,
+ THERMAL_DEVICE_ENABLED);
}
}
of_node_put(sensor_specs.np);
@@ -937,7 +943,8 @@
*ptr = tzd;
devres_add(dev, ptr);
- tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
+ if (!tz->default_disable)
+ tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);
return tzd;
}
@@ -1206,6 +1213,8 @@
}
tz->polling_delay = prop;
+ tz->default_disable = of_property_read_bool(np,
+ "disable-thermal-zone");
/*
* REVIST: for now, the thermal framework supports only
* one sensor per thermal zone. Thus, we are considering