aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/pm.c20
-rw-r--r--arch/arm/mach-omap2/pm.c20
-rw-r--r--arch/blackfin/mach-common/pm.c53
-rw-r--r--arch/powerpc/platforms/52xx/lite5200_pm.c34
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pm.c9
-rw-r--r--drivers/acpi/sleep/main.c7
-rw-r--r--include/asm-powerpc/mpc52xx.h6
-rw-r--r--include/linux/suspend.h13
-rw-r--r--kernel/power/main.c12
9 files changed, 49 insertions, 125 deletions
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 8db38dd247a4..3bf01e28df33 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -599,27 +599,15 @@ static void (*saved_idle)(void) = NULL;
599 599
600/* 600/*
601 * omap_pm_prepare - Do preliminary suspend work. 601 * omap_pm_prepare - Do preliminary suspend work.
602 * @state: suspend state we're entering.
603 * 602 *
604 */ 603 */
605static int omap_pm_prepare(suspend_state_t state) 604static int omap_pm_prepare(void)
606{ 605{
607 int error = 0;
608
609 /* We cannot sleep in idle until we have resumed */ 606 /* We cannot sleep in idle until we have resumed */
610 saved_idle = pm_idle; 607 saved_idle = pm_idle;
611 pm_idle = NULL; 608 pm_idle = NULL;
612 609
613 switch (state) 610 return 0;
614 {
615 case PM_SUSPEND_STANDBY:
616 case PM_SUSPEND_MEM:
617 break;
618 default:
619 return -EINVAL;
620 }
621
622 return error;
623} 611}
624 612
625 613
@@ -647,16 +635,14 @@ static int omap_pm_enter(suspend_state_t state)
647 635
648/** 636/**
649 * omap_pm_finish - Finish up suspend sequence. 637 * omap_pm_finish - Finish up suspend sequence.
650 * @state: State we're coming out of.
651 * 638 *
652 * This is called after we wake back up (or if entering the sleep state 639 * This is called after we wake back up (or if entering the sleep state
653 * failed). 640 * failed).
654 */ 641 */
655 642
656static int omap_pm_finish(suspend_state_t state) 643static void omap_pm_finish(void)
657{ 644{
658 pm_idle = saved_idle; 645 pm_idle = saved_idle;
659 return 0;
660} 646}
661 647
662 648
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 9aaa7a2633e8..baf7d82b458b 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -70,25 +70,12 @@ void omap2_pm_idle(void)
70 local_irq_enable(); 70 local_irq_enable();
71} 71}
72 72
73static int omap2_pm_prepare(suspend_state_t state) 73static int omap2_pm_prepare(void)
74{ 74{
75 int error = 0;
76
77 /* We cannot sleep in idle until we have resumed */ 75 /* We cannot sleep in idle until we have resumed */
78 saved_idle = pm_idle; 76 saved_idle = pm_idle;
79 pm_idle = NULL; 77 pm_idle = NULL;
80 78 return 0;
81 switch (state)
82 {
83 case PM_SUSPEND_STANDBY:
84 case PM_SUSPEND_MEM:
85 break;
86
87 default:
88 return -EINVAL;
89 }
90
91 return error;
92} 79}
93 80
94#define INT0_WAKE_MASK (OMAP_IRQ_BIT(INT_24XX_GPIO_BANK1) | \ 81#define INT0_WAKE_MASK (OMAP_IRQ_BIT(INT_24XX_GPIO_BANK1) | \
@@ -356,10 +343,9 @@ static int omap2_pm_enter(suspend_state_t state)
356 return ret; 343 return ret;
357} 344}
358 345
359static int omap2_pm_finish(suspend_state_t state) 346static void omap2_pm_finish(void)
360{ 347{
361 pm_idle = saved_idle; 348 pm_idle = saved_idle;
362 return 0;
363} 349}
364 350
365static struct platform_suspend_ops omap_pm_ops = { 351static struct platform_suspend_ops omap_pm_ops = {
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
index 6901891905cc..dac51fb06f22 100644
--- a/arch/blackfin/mach-common/pm.c
+++ b/arch/blackfin/mach-common/pm.c
@@ -89,28 +89,15 @@ void bfin_pm_suspend_standby_enter(void)
89#endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */ 89#endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */
90} 90}
91 91
92
93/* 92/*
94 * bfin_pm_prepare - Do preliminary suspend work. 93 * bfin_pm_valid - Tell the PM core that we only support the standby sleep
95 * @state: suspend state we're entering. 94 * state
95 * @state: suspend state we're checking.
96 * 96 *
97 */ 97 */
98static int bfin_pm_prepare(suspend_state_t state) 98static int bfin_pm_valid(suspend_state_t state)
99{ 99{
100 int error = 0; 100 return (state == PM_SUSPEND_STANDBY);
101
102 switch (state) {
103 case PM_SUSPEND_STANDBY:
104 break;
105
106 case PM_SUSPEND_MEM:
107 return -ENOTSUPP;
108
109 default:
110 return -EINVAL;
111 }
112
113 return error;
114} 101}
115 102
116/* 103/*
@@ -135,38 +122,8 @@ static int bfin_pm_enter(suspend_state_t state)
135 return 0; 122 return 0;
136} 123}
137 124
138/*
139 * bfin_pm_finish - Finish up suspend sequence.
140 * @state: State we're coming out of.
141 *
142 * This is called after we wake back up (or if entering the sleep state
143 * failed).
144 */
145static int bfin_pm_finish(suspend_state_t state)
146{
147 switch (state) {
148 case PM_SUSPEND_STANDBY:
149 break;
150
151 case PM_SUSPEND_MEM:
152 return -ENOTSUPP;
153
154 default:
155 return -EINVAL;
156 }
157
158 return 0;
159}
160
161static int bfin_pm_valid(suspend_state_t state)
162{
163 return (state == PM_SUSPEND_STANDBY);
164}
165
166struct platform_suspend_ops bfin_pm_ops = { 125struct platform_suspend_ops bfin_pm_ops = {
167 .prepare = bfin_pm_prepare,
168 .enter = bfin_pm_enter, 126 .enter = bfin_pm_enter,
169 .finish = bfin_pm_finish,
170 .valid = bfin_pm_valid, 127 .valid = bfin_pm_valid,
171}; 128};
172 129
diff --git a/arch/powerpc/platforms/52xx/lite5200_pm.c b/arch/powerpc/platforms/52xx/lite5200_pm.c
index f26afcd41757..ffa14aff5248 100644
--- a/arch/powerpc/platforms/52xx/lite5200_pm.c
+++ b/arch/powerpc/platforms/52xx/lite5200_pm.c
@@ -1,5 +1,5 @@
1#include <linux/init.h> 1#include <linux/init.h>
2#include <linux/pm.h> 2#include <linux/suspend.h>
3#include <asm/io.h> 3#include <asm/io.h>
4#include <asm/time.h> 4#include <asm/time.h>
5#include <asm/mpc52xx.h> 5#include <asm/mpc52xx.h>
@@ -18,6 +18,8 @@ static void __iomem *sram;
18static const int sram_size = 0x4000; /* 16 kBytes */ 18static const int sram_size = 0x4000; /* 16 kBytes */
19static void __iomem *mbar; 19static void __iomem *mbar;
20 20
21static suspend_state_t lite5200_pm_target_state;
22
21static int lite5200_pm_valid(suspend_state_t state) 23static int lite5200_pm_valid(suspend_state_t state)
22{ 24{
23 switch (state) { 25 switch (state) {
@@ -29,13 +31,22 @@ static int lite5200_pm_valid(suspend_state_t state)
29 } 31 }
30} 32}
31 33
32static int lite5200_pm_prepare(suspend_state_t state) 34static int lite5200_pm_set_target(suspend_state_t state)
35{
36 if (lite5200_pm_valid(state)) {
37 lite5200_pm_target_state = state;
38 return 0;
39 }
40 return -EINVAL;
41}
42
43static int lite5200_pm_prepare(void)
33{ 44{
34 /* deep sleep? let mpc52xx code handle that */ 45 /* deep sleep? let mpc52xx code handle that */
35 if (state == PM_SUSPEND_STANDBY) 46 if (lite5200_pm_target_state == PM_SUSPEND_STANDBY)
36 return mpc52xx_pm_prepare(state); 47 return mpc52xx_pm_prepare();
37 48
38 if (state != PM_SUSPEND_MEM) 49 if (lite5200_pm_target_state != PM_SUSPEND_MEM)
39 return -EINVAL; 50 return -EINVAL;
40 51
41 /* map registers */ 52 /* map registers */
@@ -190,17 +201,16 @@ static int lite5200_pm_enter(suspend_state_t state)
190 return 0; 201 return 0;
191} 202}
192 203
193static int lite5200_pm_finish(suspend_state_t state) 204static void lite5200_pm_finish(void)
194{ 205{
195 /* deep sleep? let mpc52xx code handle that */ 206 /* deep sleep? let mpc52xx code handle that */
196 if (state == PM_SUSPEND_STANDBY) { 207 if (lite5200_pm_target_state == PM_SUSPEND_STANDBY)
197 return mpc52xx_pm_finish(state); 208 mpc52xx_pm_finish();
198 }
199 return 0;
200} 209}
201 210
202static struct pm_ops lite5200_pm_ops = { 211static struct platform_suspend_ops lite5200_pm_ops = {
203 .valid = lite5200_pm_valid, 212 .valid = lite5200_pm_valid,
213 .set_target = lite5200_pm_set_target,
204 .prepare = lite5200_pm_prepare, 214 .prepare = lite5200_pm_prepare,
205 .enter = lite5200_pm_enter, 215 .enter = lite5200_pm_enter,
206 .finish = lite5200_pm_finish, 216 .finish = lite5200_pm_finish,
@@ -208,6 +218,6 @@ static struct pm_ops lite5200_pm_ops = {
208 218
209int __init lite5200_pm_init(void) 219int __init lite5200_pm_init(void)
210{ 220{
211 pm_set_ops(&lite5200_pm_ops); 221 suspend_set_ops(&lite5200_pm_ops);
212 return 0; 222 return 0;
213} 223}
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pm.c b/arch/powerpc/platforms/52xx/mpc52xx_pm.c
index 44fb064c7a16..7ffa7babf254 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pm.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pm.c
@@ -57,11 +57,8 @@ int mpc52xx_set_wakeup_gpio(u8 pin, u8 level)
57 return 0; 57 return 0;
58} 58}
59 59
60int mpc52xx_pm_prepare(suspend_state_t state) 60int mpc52xx_pm_prepare(void)
61{ 61{
62 if (state != PM_SUSPEND_STANDBY)
63 return -EINVAL;
64
65 /* map the whole register space */ 62 /* map the whole register space */
66 mbar = mpc52xx_find_and_map("mpc5200"); 63 mbar = mpc52xx_find_and_map("mpc5200");
67 if (!mbar) { 64 if (!mbar) {
@@ -166,15 +163,13 @@ int mpc52xx_pm_enter(suspend_state_t state)
166 return 0; 163 return 0;
167} 164}
168 165
169int mpc52xx_pm_finish(suspend_state_t state) 166void mpc52xx_pm_finish(void)
170{ 167{
171 /* call board resume code */ 168 /* call board resume code */
172 if (mpc52xx_suspend.board_resume_finish) 169 if (mpc52xx_suspend.board_resume_finish)
173 mpc52xx_suspend.board_resume_finish(mbar); 170 mpc52xx_suspend.board_resume_finish(mbar);
174 171
175 iounmap(mbar); 172 iounmap(mbar);
176
177 return 0;
178} 173}
179 174
180static struct platform_suspend_ops mpc52xx_pm_ops = { 175static struct platform_suspend_ops mpc52xx_pm_ops = {
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 3271850a1f35..c58dd0bb5506 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -85,13 +85,12 @@ static int acpi_pm_set_target(suspend_state_t pm_state)
85 85
86/** 86/**
87 * acpi_pm_prepare - Do preliminary suspend work. 87 * acpi_pm_prepare - Do preliminary suspend work.
88 * @pm_state: ignored
89 * 88 *
90 * If necessary, set the firmware waking vector and do arch-specific 89 * If necessary, set the firmware waking vector and do arch-specific
91 * nastiness to get the wakeup code to the waking vector. 90 * nastiness to get the wakeup code to the waking vector.
92 */ 91 */
93 92
94static int acpi_pm_prepare(suspend_state_t pm_state) 93static int acpi_pm_prepare(void)
95{ 94{
96 int error = acpi_sleep_prepare(acpi_target_sleep_state); 95 int error = acpi_sleep_prepare(acpi_target_sleep_state);
97 96
@@ -160,13 +159,12 @@ static int acpi_pm_enter(suspend_state_t pm_state)
160 159
161/** 160/**
162 * acpi_pm_finish - Finish up suspend sequence. 161 * acpi_pm_finish - Finish up suspend sequence.
163 * @pm_state: ignored
164 * 162 *
165 * This is called after we wake back up (or if entering the sleep state 163 * This is called after we wake back up (or if entering the sleep state
166 * failed). 164 * failed).
167 */ 165 */
168 166
169static int acpi_pm_finish(suspend_state_t pm_state) 167static void acpi_pm_finish(void)
170{ 168{
171 u32 acpi_state = acpi_target_sleep_state; 169 u32 acpi_state = acpi_target_sleep_state;
172 170
@@ -184,7 +182,6 @@ static int acpi_pm_finish(suspend_state_t pm_state)
184 init_8259A(0); 182 init_8259A(0);
185 } 183 }
186#endif 184#endif
187 return 0;
188} 185}
189 186
190static int acpi_pm_state_valid(suspend_state_t pm_state) 187static int acpi_pm_state_valid(suspend_state_t pm_state)
diff --git a/include/asm-powerpc/mpc52xx.h b/include/asm-powerpc/mpc52xx.h
index 24751df791ac..568135fe52ea 100644
--- a/include/asm-powerpc/mpc52xx.h
+++ b/include/asm-powerpc/mpc52xx.h
@@ -18,6 +18,8 @@
18#include <asm/prom.h> 18#include <asm/prom.h>
19#endif /* __ASSEMBLY__ */ 19#endif /* __ASSEMBLY__ */
20 20
21#include <linux/suspend.h>
22
21 23
22/* ======================================================================== */ 24/* ======================================================================== */
23/* Structures mapping of some unit register set */ 25/* Structures mapping of some unit register set */
@@ -267,9 +269,9 @@ extern int mpc52xx_set_wakeup_gpio(u8 pin, u8 level);
267extern int __init lite5200_pm_init(void); 269extern int __init lite5200_pm_init(void);
268 270
269/* lite5200 calls mpc5200 suspend functions, so here they are */ 271/* lite5200 calls mpc5200 suspend functions, so here they are */
270extern int mpc52xx_pm_prepare(suspend_state_t); 272extern int mpc52xx_pm_prepare(void);
271extern int mpc52xx_pm_enter(suspend_state_t); 273extern int mpc52xx_pm_enter(suspend_state_t);
272extern int mpc52xx_pm_finish(suspend_state_t); 274extern void mpc52xx_pm_finish(void);
273extern char saved_sram[0x4000]; /* reuse buffer from mpc52xx suspend */ 275extern char saved_sram[0x4000]; /* reuse buffer from mpc52xx suspend */
274#endif 276#endif
275#endif /* CONFIG_PM */ 277#endif /* CONFIG_PM */
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index dce47825dbb8..541f0c46d34f 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -46,12 +46,10 @@ typedef int __bitwise suspend_state_t;
46 * @prepare() fails. If @set_target() fails (ie. returns nonzero), 46 * @prepare() fails. If @set_target() fails (ie. returns nonzero),
47 * @prepare(), @enter() and @finish() will not be called by the PM core. 47 * @prepare(), @enter() and @finish() will not be called by the PM core.
48 * This callback is optional. However, if it is implemented, the argument 48 * This callback is optional. However, if it is implemented, the argument
49 * passed to @prepare(), @enter() and @finish() is meaningless and should 49 * passed to @enter() is meaningless and should be ignored.
50 * be ignored.
51 * 50 *
52 * @prepare: Prepare the platform for entering the system sleep state indicated 51 * @prepare: Prepare the platform for entering the system sleep state indicated
53 * by @set_target() or represented by the argument if @set_target() is not 52 * by @set_target().
54 * implemented.
55 * @prepare() is called right after devices have been suspended (ie. the 53 * @prepare() is called right after devices have been suspended (ie. the
56 * appropriate .suspend() method has been executed for each device) and 54 * appropriate .suspend() method has been executed for each device) and
57 * before the nonboot CPUs are disabled (it is executed with IRQs enabled). 55 * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
@@ -67,8 +65,7 @@ typedef int __bitwise suspend_state_t;
67 * 65 *
68 * @finish: Called when the system has just left a sleep state, right after 66 * @finish: Called when the system has just left a sleep state, right after
69 * the nonboot CPUs have been enabled and before devices are resumed (it is 67 * the nonboot CPUs have been enabled and before devices are resumed (it is
70 * executed with IRQs enabled). If @set_target() is not implemented, the 68 * executed with IRQs enabled).
71 * argument represents the sleep state being left.
72 * This callback is optional, but should be implemented by the platforms 69 * This callback is optional, but should be implemented by the platforms
73 * that implement @prepare(). If implemented, it is always called after 70 * that implement @prepare(). If implemented, it is always called after
74 * @enter() (even if @enter() fails). 71 * @enter() (even if @enter() fails).
@@ -76,9 +73,9 @@ typedef int __bitwise suspend_state_t;
76struct platform_suspend_ops { 73struct platform_suspend_ops {
77 int (*valid)(suspend_state_t state); 74 int (*valid)(suspend_state_t state);
78 int (*set_target)(suspend_state_t state); 75 int (*set_target)(suspend_state_t state);
79 int (*prepare)(suspend_state_t state); 76 int (*prepare)(void);
80 int (*enter)(suspend_state_t state); 77 int (*enter)(suspend_state_t state);
81 int (*finish)(suspend_state_t state); 78 void (*finish)(void);
82}; 79};
83 80
84#ifdef CONFIG_SUSPEND 81#ifdef CONFIG_SUSPEND
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 854bf0811d40..7d09a9894947 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -58,13 +58,6 @@ int suspend_valid_only_mem(suspend_state_t state)
58 return state == PM_SUSPEND_MEM; 58 return state == PM_SUSPEND_MEM;
59} 59}
60 60
61
62static inline void pm_finish(suspend_state_t state)
63{
64 if (suspend_ops->finish)
65 suspend_ops->finish(state);
66}
67
68/** 61/**
69 * suspend_prepare - Do prep work before entering low-power state. 62 * suspend_prepare - Do prep work before entering low-power state.
70 * 63 *
@@ -171,7 +164,7 @@ int suspend_devices_and_enter(suspend_state_t state)
171 goto Resume_console; 164 goto Resume_console;
172 } 165 }
173 if (suspend_ops->prepare) { 166 if (suspend_ops->prepare) {
174 error = suspend_ops->prepare(state); 167 error = suspend_ops->prepare();
175 if (error) 168 if (error)
176 goto Resume_devices; 169 goto Resume_devices;
177 } 170 }
@@ -180,7 +173,8 @@ int suspend_devices_and_enter(suspend_state_t state)
180 suspend_enter(state); 173 suspend_enter(state);
181 174
182 enable_nonboot_cpus(); 175 enable_nonboot_cpus();
183 pm_finish(state); 176 if (suspend_ops->finish)
177 suspend_ops->finish();
184 Resume_devices: 178 Resume_devices:
185 device_resume(); 179 device_resume();
186 Resume_console: 180 Resume_console: