linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: qoriq: Register cooling device based on device tree
@ 2015-11-24  6:55 Jia Hongtao
  2015-11-24  7:11 ` Viresh Kumar
  2015-11-24 14:18 ` Scott Wood
  0 siblings, 2 replies; 5+ messages in thread
From: Jia Hongtao @ 2015-11-24  6:55 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: Scott Wood <scottwood@freescale.com>
---
This patch depends on following patches from Scott Wood:
http://patchwork.ozlabs.org/patch/519803/
http://patchwork.ozlabs.org/patch/519804/

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

diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 4f53fa2..cb1bc3c 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;
 };
 
 /*
@@ -292,7 +294,11 @@ static const struct of_device_id node_matches[] __initconst = {
 static int __init qoriq_cpufreq_init(void)
 {
 	int ret;
-	struct device_node  *np;
+	struct device_node *np;
+	struct device_node *cpu_np;
+	unsigned int cpu_id;
+	struct cpufreq_policy cpu_policy;
+	struct cpu_data *cpud;
 	const struct of_device_id *match;
 	const struct soc_data *data;
 
@@ -309,6 +315,22 @@ static int __init qoriq_cpufreq_init(void)
 		return -ENODEV;
 
 	ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
+
+	/* Register CPU cooling device for QorIQ platform */
+	for_each_node_with_property(cpu_np, "#cooling-cells") {
+		of_property_read_u32(cpu_np, "reg", &cpu_id);
+		cpufreq_get_policy(&cpu_policy, cpu_id);
+
+		cpud = cpu_policy.driver_data;
+		cpud->cdev = of_cpufreq_cooling_register(cpu_np,
+						cpu_policy.related_cpus);
+		if (IS_ERR(cpud->cdev) && ERR_PTR(cpud->cdev) != -ENOSYS)
+			pr_err("Failed to register cooling device cpu%d: %ld\n",
+			       cpu_id, PTR_ERR(cpud->cdev));
+	}
+
+	of_node_put(cpu_np);
+
 	if (!ret)
 		pr_info("Freescale QorIQ CPU frequency scaling driver\n");
 
-- 
2.1.0.27.g96db324

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

* Re: [PATCH] cpufreq: qoriq: Register cooling device based on device tree
  2015-11-24  6:55 [PATCH] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
@ 2015-11-24  7:11 ` Viresh Kumar
  2015-11-25  8:00   ` Hongtao Jia
  2015-11-24 14:18 ` Scott Wood
  1 sibling, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2015-11-24  7:11 UTC (permalink / raw)
  To: Jia Hongtao; +Cc: edubezval, linux-pm, linuxppc-dev, devicetree, scottwood

On 24-11-15, 14:55, Jia Hongtao wrote:
> +	/* Register CPU cooling device for QorIQ platform */
> +	for_each_node_with_property(cpu_np, "#cooling-cells") {
> +		of_property_read_u32(cpu_np, "reg", &cpu_id);
> +		cpufreq_get_policy(&cpu_policy, cpu_id);

That's not the right way to do it. You already have DT node for the
CPU, look at how it is done from ->ready() callback for cpufreq-dt.

-- 
viresh

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

* Re: [PATCH] cpufreq: qoriq: Register cooling device based on device tree
  2015-11-24  6:55 [PATCH] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
  2015-11-24  7:11 ` Viresh Kumar
@ 2015-11-24 14:18 ` Scott Wood
  2015-11-24 17:24   ` Eduardo Valentin
  1 sibling, 1 reply; 5+ messages in thread
From: Scott Wood @ 2015-11-24 14:18 UTC (permalink / raw)
  To: Jia Hongtao, edubezval, viresh.kumar; +Cc: linux-pm, linuxppc-dev, devicetree

On Tue, 2015-11-24 at 14:55 +0800, Jia Hongtao wrote:
> 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: Scott Wood <scottwood@freescale.com>

When did I add "Reviewed-by" to this?

-Scott

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

* Re: [PATCH] cpufreq: qoriq: Register cooling device based on device tree
  2015-11-24 14:18 ` Scott Wood
@ 2015-11-24 17:24   ` Eduardo Valentin
  0 siblings, 0 replies; 5+ messages in thread
From: Eduardo Valentin @ 2015-11-24 17:24 UTC (permalink / raw)
  To: Scott Wood; +Cc: Jia Hongtao, viresh.kumar, linux-pm, linuxppc-dev, devicetree

On Tue, Nov 24, 2015 at 08:18:17AM -0600, Scott Wood wrote:
> On Tue, 2015-11-24 at 14:55 +0800, Jia Hongtao wrote:
> > 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.
> >=20
> > Signed-off-by: Jia Hongtao <hongtao.jia@freescale.com>
> > Reviewed-by: Scott Wood <scottwood@freescale.com>
>=20
> When did I add "Reviewed-by" to this?

This is typically why I prefer seeing people emailing their reviewed-by
and acked-by to the mailing list in reply to the patch itself, instead
of getting a patch with all the honors already added. :-/

>=20
> -Scott
>=20

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

* RE: [PATCH] cpufreq: qoriq: Register cooling device based on device tree
  2015-11-24  7:11 ` Viresh Kumar
@ 2015-11-25  8:00   ` Hongtao Jia
  0 siblings, 0 replies; 5+ messages in thread
From: Hongtao Jia @ 2015-11-25  8:00 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: edubezval@gmail.com, linux-pm@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org,
	Scott Wood



> -----Original Message-----
> From: Viresh Kumar [mailto:viresh.kumar@linaro.org]
> Sent: Tuesday, November 24, 2015 3:11 PM
> To: Jia Hongtao-B38951
> Cc: edubezval@gmail.com; linux-pm@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; devicetree@vger.kernel.org; Wood Scott-B07421
> Subject: Re: [PATCH] cpufreq: qoriq: Register cooling device based on
> device tree
>=20
> On 24-11-15, 14:55, Jia Hongtao wrote:
> > +	/* Register CPU cooling device for QorIQ platform */
> > +	for_each_node_with_property(cpu_np, "#cooling-cells") {
> > +		of_property_read_u32(cpu_np, "reg", &cpu_id);
> > +		cpufreq_get_policy(&cpu_policy, cpu_id);
>=20
> That's not the right way to do it. You already have DT node for the CPU,
> look at how it is done from ->ready() callback for cpufreq-dt.
>=20
> --
> viresh

Thanks.

I made a new patch to use ->ready callback for cpu cooling registration.
I will send V2 after test.

-Hongtao.

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

end of thread, other threads:[~2015-11-25  8:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24  6:55 [PATCH] cpufreq: qoriq: Register cooling device based on device tree Jia Hongtao
2015-11-24  7:11 ` Viresh Kumar
2015-11-25  8:00   ` Hongtao Jia
2015-11-24 14:18 ` Scott Wood
2015-11-24 17:24   ` Eduardo Valentin

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).