]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * sleep.c - ACPI sleep support. | |
3 | * | |
e2a5b420 | 4 | * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> |
1da177e4 LT |
5 | * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com> |
6 | * Copyright (c) 2000-2003 Patrick Mochel | |
7 | * Copyright (c) 2003 Open Source Development Lab | |
8 | * | |
9 | * This file is released under the GPLv2. | |
10 | * | |
11 | */ | |
12 | ||
13 | #include <linux/delay.h> | |
14 | #include <linux/irq.h> | |
15 | #include <linux/dmi.h> | |
16 | #include <linux/device.h> | |
17 | #include <linux/suspend.h> | |
f216cc37 AS |
18 | |
19 | #include <asm/io.h> | |
20 | ||
1da177e4 LT |
21 | #include <acpi/acpi_bus.h> |
22 | #include <acpi/acpi_drivers.h> | |
23 | #include "sleep.h" | |
24 | ||
25 | u8 sleep_states[ACPI_S_STATE_COUNT]; | |
26 | ||
853298bc | 27 | #ifdef CONFIG_PM_SLEEP |
296699de | 28 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
60417f59 RW |
29 | static bool acpi_sleep_finish_wake_up; |
30 | ||
31 | /* | |
32 | * ACPI 2.0 and later want us to execute _PTS after suspending devices, so we | |
33 | * allow the user to request that behavior by using the 'acpi_new_pts_ordering' | |
34 | * kernel command line option that causes the following variable to be set. | |
35 | */ | |
36 | static bool new_pts_ordering; | |
37 | ||
38 | static int __init acpi_new_pts_ordering(char *str) | |
39 | { | |
40 | new_pts_ordering = true; | |
41 | return 1; | |
42 | } | |
43 | __setup("acpi_new_pts_ordering", acpi_new_pts_ordering); | |
853298bc | 44 | #endif |
296699de | 45 | |
c9b6c8f6 | 46 | static int acpi_sleep_prepare(u32 acpi_state) |
2f3f2226 AS |
47 | { |
48 | #ifdef CONFIG_ACPI_SLEEP | |
49 | /* do we have a wakeup address for S2 and S3? */ | |
50 | if (acpi_state == ACPI_STATE_S3) { | |
51 | if (!acpi_wakeup_address) { | |
52 | return -EFAULT; | |
53 | } | |
54 | acpi_set_firmware_waking_vector((acpi_physical_address) | |
55 | virt_to_phys((void *) | |
56 | acpi_wakeup_address)); | |
57 | ||
58 | } | |
59 | ACPI_FLUSH_CPU_CACHE(); | |
60 | acpi_enable_wakeup_device_prep(acpi_state); | |
61 | #endif | |
c9b6c8f6 RW |
62 | printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", |
63 | acpi_state); | |
2f3f2226 AS |
64 | acpi_enter_sleep_state_prep(acpi_state); |
65 | return 0; | |
66 | } | |
67 | ||
296699de | 68 | #ifdef CONFIG_SUSPEND |
26398a70 | 69 | static struct platform_suspend_ops acpi_pm_ops; |
1da177e4 | 70 | |
1da177e4 LT |
71 | extern void do_suspend_lowlevel(void); |
72 | ||
73 | static u32 acpi_suspend_states[] = { | |
e2a5b420 AS |
74 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
75 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, | |
76 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, | |
e2a5b420 | 77 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 |
1da177e4 LT |
78 | }; |
79 | ||
80 | static int init_8259A_after_S1; | |
81 | ||
e9b3aba8 | 82 | /** |
c697eece | 83 | * acpi_pm_begin - Set the target system sleep state to the state |
e9b3aba8 RW |
84 | * associated with given @pm_state, if supported. |
85 | */ | |
86 | ||
c697eece | 87 | static int acpi_pm_begin(suspend_state_t pm_state) |
e9b3aba8 RW |
88 | { |
89 | u32 acpi_state = acpi_suspend_states[pm_state]; | |
90 | int error = 0; | |
91 | ||
92 | if (sleep_states[acpi_state]) { | |
93 | acpi_target_sleep_state = acpi_state; | |
60417f59 RW |
94 | if (new_pts_ordering) |
95 | return 0; | |
96 | ||
97 | error = acpi_sleep_prepare(acpi_state); | |
98 | if (error) | |
99 | acpi_target_sleep_state = ACPI_STATE_S0; | |
100 | else | |
101 | acpi_sleep_finish_wake_up = true; | |
e9b3aba8 RW |
102 | } else { |
103 | printk(KERN_ERR "ACPI does not support this state: %d\n", | |
104 | pm_state); | |
105 | error = -ENOSYS; | |
106 | } | |
107 | return error; | |
108 | } | |
109 | ||
1da177e4 LT |
110 | /** |
111 | * acpi_pm_prepare - Do preliminary suspend work. | |
1da177e4 | 112 | * |
e9b3aba8 RW |
113 | * If necessary, set the firmware waking vector and do arch-specific |
114 | * nastiness to get the wakeup code to the waking vector. | |
1da177e4 LT |
115 | */ |
116 | ||
e6c5eb95 | 117 | static int acpi_pm_prepare(void) |
1da177e4 | 118 | { |
60417f59 RW |
119 | if (new_pts_ordering) { |
120 | int error = acpi_sleep_prepare(acpi_target_sleep_state); | |
1da177e4 | 121 | |
60417f59 RW |
122 | if (error) { |
123 | acpi_target_sleep_state = ACPI_STATE_S0; | |
124 | return error; | |
125 | } | |
126 | acpi_sleep_finish_wake_up = true; | |
127 | } | |
e9b3aba8 | 128 | |
60417f59 | 129 | return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; |
1da177e4 LT |
130 | } |
131 | ||
1da177e4 LT |
132 | /** |
133 | * acpi_pm_enter - Actually enter a sleep state. | |
e9b3aba8 | 134 | * @pm_state: ignored |
1da177e4 | 135 | * |
50ad147a RW |
136 | * Flush caches and go to sleep. For STR we have to call arch-specific |
137 | * assembly, which in turn call acpi_enter_sleep_state(). | |
1da177e4 LT |
138 | * It's unfortunate, but it works. Please fix if you're feeling frisky. |
139 | */ | |
140 | ||
141 | static int acpi_pm_enter(suspend_state_t pm_state) | |
142 | { | |
143 | acpi_status status = AE_OK; | |
144 | unsigned long flags = 0; | |
e9b3aba8 | 145 | u32 acpi_state = acpi_target_sleep_state; |
1da177e4 LT |
146 | |
147 | ACPI_FLUSH_CPU_CACHE(); | |
148 | ||
149 | /* Do arch specific saving of state. */ | |
50ad147a | 150 | if (acpi_state == ACPI_STATE_S3) { |
1da177e4 | 151 | int error = acpi_save_state_mem(); |
e9b3aba8 | 152 | |
60417f59 | 153 | if (error) |
1da177e4 LT |
154 | return error; |
155 | } | |
156 | ||
1da177e4 LT |
157 | local_irq_save(flags); |
158 | acpi_enable_wakeup_device(acpi_state); | |
e9b3aba8 RW |
159 | switch (acpi_state) { |
160 | case ACPI_STATE_S1: | |
1da177e4 LT |
161 | barrier(); |
162 | status = acpi_enter_sleep_state(acpi_state); | |
163 | break; | |
164 | ||
e9b3aba8 | 165 | case ACPI_STATE_S3: |
1da177e4 LT |
166 | do_suspend_lowlevel(); |
167 | break; | |
1da177e4 | 168 | } |
872d83d0 | 169 | |
c95d47a8 RW |
170 | /* Reprogram control registers and execute _BFS */ |
171 | acpi_leave_sleep_state_prep(acpi_state); | |
172 | ||
23b168d4 | 173 | /* ACPI 3.0 specs (P62) says that it's the responsibility |
872d83d0 AP |
174 | * of the OSPM to clear the status bit [ implying that the |
175 | * POWER_BUTTON event should not reach userspace ] | |
176 | */ | |
177 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) | |
178 | acpi_clear_event(ACPI_EVENT_POWER_BUTTON); | |
179 | ||
a3627f67 SL |
180 | /* |
181 | * Disable and clear GPE status before interrupt is enabled. Some GPEs | |
182 | * (like wakeup GPE) haven't handler, this can avoid such GPE misfire. | |
183 | * acpi_leave_sleep_state will reenable specific GPEs later | |
184 | */ | |
185 | acpi_hw_disable_all_gpes(); | |
186 | ||
1da177e4 LT |
187 | local_irq_restore(flags); |
188 | printk(KERN_DEBUG "Back to C!\n"); | |
189 | ||
e9b3aba8 | 190 | /* restore processor state */ |
50ad147a | 191 | if (acpi_state == ACPI_STATE_S3) |
1da177e4 LT |
192 | acpi_restore_state_mem(); |
193 | ||
1da177e4 LT |
194 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
195 | } | |
196 | ||
1da177e4 | 197 | /** |
c697eece | 198 | * acpi_pm_finish - Instruct the platform to leave a sleep state. |
1da177e4 LT |
199 | * |
200 | * This is called after we wake back up (or if entering the sleep state | |
201 | * failed). | |
202 | */ | |
203 | ||
e6c5eb95 | 204 | static void acpi_pm_finish(void) |
1da177e4 | 205 | { |
e9b3aba8 | 206 | u32 acpi_state = acpi_target_sleep_state; |
1da177e4 | 207 | |
1da177e4 | 208 | acpi_disable_wakeup_device(acpi_state); |
1dbc1fda | 209 | acpi_leave_sleep_state(acpi_state); |
1da177e4 LT |
210 | |
211 | /* reset firmware waking vector */ | |
212 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | |
213 | ||
e9b3aba8 | 214 | acpi_target_sleep_state = ACPI_STATE_S0; |
60417f59 | 215 | acpi_sleep_finish_wake_up = false; |
e9b3aba8 | 216 | |
e8b2fd01 | 217 | #ifdef CONFIG_X86 |
1da177e4 LT |
218 | if (init_8259A_after_S1) { |
219 | printk("Broken toshiba laptop -> kicking interrupts\n"); | |
220 | init_8259A(0); | |
221 | } | |
e8b2fd01 | 222 | #endif |
1da177e4 LT |
223 | } |
224 | ||
c697eece RW |
225 | /** |
226 | * acpi_pm_end - Finish up suspend sequence. | |
227 | */ | |
228 | ||
229 | static void acpi_pm_end(void) | |
230 | { | |
231 | /* | |
60417f59 RW |
232 | * This is necessary in case acpi_pm_finish() is not called directly |
233 | * during a failing transition to a sleep state. | |
c697eece | 234 | */ |
60417f59 RW |
235 | if (acpi_sleep_finish_wake_up) |
236 | acpi_pm_finish(); | |
c697eece RW |
237 | } |
238 | ||
eb9289eb SL |
239 | static int acpi_pm_state_valid(suspend_state_t pm_state) |
240 | { | |
e8c9c502 | 241 | u32 acpi_state; |
eb9289eb | 242 | |
e8c9c502 JB |
243 | switch (pm_state) { |
244 | case PM_SUSPEND_ON: | |
245 | case PM_SUSPEND_STANDBY: | |
246 | case PM_SUSPEND_MEM: | |
247 | acpi_state = acpi_suspend_states[pm_state]; | |
248 | ||
249 | return sleep_states[acpi_state]; | |
250 | default: | |
251 | return 0; | |
252 | } | |
eb9289eb SL |
253 | } |
254 | ||
26398a70 | 255 | static struct platform_suspend_ops acpi_pm_ops = { |
eb9289eb | 256 | .valid = acpi_pm_state_valid, |
c697eece | 257 | .begin = acpi_pm_begin, |
e2a5b420 AS |
258 | .prepare = acpi_pm_prepare, |
259 | .enter = acpi_pm_enter, | |
260 | .finish = acpi_pm_finish, | |
c697eece | 261 | .end = acpi_pm_end, |
1da177e4 LT |
262 | }; |
263 | ||
296699de RW |
264 | /* |
265 | * Toshiba fails to preserve interrupts over S1, reinitialization | |
266 | * of 8259 is needed after S1 resume. | |
267 | */ | |
1855256c | 268 | static int __init init_ints_after_s1(const struct dmi_system_id *d) |
296699de RW |
269 | { |
270 | printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident); | |
271 | init_8259A_after_S1 = 1; | |
272 | return 0; | |
273 | } | |
274 | ||
275 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | |
276 | { | |
277 | .callback = init_ints_after_s1, | |
278 | .ident = "Toshiba Satellite 4030cdt", | |
279 | .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),}, | |
280 | }, | |
281 | {}, | |
282 | }; | |
283 | #endif /* CONFIG_SUSPEND */ | |
284 | ||
b0cb1a19 | 285 | #ifdef CONFIG_HIBERNATION |
caea99ef | 286 | static int acpi_hibernation_begin(void) |
74f270af | 287 | { |
7258ec5d RW |
288 | int error; |
289 | ||
74f270af | 290 | acpi_target_sleep_state = ACPI_STATE_S4; |
7258ec5d RW |
291 | if (new_pts_ordering) |
292 | return 0; | |
293 | ||
294 | error = acpi_sleep_prepare(ACPI_STATE_S4); | |
295 | if (error) | |
296 | acpi_target_sleep_state = ACPI_STATE_S0; | |
297 | else | |
298 | acpi_sleep_finish_wake_up = true; | |
299 | ||
300 | return error; | |
74f270af RW |
301 | } |
302 | ||
a3d25c27 RW |
303 | static int acpi_hibernation_prepare(void) |
304 | { | |
7258ec5d RW |
305 | if (new_pts_ordering) { |
306 | int error = acpi_sleep_prepare(ACPI_STATE_S4); | |
3c1d2b60 | 307 | |
7258ec5d RW |
308 | if (error) { |
309 | acpi_target_sleep_state = ACPI_STATE_S0; | |
310 | return error; | |
311 | } | |
312 | acpi_sleep_finish_wake_up = true; | |
313 | } | |
3c1d2b60 | 314 | |
7258ec5d | 315 | return ACPI_SUCCESS(acpi_hw_disable_all_gpes()) ? 0 : -EFAULT; |
a3d25c27 RW |
316 | } |
317 | ||
318 | static int acpi_hibernation_enter(void) | |
319 | { | |
320 | acpi_status status = AE_OK; | |
321 | unsigned long flags = 0; | |
322 | ||
323 | ACPI_FLUSH_CPU_CACHE(); | |
324 | ||
325 | local_irq_save(flags); | |
326 | acpi_enable_wakeup_device(ACPI_STATE_S4); | |
327 | /* This shouldn't return. If it returns, we have a problem */ | |
328 | status = acpi_enter_sleep_state(ACPI_STATE_S4); | |
c95d47a8 RW |
329 | /* Reprogram control registers and execute _BFS */ |
330 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); | |
a3d25c27 RW |
331 | local_irq_restore(flags); |
332 | ||
333 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | |
334 | } | |
335 | ||
c7e0831d RW |
336 | static void acpi_hibernation_leave(void) |
337 | { | |
338 | /* | |
339 | * If ACPI is not enabled by the BIOS and the boot kernel, we need to | |
340 | * enable it here. | |
341 | */ | |
342 | acpi_enable(); | |
c95d47a8 RW |
343 | /* Reprogram control registers and execute _BFS */ |
344 | acpi_leave_sleep_state_prep(ACPI_STATE_S4); | |
c7e0831d RW |
345 | } |
346 | ||
a3d25c27 RW |
347 | static void acpi_hibernation_finish(void) |
348 | { | |
a3d25c27 | 349 | acpi_disable_wakeup_device(ACPI_STATE_S4); |
1dbc1fda | 350 | acpi_leave_sleep_state(ACPI_STATE_S4); |
a3d25c27 RW |
351 | |
352 | /* reset firmware waking vector */ | |
353 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | |
74f270af RW |
354 | |
355 | acpi_target_sleep_state = ACPI_STATE_S0; | |
7258ec5d | 356 | acpi_sleep_finish_wake_up = false; |
a3d25c27 RW |
357 | } |
358 | ||
caea99ef RW |
359 | static void acpi_hibernation_end(void) |
360 | { | |
361 | /* | |
362 | * This is necessary in case acpi_hibernation_finish() is not called | |
7258ec5d | 363 | * directly during a failing transition to the sleep state. |
caea99ef | 364 | */ |
7258ec5d RW |
365 | if (acpi_sleep_finish_wake_up) |
366 | acpi_hibernation_finish(); | |
caea99ef RW |
367 | } |
368 | ||
a634cc10 RW |
369 | static int acpi_hibernation_pre_restore(void) |
370 | { | |
371 | acpi_status status; | |
372 | ||
373 | status = acpi_hw_disable_all_gpes(); | |
374 | ||
375 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | |
376 | } | |
377 | ||
378 | static void acpi_hibernation_restore_cleanup(void) | |
379 | { | |
380 | acpi_hw_enable_all_runtime_gpes(); | |
381 | } | |
382 | ||
b3dac3b3 | 383 | static struct platform_hibernation_ops acpi_hibernation_ops = { |
caea99ef RW |
384 | .begin = acpi_hibernation_begin, |
385 | .end = acpi_hibernation_end, | |
74f270af RW |
386 | .pre_snapshot = acpi_hibernation_prepare, |
387 | .finish = acpi_hibernation_finish, | |
a3d25c27 RW |
388 | .prepare = acpi_hibernation_prepare, |
389 | .enter = acpi_hibernation_enter, | |
c7e0831d | 390 | .leave = acpi_hibernation_leave, |
a634cc10 RW |
391 | .pre_restore = acpi_hibernation_pre_restore, |
392 | .restore_cleanup = acpi_hibernation_restore_cleanup, | |
a3d25c27 | 393 | }; |
b0cb1a19 | 394 | #endif /* CONFIG_HIBERNATION */ |
a3d25c27 | 395 | |
296699de RW |
396 | int acpi_suspend(u32 acpi_state) |
397 | { | |
398 | suspend_state_t states[] = { | |
399 | [1] = PM_SUSPEND_STANDBY, | |
400 | [3] = PM_SUSPEND_MEM, | |
401 | [5] = PM_SUSPEND_MAX | |
402 | }; | |
403 | ||
404 | if (acpi_state < 6 && states[acpi_state]) | |
405 | return pm_suspend(states[acpi_state]); | |
406 | if (acpi_state == 4) | |
407 | return hibernate(); | |
408 | return -EINVAL; | |
409 | } | |
410 | ||
853298bc | 411 | #ifdef CONFIG_PM_SLEEP |
fd4aff1a SL |
412 | /** |
413 | * acpi_pm_device_sleep_state - return preferred power state of ACPI device | |
414 | * in the system sleep state given by %acpi_target_sleep_state | |
415 | * @dev: device to examine | |
416 | * @wake: if set, the device should be able to wake up the system | |
417 | * @d_min_p: used to store the upper limit of allowed states range | |
418 | * Return value: preferred power state of the device on success, -ENODEV on | |
419 | * failure (ie. if there's no 'struct acpi_device' for @dev) | |
420 | * | |
421 | * Find the lowest power (highest number) ACPI device power state that | |
422 | * device @dev can be in while the system is in the sleep state represented | |
423 | * by %acpi_target_sleep_state. If @wake is nonzero, the device should be | |
424 | * able to wake up the system from this sleep state. If @d_min_p is set, | |
425 | * the highest power (lowest number) device power state of @dev allowed | |
426 | * in this system sleep state is stored at the location pointed to by it. | |
427 | * | |
428 | * The caller must ensure that @dev is valid before using this function. | |
429 | * The caller is also responsible for figuring out if the device is | |
430 | * supposed to be able to wake up the system and passing this information | |
431 | * via @wake. | |
432 | */ | |
433 | ||
434 | int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p) | |
435 | { | |
436 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | |
437 | struct acpi_device *adev; | |
438 | char acpi_method[] = "_SxD"; | |
439 | unsigned long d_min, d_max; | |
440 | ||
441 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | |
ead77594 | 442 | printk(KERN_DEBUG "ACPI handle has no context!\n"); |
fd4aff1a SL |
443 | return -ENODEV; |
444 | } | |
445 | ||
446 | acpi_method[2] = '0' + acpi_target_sleep_state; | |
447 | /* | |
448 | * If the sleep state is S0, we will return D3, but if the device has | |
449 | * _S0W, we will use the value from _S0W | |
450 | */ | |
451 | d_min = ACPI_STATE_D0; | |
452 | d_max = ACPI_STATE_D3; | |
453 | ||
454 | /* | |
455 | * If present, _SxD methods return the minimum D-state (highest power | |
456 | * state) we can use for the corresponding S-states. Otherwise, the | |
457 | * minimum D-state is D0 (ACPI 3.x). | |
458 | * | |
459 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer | |
460 | * provided -- that's our fault recovery, we ignore retval. | |
461 | */ | |
462 | if (acpi_target_sleep_state > ACPI_STATE_S0) | |
463 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_min); | |
464 | ||
465 | /* | |
466 | * If _PRW says we can wake up the system from the target sleep state, | |
467 | * the D-state returned by _SxD is sufficient for that (we assume a | |
468 | * wakeup-aware driver if wake is set). Still, if _SxW exists | |
469 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that | |
470 | * can wake the system. _S0W may be valid, too. | |
471 | */ | |
472 | if (acpi_target_sleep_state == ACPI_STATE_S0 || | |
473 | (wake && adev->wakeup.state.enabled && | |
474 | adev->wakeup.sleep_state <= acpi_target_sleep_state)) { | |
ad3399c3 RW |
475 | acpi_status status; |
476 | ||
fd4aff1a | 477 | acpi_method[3] = 'W'; |
ad3399c3 RW |
478 | status = acpi_evaluate_integer(handle, acpi_method, NULL, |
479 | &d_max); | |
480 | if (ACPI_FAILURE(status)) { | |
481 | d_max = d_min; | |
482 | } else if (d_max < d_min) { | |
483 | /* Warn the user of the broken DSDT */ | |
484 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", | |
485 | acpi_method); | |
486 | /* Sanitize it */ | |
fd4aff1a | 487 | d_min = d_max; |
ad3399c3 | 488 | } |
fd4aff1a SL |
489 | } |
490 | ||
491 | if (d_min_p) | |
492 | *d_min_p = d_min; | |
493 | return d_max; | |
494 | } | |
853298bc | 495 | #endif |
fd4aff1a | 496 | |
f216cc37 AS |
497 | static void acpi_power_off_prepare(void) |
498 | { | |
499 | /* Prepare to power off the system */ | |
500 | acpi_sleep_prepare(ACPI_STATE_S5); | |
3c1d2b60 | 501 | acpi_hw_disable_all_gpes(); |
f216cc37 AS |
502 | } |
503 | ||
504 | static void acpi_power_off(void) | |
505 | { | |
506 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | |
507 | printk("%s called\n", __FUNCTION__); | |
508 | local_irq_disable(); | |
9c1c6a1b | 509 | acpi_enable_wakeup_device(ACPI_STATE_S5); |
f216cc37 AS |
510 | acpi_enter_sleep_state(ACPI_STATE_S5); |
511 | } | |
512 | ||
aafbcd16 | 513 | int __init acpi_sleep_init(void) |
1da177e4 | 514 | { |
296699de RW |
515 | acpi_status status; |
516 | u8 type_a, type_b; | |
517 | #ifdef CONFIG_SUSPEND | |
e2a5b420 | 518 | int i = 0; |
1da177e4 LT |
519 | |
520 | dmi_check_system(acpisleep_dmi_table); | |
296699de | 521 | #endif |
1da177e4 LT |
522 | |
523 | if (acpi_disabled) | |
524 | return 0; | |
525 | ||
5a50fe70 FP |
526 | sleep_states[ACPI_STATE_S0] = 1; |
527 | printk(KERN_INFO PREFIX "(supports S0"); | |
528 | ||
296699de | 529 | #ifdef CONFIG_SUSPEND |
5a50fe70 | 530 | for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++) { |
1da177e4 LT |
531 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); |
532 | if (ACPI_SUCCESS(status)) { | |
533 | sleep_states[i] = 1; | |
534 | printk(" S%d", i); | |
535 | } | |
1da177e4 | 536 | } |
1da177e4 | 537 | |
26398a70 | 538 | suspend_set_ops(&acpi_pm_ops); |
296699de | 539 | #endif |
a3d25c27 | 540 | |
b0cb1a19 | 541 | #ifdef CONFIG_HIBERNATION |
296699de RW |
542 | status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b); |
543 | if (ACPI_SUCCESS(status)) { | |
a3d25c27 | 544 | hibernation_set_ops(&acpi_hibernation_ops); |
296699de | 545 | sleep_states[ACPI_STATE_S4] = 1; |
f216cc37 | 546 | printk(" S4"); |
296699de | 547 | } |
a3d25c27 | 548 | #endif |
f216cc37 AS |
549 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
550 | if (ACPI_SUCCESS(status)) { | |
551 | sleep_states[ACPI_STATE_S5] = 1; | |
552 | printk(" S5"); | |
553 | pm_power_off_prepare = acpi_power_off_prepare; | |
554 | pm_power_off = acpi_power_off; | |
555 | } | |
556 | printk(")\n"); | |
1da177e4 LT |
557 | return 0; |
558 | } |