summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-09-05 17:28:58 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:28:26 +0800
commit9bd0b1d47b7b7b6119cd581b30039f7cd9b7f197 (patch)
tree799949e0bb9ad33a5f9e024a7c718397d0bf727f /drivers/thermal
parentd58df887c92b9b0090da8b7b1a9edc46e080c429 (diff)
MLK-16372-1 thermal: imx_sc: add get_trend and set_trip_temp support
Add get_trend and set_trip_temp callback to support cpu-freq cooling function. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/imx_sc_thermal.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c
index c956e420d395..ce9bf6d7df20 100644
--- a/drivers/thermal/imx_sc_thermal.c
+++ b/drivers/thermal/imx_sc_thermal.c
@@ -17,9 +17,14 @@
#include <linux/thermal.h>
#include <soc/imx8/sc/sci.h>
+#include "thermal_core.h"
+
struct imx_sc_sensor {
struct thermal_zone_device *tzd;
+ struct thermal_cooling_device *cdev;
sc_rsrc_t hw_id;
+ int temp_passive;
+ int temp_critical;
};
struct imx_sc_tsens_device {
@@ -76,13 +81,41 @@ static int imx_sc_tsens_get_temp(void *data, int *temp)
static int imx_sc_tsens_get_trend(void *p, int trip, enum thermal_trend *trend)
{
+ int trip_temp;
+ struct imx_sc_sensor *sensor = p;
+
+ if (!sensor->tzd)
+ return 0;
+
+ trip_temp = (trip == IMX_TRIP_PASSIVE) ? sensor->temp_passive :
+ sensor->temp_critical;
+
+ if (sensor->tzd->temperature >= trip_temp)
+ *trend = THERMAL_TREND_RAISE_FULL;
+ else
+ *trend = THERMAL_TREND_DROP_FULL;
+
return 0;
}
+static int imx_sc_set_trip_temp(void *p, int trip,
+ int temp)
+{
+ struct imx_sc_sensor *sensor = p;
+
+ if (trip == IMX_TRIP_CRITICAL)
+ sensor->temp_critical = temp;
+
+ if (trip == IMX_TRIP_PASSIVE)
+ sensor->temp_passive = temp;
+
+ return 0;
+}
static const struct thermal_zone_of_device_ops imx_sc_tsens_ops = {
.get_temp = imx_sc_tsens_get_temp,
.get_trend = imx_sc_tsens_get_trend,
+ .set_trip_temp = imx_sc_set_trip_temp,
};
static const struct of_device_id imx_sc_tsens_table[] = {
@@ -98,6 +131,7 @@ static int imx_sc_tsens_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node;
struct imx_sc_tsens_device *tsens_dev;
struct imx_sc_sensor *sensor;
+ const struct thermal_trip *trip;
struct thermal_zone_device *tzd;
sc_err_t sciErr;
uint32_t mu_id;
@@ -142,6 +176,9 @@ static int imx_sc_tsens_probe(struct platform_device *pdev)
goto failed;
}
sensor->tzd = tzd;
+ trip = of_thermal_get_trip_points(sensor->tzd);
+ sensor->temp_passive = trip[0].temperature;
+ sensor->temp_critical = trip[1].temperature;
}
return 0;