diff options
Diffstat (limited to 'arch/arm/mach-davinci/clock.c')
-rw-r--r-- | arch/arm/mach-davinci/clock.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c index e4e3af179f02..00861139101d 100644 --- a/arch/arm/mach-davinci/clock.c +++ b/arch/arm/mach-davinci/clock.c | |||
@@ -44,7 +44,7 @@ static void __clk_enable(struct clk *clk) | |||
44 | __clk_enable(clk->parent); | 44 | __clk_enable(clk->parent); |
45 | if (clk->usecount++ == 0 && (clk->flags & CLK_PSC)) | 45 | if (clk->usecount++ == 0 && (clk->flags & CLK_PSC)) |
46 | davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, | 46 | davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, |
47 | PSC_STATE_ENABLE); | 47 | true, clk->flags); |
48 | } | 48 | } |
49 | 49 | ||
50 | static void __clk_disable(struct clk *clk) | 50 | static void __clk_disable(struct clk *clk) |
@@ -54,8 +54,7 @@ static void __clk_disable(struct clk *clk) | |||
54 | if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) && | 54 | if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) && |
55 | (clk->flags & CLK_PSC)) | 55 | (clk->flags & CLK_PSC)) |
56 | davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, | 56 | davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, |
57 | (clk->flags & PSC_SWRSTDISABLE) ? | 57 | false, clk->flags); |
58 | PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE); | ||
59 | if (clk->parent) | 58 | if (clk->parent) |
60 | __clk_disable(clk->parent); | 59 | __clk_disable(clk->parent); |
61 | } | 60 | } |
@@ -239,8 +238,7 @@ static int __init clk_disable_unused(void) | |||
239 | pr_debug("Clocks: disable unused %s\n", ck->name); | 238 | pr_debug("Clocks: disable unused %s\n", ck->name); |
240 | 239 | ||
241 | davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc, | 240 | davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc, |
242 | (ck->flags & PSC_SWRSTDISABLE) ? | 241 | false, ck->flags); |
243 | PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE); | ||
244 | } | 242 | } |
245 | spin_unlock_irq(&clockfw_lock); | 243 | spin_unlock_irq(&clockfw_lock); |
246 | 244 | ||
@@ -368,6 +366,12 @@ static unsigned long clk_leafclk_recalc(struct clk *clk) | |||
368 | return clk->parent->rate; | 366 | return clk->parent->rate; |
369 | } | 367 | } |
370 | 368 | ||
369 | int davinci_simple_set_rate(struct clk *clk, unsigned long rate) | ||
370 | { | ||
371 | clk->rate = rate; | ||
372 | return 0; | ||
373 | } | ||
374 | |||
371 | static unsigned long clk_pllclk_recalc(struct clk *clk) | 375 | static unsigned long clk_pllclk_recalc(struct clk *clk) |
372 | { | 376 | { |
373 | u32 ctrl, mult = 1, prediv = 1, postdiv = 1; | 377 | u32 ctrl, mult = 1, prediv = 1, postdiv = 1; |
@@ -506,6 +510,38 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, | |||
506 | } | 510 | } |
507 | EXPORT_SYMBOL(davinci_set_pllrate); | 511 | EXPORT_SYMBOL(davinci_set_pllrate); |
508 | 512 | ||
513 | /** | ||
514 | * davinci_set_refclk_rate() - Set the reference clock rate | ||
515 | * @rate: The new rate. | ||
516 | * | ||
517 | * Sets the reference clock rate to a given value. This will most likely | ||
518 | * result in the entire clock tree getting updated. | ||
519 | * | ||
520 | * This is used to support boards which use a reference clock different | ||
521 | * than that used by default in <soc>.c file. The reference clock rate | ||
522 | * should be updated early in the boot process; ideally soon after the | ||
523 | * clock tree has been initialized once with the default reference clock | ||
524 | * rate (davinci_common_init()). | ||
525 | * | ||
526 | * Returns 0 on success, error otherwise. | ||
527 | */ | ||
528 | int davinci_set_refclk_rate(unsigned long rate) | ||
529 | { | ||
530 | struct clk *refclk; | ||
531 | |||
532 | refclk = clk_get(NULL, "ref"); | ||
533 | if (IS_ERR(refclk)) { | ||
534 | pr_err("%s: failed to get reference clock.\n", __func__); | ||
535 | return PTR_ERR(refclk); | ||
536 | } | ||
537 | |||
538 | clk_set_rate(refclk, rate); | ||
539 | |||
540 | clk_put(refclk); | ||
541 | |||
542 | return 0; | ||
543 | } | ||
544 | |||
509 | int __init davinci_clk_init(struct clk_lookup *clocks) | 545 | int __init davinci_clk_init(struct clk_lookup *clocks) |
510 | { | 546 | { |
511 | struct clk_lookup *c; | 547 | struct clk_lookup *c; |