aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongtao Jia <hongtao.jia@freescale.com>2015-11-26 04:21:11 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-12-09 18:19:35 -0500
commit8ae1702a0df5e0730607b97fd9fd1f8066870832 (patch)
tree6f270c2c367eb7256a2fc50f8e7fc8e7e1297511
parent790d849bf811a8ab5d4cd2cce0f6fda92f6aebf2 (diff)
cpufreq: qoriq: Register cooling device based on device tree
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> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpufreq/qoriq-cpufreq.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/cpufreq/qoriq-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 358f0752c31e..b23e525a7af3 100644
--- a/drivers/cpufreq/qoriq-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/cpufreq.h> 14#include <linux/cpufreq.h>
15#include <linux/cpu_cooling.h>
15#include <linux/errno.h> 16#include <linux/errno.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
@@ -33,6 +34,7 @@
33struct cpu_data { 34struct cpu_data {
34 struct clk **pclk; 35 struct clk **pclk;
35 struct cpufreq_frequency_table *table; 36 struct cpufreq_frequency_table *table;
37 struct thermal_cooling_device *cdev;
36}; 38};
37 39
38/** 40/**
@@ -321,6 +323,27 @@ static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
321 return clk_set_parent(policy->clk, parent); 323 return clk_set_parent(policy->clk, parent);
322} 324}
323 325
326
327static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)
328{
329 struct cpu_data *cpud = policy->driver_data;
330 struct device_node *np = of_get_cpu_node(policy->cpu, NULL);
331
332 if (of_find_property(np, "#cooling-cells", NULL)) {
333 cpud->cdev = of_cpufreq_cooling_register(np,
334 policy->related_cpus);
335
336 if (IS_ERR(cpud->cdev)) {
337 pr_err("Failed to register cooling device cpu%d: %ld\n",
338 policy->cpu, PTR_ERR(cpud->cdev));
339
340 cpud->cdev = NULL;
341 }
342 }
343
344 of_node_put(np);
345}
346
324static struct cpufreq_driver qoriq_cpufreq_driver = { 347static struct cpufreq_driver qoriq_cpufreq_driver = {
325 .name = "qoriq_cpufreq", 348 .name = "qoriq_cpufreq",
326 .flags = CPUFREQ_CONST_LOOPS, 349 .flags = CPUFREQ_CONST_LOOPS,
@@ -329,6 +352,7 @@ static struct cpufreq_driver qoriq_cpufreq_driver = {
329 .verify = cpufreq_generic_frequency_table_verify, 352 .verify = cpufreq_generic_frequency_table_verify,
330 .target_index = qoriq_cpufreq_target, 353 .target_index = qoriq_cpufreq_target,
331 .get = cpufreq_generic_get, 354 .get = cpufreq_generic_get,
355 .ready = qoriq_cpufreq_ready,
332 .attr = cpufreq_generic_attr, 356 .attr = cpufreq_generic_attr,
333}; 357};
334 358