13 #include <linux/module.h>
14 #include <linux/kernel.h>
16 #include <linux/errno.h>
23 #include <mach/hardware.h>
27 #include <mach/cputype.h>
59 if (clk ==
NULL || IS_ERR(clk))
64 spin_unlock_irqrestore(&clockfw_lock, flags);
74 if (clk ==
NULL || IS_ERR(clk))
79 spin_unlock_irqrestore(&clockfw_lock, flags);
85 if (clk ==
NULL || IS_ERR(clk))
94 if (clk ==
NULL || IS_ERR(clk))
105 static void propagate_rate(
struct clk *root)
121 if (clk ==
NULL || IS_ERR(clk))
133 spin_unlock_irqrestore(&clockfw_lock, flags);
143 if (clk ==
NULL || IS_ERR(clk))
160 spin_unlock_irqrestore(&clockfw_lock, flags);
168 if (clk ==
NULL || IS_ERR(clk))
172 "CLK: %s parent %s has no rate!\n",
202 if (clk ==
NULL || IS_ERR(clk))
212 #ifdef CONFIG_DAVINCI_RESET_CLOCKS
216 int __init davinci_clk_disable_unused(
void)
220 spin_lock_irq(&clockfw_lock);
236 spin_unlock_irq(&clockfw_lock);
242 static unsigned long clk_sysclk_recalc(
struct clk *clk)
261 pll = clk->
parent->pll_data;
303 pll = clk->
parent->pll_data;
305 input = clk->
parent->rate;
319 if (input / ratio > clk->
maxrate)
347 }
while (v & PLLSTAT_GOSTAT);
353 static unsigned long clk_leafclk_recalc(
struct clk *clk)
367 static unsigned long clk_pllclk_recalc(
struct clk *clk)
372 unsigned long rate = clk->
rate;
389 if (prediv & PLLDIV_EN)
401 if (postdiv & PLLDIV_EN)
413 pr_debug(
"PLL%d: input = %lu MHz [ ",
423 pr_debug(
"] --> %lu MHz output.\n", rate / 1000000);
439 unsigned int mult,
unsigned int postdiv)
442 unsigned int locktime;
454 locktime = ((2000 * prediv) / 100);
455 prediv = (prediv - 1) | PLLDIV_EN;
460 postdiv = (postdiv - 1) | PLLDIV_EN;
499 spin_unlock_irqrestore(&clockfw_lock, flags);
525 if (IS_ERR(refclk)) {
526 pr_err(
"%s: failed to get reference clock.\n", __func__);
527 return PTR_ERR(refclk);
541 size_t num_clocks = 0;
543 for (c = clocks; c->
clk; c++) {
550 clk->
recalc = clk_pllclk_recalc;
554 clk->
recalc = clk_sysclk_recalc;
558 clk->
recalc = clk_leafclk_recalc;
592 #ifdef CONFIG_DEBUG_FS
597 #define CLKNAME_MAX 10
602 dump_clock(
struct seq_file *
s,
unsigned nest,
struct clk *parent)
605 char buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
617 memset(buf,
' ',
sizeof(buf) - 1);
618 buf[
sizeof(
buf) - 1] = 0;
621 min(i, (
unsigned)(
sizeof(buf) - 1 - nest)));
629 dump_clock(s, nest + NEST_DELTA, clk);
633 static int davinci_ck_show(
struct seq_file *
m,
void *v)
643 dump_clock(m, 0, clk);
655 .
open = davinci_ck_open,
661 static int __init davinci_clk_debugfs_init(
void)
664 &davinci_ck_operations);