18 #include <linux/module.h>
24 #include <asm/clock.h>
52 if (clk ==
NULL || IS_ERR(clk))
57 spin_unlock_irqrestore(&clockfw_lock, flags);
67 if (clk ==
NULL || IS_ERR(clk))
72 spin_unlock_irqrestore(&clockfw_lock, flags);
78 if (clk ==
NULL || IS_ERR(clk))
87 if (clk ==
NULL || IS_ERR(clk))
114 if (clk ==
NULL || IS_ERR(clk))
126 spin_unlock_irqrestore(&clockfw_lock, flags);
136 if (clk ==
NULL || IS_ERR(clk))
153 spin_unlock_irqrestore(&clockfw_lock, flags);
161 if (clk ==
NULL || IS_ERR(clk))
165 "CLK: %s parent %s has no rate!\n",
193 if (clk ==
NULL || IS_ERR(clk))
209 static unsigned long clk_sysclk_recalc(
struct clk *clk)
224 pll = clk->
parent->pll_data;
231 pr_debug(
"%s: (no divider) rate = %lu KHz\n",
232 clk->
name, rate / 1000);
238 pr_debug(
"%s: (fixed divide by %d) rate = %lu KHz\n",
239 clk->
name, clk->
div, rate / 1000);
243 v = pll_read(pll, clk->
div);
252 pr_debug(
"%s: (divide by %d) rate = %lu KHz\n",
253 clk->
name, plldiv, rate / 1000);
258 static unsigned long clk_leafclk_recalc(
struct clk *clk)
263 pr_debug(
"%s: (parent %s) rate = %lu KHz\n",
269 static unsigned long clk_pllclk_recalc(
struct clk *clk)
274 unsigned long rate = clk->
rate;
279 ctrl = pll_read(pll,
PLLCTL);
288 mult = pll_read(pll,
PLLM);
292 prediv = pll_read(pll,
PLLPRE);
293 if (prediv & PLLDIV_EN)
299 postdiv = pll_read(pll,
PLLPOST);
300 if (postdiv & PLLDIV_EN)
314 pr_debug(
"PLL%d: input = %luMHz, pre[%d] mul[%d] post[%d] "
315 "--> %luMHz output.\n",
317 prediv, mult, postdiv, rate / 1000000);
319 pr_debug(
"PLL%d: input = %luMHz, bypass mode.\n",
326 static void __init __init_clk(
struct clk *clk)
328 INIT_LIST_HEAD(&clk->
node);
336 clk->
recalc = clk_pllclk_recalc;
340 clk->
recalc = clk_sysclk_recalc;
344 clk->
recalc = clk_leafclk_recalc;
352 size_t num_clocks = 0;
354 for (c = clocks; c->
clk; c++) {
369 #ifdef CONFIG_DEBUG_FS
374 #define CLKNAME_MAX 10
382 char buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
392 memset(buf,
' ',
sizeof(buf) - 1);
393 buf[
sizeof(
buf) - 1] = 0;
396 min(i, (
unsigned)(
sizeof(buf) - 1 - nest)));
404 dump_clock(s, nest + NEST_DELTA, clk);
408 static int c6x_ck_show(
struct seq_file *
m,
void *v)
418 dump_clock(m, 0, clk);
436 static int __init c6x_clk_debugfs_init(
void)