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 | 22 ++++++++++++++++++++++ include/linux/thermal.h | 9 +++++++++ 2 files changed, 31 insertions(+)
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index f7049ee16e98..a746ce323ff6 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -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); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 0b47cb72b96e..419cf0f0de27 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -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 */