12 #include <linux/module.h>
13 #include <linux/kernel.h>
17 #include <linux/slab.h>
20 #include <mach/regs-clock.h>
21 #include <mach/cpufreq.h>
23 #define CPUFREQ_LEVEL_END (L13 + 1)
25 static int max_support_idx;
28 static struct clk *cpu_clk;
29 static struct clk *moutcore;
30 static struct clk *mout_mpll;
31 static struct clk *mout_apll;
68 { 0, 3, 7, 0, 6, 1, 2, 0 },
71 { 0, 3, 7, 0, 6, 1, 2, 0 },
74 { 0, 3, 7, 0, 5, 1, 2, 0 },
77 { 0, 3, 7, 0, 5, 1, 2, 0 },
80 { 0, 3, 6, 0, 4, 1, 2, 0 },
83 { 0, 2, 5, 0, 4, 1, 1, 0 },
86 { 0, 2, 5, 0, 3, 1, 1, 0 },
89 { 0, 2, 5, 0, 3, 1, 1, 0 },
92 { 0, 2, 4, 0, 3, 1, 1, 0 },
95 { 0, 2, 4, 0, 3, 1, 1, 0 },
98 { 0, 2, 4, 0, 3, 1, 1, 0 },
101 { 0, 2, 4, 0, 3, 1, 1, 0 },
104 { 0, 2, 4, 0, 2, 1, 1, 0 },
107 { 0, 1, 3, 0, 1, 1, 1, 0 },
117 { 0, 3, 7, 0, 6, 1, 2, 0 },
120 { 0, 3, 7, 0, 6, 1, 2, 0 },
123 { 0, 3, 7, 0, 5, 1, 2, 0 },
126 { 0, 3, 7, 0, 5, 1, 2, 0 },
129 { 0, 3, 6, 0, 4, 1, 2, 0 },
132 { 0, 2, 5, 0, 4, 1, 1, 0 },
135 { 0, 2, 5, 0, 3, 1, 1, 0 },
138 { 0, 2, 5, 0, 3, 1, 1, 0 },
141 { 0, 2, 4, 0, 3, 1, 1, 0 },
144 { 0, 2, 4, 0, 3, 1, 1, 0 },
147 { 0, 2, 4, 0, 3, 1, 1, 0 },
150 { 0, 2, 4, 0, 3, 1, 1, 0 },
153 { 0, 2, 4, 0, 2, 1, 1, 0 },
156 { 0, 1, 3, 0, 1, 1, 1, 0 },
255 ((250 << 16) | (4 << 8) | (0x0)),
258 ((175 << 16) | (3 << 8) | (0x0)),
261 ((325 << 16) | (6 << 8) | (0x0)),
264 ((200 << 16) | (4 << 8) | (0x0)),
267 ((275 << 16) | (6 << 8) | (0x0)),
270 ((125 << 16) | (3 << 8) | (0x0)),
273 ((150 << 16) | (4 << 8) | (0x0)),
276 ((100 << 16) | (3 << 8) | (0x0)),
279 ((175 << 16) | (3 << 8) | (0x1)),
282 ((200 << 16) | (4 << 8) | (0x1)),
285 ((125 << 16) | (3 << 8) | (0x1)),
288 ((100 << 16) | (3 << 8) | (0x1)),
291 ((200 << 16) | (4 << 8) | (0x2)),
294 ((100 << 16) | (3 << 8) | (0x2)),
298 1350000, 1287500, 1250000, 1187500, 1137500, 1087500, 1037500,
299 1000000, 987500, 975000, 950000, 925000, 900000, 900000
302 static void exynos4x12_set_clkdiv(
unsigned int div_index)
305 unsigned int stat_cpu1;
309 tmp = exynos4x12_clkdiv_table[div_index].clkdiv;
317 tmp = exynos4x12_clkdiv_table[div_index].clkdiv1;
329 static void exynos4x12_set_apll(
unsigned int index)
331 unsigned int tmp, pdiv;
341 }
while (tmp != 0x2);
344 pdiv = ((exynos4x12_apll_pms_table[
index] >> 8) & 0x3f);
350 tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0));
351 tmp |= exynos4x12_apll_pms_table[
index];
372 unsigned int old_pm = exynos4x12_apll_pms_table[old_index] >> 8;
373 unsigned int new_pm = exynos4x12_apll_pms_table[new_index] >> 8;
375 return (old_pm == new_pm) ? 0 : 1;
378 static void exynos4x12_set_frequency(
unsigned int old_index,
379 unsigned int new_index)
383 if (old_index > new_index) {
386 exynos4x12_set_clkdiv(new_index);
390 tmp |= (exynos4x12_apll_pms_table[new_index] & 0x7);
396 exynos4x12_set_clkdiv(new_index);
398 exynos4x12_set_apll(new_index);
400 }
else if (old_index < new_index) {
405 tmp |= (exynos4x12_apll_pms_table[new_index] & 0x7);
408 exynos4x12_set_clkdiv(new_index);
412 exynos4x12_set_apll(new_index);
414 exynos4x12_set_clkdiv(new_index);
419 static void __init set_volt_table(
void)
423 max_support_idx =
L1;
429 exynos4x12_volt_table[i] = asv_voltage_4x12[i];
442 return PTR_ERR(cpu_clk);
445 if (IS_ERR(moutcore))
449 if (IS_ERR(mout_mpll))
455 if (IS_ERR(mout_apll))
460 exynos4x12_clkdiv_table[
i].index =
i;
493 exynos4x12_clkdiv_table[
i].clkdiv =
tmp;
510 exynos4x12_clkdiv_table[
i].clkdiv1 =
tmp;
521 info->
set_freq = exynos4x12_set_frequency;
533 pr_debug(
"%s: failed initialization\n", __func__);