[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-3.0 / pm-wip / voltdm / 0093-OMAP2-clock-allow-per-SoC-clock-init-code-to-prevent.patch
1 From 6479ce1adbb20504cba420d8f0f5af4c9ee91e73 Mon Sep 17 00:00:00 2001
2 From: Paul Walmsley <paul@pwsan.com>
3 Date: Sun, 10 Jul 2011 05:57:06 -0600
4 Subject: [PATCH 093/149] OMAP2+: clock: allow per-SoC clock init code to prevent clockdomain calls from clock code
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The OMAP2/3 clock code was written to notify the clockdomain code when
10 the first clock in a clockdomain is enabled and when the last enabled
11 clock in a clockdomain is disabled. OMAP4 requires a different
12 approach: the hwmod code needs to signal the clockdomain code when to
13 force-enable and auto-idle a clockdomain during the IP block enable
14 process. The current conjecture is that once that hwmod sequence is
15 implemented, it will no longer be necessary for the clock code to call
16 into the clockdomain code for "optional clocks" on OMAP4.
18 Add a static flag to the OMAP2+ clock code, clkdm_control, that by
19 default preserves the OMAP2/3 behavior. Also add a function,
20 omap2_clk_disable_clkdm_control(), intended to be called from OMAP4
21 and beyond clock initcalls, that disables the old behavior.
23 Part of this patch was originally based on a patch by Rajendra Nayak
24 <rnayak@ti.com>.
26 Signed-off-by: Paul Walmsley <paul@pwsan.com>
27 Cc: BenoƮt Cousson <b-cousson@ti.com>
28 Cc: Rajendra Nayak <rnayak@ti.com>
29 ---
30 arch/arm/mach-omap2/clock.c | 27 ++++++++++++++++++++++++---
31 arch/arm/mach-omap2/clock.h | 3 +++
32 2 files changed, 27 insertions(+), 3 deletions(-)
34 diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
35 index 180299e..fc84576 100644
36 --- a/arch/arm/mach-omap2/clock.c
37 +++ b/arch/arm/mach-omap2/clock.c
38 @@ -38,6 +38,14 @@
39 u8 cpu_mask;
41 /*
42 + * clkdm_control: if true, then when a clock is enabled in the
43 + * hardware, its clockdomain will first be enabled; and when a clock
44 + * is disabled in the hardware, its clockdomain will be disabled
45 + * afterwards.
46 + */
47 +static bool clkdm_control = true;
48 +
49 +/*
50 * OMAP2+ specific clock functions
51 */
53 @@ -100,6 +108,19 @@ void omap2_init_clk_clkdm(struct clk *clk)
54 }
56 /**
57 + * omap2_clk_disable_clkdm_control - disable clkdm control on clk enable/disable
58 + *
59 + * Prevent the OMAP clock code from calling into the clockdomain code
60 + * when a hardware clock in that clockdomain is enabled or disabled.
61 + * Intended to be called at init time from omap*_clk_init(). No
62 + * return value.
63 + */
64 +void __init omap2_clk_disable_clkdm_control(void)
65 +{
66 + clkdm_control = false;
67 +}
68 +
69 +/**
70 * omap2_clk_dflt_find_companion - find companion clock to @clk
71 * @clk: struct clk * to find the companion clock of
72 * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
73 @@ -268,7 +289,7 @@ void omap2_clk_disable(struct clk *clk)
74 clk->ops->disable(clk);
75 }
77 - if (clk->clkdm)
78 + if (clkdm_control && clk->clkdm)
79 clkdm_clk_disable(clk->clkdm, clk);
81 if (clk->parent)
82 @@ -308,7 +329,7 @@ int omap2_clk_enable(struct clk *clk)
83 }
84 }
86 - if (clk->clkdm) {
87 + if (clkdm_control && clk->clkdm) {
88 ret = clkdm_clk_enable(clk->clkdm, clk);
89 if (ret) {
90 WARN(1, "clock: %s: could not enable clockdomain %s: "
91 @@ -330,7 +351,7 @@ int omap2_clk_enable(struct clk *clk)
92 return 0;
94 oce_err3:
95 - if (clk->clkdm)
96 + if (clkdm_control && clk->clkdm)
97 clkdm_clk_disable(clk->clkdm, clk);
98 oce_err2:
99 if (clk->parent)
100 diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
101 index e10ff2b..48ac568 100644
102 --- a/arch/arm/mach-omap2/clock.h
103 +++ b/arch/arm/mach-omap2/clock.h
104 @@ -16,6 +16,8 @@
105 #ifndef __ARCH_ARM_MACH_OMAP2_CLOCK_H
106 #define __ARCH_ARM_MACH_OMAP2_CLOCK_H
108 +#include <linux/kernel.h>
109 +
110 #include <plat/clock.h>
112 /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
113 @@ -72,6 +74,7 @@ void omap2_clk_disable_unused(struct clk *clk);
114 #endif
116 void omap2_init_clk_clkdm(struct clk *clk);
117 +void __init omap2_clk_disable_clkdm_control(void);
119 /* clkt_clksel.c public functions */
120 u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
121 --
122 1.6.6.1