thermal: add trip flag for control algorithm
authorLukasz Luba <l.luba@partner.samsung.com>
Thu, 8 Nov 2018 11:00:54 +0000 (12:00 +0100)
committerLukasz Luba <l.luba@partner.samsung.com>
Fri, 17 May 2019 07:15:46 +0000 (09:15 +0200)
The patch adds support of a new flag comming from DT trip point
description. The flag is used by control algorithm for thresholds:
'switch_on' and 'desired' temperature.

Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
drivers/thermal/of-thermal.c
include/linux/thermal.h

index f7049ee16e98e1d2eb8282495dd3daf2fc3df846..a746ce323ff637f8120a7b452b98cb841f17e815 100644 (file)
@@ -288,6 +288,20 @@ static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
        return 0;
 }
 
+static int
+of_thermal_get_trip_ctrl_alg_flag(struct thermal_zone_device *tz,int trip,
+                                 enum thermal_trip_ctrl_alg *flag)
+{
+       struct __thermal_zone *data = tz->devdata;
+
+       if (trip >= data->ntrips || trip < 0)
+               return -EDOM;
+
+       *flag = data->trips[trip].alg_flag;
+
+       return 0;
+}
+
 static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
                                    int *temp)
 {
@@ -370,6 +384,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
        .set_mode = of_thermal_set_mode,
 
        .get_trip_type = of_thermal_get_trip_type,
+       .get_trip_ctrl_alg_flag = of_thermal_get_trip_ctrl_alg_flag,
        .get_trip_temp = of_thermal_get_trip_temp,
        .set_trip_temp = of_thermal_set_trip_temp,
        .get_trip_hyst = of_thermal_get_trip_hyst,
@@ -778,6 +793,13 @@ static int thermal_of_populate_trip(struct device_node *np,
                return ret;
        }
 
+       ret = of_property_read_u32(np, "ctrl-alg", &prop);
+       if (ret < 0) {
+               trip->alg_flag = THERMAL_TRIP_CTRL_ALG_NONE;
+       } else {
+               trip->alg_flag = (enum thermal_trip_ctrl_alg) prop;
+       }
+
        /* Required for cooling map matching */
        trip->np = np;
        of_node_get(np);
index 0b47cb72b96e8f5ea9f48f2b128f89ee607b1107..419cf0f0de27209aa8c8244c6c045d7e014158f5 100644 (file)
@@ -70,6 +70,12 @@ enum thermal_trip_type {
        THERMAL_TRIP_CRITICAL,
 };
 
+enum thermal_trip_ctrl_alg {
+       THERMAL_TRIP_CTRL_ALG_NONE = 0,
+       THERMAL_TRIP_CTRL_ALG_SWITCH_ON = 1,
+       THERMAL_TRIP_CTRL_ALG_DESIRED = 2,
+};
+
 enum thermal_trend {
        THERMAL_TREND_STABLE, /* temperature is stable */
        THERMAL_TREND_RAISING, /* temperature is raising */
@@ -103,6 +109,8 @@ struct thermal_zone_device_ops {
                enum thermal_device_mode);
        int (*get_trip_type) (struct thermal_zone_device *, int,
                enum thermal_trip_type *);
+       int (*get_trip_ctrl_alg_flag) (struct thermal_zone_device *, int,
+               enum thermal_trip_ctrl_alg *);
        int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
        int (*set_trip_temp) (struct thermal_zone_device *, int, int);
        int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
@@ -374,6 +382,7 @@ struct thermal_trip {
        int temperature;
        int hysteresis;
        enum thermal_trip_type type;
+       enum thermal_trip_ctrl_alg alg_flag;
 };
 
 /* Function declarations */