From f891996fc9af3f65791d4eb15ec42f19e0b4425e Mon Sep 17 00:00:00 2001 From: Anson Huang Date: Tue, 1 Aug 2017 15:53:31 +0800 Subject: [PATCH] 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 --- drivers/thermal/qoriq_thermal.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 4b1be03f21fe..8ea3b2b4b398 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -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 */ -- 2.17.1