Skip to content

Commit 705814b

Browse files
Santosh ShilimkarKevin Hilman
authored andcommitted
ARM: OMAP4+: PM: Consolidate OMAP4 PM code to re-use it for OMAP5
OMAP5 has backward compatible PRCM block and it's programming model is mostly similar to OMAP4. Same is going to be maintained for future OMAP4 based SOCs. Hence consolidate the OMAP4 power management code so that it can be re-used on OMAP5 and later devices. While at it, update the kernel-doc for omap4_pm_init(). Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Signed-off-by: Kevin Hilman <khilman@linaro.org>
1 parent baf4b7d commit 705814b

File tree

1 file changed

+48
-10
lines changed

1 file changed

+48
-10
lines changed

arch/arm/mach-omap2/pm44xx.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* OMAP4 Power Management Routines
2+
* OMAP4+ Power Management Routines
33
*
4-
* Copyright (C) 2010-2011 Texas Instruments, Inc.
4+
* Copyright (C) 2010-2013 Texas Instruments, Inc.
55
* Rajendra Nayak <rnayak@ti.com>
66
* Santosh Shilimkar <santosh.shilimkar@ti.com>
77
*
@@ -135,16 +135,16 @@ static void omap_default_idle(void)
135135
}
136136

137137
/**
138-
* omap4_pm_init - Init routine for OMAP4 PM
138+
* omap4_init_static_deps - Add OMAP4 static dependencies
139139
*
140-
* Initializes all powerdomain and clockdomain target states
141-
* and all PRCM settings.
140+
* Add needed static clockdomain dependencies on OMAP4 devices.
141+
* Return: 0 on success or 'err' on failures
142142
*/
143-
int __init omap4_pm_init(void)
143+
static inline int omap4_init_static_deps(void)
144144
{
145-
int ret;
146145
struct clockdomain *emif_clkdm, *mpuss_clkdm, *l3_1_clkdm;
147146
struct clockdomain *ducati_clkdm, *l3_2_clkdm;
147+
int ret = 0;
148148

149149
if (omap_rev() == OMAP4430_REV_ES1_0) {
150150
WARN(1, "Power Management not supported on OMAP4430 ES1.0\n");
@@ -163,14 +163,18 @@ int __init omap4_pm_init(void)
163163
ret = pwrdm_for_each(pwrdms_setup, NULL);
164164
if (ret) {
165165
pr_err("Failed to setup powerdomains\n");
166-
goto err2;
166+
return ret;
167167
}
168168

169169
/*
170170
* The dynamic dependency between MPUSS -> MEMIF and
171171
* MPUSS -> L4_PER/L3_* and DUCATI -> L3_* doesn't work as
172172
* expected. The hardware recommendation is to enable static
173173
* dependencies for these to avoid system lock ups or random crashes.
174+
* The L4 wakeup depedency is added to workaround the OCP sync hardware
175+
* BUG with 32K synctimer which lead to incorrect timer value read
176+
* from the 32K counter. The BUG applies for GPTIMER1 and WDT2 which
177+
* are part of L4 wakeup clockdomain.
174178
*/
175179
mpuss_clkdm = clkdm_lookup("mpuss_clkdm");
176180
emif_clkdm = clkdm_lookup("l3_emif_clkdm");
@@ -179,7 +183,7 @@ int __init omap4_pm_init(void)
179183
ducati_clkdm = clkdm_lookup("ducati_clkdm");
180184
if ((!mpuss_clkdm) || (!emif_clkdm) || (!l3_1_clkdm) ||
181185
(!l3_2_clkdm) || (!ducati_clkdm))
182-
goto err2;
186+
return -EINVAL;
183187

184188
ret = clkdm_add_wkdep(mpuss_clkdm, emif_clkdm);
185189
ret |= clkdm_add_wkdep(mpuss_clkdm, l3_1_clkdm);
@@ -188,9 +192,42 @@ int __init omap4_pm_init(void)
188192
ret |= clkdm_add_wkdep(ducati_clkdm, l3_2_clkdm);
189193
if (ret) {
190194
pr_err("Failed to add MPUSS -> L3/EMIF/L4PER, DUCATI -> L3 wakeup dependency\n");
195+
return -EINVAL;
196+
}
197+
198+
return ret;
199+
}
200+
201+
/**
202+
* omap4_pm_init - Init routine for OMAP4+ devices
203+
*
204+
* Initializes all powerdomain and clockdomain target states
205+
* and all PRCM settings.
206+
* Return: Returns the error code returned by called functions.
207+
*/
208+
int __init omap4_pm_init(void)
209+
{
210+
int ret = 0;
211+
212+
if (omap_rev() == OMAP4430_REV_ES1_0) {
213+
WARN(1, "Power Management not supported on OMAP4430 ES1.0\n");
214+
return -ENODEV;
215+
}
216+
217+
pr_info("Power Management for TI OMAP4+ devices.\n");
218+
219+
ret = pwrdm_for_each(pwrdms_setup, NULL);
220+
if (ret) {
221+
pr_err("Failed to setup powerdomains.\n");
191222
goto err2;
192223
}
193224

225+
if (cpu_is_omap44xx()) {
226+
ret = omap4_init_static_deps();
227+
if (ret)
228+
goto err2;
229+
}
230+
194231
ret = omap4_mpuss_init();
195232
if (ret) {
196233
pr_err("Failed to initialise OMAP4 MPUSS\n");
@@ -206,7 +243,8 @@ int __init omap4_pm_init(void)
206243
/* Overwrite the default cpu_do_idle() */
207244
arm_pm_idle = omap_default_idle;
208245

209-
omap4_idle_init();
246+
if (cpu_is_omap44xx())
247+
omap4_idle_init();
210248

211249
err2:
212250
return ret;

0 commit comments

Comments
 (0)