From 2eb8c7104c648ad4bfae1f5333f98c09522149b5 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 22 Dec 2015 22:27:58 +0100 Subject: clk: add flag for clocks that need to be enabled on rate changes Some clocks need to be enabled to accept rate changes. This patch adds a new flag CLK_SET_RATE_UNGATE that lets clk_change_rate enable the clock before trying to change the rate and disable it again afterwards. This of course doesn't effect clocks that are already running at that point, as their refcount will only temporarily increase. Signed-off-by: Heiko Stuebner Tested-by: Sjoerd Simons Reviewed-by: Sjoerd Simons Signed-off-by: Michael Turquette --- drivers/clk/clk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'drivers/clk') diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f13c3f4228d4..bd64a9414de2 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1443,6 +1443,15 @@ static void clk_change_rate(struct clk_core *core) else if (core->parent) best_parent_rate = core->parent->rate; + if (core->flags & CLK_SET_RATE_UNGATE) { + unsigned long flags; + + clk_core_prepare(core); + flags = clk_enable_lock(); + clk_core_enable(core); + clk_enable_unlock(flags); + } + if (core->new_parent && core->new_parent != core->parent) { old_parent = __clk_set_parent_before(core, core->new_parent); trace_clk_set_parent(core, core->new_parent); @@ -1469,6 +1478,15 @@ static void clk_change_rate(struct clk_core *core) core->rate = clk_recalc(core, best_parent_rate); + if (core->flags & CLK_SET_RATE_UNGATE) { + unsigned long flags; + + flags = clk_enable_lock(); + clk_core_disable(core); + clk_enable_unlock(flags); + clk_core_unprepare(core); + } + if (core->notifier_count && old_rate != core->rate) __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); -- cgit v1.2.3