]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/plat-omap/clock.c
OMAP clock: move rate recalc, propagation code up to plat-omap/clock.c
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / clock.c
index bf6a10c5fc4ffdfd5f9abb74bec8da1c1140e57e..9f458cbaa413e51ffd7c42a26b505b39816d673d 100644 (file)
@@ -183,8 +183,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
                return ret;
 
        spin_lock_irqsave(&clockfw_lock, flags);
-       if (arch_clock->clk_set_rate)
+
+       if (arch_clock->clk_set_rate) {
                ret = arch_clock->clk_set_rate(clk, rate);
+               if (ret == 0) {
+                       (*clk->recalc)(clk);
+                       if (clk->flags & RATE_PROPAGATES)
+                               propagate_rate(clk);
+               }
+       }
+
        spin_unlock_irqrestore(&clockfw_lock, flags);
 
        return ret;
@@ -200,8 +208,16 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
                return ret;
 
        spin_lock_irqsave(&clockfw_lock, flags);
-       if (arch_clock->clk_set_parent)
-               ret =  arch_clock->clk_set_parent(clk, parent);
+
+       if (arch_clock->clk_set_parent) {
+               ret = arch_clock->clk_set_parent(clk, parent);
+               if (ret == 0) {
+                       (*clk->recalc)(clk);
+                       if (clk->flags & RATE_PROPAGATES)
+                               propagate_rate(clk);
+               }
+       }
+
        spin_unlock_irqrestore(&clockfw_lock, flags);
 
        return ret;
@@ -256,8 +272,6 @@ void followparent_recalc(struct clk *clk)
                return;
 
        clk->rate = clk->parent->rate;
-       if (unlikely(clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
 }
 
 /* Propagate rate to children */
@@ -271,8 +285,11 @@ void propagate_rate(struct clk * tclk)
        list_for_each_entry(clkp, &clocks, node) {
                if (likely(clkp->parent != tclk))
                        continue;
-               if (likely((u32)clkp->recalc))
+               if (likely((u32)clkp->recalc)) {
                        clkp->recalc(clkp);
+                       if (clkp->flags & RATE_PROPAGATES)
+                               propagate_rate(clkp);
+               }
        }
 }
 
@@ -288,8 +305,11 @@ void recalculate_root_clocks(void)
        struct clk *clkp;
 
        list_for_each_entry(clkp, &clocks, node) {
-               if (unlikely(!clkp->parent) && likely((u32)clkp->recalc))
+               if (unlikely(!clkp->parent) && likely((u32)clkp->recalc)) {
                        clkp->recalc(clkp);
+                       if (clkp->flags & RATE_PROPAGATES)
+                               propagate_rate(clkp);
+               }
        }
 }
 
@@ -383,8 +403,11 @@ static int __init clk_disable_unused(void)
        unsigned long flags;
 
        list_for_each_entry(ck, &clocks, node) {
-               if (ck->usecount > 0 || (ck->flags & ALWAYS_ENABLED) ||
-                       ck->enable_reg == 0)
+               if (ck->usecount > 0 ||
+                   (ck->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)))
+                       continue;
+
+               if (cpu_class_is_omap1() && ck->enable_reg == 0)
                        continue;
 
                spin_lock_irqsave(&clockfw_lock, flags);
@@ -428,23 +451,23 @@ static int clk_debugfs_register_one(struct clk *c)
        if (c->id != 0)
                sprintf(p, ":%d", c->id);
        d = debugfs_create_dir(s, pa ? pa->dent : clk_debugfs_root);
-       if (IS_ERR(d))
-               return PTR_ERR(d);
+       if (!d)
+               return -ENOMEM;
        c->dent = d;
 
        d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);
-       if (IS_ERR(d)) {
-               err = PTR_ERR(d);
+       if (!d) {
+               err = -ENOMEM;
                goto err_out;
        }
        d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);
-       if (IS_ERR(d)) {
-               err = PTR_ERR(d);
+       if (!d) {
+               err = -ENOMEM;
                goto err_out;
        }
        d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);
-       if (IS_ERR(d)) {
-               err = PTR_ERR(d);
+       if (!d) {
+               err = -ENOMEM;
                goto err_out;
        }
        return 0;
@@ -483,8 +506,8 @@ static int __init clk_debugfs_init(void)
        int err;
 
        d = debugfs_create_dir("clock", NULL);
-       if (IS_ERR(d))
-               return PTR_ERR(d);
+       if (!d)
+               return -ENOMEM;
        clk_debugfs_root = d;
 
        list_for_each_entry(c, &clocks, node) {