diff options
author | Alex Frid <afrid@nvidia.com> | 2012-07-28 18:38:48 -0700 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2012-08-09 19:08:35 -0700 |
commit | 22e38e5e415422d472160dbf03155a02a795e36c (patch) | |
tree | b88a3d6f93f169e3835d8152fdd6a6b9cf9e77cf /arch/arm/mach-tegra/clock.h | |
parent | 9727a8fc2ebc81977d7b74ca0ed4b7f739f9ccb4 (diff) |
ARM: tegra: clock: Implement clk_prepare/clk_unprepare
Implemented clk_prepare/clk_unprepare APIs that will be used after
CONFIG_HAVE_CLK_PREPARE is set. Then, these APIs will be called only
in non-atomic context, and can hold mutex. On the other hand current
clk_enable/clk_disable will be no longer allowed to hold mutex, as
they may be called in atomic context.
Implementation took advantage of tegra clock "cansleep" attribute
that indicates if clock requires preparation. Hence, the interfaces
are splitted respectively: all work on sleeping clocks is done only
in clk_prepare/clk_unprepare, and all work for non-sleeping clocks
is done only in clk_enable/clk_disable APIs. Calling "complimentary"
APIs on either type of clocks is allowed, and actually expected,
since clients may not know the clock attributes. However, calling
clk_enable on non-prepared sleeping clock would fail.
When macro CONFIG_HAVE_CLK_PREPARE is not set, there is no changes
in behavior of clk_enable/clk_disable APIs, with one exception:
propagation of enable/disable state to sleeping parent passes through
might_sleep macro, which may help to catch clock tree inconsistencies
(e.g., non-sleeping child of sleeping parent).
On code base with CONFIG_HAVE_CLK_PREPARE not set, and might_sleep is
resolved to NOP, this commit does not change clk_enable/clk_disable
at all.
Change-Id: I09bbae7845903054cadb4de84aee1cb3fb0def4b
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/119187
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/clock.h')
-rw-r--r-- | arch/arm/mach-tegra/clock.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h index 84ad09615fd9..b83f54e837e3 100644 --- a/arch/arm/mach-tegra/clock.h +++ b/arch/arm/mach-tegra/clock.h @@ -25,6 +25,7 @@ #ifndef __ASSEMBLY__ #include <linux/clkdev.h> +#include <linux/clk.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/spinlock.h> @@ -328,6 +329,21 @@ static inline void clk_unlock_restore(struct clk *c, unsigned long *flags) } } +static inline int tegra_clk_prepare_enable(struct clk *c) +{ + if (clk_cansleep(c)) + return clk_prepare_enable(c); + return clk_enable(c); +} + +static inline void tegra_clk_disable_unprepare(struct clk *c) +{ + if (clk_cansleep(c)) + clk_disable_unprepare(c); + else + clk_disable(c); +} + static inline void clk_lock_init(struct clk *c) { mutex_init(&c->mutex); |