[PATCH RFC 2/8] thermal: Introduce new property monitor_type for trip point.

From: Thara Gopinath
Date: Wed Sep 16 2020 - 23:29:18 EST


Thermal trip points can be defined to indicate whether a
temperature rise or a temperature fall is to be monitored. This
property can now be defined in the DT bindings for a trip point.
To support this following three changes are introduced to thermal
core and sysfs code.
1. Define a new variable in thermal_trip to capture the monitor
rising/falling information from trip point DT bindings.
2. Define a new ops in thermal_zone_device_ops that can be populated
to indicate whether a trip is being monitored for rising or falling
temperature. If the ops is not populated or if the binding is missing
in the DT, it is assumed that the trip is being monitored for rising
temperature. (default behavior today)

Signed-off-by: Thara Gopinath <thara.gopinath@xxxxxxxxxx>
---
drivers/thermal/thermal_core.h | 2 ++
include/linux/thermal.h | 2 ++
include/uapi/linux/thermal.h | 5 +++++
3 files changed, 9 insertions(+)

diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index e00fc5585ea8..c56addfe2284 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -77,12 +77,14 @@ int power_actor_set_power(struct thermal_cooling_device *cdev,
* @temperature: temperature value in miliCelsius
* @hysteresis: relative hysteresis in miliCelsius
* @type: trip point type
+ * @monitor_type: trip point monitor type
*/
struct thermal_trip {
struct device_node *np;
int temperature;
int hysteresis;
enum thermal_trip_type type;
+ enum thermal_trip_monitor_type monitor_type;
};

int get_tz_trend(struct thermal_zone_device *tz, int trip);
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 42ef807e5d84..a50ed958d0bd 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -72,6 +72,8 @@ struct thermal_zone_device_ops {
int (*set_trip_temp) (struct thermal_zone_device *, int, int);
int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
+ int (*get_trip_mon_type)(struct thermal_zone_device *, int,
+ enum thermal_trip_monitor_type *);
int (*get_crit_temp) (struct thermal_zone_device *, int *);
int (*set_emul_temp) (struct thermal_zone_device *, int);
int (*get_trend) (struct thermal_zone_device *, int,
diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h
index c105054cbb57..d3bb4e4fad69 100644
--- a/include/uapi/linux/thermal.h
+++ b/include/uapi/linux/thermal.h
@@ -16,6 +16,11 @@ enum thermal_trip_type {
THERMAL_TRIP_CRITICAL,
};

+enum thermal_trip_monitor_type {
+ THERMAL_TRIP_MONITOR_RISING = 0,
+ THERMAL_TRIP_MONITOR_FALLING
+};
+
/* Adding event notification support elements */
#define THERMAL_GENL_FAMILY_NAME "thermal"
#define THERMAL_GENL_VERSION 0x01
--
2.25.1