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.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 653ae2955b55..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,42 +34,34 @@ 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 unsigned int cur = ucv2_getspeed(0);
50 struct cpufreq_freqs freqs; 41 struct cpufreq_freqs freqs;
51 struct clk *mclk = clk_get(NULL, "MAIN_CLK"); 42 int ret;
52 43
53 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); 44 freqs.old = policy->cur;
45 freqs.new = target_freq;
54 46
55 if (!clk_set_rate(mclk, target_freq * 1000)) { 47 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
56 freqs.old = cur; 48 ret = clk_set_rate(policy->mclk, target_freq * 1000);
57 freqs.new = target_freq; 49 cpufreq_notify_post_transition(policy, &freqs, ret);
58 }
59
60 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
61 50
62 return 0; 51 return ret;
63} 52}
64 53
65static int __init ucv2_cpu_init(struct cpufreq_policy *policy) 54static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
66{ 55{
67 if (policy->cpu != 0) 56 if (policy->cpu != 0)
68 return -EINVAL; 57 return -EINVAL;
58
69 policy->min = policy->cpuinfo.min_freq = 250000; 59 policy->min = policy->cpuinfo.min_freq = 250000;
70 policy->max = policy->cpuinfo.max_freq = 1000000; 60 policy->max = policy->cpuinfo.max_freq = 1000000;
71 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);
72 return 0; 65 return 0;
73} 66}
74 67
@@ -76,7 +69,7 @@ static struct cpufreq_driver ucv2_driver = {
76 .flags = CPUFREQ_STICKY, 69 .flags = CPUFREQ_STICKY,
77 .verify = ucv2_verify_speed, 70 .verify = ucv2_verify_speed,
78 .target = ucv2_target, 71 .target = ucv2_target,
79 .get = ucv2_getspeed, 72 .get = cpufreq_generic_get,
80 .init = ucv2_cpu_init, 73 .init = ucv2_cpu_init,
81 .name = "UniCore-II", 74 .name = "UniCore-II",
82}; 75};