14 #include <linux/kernel.h>
15 #include <linux/list.h>
16 #include <linux/errno.h>
26 #include <plat/clock.h>
30 #include <mach/hardware.h>
46 return val & clk->
enable_bit ? 48000000 : 12000000;
53 div = (div >> 17) & 0x7;
59 static void omap1_clk_allow_idle(
struct clk *
clk)
70 static void omap1_clk_deny_idle(
struct clk *clk)
110 if (dspmmu_exp < dsp_exp)
111 dspmmu_exp = dsp_exp;
112 if (dspmmu_exp > dsp_exp+1)
113 dspmmu_exp = dsp_exp+1;
114 if (tc_exp < arm_exp)
116 if (tc_exp < dspmmu_exp)
118 if (tc_exp > lcd_exp)
120 if (tc_exp > per_exp)
134 static int calc_dsor_exp(
struct clk *clk,
unsigned long rate)
147 unsigned long realrate;
155 realrate = parent->
rate;
156 for (dsor_exp=0; dsor_exp<4; dsor_exp++) {
157 if (realrate <= rate)
171 return clk->
parent->rate / dsor;
189 return clk->
parent->rate / dsor;
197 unsigned long ref_rate;
199 ref_rate = ck_ref_p->
rate;
205 if (ptr->
xtal != ref_rate)
209 if (ptr->
rate <= rate)
233 dsor_exp = calc_dsor_exp(clk, rate);
243 clk->
rate = clk->
parent->rate / (1 << dsor_exp);
250 int dsor_exp = calc_dsor_exp(clk, rate);
255 return clk->
parent->rate / (1 << dsor_exp);
263 dsor_exp = calc_dsor_exp(clk, rate);
272 regval = verify_ckctl_value(regval);
274 clk->
rate = clk->
parent->rate / (1 << dsor_exp);
283 unsigned long ref_rate;
285 ref_rate = ck_ref_p->
rate;
293 if (ptr->
xtal != ref_rate)
296 highest_rate = ptr->
rate;
299 if (ptr->
rate <= rate)
306 static unsigned calc_ext_dsor(
unsigned long rate)
319 for (dsor = 2; dsor < 96; ++dsor) {
320 if ((dsor & 1) && dsor > 8)
322 if (rate >= 96000000 / dsor)
334 if (rate == 12000000)
336 else if (rate == 48000000)
352 dsor = calc_ext_dsor(rate);
353 clk->
rate = 96000000 / dsor;
355 ratio_bits = ((dsor - 8) / 2 + 6) << 2;
357 ratio_bits = (dsor - 2) << 2;
369 unsigned long p_rate;
371 p_rate = clk->
parent->rate;
373 div = (p_rate + rate - 1) / rate;
375 if (div < 0 || div > 7)
383 clk->
rate = p_rate / (div + 1);
390 return 96000000 / calc_ext_dsor(rate);
402 ratio_bits = (ratio_bits & 0xfc) >> 2;
404 dsor = (ratio_bits - 6) * 2 + 8;
406 dsor = ratio_bits + 2;
408 clk-> rate = 96000000 / dsor;
422 omap1_clk_deny_idle(clk->
parent);
425 ret = clk->
ops->enable(clk);
442 clk->
ops->disable(clk);
446 omap1_clk_allow_idle(clk->
parent);
451 static int omap1_clk_enable_generic(
struct clk *clk)
475 static void omap1_clk_disable_generic(
struct clk *clk)
495 .enable = omap1_clk_enable_generic,
496 .disable = omap1_clk_disable_generic,
499 static int omap1_clk_enable_dsp_domain(
struct clk *clk)
505 retval = omap1_clk_enable_generic(clk);
512 static void omap1_clk_disable_dsp_domain(
struct clk *clk)
515 omap1_clk_disable_generic(clk);
521 .enable = omap1_clk_enable_dsp_domain,
522 .disable = omap1_clk_disable_dsp_domain,
526 static int omap1_clk_enable_uart_functional_16xx(
struct clk *clk)
531 ret = omap1_clk_enable_generic(clk);
543 static void omap1_clk_disable_uart_functional_16xx(
struct clk *clk)
551 omap1_clk_disable_generic(clk);
556 .enable = omap1_clk_enable_uart_functional_16xx,
557 .disable = omap1_clk_disable_uart_functional_16xx,
581 #ifdef CONFIG_OMAP_RESET_CLOCKS
590 pr_info(
"Skipping reset check for DSP domain clock \"%s\"\n",
605 clk->
ops->disable(clk);