aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2015-12-22 16:27:58 -0500
committerMichael Turquette <mturquette@baylibre.com>2015-12-23 15:57:31 -0500
commit2eb8c7104c648ad4bfae1f5333f98c09522149b5 (patch)
treee6f85898c587de5c2bae29a459c700a9c6cf341d
parent84a8c541664b037a4d1fdc3151466b4ec45c37a5 (diff)
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 <heiko@sntech.de> Tested-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Signed-off-by: Michael Turquette <mturquette@baylibre.com>
-rw-r--r--drivers/clk/clk.c18
-rw-r--r--include/linux/clk-provider.h1
2 files changed, 19 insertions, 0 deletions
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)
1443 else if (core->parent) 1443 else if (core->parent)
1444 best_parent_rate = core->parent->rate; 1444 best_parent_rate = core->parent->rate;
1445 1445
1446 if (core->flags & CLK_SET_RATE_UNGATE) {
1447 unsigned long flags;
1448
1449 clk_core_prepare(core);
1450 flags = clk_enable_lock();
1451 clk_core_enable(core);
1452 clk_enable_unlock(flags);
1453 }
1454
1446 if (core->new_parent && core->new_parent != core->parent) { 1455 if (core->new_parent && core->new_parent != core->parent) {
1447 old_parent = __clk_set_parent_before(core, core->new_parent); 1456 old_parent = __clk_set_parent_before(core, core->new_parent);
1448 trace_clk_set_parent(core, core->new_parent); 1457 trace_clk_set_parent(core, core->new_parent);
@@ -1469,6 +1478,15 @@ static void clk_change_rate(struct clk_core *core)
1469 1478
1470 core->rate = clk_recalc(core, best_parent_rate); 1479 core->rate = clk_recalc(core, best_parent_rate);
1471 1480
1481 if (core->flags & CLK_SET_RATE_UNGATE) {
1482 unsigned long flags;
1483
1484 flags = clk_enable_lock();
1485 clk_core_disable(core);
1486 clk_enable_unlock(flags);
1487 clk_core_unprepare(core);
1488 }
1489
1472 if (core->notifier_count && old_rate != core->rate) 1490 if (core->notifier_count && old_rate != core->rate)
1473 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); 1491 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate);
1474 1492
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index c56988ac63f7..a971ce462565 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -31,6 +31,7 @@
31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */ 31#define CLK_SET_RATE_NO_REPARENT BIT(7) /* don't re-parent on rate change */
32#define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ 32#define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */
33#define CLK_RECALC_NEW_RATES BIT(9) /* recalc rates after notifications */ 33#define CLK_RECALC_NEW_RATES BIT(9) /* recalc rates after notifications */
34#define CLK_SET_RATE_UNGATE BIT(10) /* clock needs to run to set rate */
34 35
35struct clk; 36struct clk;
36struct clk_hw; 37struct clk_hw;