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

Commit 2a1abd14 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: thermal: Add support for THERMAL_MAX_LIMIT cdev



Thermal cooling device can define THERMAL_NO_LIMIT as a state in
devicetree if the default max or min state has to be used. If the user
has to apply a specific mitigation state from the max and min the state
has to be mentioned. If the device has multiple speed bins and if the
number of state changes, the max mitigation state will vary.

In order to apply max mitigation irrespective of the number of states,
add support for the THERMAL_MAX_LIMIT macro. Users can define any state
as a an offset from the THERMAL_MAX_LIMIT macro.

Change-Id: I1808f0c6caa2918ca978842a6dc348956d69590c
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent ffd90498
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1424,9 +1424,26 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
	if (ret)
		return ret;

	/* lower default 0, upper default max_state */
	lower = lower == THERMAL_NO_LIMIT ? 0 : lower;
	upper = upper == THERMAL_NO_LIMIT ? max_state : upper;
	/*
	 * If upper or lower has a MACRO to define the mitigation state,
	 * based on the MACRO determine the default state to use or the
	 * offset from the max_state.
	 */
	if (upper > (THERMAL_MAX_LIMIT - max_state)) {
		/* upper default max_state */
		if (upper == THERMAL_NO_LIMIT)
			upper = max_state;
		else
			upper = max_state - (THERMAL_MAX_LIMIT - upper);
	}

	if (lower > (THERMAL_MAX_LIMIT - max_state)) {
		/* lower default 0 */
		if (lower == THERMAL_NO_LIMIT)
			lower = 0;
		else
			lower =  max_state - (THERMAL_MAX_LIMIT - lower);
	}

	if (lower > upper || upper > max_state)
		return -EINVAL;
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@

/* On cooling devices upper and lower limits */
#define THERMAL_NO_LIMIT		(~0)
#define THERMAL_MAX_LIMIT		(THERMAL_NO_LIMIT - 1)

#endif
+3 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
/* No upper/lower limit requirement */
#define THERMAL_NO_LIMIT	((u32)~0)

/* upper limit requirement */
#define THERMAL_MAX_LIMIT	(THERMAL_NO_LIMIT - 1)

/* Default weight of a bound cooling device */
#define THERMAL_WEIGHT_DEFAULT 0