]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP clock: move rate recalc, propagation code up to plat-omap/clock.c
authorPaul Walmsley <paul@pwsan.com>
Wed, 7 Jan 2009 15:20:23 +0000 (17:20 +0200)
committerTony Lindgren <tony@atomide.com>
Wed, 7 Jan 2009 15:20:23 +0000 (17:20 +0200)
Previously the individual clock recalculation functions handled their
own rate recalculation.  This can be handled in the clk_set_rate(),
clk_set_parent(), and recalculate_root_clocks() functions in
plat-omap/clock.c.  Removes duplicate code and clarifies the role of the
recalc functions.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/clock.c
arch/arm/mach-omap2/clock.c
arch/arm/mach-omap2/clock24xx.c
arch/arm/mach-omap2/clock34xx.c
arch/arm/plat-omap/clock.c

index 4d0c44497ee13635660f4d4a5ddc1ab2013c46b4..ae2b304d3f29a89487c97c784cebdc019a7df9cf 100644 (file)
@@ -225,9 +225,6 @@ static void omap1_ckctl_recalc(struct clk * clk)
        if (unlikely(clk->rate == clk->parent->rate / dsor))
                return; /* No change, quick exit */
        clk->rate = clk->parent->rate / dsor;
-
-       if (unlikely(clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
 }
 
 static void omap1_ckctl_recalc_dsp_domain(struct clk * clk)
@@ -248,9 +245,6 @@ static void omap1_ckctl_recalc_dsp_domain(struct clk * clk)
        if (unlikely(clk->rate == clk->parent->rate / dsor))
                return; /* No change, quick exit */
        clk->rate = clk->parent->rate / dsor;
-
-       if (unlikely(clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
 }
 
 /* MPU virtual clock functions */
@@ -314,9 +308,6 @@ static int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate)
                ret = 0;
        }
 
-       if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
-               propagate_rate(clk);
-
        return ret;
 }
 
@@ -423,8 +414,6 @@ static int omap1_set_sossi_rate(struct clk *clk, unsigned long rate)
        omap_writel(l, MOD_CONF_CTRL_1);
 
        clk->rate = p_rate / (div + 1);
-       if (unlikely(clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
 
        return 0;
 }
@@ -583,9 +572,6 @@ static int omap1_clk_set_rate(struct clk *clk, unsigned long rate)
                ret = 0;
        }
 
-       if (unlikely(ret == 0 && (clk->flags & RATE_PROPAGATES)))
-               propagate_rate(clk);
-
        return ret;
 }
 
index 8a064b3d1d93211afa9f13e91029800c05c18543..13db3d5f5c9c34f555197eca5c6aeee721f9cec9 100644 (file)
@@ -302,9 +302,6 @@ void omap2_fixed_divisor_recalc(struct clk *clk)
        WARN_ON(!clk->fixed_div);
 
        clk->rate = clk->parent->rate / clk->fixed_div;
-
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
 }
 
 /**
@@ -506,9 +503,6 @@ void omap2_clksel_recalc(struct clk *clk)
        clk->rate = clk->parent->rate / div;
 
        pr_debug("clock: new clock rate is %ld (div %d)\n", clk->rate, div);
-
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
 }
 
 /**
@@ -779,9 +773,6 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
        if (clk->set_rate != NULL)
                ret = clk->set_rate(clk, rate);
 
-       if (ret == 0 && (clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
-
        return ret;
 }
 
@@ -863,9 +854,6 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
        pr_debug("clock: set parent of %s to %s (new rate %ld)\n",
                 clk->name, clk->parent->name, clk->rate);
 
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
-
        return 0;
 }
 
index 8567de23c6cd25f4f6a301cd5b21437a5ad15566..9e1328f1902e89ad740cb231a9dba40a043c5567 100644 (file)
@@ -178,8 +178,6 @@ static long omap2_dpllcore_round_rate(unsigned long target_rate)
 static void omap2_dpllcore_recalc(struct clk *clk)
 {
        clk->rate = omap2xxx_clk_get_core_rate(clk);
-
-       propagate_rate(clk);
 }
 
 static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
@@ -250,7 +248,6 @@ static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate)
                omap2xxx_sdrc_init_params(omap2xxx_sdrc_dll_is_unlocked());
                omap2xxx_sdrc_reprogram(done_rate, 0);
        }
-       omap2_dpllcore_recalc(&dpll_ck);
        ret = 0;
 
 dpll_exit:
@@ -379,7 +376,6 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate)
 
                local_irq_restore(flags);
        }
-       omap2_dpllcore_recalc(&dpll_ck);
 
        return 0;
 }
@@ -469,13 +465,11 @@ static u32 omap2_get_sysclkdiv(void)
 static void omap2_osc_clk_recalc(struct clk *clk)
 {
        clk->rate = omap2_get_apll_clkin() * omap2_get_sysclkdiv();
-       propagate_rate(clk);
 }
 
 static void omap2_sys_clk_recalc(struct clk *clk)
 {
        clk->rate = clk->parent->rate / omap2_get_sysclkdiv();
-       propagate_rate(clk);
 }
 
 /*
index 738a0298636303b512b727cca14aa5025f7eafa6..22cbccedad8657cc099d4a31913d7cc1222c7bbc 100644 (file)
@@ -54,8 +54,6 @@
 static void omap3_dpll_recalc(struct clk *clk)
 {
        clk->rate = omap2_get_dpll_rate(clk);
-
-       propagate_rate(clk);
 }
 
 /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
@@ -429,8 +427,6 @@ static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
 
        }
 
-       omap3_dpll_recalc(clk);
-
        return 0;
 }
 
@@ -493,8 +489,6 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
                                  sp->actim_ctrlb, new_div);
        local_irq_enable();
 
-       omap2_clksel_recalc(clk);
-
        return 0;
 }
 
@@ -612,9 +606,6 @@ static void omap3_clkoutx2_recalc(struct clk *clk)
                clk->rate = clk->parent->rate;
        else
                clk->rate = clk->parent->rate * 2;
-
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
 }
 
 /* Common clock code */
index d13acd2e57bf0d1d6aee4a14e6700e2e056a0e68..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);
+               }
        }
 }