14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/list.h>
17 #include <linux/errno.h>
20 #include <linux/device.h>
23 #include <mach/hardware.h>
25 #include <mach/regs-clock.h>
28 #include <plat/clock.h>
69 static const u32 clock_table[][3] = {
76 static unsigned long s5p64x0_armclk_get_rate(
struct clk *
clk)
84 return rate / (clkdiv + 1);
87 static unsigned long s5p64x0_armclk_round_rate(
struct clk *
clk,
92 for (iter = 1 ; iter <
ARRAY_SIZE(clock_table) ; iter++) {
93 if (rate > clock_table[iter][0])
94 return clock_table[iter-1][0];
97 return clock_table[
ARRAY_SIZE(clock_table) - 1][0];
100 static int s5p64x0_armclk_set_rate(
struct clk *clk,
unsigned long rate)
105 u32 cur_rate = clk->
ops->get_rate(clk);
108 round_tmp = clk->
ops->round_rate(clk, rate);
109 if (round_tmp == cur_rate)
113 for (iter = 0 ; iter <
ARRAY_SIZE(clock_table) ; iter++) {
114 if (round_tmp == clock_table[iter][0])
122 if (cur_rate > round_tmp) {
125 clk_div0_tmp |= clock_table[iter][1];
130 clk_div0_tmp |= clock_table[iter][2];
138 clk_div0_tmp |= clock_table[iter][2];
142 clk_div0_tmp |= clock_table[iter][1];
147 clk->
rate = clock_table[iter][0];
152 static struct clk_ops s5p64x0_clkarm_ops = {
153 .get_rate = s5p64x0_armclk_get_rate,
154 .set_rate = s5p64x0_armclk_set_rate,
155 .round_rate = s5p64x0_armclk_round_rate,
162 .parent = &clk_mout_apll.
clk,
163 .ops = &s5p64x0_clkarm_ops,
172 .parent = &clk_mout_mpll.
clk,
177 static struct clk *clkset_hclk_low_list[] = {
183 .sources = clkset_hclk_low_list,
184 .nr_sources =
ARRAY_SIZE(clkset_hclk_low_list),