ARM: davinci: clk framework support for enable/disable functionality
authorPhilip Avinash <avinashphilip@ti.com>
Mon, 25 Mar 2013 09:37:48 +0000 (15:07 +0530)
committerSekhar Nori <nsekhar@ti.com>
Mon, 1 Apr 2013 11:24:47 +0000 (16:54 +0530)
DaVinci clock implementation does not support clock enable/disable
functionality on non-PSC clock nodes.

On DA850 SoC, EHRPWM module requires support for enable/disable
of TBCLK controlled using a system module register.

This patch adds a method for enabling/disabling non-PSC clocks
into DaVinci clock implementation.

Signed-off-by: Philip Avinash <avinashphilip@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
arch/arm/mach-davinci/clock.c
arch/arm/mach-davinci/clock.h

index d458558ee84a436a0506835c3ca9bdfa722798de..dc9a470ff9c57afe9855bfaf592a27a62b3888a6 100644 (file)
@@ -35,19 +35,26 @@ static void __clk_enable(struct clk *clk)
 {
        if (clk->parent)
                __clk_enable(clk->parent);
-       if (clk->usecount++ == 0 && (clk->flags & CLK_PSC))
-               davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
-                               true, clk->flags);
+       if (clk->usecount++ == 0) {
+               if (clk->flags & CLK_PSC)
+                       davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
+                                          true, clk->flags);
+               else if (clk->clk_enable)
+                       clk->clk_enable(clk);
+       }
 }
 
 static void __clk_disable(struct clk *clk)
 {
        if (WARN_ON(clk->usecount == 0))
                return;
-       if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) &&
-           (clk->flags & CLK_PSC))
-               davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
-                               false, clk->flags);
+       if (--clk->usecount == 0) {
+               if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC))
+                       davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
+                                          false, clk->flags);
+               else if (clk->clk_disable)
+                       clk->clk_disable(clk);
+       }
        if (clk->parent)
                __clk_disable(clk->parent);
 }
index 8694b395fc92602a60355bb35bd414f0137b041c..1e4e836173a14cab56650945cd2fcd41e18cf014 100644 (file)
@@ -104,6 +104,8 @@ struct clk {
        int (*set_rate) (struct clk *clk, unsigned long rate);
        int (*round_rate) (struct clk *clk, unsigned long rate);
        int (*reset) (struct clk *clk, bool reset);
+       void (*clk_enable) (struct clk *clk);
+       void (*clk_disable) (struct clk *clk);
 };
 
 /* Clock flags: SoC-specific flags start at BIT(16) */