aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/unicore2-cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/unicore2-cpufreq.c')
-rw-r--r--drivers/cpufreq/unicore2-cpufreq.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 86f6cfec2e09..36cc330b8747 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -11,6 +11,7 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14#include <linux/err.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/types.h> 16#include <linux/types.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -33,28 +34,18 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy)
33 return 0; 34 return 0;
34} 35}
35 36
36static unsigned int ucv2_getspeed(unsigned int cpu)
37{
38 struct clk *mclk = clk_get(NULL, "MAIN_CLK");
39
40 if (cpu)
41 return 0;
42 return clk_get_rate(mclk)/1000;
43}
44
45static int ucv2_target(struct cpufreq_policy *policy, 37static int ucv2_target(struct cpufreq_policy *policy,
46 unsigned int target_freq, 38 unsigned int target_freq,
47 unsigned int relation) 39 unsigned int relation)
48{ 40{
49 struct cpufreq_freqs freqs; 41 struct cpufreq_freqs freqs;
50 struct clk *mclk = clk_get(NULL, "MAIN_CLK");
51 int ret; 42 int ret;
52 43
53 freqs.old = policy->cur; 44 freqs.old = policy->cur;
54 freqs.new = target_freq; 45 freqs.new = target_freq;
55 46
56 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); 47 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
57 ret = clk_set_rate(mclk, target_freq * 1000); 48 ret = clk_set_rate(policy->mclk, target_freq * 1000);
58 cpufreq_notify_post_transition(policy, &freqs, ret); 49 cpufreq_notify_post_transition(policy, &freqs, ret);
59 50
60 return ret; 51 return ret;
@@ -64,9 +55,13 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
64{ 55{
65 if (policy->cpu != 0) 56 if (policy->cpu != 0)
66 return -EINVAL; 57 return -EINVAL;
58
67 policy->min = policy->cpuinfo.min_freq = 250000; 59 policy->min = policy->cpuinfo.min_freq = 250000;
68 policy->max = policy->cpuinfo.max_freq = 1000000; 60 policy->max = policy->cpuinfo.max_freq = 1000000;
69 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; 61 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
62 policy->clk = clk_get(NULL, "MAIN_CLK");
63 if (IS_ERR(policy->clk))
64 return PTR_ERR(policy->clk);
70 return 0; 65 return 0;
71} 66}
72 67
@@ -74,7 +69,7 @@ static struct cpufreq_driver ucv2_driver = {
74 .flags = CPUFREQ_STICKY, 69 .flags = CPUFREQ_STICKY,
75 .verify = ucv2_verify_speed, 70 .verify = ucv2_verify_speed,
76 .target = ucv2_target, 71 .target = ucv2_target,
77 .get = ucv2_getspeed, 72 .get = cpufreq_generic_get,
78 .init = ucv2_cpu_init, 73 .init = ucv2_cpu_init,
79 .name = "UniCore-II", 74 .name = "UniCore-II",
80}; 75};