summaryrefslogtreecommitdiff
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2013-03-12 20:26:03 +0100
committerMike Turquette <mturquette@linaro.org>2013-03-19 12:58:42 -0700
commit1c155b3dfe08351f5fc811062648969f1ba7af53 (patch)
treef1e96de00305a0d3148d8131fd383e96e895d4bf /drivers/clk/clk.c
parent3d6ee287a3e341c88eafd0b4620b12d640b3736b (diff)
clk: Unprepare the unused prepared slow clocks at late init
The unused ungated fast clocks are already being disabled from clk_disable_unused at late init. This patch extend this sequence to the slow unused prepared clocks to be unprepared. Unless the optional .is_prepared callback is implemented by a clk_hw the clk_disable_unused sequence will not unprepare any unused clocks, since it will fall back to use the software prepare counter. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org> [mturquette@linaro.org: fixed hlist accessors per b67bfe0d]
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7571b5054f3c..c0141f3e1109 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -336,6 +336,28 @@ static inline int clk_debug_register(struct clk *clk) { return 0; }
#endif
/* caller must hold prepare_lock */
+static void clk_unprepare_unused_subtree(struct clk *clk)
+{
+ struct clk *child;
+
+ if (!clk)
+ return;
+
+ hlist_for_each_entry(child, &clk->children, child_node)
+ clk_unprepare_unused_subtree(child);
+
+ if (clk->prepare_count)
+ return;
+
+ if (clk->flags & CLK_IGNORE_UNUSED)
+ return;
+
+ if (__clk_is_prepared(clk))
+ if (clk->ops->unprepare)
+ clk->ops->unprepare(clk->hw);
+}
+
+/* caller must hold prepare_lock */
static void clk_disable_unused_subtree(struct clk *clk)
{
struct clk *child;
@@ -386,6 +408,12 @@ static int clk_disable_unused(void)
hlist_for_each_entry(clk, &clk_orphan_list, child_node)
clk_disable_unused_subtree(clk);
+ hlist_for_each_entry(clk, &clk_root_list, child_node)
+ clk_unprepare_unused_subtree(clk);
+
+ hlist_for_each_entry(clk, &clk_orphan_list, child_node)
+ clk_unprepare_unused_subtree(clk);
+
mutex_unlock(&prepare_lock);
return 0;