20 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <mach/hardware.h>
27 #define CLK32_FREQ 32768
28 #define NANOSECOND (1000 * 1000 * 1000)
32 static int cpu_freq_khz_min;
33 static int cpu_freq_khz_max;
35 static struct clk *cpu_clk;
39 static struct cpu_op *cpu_op_tbl;
41 static int set_cpu_freq(
int freq)
47 if (org_cpu_rate == freq)
67 static unsigned int mxc_get_speed(
unsigned int cpu)
76 unsigned int target_freq,
unsigned int relation)
84 target_freq, relation, &index);
88 freqs.new = freq_Hz / 1000;
93 ret = set_cpu_freq(freq_Hz);
107 if (policy->
cpu != 0)
114 if (IS_ERR(cpu_clk)) {
116 return PTR_ERR(cpu_clk);
121 cpu_freq_khz_min = cpu_op_tbl[0].
cpu_rate / 1000;
122 cpu_freq_khz_max = cpu_op_tbl[0].
cpu_rate / 1000;
127 if (!imx_freq_table) {
132 for (i = 0; i < cpu_op_nr; i++) {
136 if ((cpu_op_tbl[i].cpu_rate / 1000) < cpu_freq_khz_min)
137 cpu_freq_khz_min = cpu_op_tbl[
i].
cpu_rate / 1000;
139 if ((cpu_op_tbl[i].cpu_rate / 1000) > cpu_freq_khz_max)
140 cpu_freq_khz_max = cpu_op_tbl[
i].
cpu_rate / 1000;
147 policy->
min = policy->
cpuinfo.min_freq = cpu_freq_khz_min;
148 policy->
max = policy->
cpuinfo.max_freq = cpu_freq_khz_max;
156 printk(
KERN_ERR "%s: failed to register i.MXC CPUfreq with error code %d\n",
164 kfree(imx_freq_table);
174 set_cpu_freq(cpu_freq_khz_max * 1000);
176 kfree(imx_freq_table);
182 .verify = mxc_verify_speed,
183 .target = mxc_set_target,
184 .get = mxc_get_speed,
185 .init = mxc_cpufreq_init,
186 .exit = mxc_cpufreq_exit,
190 static int __devinit mxc_cpufreq_driver_init(
void)
195 static void mxc_cpufreq_driver_exit(
void)