summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/imx_thermal.c
diff options
context:
space:
mode:
authorBastian Stender2018-06-08 11:06:39 +0200
committerRafael J. Wysocki2018-07-02 11:26:36 +0200
commita1d0015423920672c3f32e69bd9feef2ec629b57 (patch)
tree59141b92e8d8fcb30c54cadf3617e9574f4b0e62 /drivers/thermal/imx_thermal.c
parentcpufreq: intel_pstate: use match_string() helper (diff)
downloadkernel-qcow2-linux-a1d0015423920672c3f32e69bd9feef2ec629b57.tar.gz
kernel-qcow2-linux-a1d0015423920672c3f32e69bd9feef2ec629b57.tar.xz
kernel-qcow2-linux-a1d0015423920672c3f32e69bd9feef2ec629b57.zip
cpufreq: imx6q/thermal: imx: register cooling device depending on OF
The cooling device should be part of the i.MX cpufreq driver, but it cannot be removed for the sake of DT stability. So turn the cooling device registration into a separate function and perform the registration only if the CPU OF node does not have the #cooling-cells property. Use of_cpufreq_power_cooling_register in imx_thermal code to link the cooling device to the device tree node provided. This makes it possible to bind the cpufreq cooling device to a custom thermal zone via a cooling-maps entry like: cooling-maps { map0 { trip = <&board_alert>; cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; }; }; Assuming a cpu node exists with label "cpu0" and #cooling-cells property. Signed-off-by: Bastian Stender <bst@pengutronix.de> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/thermal/imx_thermal.c')
-rw-r--r--drivers/thermal/imx_thermal.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 334d98be03b9..cbfcca828cd7 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -3,6 +3,7 @@
// Copyright 2013 Freescale Semiconductor, Inc.
#include <linux/clk.h>
+#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/cpu_cooling.h>
#include <linux/delay.h>
@@ -644,6 +645,27 @@ static const struct of_device_id of_imx_thermal_match[] = {
};
MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
+/*
+ * Create cooling device in case no #cooling-cells property is available in
+ * CPU node
+ */
+static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
+{
+ struct device_node *np = of_get_cpu_node(data->policy->cpu, NULL);
+ int ret;
+
+ if (!np || !of_find_property(np, "#cooling-cells", NULL)) {
+ data->cdev = cpufreq_cooling_register(data->policy);
+ if (IS_ERR(data->cdev)) {
+ ret = PTR_ERR(data->cdev);
+ cpufreq_cpu_put(data->policy);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static int imx_thermal_probe(struct platform_device *pdev)
{
struct imx_thermal_data *data;
@@ -724,12 +746,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
}
- data->cdev = cpufreq_cooling_register(data->policy);
- if (IS_ERR(data->cdev)) {
- ret = PTR_ERR(data->cdev);
+ ret = imx_thermal_register_legacy_cooling(data);
+ if (ret) {
dev_err(&pdev->dev,
"failed to register cpufreq cooling device: %d\n", ret);
- cpufreq_cpu_put(data->policy);
return ret;
}