diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-02-02 04:30:50 -0500 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2012-03-05 19:01:19 -0500 |
commit | 1416408d31236dc2a80d269aa23ffa93aa01e833 (patch) | |
tree | fb77d8bad2e21597ed5d0b34fdd040044999e2c2 | |
parent | b7c39a3f59ae55aa49ebf670e9329bc7da6d3c65 (diff) |
ARM: OMAP2+: PM: share some suspend-related functions across OMAP2, 3, 4
The platform_suspend_ops can be shared across OMAP2, 3, and 4, along
with all of the functions referenced in that structure. This patch
shares them. It also removes the suspend_state file-scoped variable
in the OMAP2 and 3 PM code; it does not appear to be actually needed
by anything.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Reviewed-by: Kevin Hilman <khilman@ti.com>
[khilman@ti.com: minor rework needed due to rebase/merge with conflicting changes]
Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/pm.c | 64 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm24xx.c | 62 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm34xx.c | 52 | ||||
-rw-r--r-- | arch/arm/mach-omap2/pm44xx.c | 39 |
5 files changed, 76 insertions, 142 deletions
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index f9e807958f3e..28706696a341 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c | |||
@@ -15,11 +15,13 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/opp.h> | 16 | #include <linux/opp.h> |
17 | #include <linux/export.h> | 17 | #include <linux/export.h> |
18 | #include <linux/suspend.h> | ||
18 | 19 | ||
19 | #include <plat/omap-pm.h> | 20 | #include <plat/omap-pm.h> |
20 | #include <plat/omap_device.h> | 21 | #include <plat/omap_device.h> |
21 | #include "common.h" | 22 | #include "common.h" |
22 | 23 | ||
24 | #include "prcm-common.h" | ||
23 | #include "voltage.h" | 25 | #include "voltage.h" |
24 | #include "powerdomain.h" | 26 | #include "powerdomain.h" |
25 | #include "clockdomain.h" | 27 | #include "clockdomain.h" |
@@ -28,6 +30,12 @@ | |||
28 | 30 | ||
29 | static struct omap_device_pm_latency *pm_lats; | 31 | static struct omap_device_pm_latency *pm_lats; |
30 | 32 | ||
33 | /* | ||
34 | * omap_pm_suspend: points to a function that does the SoC-specific | ||
35 | * suspend work | ||
36 | */ | ||
37 | int (*omap_pm_suspend)(void); | ||
38 | |||
31 | static int __init _init_omap_device(char *name) | 39 | static int __init _init_omap_device(char *name) |
32 | { | 40 | { |
33 | struct omap_hwmod *oh; | 41 | struct omap_hwmod *oh; |
@@ -134,6 +142,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst) | |||
134 | return ret; | 142 | return ret; |
135 | } | 143 | } |
136 | 144 | ||
145 | |||
146 | |||
137 | /* | 147 | /* |
138 | * This API is to be called during init to set the various voltage | 148 | * This API is to be called during init to set the various voltage |
139 | * domains to the voltage as per the opp table. Typically we boot up | 149 | * domains to the voltage as per the opp table. Typically we boot up |
@@ -201,6 +211,56 @@ exit: | |||
201 | return -EINVAL; | 211 | return -EINVAL; |
202 | } | 212 | } |
203 | 213 | ||
214 | #ifdef CONFIG_SUSPEND | ||
215 | static int omap_pm_enter(suspend_state_t suspend_state) | ||
216 | { | ||
217 | int ret = 0; | ||
218 | |||
219 | if (!omap_pm_suspend) | ||
220 | return -ENOENT; /* XXX doublecheck */ | ||
221 | |||
222 | switch (suspend_state) { | ||
223 | case PM_SUSPEND_STANDBY: | ||
224 | case PM_SUSPEND_MEM: | ||
225 | ret = omap_pm_suspend(); | ||
226 | break; | ||
227 | default: | ||
228 | ret = -EINVAL; | ||
229 | } | ||
230 | |||
231 | return ret; | ||
232 | } | ||
233 | |||
234 | static int omap_pm_begin(suspend_state_t state) | ||
235 | { | ||
236 | disable_hlt(); | ||
237 | if (cpu_is_omap34xx()) | ||
238 | omap_prcm_irq_prepare(); | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static void omap_pm_end(void) | ||
243 | { | ||
244 | enable_hlt(); | ||
245 | return; | ||
246 | } | ||
247 | |||
248 | static void omap_pm_finish(void) | ||
249 | { | ||
250 | if (cpu_is_omap34xx()) | ||
251 | omap_prcm_irq_complete(); | ||
252 | } | ||
253 | |||
254 | static const struct platform_suspend_ops omap_pm_ops = { | ||
255 | .begin = omap_pm_begin, | ||
256 | .end = omap_pm_end, | ||
257 | .enter = omap_pm_enter, | ||
258 | .finish = omap_pm_finish, | ||
259 | .valid = suspend_valid_only_mem, | ||
260 | }; | ||
261 | |||
262 | #endif /* CONFIG_SUSPEND */ | ||
263 | |||
204 | static void __init omap3_init_voltages(void) | 264 | static void __init omap3_init_voltages(void) |
205 | { | 265 | { |
206 | if (!cpu_is_omap34xx()) | 266 | if (!cpu_is_omap34xx()) |
@@ -243,6 +303,10 @@ static int __init omap2_common_pm_late_init(void) | |||
243 | /* Smartreflex device init */ | 303 | /* Smartreflex device init */ |
244 | omap_devinit_smartreflex(); | 304 | omap_devinit_smartreflex(); |
245 | 305 | ||
306 | #ifdef CONFIG_SUSPEND | ||
307 | suspend_set_ops(&omap_pm_ops); | ||
308 | #endif | ||
309 | |||
246 | return 0; | 310 | return 0; |
247 | } | 311 | } |
248 | late_initcall(omap2_common_pm_late_init); | 312 | late_initcall(omap2_common_pm_late_init); |
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index eef67f67872e..a0514310d15f 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h | |||
@@ -23,6 +23,7 @@ extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state); | |||
23 | extern int omap3_idle_init(void); | 23 | extern int omap3_idle_init(void); |
24 | extern int omap4_idle_init(void); | 24 | extern int omap4_idle_init(void); |
25 | extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused); | 25 | extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused); |
26 | extern int (*omap_pm_suspend)(void); | ||
26 | 27 | ||
27 | #if defined(CONFIG_PM_OPP) | 28 | #if defined(CONFIG_PM_OPP) |
28 | extern int omap3_opp_init(void); | 29 | extern int omap3_opp_init(void); |
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c index c4fdde477421..5ca45ca76946 100644 --- a/arch/arm/mach-omap2/pm24xx.c +++ b/arch/arm/mach-omap2/pm24xx.c | |||
@@ -52,19 +52,6 @@ | |||
52 | #include "powerdomain.h" | 52 | #include "powerdomain.h" |
53 | #include "clockdomain.h" | 53 | #include "clockdomain.h" |
54 | 54 | ||
55 | #ifdef CONFIG_SUSPEND | ||
56 | static suspend_state_t suspend_state = PM_SUSPEND_ON; | ||
57 | static inline bool is_suspending(void) | ||
58 | { | ||
59 | return (suspend_state != PM_SUSPEND_ON); | ||
60 | } | ||
61 | #else | ||
62 | static inline bool is_suspending(void) | ||
63 | { | ||
64 | return false; | ||
65 | } | ||
66 | #endif | ||
67 | |||
68 | static void (*omap2_sram_idle)(void); | 55 | static void (*omap2_sram_idle)(void); |
69 | static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, | 56 | static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, |
70 | void __iomem *sdrc_power); | 57 | void __iomem *sdrc_power); |
@@ -84,7 +71,7 @@ static int omap2_fclks_active(void) | |||
84 | return (f1 | f2) ? 1 : 0; | 71 | return (f1 | f2) ? 1 : 0; |
85 | } | 72 | } |
86 | 73 | ||
87 | static void omap2_enter_full_retention(void) | 74 | static int omap2_enter_full_retention(void) |
88 | { | 75 | { |
89 | u32 l; | 76 | u32 l; |
90 | 77 | ||
@@ -147,6 +134,8 @@ no_sleep: | |||
147 | 134 | ||
148 | /* Mask future PRCM-to-MPU interrupts */ | 135 | /* Mask future PRCM-to-MPU interrupts */ |
149 | omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET); | 136 | omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET); |
137 | |||
138 | return 0; | ||
150 | } | 139 | } |
151 | 140 | ||
152 | static int omap2_i2c_active(void) | 141 | static int omap2_i2c_active(void) |
@@ -243,46 +232,6 @@ out: | |||
243 | local_fiq_enable(); | 232 | local_fiq_enable(); |
244 | } | 233 | } |
245 | 234 | ||
246 | #ifdef CONFIG_SUSPEND | ||
247 | static int omap2_pm_begin(suspend_state_t state) | ||
248 | { | ||
249 | disable_hlt(); | ||
250 | suspend_state = state; | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int omap2_pm_enter(suspend_state_t state) | ||
255 | { | ||
256 | int ret = 0; | ||
257 | |||
258 | switch (state) { | ||
259 | case PM_SUSPEND_STANDBY: | ||
260 | case PM_SUSPEND_MEM: | ||
261 | omap2_enter_full_retention(); | ||
262 | break; | ||
263 | default: | ||
264 | ret = -EINVAL; | ||
265 | } | ||
266 | |||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | static void omap2_pm_end(void) | ||
271 | { | ||
272 | suspend_state = PM_SUSPEND_ON; | ||
273 | enable_hlt(); | ||
274 | } | ||
275 | |||
276 | static const struct platform_suspend_ops omap_pm_ops = { | ||
277 | .begin = omap2_pm_begin, | ||
278 | .enter = omap2_pm_enter, | ||
279 | .end = omap2_pm_end, | ||
280 | .valid = suspend_valid_only_mem, | ||
281 | }; | ||
282 | #else | ||
283 | static const struct platform_suspend_ops __initdata omap_pm_ops; | ||
284 | #endif /* CONFIG_SUSPEND */ | ||
285 | |||
286 | static void __init prcm_setup_regs(void) | 235 | static void __init prcm_setup_regs(void) |
287 | { | 236 | { |
288 | int i, num_mem_banks; | 237 | int i, num_mem_banks; |
@@ -327,6 +276,10 @@ static void __init prcm_setup_regs(void) | |||
327 | clkdm_for_each(omap_pm_clkdms_setup, NULL); | 276 | clkdm_for_each(omap_pm_clkdms_setup, NULL); |
328 | clkdm_add_wkdep(mpu_clkdm, wkup_clkdm); | 277 | clkdm_add_wkdep(mpu_clkdm, wkup_clkdm); |
329 | 278 | ||
279 | #ifdef CONFIG_SUSPEND | ||
280 | omap_pm_suspend = omap2_enter_full_retention; | ||
281 | #endif | ||
282 | |||
330 | /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk | 283 | /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk |
331 | * stabilisation */ | 284 | * stabilisation */ |
332 | omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, | 285 | omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, |
@@ -427,7 +380,6 @@ static int __init omap2_pm_init(void) | |||
427 | omap24xx_cpu_suspend_sz); | 380 | omap24xx_cpu_suspend_sz); |
428 | } | 381 | } |
429 | 382 | ||
430 | suspend_set_ops(&omap_pm_ops); | ||
431 | arm_pm_idle = omap2_pm_idle; | 383 | arm_pm_idle = omap2_pm_idle; |
432 | 384 | ||
433 | return 0; | 385 | return 0; |
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 5fc1a987fccc..da054370f837 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c | |||
@@ -50,10 +50,6 @@ | |||
50 | #include "sdrc.h" | 50 | #include "sdrc.h" |
51 | #include "control.h" | 51 | #include "control.h" |
52 | 52 | ||
53 | #ifdef CONFIG_SUSPEND | ||
54 | static suspend_state_t suspend_state = PM_SUSPEND_ON; | ||
55 | #endif | ||
56 | |||
57 | /* pm34xx errata defined in pm.h */ | 53 | /* pm34xx errata defined in pm.h */ |
58 | u16 pm34xx_errata; | 54 | u16 pm34xx_errata; |
59 | 55 | ||
@@ -472,50 +468,6 @@ restore: | |||
472 | return ret; | 468 | return ret; |
473 | } | 469 | } |
474 | 470 | ||
475 | static int omap3_pm_enter(suspend_state_t unused) | ||
476 | { | ||
477 | int ret = 0; | ||
478 | |||
479 | switch (suspend_state) { | ||
480 | case PM_SUSPEND_STANDBY: | ||
481 | case PM_SUSPEND_MEM: | ||
482 | ret = omap3_pm_suspend(); | ||
483 | break; | ||
484 | default: | ||
485 | ret = -EINVAL; | ||
486 | } | ||
487 | |||
488 | return ret; | ||
489 | } | ||
490 | |||
491 | /* Hooks to enable / disable UART interrupts during suspend */ | ||
492 | static int omap3_pm_begin(suspend_state_t state) | ||
493 | { | ||
494 | disable_hlt(); | ||
495 | suspend_state = state; | ||
496 | omap_prcm_irq_prepare(); | ||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | static void omap3_pm_end(void) | ||
501 | { | ||
502 | suspend_state = PM_SUSPEND_ON; | ||
503 | enable_hlt(); | ||
504 | return; | ||
505 | } | ||
506 | |||
507 | static void omap3_pm_finish(void) | ||
508 | { | ||
509 | omap_prcm_irq_complete(); | ||
510 | } | ||
511 | |||
512 | static const struct platform_suspend_ops omap_pm_ops = { | ||
513 | .begin = omap3_pm_begin, | ||
514 | .end = omap3_pm_end, | ||
515 | .enter = omap3_pm_enter, | ||
516 | .finish = omap3_pm_finish, | ||
517 | .valid = suspend_valid_only_mem, | ||
518 | }; | ||
519 | #endif /* CONFIG_SUSPEND */ | 471 | #endif /* CONFIG_SUSPEND */ |
520 | 472 | ||
521 | 473 | ||
@@ -823,8 +775,8 @@ static int __init omap3_pm_init(void) | |||
823 | core_clkdm = clkdm_lookup("core_clkdm"); | 775 | core_clkdm = clkdm_lookup("core_clkdm"); |
824 | 776 | ||
825 | #ifdef CONFIG_SUSPEND | 777 | #ifdef CONFIG_SUSPEND |
826 | suspend_set_ops(&omap_pm_ops); | 778 | omap_pm_suspend = omap3_pm_suspend; |
827 | #endif /* CONFIG_SUSPEND */ | 779 | #endif |
828 | 780 | ||
829 | arm_pm_idle = omap3_pm_idle; | 781 | arm_pm_idle = omap3_pm_idle; |
830 | omap3_idle_init(); | 782 | omap3_idle_init(); |
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c index 84d52f729af4..91e0b1c9b76c 100644 --- a/arch/arm/mach-omap2/pm44xx.c +++ b/arch/arm/mach-omap2/pm44xx.c | |||
@@ -83,41 +83,6 @@ static int omap4_pm_suspend(void) | |||
83 | 83 | ||
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | |||
87 | static int omap4_pm_enter(suspend_state_t suspend_state) | ||
88 | { | ||
89 | int ret = 0; | ||
90 | |||
91 | switch (suspend_state) { | ||
92 | case PM_SUSPEND_STANDBY: | ||
93 | case PM_SUSPEND_MEM: | ||
94 | ret = omap4_pm_suspend(); | ||
95 | break; | ||
96 | default: | ||
97 | ret = -EINVAL; | ||
98 | } | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | static int omap4_pm_begin(suspend_state_t state) | ||
104 | { | ||
105 | disable_hlt(); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static void omap4_pm_end(void) | ||
110 | { | ||
111 | enable_hlt(); | ||
112 | return; | ||
113 | } | ||
114 | |||
115 | static const struct platform_suspend_ops omap_pm_ops = { | ||
116 | .begin = omap4_pm_begin, | ||
117 | .end = omap4_pm_end, | ||
118 | .enter = omap4_pm_enter, | ||
119 | .valid = suspend_valid_only_mem, | ||
120 | }; | ||
121 | #endif /* CONFIG_SUSPEND */ | 86 | #endif /* CONFIG_SUSPEND */ |
122 | 87 | ||
123 | static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) | 88 | static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) |
@@ -234,8 +199,8 @@ static int __init omap4_pm_init(void) | |||
234 | (void) clkdm_for_each(omap_pm_clkdms_setup, NULL); | 199 | (void) clkdm_for_each(omap_pm_clkdms_setup, NULL); |
235 | 200 | ||
236 | #ifdef CONFIG_SUSPEND | 201 | #ifdef CONFIG_SUSPEND |
237 | suspend_set_ops(&omap_pm_ops); | 202 | omap_pm_suspend = omap4_pm_suspend; |
238 | #endif /* CONFIG_SUSPEND */ | 203 | #endif |
239 | 204 | ||
240 | /* Overwrite the default cpu_do_idle() */ | 205 | /* Overwrite the default cpu_do_idle() */ |
241 | arm_pm_idle = omap_default_idle; | 206 | arm_pm_idle = omap_default_idle; |