aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2012-01-27 05:44:49 -0500
committerPaul Mundt <lethal@linux-sh.org>2012-01-27 05:44:49 -0500
commitecbef17adbbbe89eb6b3e4d4e5b756d63041319c (patch)
tree85b644cc988fa9afaa068154ef57313f234a5d7e /arch/sh
parent3bccf467727c82421e5f7b630c9bb864ebe8d2e6 (diff)
sh: cpufreq: struct device lookup from CPU topology.
The struct device pointer associated with the CPU we're on can be fetched via the topology information. Tie this in to localize the CPU clock lookup. While we're at it, tidy up some of the debug/info printing notices too. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r--arch/sh/kernel/cpufreq.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/arch/sh/kernel/cpufreq.c b/arch/sh/kernel/cpufreq.c
index 8203865e16b7..66dbb74546c3 100644
--- a/arch/sh/kernel/cpufreq.c
+++ b/arch/sh/kernel/cpufreq.c
@@ -14,6 +14,8 @@
14 * License. See the file "COPYING" in the main directory of this archive 14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details. 15 * for more details.
16 */ 16 */
17#define pr_fmt(fmt) "cpufreq: " fmt
18
17#include <linux/types.h> 19#include <linux/types.h>
18#include <linux/cpufreq.h> 20#include <linux/cpufreq.h>
19#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -21,6 +23,7 @@
21#include <linux/init.h> 23#include <linux/init.h>
22#include <linux/err.h> 24#include <linux/err.h>
23#include <linux/cpumask.h> 25#include <linux/cpumask.h>
26#include <linux/cpu.h>
24#include <linux/smp.h> 27#include <linux/smp.h>
25#include <linux/sched.h> /* set_cpus_allowed() */ 28#include <linux/sched.h> /* set_cpus_allowed() */
26#include <linux/clk.h> 29#include <linux/clk.h>
@@ -45,6 +48,7 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
45 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu); 48 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu);
46 cpumask_t cpus_allowed; 49 cpumask_t cpus_allowed;
47 struct cpufreq_freqs freqs; 50 struct cpufreq_freqs freqs;
51 struct device *dev;
48 long freq; 52 long freq;
49 53
50 if (!cpu_online(cpu)) 54 if (!cpu_online(cpu))
@@ -55,13 +59,15 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
55 59
56 BUG_ON(smp_processor_id() != cpu); 60 BUG_ON(smp_processor_id() != cpu);
57 61
62 dev = get_cpu_device(cpu);
63
58 /* Convert target_freq from kHz to Hz */ 64 /* Convert target_freq from kHz to Hz */
59 freq = clk_round_rate(cpuclk, target_freq * 1000); 65 freq = clk_round_rate(cpuclk, target_freq * 1000);
60 66
61 if (freq < (policy->min * 1000) || freq > (policy->max * 1000)) 67 if (freq < (policy->min * 1000) || freq > (policy->max * 1000))
62 return -EINVAL; 68 return -EINVAL;
63 69
64 pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000); 70 dev_dbg(dev, "requested frequency %u Hz\n", target_freq * 1000);
65 71
66 freqs.cpu = cpu; 72 freqs.cpu = cpu;
67 freqs.old = sh_cpufreq_get(cpu); 73 freqs.old = sh_cpufreq_get(cpu);
@@ -73,7 +79,7 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy,
73 clk_set_rate(cpuclk, freq); 79 clk_set_rate(cpuclk, freq);
74 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 80 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
75 81
76 pr_debug("cpufreq: set frequency %lu Hz\n", freq); 82 dev_dbg(dev, "set frequency %lu Hz\n", freq);
77 83
78 return 0; 84 return 0;
79} 85}
@@ -82,13 +88,16 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
82{ 88{
83 unsigned int cpu = policy->cpu; 89 unsigned int cpu = policy->cpu;
84 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu); 90 struct clk *cpuclk = &per_cpu(sh_cpuclk, cpu);
91 struct device *dev;
85 92
86 if (!cpu_online(cpu)) 93 if (!cpu_online(cpu))
87 return -ENODEV; 94 return -ENODEV;
88 95
89 cpuclk = clk_get(NULL, "cpu_clk"); 96 dev = get_cpu_device(cpu);
97
98 cpuclk = clk_get(dev, "cpu_clk");
90 if (IS_ERR(cpuclk)) { 99 if (IS_ERR(cpuclk)) {
91 printk(KERN_ERR "cpufreq: couldn't get CPU#%d clk\n", cpu); 100 dev_err(dev, "couldn't get CPU clk\n");
92 return PTR_ERR(cpuclk); 101 return PTR_ERR(cpuclk);
93 } 102 }
94 103
@@ -106,16 +115,14 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
106 * properly to support scaling. 115 * properly to support scaling.
107 */ 116 */
108 if (unlikely(policy->min == policy->max)) { 117 if (unlikely(policy->min == policy->max)) {
109 printk(KERN_ERR "cpufreq: clock framework rate rounding " 118 dev_err(dev, "rate rounding not supported on this CPU.\n");
110 "not supported on CPU#%d.\n", cpu);
111
112 clk_put(cpuclk); 119 clk_put(cpuclk);
113 return -EINVAL; 120 return -EINVAL;
114 } 121 }
115 122
116 printk(KERN_INFO "cpufreq: CPU#%d Frequencies - Minimum %u.%03u MHz, " 123 dev_info(dev, "CPU Frequencies - Minimum %u.%03u MHz, "
117 "Maximum %u.%03u MHz.\n", 124 "Maximum %u.%03u MHz.\n",
118 cpu, policy->min / 1000, policy->min % 1000, 125 policy->min / 1000, policy->min % 1000,
119 policy->max / 1000, policy->max % 1000); 126 policy->max / 1000, policy->max % 1000);
120 127
121 return 0; 128 return 0;
@@ -147,7 +154,7 @@ static struct cpufreq_driver sh_cpufreq_driver = {
147 154
148static int __init sh_cpufreq_module_init(void) 155static int __init sh_cpufreq_module_init(void)
149{ 156{
150 printk(KERN_INFO "cpufreq: SuperH CPU frequency driver.\n"); 157 pr_notice("SuperH CPU frequency driver.\n");
151 return cpufreq_register_driver(&sh_cpufreq_driver); 158 return cpufreq_register_driver(&sh_cpufreq_driver);
152} 159}
153 160