summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-09-08 16:04:25 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit51210e347c72c68d51a4d8445e7dc498e0aea0fc (patch)
tree23c1c48f3ef9ec95db0d0f7a161e025d583a676c /drivers/thermal
parent2798e2bf7ce1be8a4097028f2346bd69a09545a7 (diff)
MLK-16415 thermal: imx_sc: add device cooling for all thermal zones
For system controller thermal devices, add device cooling for all thermal zones, when temperature exceeds passive trip point, thermal driver will send out notification, all devices that register device cooling notification can take actions to cooling down the chip, such as for GPU, below message will be printed out: [ 581.284453] System is too hot. GPU3D will work at 1/64 clock. And when temperature drops to below passive trip point, GPU cooling action will be cancelled: [ 578.300532] Hot alarm is canceled. GPU3D clock will return to 64/64 Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/imx_sc_thermal.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c
index ce9bf6d7df20..8503c38a4507 100644
--- a/drivers/thermal/imx_sc_thermal.c
+++ b/drivers/thermal/imx_sc_thermal.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/device_cooling.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/slab.h>
@@ -179,6 +180,28 @@ static int imx_sc_tsens_probe(struct platform_device *pdev)
trip = of_thermal_get_trip_points(sensor->tzd);
sensor->temp_passive = trip[0].temperature;
sensor->temp_critical = trip[1].temperature;
+
+ sensor->cdev = devfreq_cooling_register();
+ if (IS_ERR(sensor->cdev)) {
+ dev_err(&pdev->dev,
+ "failed to register devfreq cooling device: %d\n",
+ ret);
+ goto failed;
+ }
+
+ ret = thermal_zone_bind_cooling_device(sensor->tzd,
+ IMX_TRIP_PASSIVE,
+ sensor->cdev,
+ THERMAL_NO_LIMIT,
+ THERMAL_NO_LIMIT,
+ THERMAL_WEIGHT_DEFAULT);
+ if (ret) {
+ dev_err(&sensor->tzd->device,
+ "binding zone %s with cdev %s failed:%d\n",
+ sensor->tzd->type, sensor->cdev->type, ret);
+ devfreq_cooling_unregister(sensor->cdev);
+ goto failed;
+ }
}
return 0;