summaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorAnson Huang <Anson.Huang@nxp.com>2017-08-01 15:53:31 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:27:47 +0800
commitd96fc20741095a417d1cacf89dee8b1ea26ca056 (patch)
treee6fa3ad3a34bc8f203b6c448ca729200b08c2806 /drivers/thermal
parent36f07d50d113a27e7c03fbd1b31392f117b6fa88 (diff)
MLK-16109-1 thermal: qoriq: add device cooling support
On i.MX8MQ, once temperautre exceeds hot threshold, some modules like GPU etc. can reduce its frequency to cool down the chip. All modules can register this device cooling notifier to receive thermal HOT notification. Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/qoriq_thermal.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
index 1c132fa35060..c6767de2f978 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/device_cooling.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/of.h>
@@ -75,6 +76,7 @@ struct qoriq_tmu_regs {
*/
struct qoriq_tmu_data {
struct thermal_zone_device *tz;
+ struct thermal_cooling_device *cdev;
struct qoriq_tmu_regs __iomem *regs;
int sensor_id;
bool little_endian;
@@ -288,6 +290,30 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
goto err_tmu;
}
+ data->cdev = devfreq_cooling_register();
+ if (IS_ERR(data->cdev)) {
+ ret = PTR_ERR(data->cdev);
+ if (ret != -EPROBE_DEFER)
+ dev_err(&pdev->dev,
+ "failed to register devfreq cooling device: %d\n",
+ ret);
+ return ret;
+ }
+
+ ret = thermal_zone_bind_cooling_device(data->tz,
+ TMU_TRIP_PASSIVE,
+ data->cdev,
+ THERMAL_NO_LIMIT,
+ THERMAL_NO_LIMIT,
+ THERMAL_WEIGHT_DEFAULT);
+ if (ret) {
+ dev_err(&data->tz->device,
+ "binding zone %s with cdev %s failed:%d\n",
+ data->tz->type, data->cdev->type, ret);
+ devfreq_cooling_unregister(data->cdev);
+ return ret;
+ }
+
trip = of_thermal_get_trip_points(data->tz);
data->temp_passive = trip[0].temperature;
data->temp_critical = trip[1].temperature;
@@ -311,6 +337,7 @@ static int qoriq_tmu_remove(struct platform_device *pdev)
{
struct qoriq_tmu_data *data = platform_get_drvdata(pdev);
+ devfreq_cooling_unregister(data->cdev);
thermal_zone_of_sensor_unregister(&pdev->dev, data->tz);
/* Disable monitoring */