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

Commit 48f5bbfb authored by Eduardo Valentin's avatar Eduardo Valentin Committed by Kevin Hilman
Browse files

thermal: support slope and offset coefficients



It is common to have a linear extrapolation from
the current sensor readings and the actual temperature
value. This is specially the case when the sensor
is in use to extrapolate hotspots.

This patch adds slope and offset constants for
single sensor linear extrapolation equation. Because
the same sensor can be use in different locations,
from board to board, these constants are added
as part of thermal_zone_params.

The constants are available through sysfs.

It is up to the device driver to determine
the usage of these values.

Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
(cherry picked from commit 9d0be7f4810257a9b0fc78fff641f14409f14ab3)
Signed-off-by: default avatarKevin Hilman <khilman@linaro.org>
parent babef976
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -190,6 +190,8 @@ Thermal zone device sys I/F, created once it's registered:
    |---k_i:                    PID's integral term in the power allocator gov
    |---k_i:                    PID's integral term in the power allocator gov
    |---k_d:                    PID's derivative term in the power allocator
    |---k_d:                    PID's derivative term in the power allocator
    |---integral_cutoff:        Offset above which errors are accumulated
    |---integral_cutoff:        Offset above which errors are accumulated
    |---slope:                  Slope constant applied as linear extrapolation
    |---offset:                 Offset constant applied as linear extrapolation


Thermal cooling device sys I/F, created once it's registered:
Thermal cooling device sys I/F, created once it's registered:
/sys/class/thermal/cooling_device[0-*]:
/sys/class/thermal/cooling_device[0-*]:
@@ -359,6 +361,20 @@ integral_cutoff
	Documentation/thermal/power_allocator.txt
	Documentation/thermal/power_allocator.txt
	RW, Optional
	RW, Optional


slope
	The slope constant used in a linear extrapolation model
	to determine a hotspot temperature based off the sensor's
	raw readings. It is up to the device driver to determine
	the usage of these values.
	RW, Optional

offset
	The offset constant used in a linear extrapolation model
	to determine a hotspot temperature based off the sensor's
	raw readings. It is up to the device driver to determine
	the usage of these values.
	RW, Optional

*****************************
*****************************
* Cooling device attributes *
* Cooling device attributes *
*****************************
*****************************
+4 −0
Original line number Original line Diff line number Diff line
@@ -942,6 +942,8 @@ create_s32_tzp_attr(k_pu);
create_s32_tzp_attr(k_i);
create_s32_tzp_attr(k_i);
create_s32_tzp_attr(k_d);
create_s32_tzp_attr(k_d);
create_s32_tzp_attr(integral_cutoff);
create_s32_tzp_attr(integral_cutoff);
create_s32_tzp_attr(slope);
create_s32_tzp_attr(offset);
#undef create_s32_tzp_attr
#undef create_s32_tzp_attr


static struct device_attribute *dev_tzp_attrs[] = {
static struct device_attribute *dev_tzp_attrs[] = {
@@ -951,6 +953,8 @@ static struct device_attribute *dev_tzp_attrs[] = {
	&dev_attr_k_i,
	&dev_attr_k_i,
	&dev_attr_k_d,
	&dev_attr_k_d,
	&dev_attr_integral_cutoff,
	&dev_attr_integral_cutoff,
	&dev_attr_slope,
	&dev_attr_offset,
};
};


static int create_tzp_attrs(struct device *dev)
static int create_tzp_attrs(struct device *dev)
+11 −0
Original line number Original line Diff line number Diff line
@@ -302,6 +302,17 @@ struct thermal_zone_params {


	/* threshold below which the error is no longer accumulated */
	/* threshold below which the error is no longer accumulated */
	s32 integral_cutoff;
	s32 integral_cutoff;

	/*
	 * @slope:	slope of a linear temperature adjustment curve.
	 * 		Used by thermal zone drivers.
	 */
	int slope;
	/*
	 * @offset:	offset of a linear temperature adjustment curve.
	 * 		Used by thermal zone drivers (default 0).
	 */
	int offset;
};
};


struct thermal_genl_event {
struct thermal_genl_event {