From: Jia Hongtao <hongtao.jia@freescale.com>
To: <edubezval@gmail.com>, <viresh.kumar@linaro.org>
Cc: <linux-pm@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
<devicetree@vger.kernel.org>, <scottwood@freescale.com>,
<hongtao.jia@freescale.com>
Subject: [PATCH] cpufreq: qoriq: Register cooling device based on device tree
Date: Tue, 24 Nov 2015 14:55:29 +0800 [thread overview]
Message-ID: <1448348129-46675-1-git-send-email-hongtao.jia@freescale.com> (raw)
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
next reply other threads:[~2015-11-24 7:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 6:55 Jia Hongtao [this message]
2015-11-24 7:11 ` [PATCH] cpufreq: qoriq: Register cooling device based on device tree Viresh Kumar
2015-11-25 8:00 ` Hongtao Jia
2015-11-24 14:18 ` Scott Wood
2015-11-24 17:24 ` Eduardo Valentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448348129-46675-1-git-send-email-hongtao.jia@freescale.com \
--to=hongtao.jia@freescale.com \
--cc=devicetree@vger.kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=scottwood@freescale.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).