1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/err.h>
15#include <linux/kernel.h>
16#include <linux/types.h>
17#include <linux/init.h>
18#include <linux/clk.h>
19#include <linux/cpufreq.h>
20
21#include <mach/hardware.h>
22
23static struct cpufreq_driver ucv2_driver;
24
25
26
27
28static int ucv2_verify_speed(struct cpufreq_policy *policy)
29{
30 if (policy->cpu)
31 return -EINVAL;
32
33 cpufreq_verify_within_cpu_limits(policy);
34 return 0;
35}
36
37static int ucv2_target(struct cpufreq_policy *policy,
38 unsigned int target_freq,
39 unsigned int relation)
40{
41 struct cpufreq_freqs freqs;
42 int ret;
43
44 freqs.old = policy->cur;
45 freqs.new = target_freq;
46
47 cpufreq_freq_transition_begin(policy, &freqs);
48 ret = clk_set_rate(policy->clk, target_freq * 1000);
49 cpufreq_freq_transition_end(policy, &freqs, ret);
50
51 return ret;
52}
53
54static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
55{
56 if (policy->cpu != 0)
57 return -EINVAL;
58
59 policy->min = policy->cpuinfo.min_freq = 250000;
60 policy->max = policy->cpuinfo.max_freq = 1000000;
61 policy->clk = clk_get(NULL, "MAIN_CLK");
62 return PTR_ERR_OR_ZERO(policy->clk);
63}
64
65static struct cpufreq_driver ucv2_driver = {
66 .flags = CPUFREQ_STICKY | CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
67 .verify = ucv2_verify_speed,
68 .target = ucv2_target,
69 .get = cpufreq_generic_get,
70 .init = ucv2_cpu_init,
71 .name = "UniCore-II",
72};
73
74static int __init ucv2_cpufreq_init(void)
75{
76 return cpufreq_register_driver(&ucv2_driver);
77}
78
79arch_initcall(ucv2_cpufreq_init);
80