Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0747940a authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

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: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 37c816de
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -187,6 +187,10 @@ Optional property:
			2000mW, while on a 10'' tablet is around
			4500mW.

- disable-thermal-zone: Disable the thermal zone monitoring by default. These
  Type:bool		thermal zones will be enabled by userspace daemons
			based on usecase.

- tracks-low:		Indicates that the temperature sensor tracks the low
  Type: bool		thresholds, so the governors may mitigate by ensuring
			timing closures and other low temperature operating
+11 −2
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ struct __sensor_param {
 * @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 @@ struct __thermal_zone {
	int slope;
	int offset;
	struct thermal_zone_device *tzd;
	bool default_disable;

	/* trip data */
	int ntrips;
@@ -710,6 +712,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
	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 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
			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,6 +943,7 @@ struct thermal_zone_device *devm_thermal_of_virtual_sensor_register(
	*ptr = tzd;
	devres_add(dev, ptr);

	if (!tz->default_disable)
		tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED);

	return tzd;
@@ -1206,6 +1213,8 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)
	}
	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