aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt7
-rw-r--r--drivers/cpufreq/Kconfig2
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c16
3 files changed, 24 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
index 051f764bedb8..f055515d2b62 100644
--- a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
+++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt
@@ -15,6 +15,10 @@ Optional properties:
15- clock-latency: Specify the possible maximum transition latency for clock, 15- clock-latency: Specify the possible maximum transition latency for clock,
16 in unit of nanoseconds. 16 in unit of nanoseconds.
17- voltage-tolerance: Specify the CPU voltage tolerance in percentage. 17- voltage-tolerance: Specify the CPU voltage tolerance in percentage.
18- #cooling-cells:
19- cooling-min-level:
20- cooling-max-level:
21 Please refer to Documentation/devicetree/bindings/thermal/thermal.txt.
18 22
19Examples: 23Examples:
20 24
@@ -33,6 +37,9 @@ cpus {
33 198000 850000 37 198000 850000
34 >; 38 >;
35 clock-latency = <61036>; /* two CLK32 periods */ 39 clock-latency = <61036>; /* two CLK32 periods */
40 #cooling-cells = <2>;
41 cooling-min-level = <0>;
42 cooling-max-level = <2>;
36 }; 43 };
37 44
38 cpu@1 { 45 cpu@1 {
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 38093e272377..6b8cde5f98af 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -181,7 +181,7 @@ config CPU_FREQ_GOV_CONSERVATIVE
181 181
182config GENERIC_CPUFREQ_CPU0 182config GENERIC_CPUFREQ_CPU0
183 tristate "Generic CPU0 cpufreq driver" 183 tristate "Generic CPU0 cpufreq driver"
184 depends on HAVE_CLK && REGULATOR && PM_OPP && OF 184 depends on HAVE_CLK && REGULATOR && PM_OPP && OF && THERMAL && CPU_THERMAL
185 help 185 help
186 This adds a generic cpufreq driver for CPU0 frequency management. 186 This adds a generic cpufreq driver for CPU0 frequency management.
187 It supports both uniprocessor (UP) and symmetric multiprocessor (SMP) 187 It supports both uniprocessor (UP) and symmetric multiprocessor (SMP)
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index d4585ce2346c..91c7bb67bc74 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -13,7 +13,9 @@
13 13
14#include <linux/clk.h> 14#include <linux/clk.h>
15#include <linux/cpu.h> 15#include <linux/cpu.h>
16#include <linux/cpu_cooling.h>
16#include <linux/cpufreq.h> 17#include <linux/cpufreq.h>
18#include <linux/cpumask.h>
17#include <linux/err.h> 19#include <linux/err.h>
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/of.h> 21#include <linux/of.h>
@@ -21,6 +23,7 @@
21#include <linux/platform_device.h> 23#include <linux/platform_device.h>
22#include <linux/regulator/consumer.h> 24#include <linux/regulator/consumer.h>
23#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/thermal.h>
24 27
25static unsigned int transition_latency; 28static unsigned int transition_latency;
26static unsigned int voltage_tolerance; /* in percentage */ 29static unsigned int voltage_tolerance; /* in percentage */
@@ -29,6 +32,7 @@ static struct device *cpu_dev;
29static struct clk *cpu_clk; 32static struct clk *cpu_clk;
30static struct regulator *cpu_reg; 33static struct regulator *cpu_reg;
31static struct cpufreq_frequency_table *freq_table; 34static struct cpufreq_frequency_table *freq_table;
35static struct thermal_cooling_device *cdev;
32 36
33static unsigned int cpu0_get_speed(unsigned int cpu) 37static unsigned int cpu0_get_speed(unsigned int cpu)
34{ 38{
@@ -201,6 +205,17 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
201 goto out_free_table; 205 goto out_free_table;
202 } 206 }
203 207
208 /*
209 * For now, just loading the cooling device;
210 * thermal DT code takes care of matching them.
211 */
212 if (of_find_property(np, "#cooling-cells", NULL)) {
213 cdev = of_cpufreq_cooling_register(np, cpu_present_mask);
214 if (IS_ERR(cdev))
215 pr_err("running cpufreq without cooling device: %ld\n",
216 PTR_ERR(cdev));
217 }
218
204 of_node_put(np); 219 of_node_put(np);
205 return 0; 220 return 0;
206 221
@@ -213,6 +228,7 @@ out_put_node:
213 228
214static int cpu0_cpufreq_remove(struct platform_device *pdev) 229static int cpu0_cpufreq_remove(struct platform_device *pdev)
215{ 230{
231 cpufreq_cooling_unregister(cdev);
216 cpufreq_unregister_driver(&cpu0_cpufreq_driver); 232 cpufreq_unregister_driver(&cpu0_cpufreq_driver);
217 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 233 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
218 234