linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree
@ 2015-11-26  9:21 Jia Hongtao
  2015-12-14 23:58 ` Rafael J. Wysocki
  0 siblings, 1 reply; 17+ messages in thread
From: Jia Hongtao @ 2015-11-26  9:21 UTC (permalink / raw)
  To: edubezval, viresh.kumar
  Cc: linux-pm, linuxppc-dev, devicetree, scottwood, hongtao.jia

Register the qoriq cpufreq driver as a cooling device, based on the
thermal device tree framework. When temperature crosses the passive trip
point cpufreq is used to throttle CPUs.

Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Changes for V3:
* Removed unnecessary cpu node NULL check.

Changes for V2:
* Using ->ready callback for cpu cooling device registering.

 drivers/cpufreq/qoriq-cpufreq.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 4f53fa2..cb6a62c 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -12,6 +12,7 @@
 
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
+#include <linux/cpu_cooling.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -33,6 +34,7 @@
 struct cpu_data {
 	struct clk **pclk;
 	struct cpufreq_frequency_table *table;
+	struct thermal_cooling_device *cdev;
 };
 
 /*
@@ -260,6 +262,27 @@ static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
 	return clk_set_parent(policy->clk, parent);
 }
 
+
+static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)
+{
+	struct cpu_data *cpud = policy->driver_data;
+	struct device_node *np = of_get_cpu_node(policy->cpu, NULL);
+
+	if (of_find_property(np, "#cooling-cells", NULL)) {
+		cpud->cdev = of_cpufreq_cooling_register(np,
+							 policy->related_cpus);
+
+		if (IS_ERR(cpud->cdev)) {
+			pr_err("Failed to register cooling device cpu%d: %ld\n",
+					policy->cpu, PTR_ERR(cpud->cdev));
+
+			cpud->cdev = NULL;
+		}
+	}
+
+	of_node_put(np);
+}
+
 static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.name		= "qoriq_cpufreq",
 	.flags		= CPUFREQ_CONST_LOOPS,
@@ -268,6 +291,7 @@ static struct cpufreq_driver qoriq_cpufreq_driver = {
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qoriq_cpufreq_target,
 	.get		= cpufreq_generic_get,
+	.ready		= qoriq_cpufreq_ready,
 	.attr		= cpufreq_generic_attr,
 };
 
-- 
2.1.0.27.g96db324

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-02-29 14:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-26  9:21 [PATCH V3] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
2015-12-14 23:58 ` Rafael J. Wysocki
2015-12-18 22:32   ` Arnd Bergmann
2016-01-11 14:54     ` 答复: " Hongtao Jia
2016-01-11 17:34       ` Scott Wood
2016-01-11 21:13         ` Arnd Bergmann
2016-02-26 18:04     ` Li Yang
2016-02-26 20:20       ` Arnd Bergmann
2016-02-26 23:07         ` Li Yang
2016-02-26 23:16           ` Arnd Bergmann
2016-02-26 23:31             ` Li Yang
2016-02-27  0:04               ` Li Yang
2016-02-27  0:08                 ` Scott Wood
2016-02-27  0:41                   ` Li Yang
2016-02-29 10:05                     ` Arnd Bergmann
2016-02-29 14:33                       ` Rafael J. Wysocki
2016-02-29 14:39                         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).