]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
clk: introduce optional disable_unused callback
authorMike Turquette <mturquette@linaro.org>
Tue, 4 Dec 2012 19:00:35 +0000 (11:00 -0800)
committerMike Turquette <mturquette@linaro.org>
Tue, 11 Dec 2012 06:35:02 +0000 (22:35 -0800)
Some gate clocks have special needs which must be handled during the
disable-unused clocks sequence.  These needs might be driven by software
due to the fact that we're disabling a clock outside of the normal
clk_disable path and a clk's enable_count will not be accurate.  On the
other hand a specific hardware programming sequence might need to be
followed for this corner case.

This change is needed for the upcoming OMAP port to the common clock
framework.  Specifically, it is undesirable to treat the disable-unused
path identically to the normal clk_disable path since other software
layers are involved.  In this case OMAP's clockdomain code throws WARNs
and bails early due to the clock's enable_count being set to zero.  A
custom callback mitigates this problem nicely.

Cc: Paul Walmsley <paul@pwsan.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
drivers/clk/clk.c
include/linux/clk-provider.h

index 9955ad7e786e5a3eabcff56ebc8516100db46928..251e45d6024d26b188d1e81195318fcb82cdc502 100644 (file)
@@ -219,8 +219,17 @@ static void clk_disable_unused_subtree(struct clk *clk)
        if (clk->flags & CLK_IGNORE_UNUSED)
                goto unlock_out;
 
-       if (__clk_is_enabled(clk) && clk->ops->disable)
-               clk->ops->disable(clk->hw);
+       /*
+        * some gate clocks have special needs during the disable-unused
+        * sequence.  call .disable_unused if available, otherwise fall
+        * back to .disable
+        */
+       if (__clk_is_enabled(clk)) {
+               if (clk->ops->disable_unused)
+                       clk->ops->disable_unused(clk->hw);
+               else if (clk->ops->disable)
+                       clk->ops->disable(clk->hw);
+       }
 
 unlock_out:
        spin_unlock_irqrestore(&enable_lock, flags);
index 3593a3ce3f0ded91834a6627d0efebe7b22b17c6..1c94d18514e2db0f4c0aba29bf5e121e7348cac9 100644 (file)
@@ -57,6 +57,11 @@ struct clk_hw;
  *             This function must not sleep. Optional, if this op is not
  *             set then the enable count will be used.
  *
+ * @disable_unused: Disable the clock atomically.  Only called from
+ *             clk_disable_unused for gate clocks with special needs.
+ *             Called with enable_lock held.  This function must not
+ *             sleep.
+ *
  * @recalc_rate        Recalculate the rate of this clock, by querying hardware. The
  *             parent rate is an input parameter.  It is up to the caller to
  *             ensure that the prepare_mutex is held across this call.
@@ -106,6 +111,7 @@ struct clk_ops {
        int             (*enable)(struct clk_hw *hw);
        void            (*disable)(struct clk_hw *hw);
        int             (*is_enabled)(struct clk_hw *hw);
+       void            (*disable_unused)(struct clk_hw *hw);
        unsigned long   (*recalc_rate)(struct clk_hw *hw,
                                        unsigned long parent_rate);
        long            (*round_rate)(struct clk_hw *hw, unsigned long,