]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/clock.c
OMAP2 clock: drop CONFIG_PARTICIPANT clock flag
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / clock.c
index 42af2865cbdd689048f4dbca222451e71ff419fd..8599b34305b5d19e66eac227da7023678790cc7a 100644 (file)
 #define DPLL_FINT_UNDERFLOW            -1
 #define DPLL_FINT_INVALID              -2
 
-/* Some OMAP2xxx CM_CLKSEL_PLL.ST_CORE_CLK bits - for omap2_get_dpll_rate() */
-#define ST_CORE_CLK_REF                        0x1
-#define ST_CORE_CLK_32K                        0x3
-
 /* Bitmask to isolate the register type of clk.enable_reg */
 #define PRCM_REGTYPE_MASK              0xf0
 /* various CM register type options */
@@ -228,7 +224,11 @@ void omap2_init_clksel_parent(struct clk *clk)
                                                 clk->name, clks->parent->name,
                                                 ((clk->parent) ?
                                                  clk->parent->name : "NULL"));
+                                       if (clk->parent)
+                                               omap_clk_del_child(clk->parent,
+                                                                  clk);
                                        clk->parent = clks->parent;
+                                       omap_clk_add_child(clk->parent, clk);
                                };
                                found = 1;
                        }
@@ -245,6 +245,7 @@ void omap2_init_clksel_parent(struct clk *clk)
 /**
  * omap2_get_dpll_rate - returns the current DPLL CLKOUT rate
  * @clk: struct clk * of a DPLL
+ * @parent_rate: rate of the parent of the DPLL clock
  *
  * DPLLs can be locked or bypassed - basically, enabled or disabled.
  * When locked, the DPLL output depends on the M and N values.  When
@@ -256,7 +257,7 @@ void omap2_init_clksel_parent(struct clk *clk)
  * locked, or the appropriate bypass rate if the DPLL is bypassed, or 0
  * if the clock @clk is not a DPLL.
  */
-u32 omap2_get_dpll_rate(struct clk *clk)
+u32 omap2_get_dpll_rate(struct clk *clk, unsigned long parent_rate)
 {
        long long dpll_clk;
        u32 dpll_mult, dpll_div, v;
@@ -267,19 +268,20 @@ u32 omap2_get_dpll_rate(struct clk *clk)
                return 0;
 
        /* Return bypass rate if DPLL is bypassed */
-       v = cm_read_mod_reg(clk->prcm_mod, dd->idlest_reg);
-       v &= dd->idlest_mask;
-       v >>= __ffs(dd->idlest_mask);
+       v = cm_read_mod_reg(clk->prcm_mod, dd->control_reg);
+       v &= dd->enable_mask;
+       v >>= __ffs(dd->enable_mask);
+
        if (cpu_is_omap24xx()) {
 
-               if (v == ST_CORE_CLK_REF)
-                       return clk->parent->rate; /* sys_clk */
-               else if (v == ST_CORE_CLK_32K)
-                       return 32768;
+               if (v == OMAP2XXX_EN_DPLL_LPBYPASS ||
+                   v == OMAP2XXX_EN_DPLL_FRBYPASS)
+                       return parent_rate;
 
        } else if (cpu_is_omap34xx()) {
 
-               if (!v)
+               if (v == OMAP3XXX_EN_DPLL_LPBYPASS ||
+                   v == OMAP3XXX_EN_DPLL_FRBYPASS)
                        return dd->bypass_clk->rate;
 
        }
@@ -290,7 +292,7 @@ u32 omap2_get_dpll_rate(struct clk *clk)
        dpll_div = v & dd->div1_mask;
        dpll_div >>= __ffs(dd->div1_mask);
 
-       dpll_clk = (long long)clk->parent->rate * dpll_mult;
+       dpll_clk = (long long)parent_rate * dpll_mult;
        do_div(dpll_clk, dpll_div + 1);
 
        return dpll_clk;
@@ -300,14 +302,19 @@ u32 omap2_get_dpll_rate(struct clk *clk)
  * Used for clocks that have the same value as the parent clock,
  * divided by some factor
  */
-void omap2_fixed_divisor_recalc(struct clk *clk)
+void omap2_fixed_divisor_recalc(struct clk *clk, unsigned long parent_rate,
+                               u8 rate_storage)
 {
-       WARN_ON(!clk->fixed_div);
+       unsigned long rate;
 
-       clk->rate = clk->parent->rate / clk->fixed_div;
+       WARN_ON(!clk->fixed_div); /* XXX move this to init */
 
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
+       rate = parent_rate / clk->fixed_div;
+
+       if (rate_storage == CURRENT_RATE)
+               clk->rate = rate;
+       else if (rate_storage == TEMP_RATE)
+               clk->temp_rate = rate;
 }
 
 /**
@@ -494,9 +501,11 @@ int omap2_clk_enable(struct clk *clk)
  * Used for clocks that are part of CLKSEL_xyz governed clocks.
  * REVISIT: Maybe change to use clk->enable() functions like on omap1?
  */
-void omap2_clksel_recalc(struct clk *clk)
+void omap2_clksel_recalc(struct clk *clk, unsigned long parent_rate,
+                        u8 rate_storage)
 {
        u32 div = 0;
+       unsigned long rate;
 
        pr_debug("clock: recalc'ing clksel clk %s\n", clk->name);
 
@@ -504,14 +513,14 @@ void omap2_clksel_recalc(struct clk *clk)
        if (div == 0)
                return;
 
-       if (clk->rate == (clk->parent->rate / div))
-               return;
-       clk->rate = clk->parent->rate / div;
+       rate = parent_rate / div;
 
-       pr_debug("clock: new clock rate is %ld (div %d)\n", clk->rate, div);
+       if (rate_storage == CURRENT_RATE)
+               clk->rate = rate;
+       else if (rate_storage == TEMP_RATE)
+               clk->temp_rate = rate;
 
-       if (clk->flags & RATE_PROPAGATES)
-               propagate_rate(clk);
+       pr_debug("clock: new clock rate is %ld (div %d)\n", clk->rate, div);
 }
 
 /**
@@ -554,8 +563,6 @@ static const struct clksel *omap2_get_clksel_by_parent(struct clk *clk,
  *
  * Finds 'best' divider value in an array based on the source and target
  * rates.  The divider array must be sorted with smallest divider first.
- * Note that this will not work for clocks which are part of CONFIG_PARTICIPANT,
- * they are only settable as part of virtual_prcm set.
  *
  * Returns the rounded clock rate or returns 0xffffffff on error.
  */
@@ -616,8 +623,6 @@ u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
  * Compatibility wrapper for OMAP clock framework
  * Finds best target rate based on the source clock and possible dividers.
  * rates. The divider array must be sorted with smallest divider first.
- * Note that this will not work for clocks which are part of CONFIG_PARTICIPANT,
- * they are only settable as part of virtual_prcm set.
  *
  * Returns the rounded clock rate or returns 0xffffffff on error.
  */
@@ -635,10 +640,6 @@ long omap2_clk_round_rate(struct clk *clk, unsigned long rate)
        if (clk->round_rate != NULL)
                return clk->round_rate(clk, rate);
 
-       if (clk->flags & RATE_FIXED)
-               printk(KERN_ERR "clock: generic omap2_clk_round_rate called "
-                      "on fixed-rate clock %s\n", clk->name);
-
        return clk->rate;
 }
 
@@ -773,18 +774,9 @@ int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
 
        pr_debug("clock: set_rate for clock %s to rate %ld\n", clk->name, rate);
 
-       /* CONFIG_PARTICIPANT clocks are changed only in sets via the
-          rate table mechanism, driven by mpu_speed  */
-       if (clk->flags & CONFIG_PARTICIPANT)
-               return -EINVAL;
-
-       /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */
        if (clk->set_rate != NULL)
                ret = clk->set_rate(clk, rate);
 
-       if (ret == 0 && (clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
-
        return ret;
 }
 
@@ -826,9 +818,6 @@ int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
 {
        u32 field_val, v, parent_div;
 
-       if (clk->flags & CONFIG_PARTICIPANT)
-               return -EINVAL;
-
        if (!clk->clksel)
                return -EINVAL;
 
@@ -866,12 +855,14 @@ 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;
 }
 
+struct clk *omap2_clk_get_parent(struct clk *clk)
+{
+       return clk->parent;
+}
+
 /* DPLL rate rounding code */
 
 /**