blob: e2e4e617952b1745700075c93510bc3b359f8d7d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sleep.c - ACPI sleep support.
3 *
Alexey Starikovskiye2a5b422005-03-18 16:20:46 -05004 * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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>
Alexey Starikovskiyf216cc32007-09-20 21:32:35 +040018
19#include <asm/io.h>
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <acpi/acpi_bus.h>
22#include <acpi/acpi_drivers.h>
23#include "sleep.h"
24
25u8 sleep_states[ACPI_S_STATE_COUNT];
26
Alexey Starikovskiy853298b2007-09-25 18:45:15 +040027#ifdef CONFIG_PM_SLEEP
Rafael J. Wysocki296699d2007-07-29 23:27:18 +020028static u32 acpi_target_sleep_state = ACPI_STATE_S0;
Alexey Starikovskiy853298b2007-09-25 18:45:15 +040029#endif
Rafael J. Wysocki296699d2007-07-29 23:27:18 +020030
Alexey Starikovskiy2f3f22262007-09-24 14:33:21 +020031int acpi_sleep_prepare(u32 acpi_state)
32{
33#ifdef CONFIG_ACPI_SLEEP
34 /* do we have a wakeup address for S2 and S3? */
35 if (acpi_state == ACPI_STATE_S3) {
36 if (!acpi_wakeup_address) {
37 return -EFAULT;
38 }
39 acpi_set_firmware_waking_vector((acpi_physical_address)
40 virt_to_phys((void *)
41 acpi_wakeup_address));
42
43 }
44 ACPI_FLUSH_CPU_CACHE();
45 acpi_enable_wakeup_device_prep(acpi_state);
46#endif
Alexey Starikovskiy2f3f22262007-09-24 14:33:21 +020047 acpi_enter_sleep_state_prep(acpi_state);
48 return 0;
49}
50
Rafael J. Wysocki296699d2007-07-29 23:27:18 +020051#ifdef CONFIG_SUSPEND
Rafael J. Wysocki26398a72007-10-18 03:04:40 -070052static struct platform_suspend_ops acpi_pm_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054extern void do_suspend_lowlevel(void);
55
56static u32 acpi_suspend_states[] = {
Alexey Starikovskiye2a5b422005-03-18 16:20:46 -050057 [PM_SUSPEND_ON] = ACPI_STATE_S0,
58 [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
59 [PM_SUSPEND_MEM] = ACPI_STATE_S3,
Alexey Starikovskiye2a5b422005-03-18 16:20:46 -050060 [PM_SUSPEND_MAX] = ACPI_STATE_S5
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
63static int init_8259A_after_S1;
64
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020065/**
Rafael J. Wysockic697eec2008-01-08 00:04:17 +010066 * acpi_pm_begin - Set the target system sleep state to the state
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020067 * associated with given @pm_state, if supported.
68 */
69
Rafael J. Wysockic697eec2008-01-08 00:04:17 +010070static int acpi_pm_begin(suspend_state_t pm_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 u32 acpi_state = acpi_suspend_states[pm_state];
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020073 int error = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020075 if (sleep_states[acpi_state]) {
76 acpi_target_sleep_state = acpi_state;
77 } else {
78 printk(KERN_ERR "ACPI does not support this state: %d\n",
79 pm_state);
80 error = -ENOSYS;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 }
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020082 return error;
83}
84
85/**
86 * acpi_pm_prepare - Do preliminary suspend work.
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020087 *
88 * If necessary, set the firmware waking vector and do arch-specific
89 * nastiness to get the wakeup code to the waking vector.
90 */
91
Rafael J. Wysockie6c5eb92007-10-18 03:04:41 -070092static int acpi_pm_prepare(void)
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +020093{
94 int error = acpi_sleep_prepare(acpi_target_sleep_state);
95
96 if (error)
97 acpi_target_sleep_state = ACPI_STATE_S0;
98
99 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/**
103 * acpi_pm_enter - Actually enter a sleep state.
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200104 * @pm_state: ignored
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 *
Rafael J. Wysocki50ad1472007-07-24 11:58:39 +0200106 * Flush caches and go to sleep. For STR we have to call arch-specific
107 * assembly, which in turn call acpi_enter_sleep_state().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 * It's unfortunate, but it works. Please fix if you're feeling frisky.
109 */
110
111static int acpi_pm_enter(suspend_state_t pm_state)
112{
113 acpi_status status = AE_OK;
114 unsigned long flags = 0;
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200115 u32 acpi_state = acpi_target_sleep_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117 ACPI_FLUSH_CPU_CACHE();
118
119 /* Do arch specific saving of state. */
Rafael J. Wysocki50ad1472007-07-24 11:58:39 +0200120 if (acpi_state == ACPI_STATE_S3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 int error = acpi_save_state_mem();
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200122
123 if (error) {
124 acpi_target_sleep_state = ACPI_STATE_S0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 return error;
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200126 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 }
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 local_irq_save(flags);
130 acpi_enable_wakeup_device(acpi_state);
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200131 switch (acpi_state) {
132 case ACPI_STATE_S1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 barrier();
134 status = acpi_enter_sleep_state(acpi_state);
135 break;
136
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200137 case ACPI_STATE_S3:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 do_suspend_lowlevel();
139 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 }
Arnaud Patard872d83d2006-04-27 05:25:00 -0400141
142 /* ACPI 3.0 specs (P62) says that it's the responsabilty
143 * of the OSPM to clear the status bit [ implying that the
144 * POWER_BUTTON event should not reach userspace ]
145 */
146 if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3))
147 acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
148
Shaohua Lia3627f62007-06-20 09:17:58 +0800149 /*
150 * Disable and clear GPE status before interrupt is enabled. Some GPEs
151 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
152 * acpi_leave_sleep_state will reenable specific GPEs later
153 */
154 acpi_hw_disable_all_gpes();
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 local_irq_restore(flags);
157 printk(KERN_DEBUG "Back to C!\n");
158
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200159 /* restore processor state */
Rafael J. Wysocki50ad1472007-07-24 11:58:39 +0200160 if (acpi_state == ACPI_STATE_S3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 acpi_restore_state_mem();
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
164}
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166/**
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100167 * acpi_pm_finish - Instruct the platform to leave a sleep state.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 *
169 * This is called after we wake back up (or if entering the sleep state
170 * failed).
171 */
172
Rafael J. Wysockie6c5eb92007-10-18 03:04:41 -0700173static void acpi_pm_finish(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200175 u32 acpi_state = acpi_target_sleep_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 acpi_disable_wakeup_device(acpi_state);
Alexey Starikovskiy1dbc1fd2007-10-22 14:18:12 +0400178 acpi_leave_sleep_state(acpi_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180 /* reset firmware waking vector */
181 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
182
Rafael J. Wysockie9b3aba2007-07-17 22:40:06 +0200183 acpi_target_sleep_state = ACPI_STATE_S0;
184
Len Browne8b2fd02007-07-24 22:26:33 -0400185#ifdef CONFIG_X86
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 if (init_8259A_after_S1) {
187 printk("Broken toshiba laptop -> kicking interrupts\n");
188 init_8259A(0);
189 }
Len Browne8b2fd02007-07-24 22:26:33 -0400190#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191}
192
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100193/**
194 * acpi_pm_end - Finish up suspend sequence.
195 */
196
197static void acpi_pm_end(void)
198{
199 /*
200 * This is necessary in case acpi_pm_finish() is not called during a
201 * failing transition to a sleep state.
202 */
203 acpi_target_sleep_state = ACPI_STATE_S0;
204}
205
Shaohua Lieb9289e2005-10-30 15:00:01 -0800206static int acpi_pm_state_valid(suspend_state_t pm_state)
207{
Johannes Berge8c9c502007-04-30 15:09:54 -0700208 u32 acpi_state;
Shaohua Lieb9289e2005-10-30 15:00:01 -0800209
Johannes Berge8c9c502007-04-30 15:09:54 -0700210 switch (pm_state) {
211 case PM_SUSPEND_ON:
212 case PM_SUSPEND_STANDBY:
213 case PM_SUSPEND_MEM:
214 acpi_state = acpi_suspend_states[pm_state];
215
216 return sleep_states[acpi_state];
217 default:
218 return 0;
219 }
Shaohua Lieb9289e2005-10-30 15:00:01 -0800220}
221
Rafael J. Wysocki26398a72007-10-18 03:04:40 -0700222static struct platform_suspend_ops acpi_pm_ops = {
Shaohua Lieb9289e2005-10-30 15:00:01 -0800223 .valid = acpi_pm_state_valid,
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100224 .begin = acpi_pm_begin,
Alexey Starikovskiye2a5b422005-03-18 16:20:46 -0500225 .prepare = acpi_pm_prepare,
226 .enter = acpi_pm_enter,
227 .finish = acpi_pm_finish,
Rafael J. Wysockic697eec2008-01-08 00:04:17 +0100228 .end = acpi_pm_end,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229};
230
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200231/*
232 * Toshiba fails to preserve interrupts over S1, reinitialization
233 * of 8259 is needed after S1 resume.
234 */
Jeff Garzik18552562007-10-03 15:15:40 -0400235static int __init init_ints_after_s1(const struct dmi_system_id *d)
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200236{
237 printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
238 init_8259A_after_S1 = 1;
239 return 0;
240}
241
242static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
243 {
244 .callback = init_ints_after_s1,
245 .ident = "Toshiba Satellite 4030cdt",
246 .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
247 },
248 {},
249};
250#endif /* CONFIG_SUSPEND */
251
Rafael J. Wysockib0cb1a12007-07-29 23:24:36 +0200252#ifdef CONFIG_HIBERNATION
Rafael J. Wysocki74f270a2007-10-18 03:04:42 -0700253static int acpi_hibernation_start(void)
254{
255 acpi_target_sleep_state = ACPI_STATE_S4;
256 return 0;
257}
258
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700259static int acpi_hibernation_prepare(void)
260{
261 return acpi_sleep_prepare(ACPI_STATE_S4);
262}
263
264static int acpi_hibernation_enter(void)
265{
266 acpi_status status = AE_OK;
267 unsigned long flags = 0;
268
269 ACPI_FLUSH_CPU_CACHE();
270
271 local_irq_save(flags);
272 acpi_enable_wakeup_device(ACPI_STATE_S4);
273 /* This shouldn't return. If it returns, we have a problem */
274 status = acpi_enter_sleep_state(ACPI_STATE_S4);
275 local_irq_restore(flags);
276
277 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
278}
279
Rafael J. Wysockic7e08312007-10-18 03:04:55 -0700280static void acpi_hibernation_leave(void)
281{
282 /*
283 * If ACPI is not enabled by the BIOS and the boot kernel, we need to
284 * enable it here.
285 */
286 acpi_enable();
287}
288
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700289static void acpi_hibernation_finish(void)
290{
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700291 acpi_disable_wakeup_device(ACPI_STATE_S4);
Alexey Starikovskiy1dbc1fd2007-10-22 14:18:12 +0400292 acpi_leave_sleep_state(ACPI_STATE_S4);
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700293
294 /* reset firmware waking vector */
295 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
Rafael J. Wysocki74f270a2007-10-18 03:04:42 -0700296
297 acpi_target_sleep_state = ACPI_STATE_S0;
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700298}
299
Rafael J. Wysockia634cc12007-07-19 01:47:30 -0700300static int acpi_hibernation_pre_restore(void)
301{
302 acpi_status status;
303
304 status = acpi_hw_disable_all_gpes();
305
306 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
307}
308
309static void acpi_hibernation_restore_cleanup(void)
310{
311 acpi_hw_enable_all_runtime_gpes();
312}
313
Rafael J. Wysockib3dac3b2007-10-18 03:04:43 -0700314static struct platform_hibernation_ops acpi_hibernation_ops = {
Rafael J. Wysocki74f270a2007-10-18 03:04:42 -0700315 .start = acpi_hibernation_start,
316 .pre_snapshot = acpi_hibernation_prepare,
317 .finish = acpi_hibernation_finish,
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700318 .prepare = acpi_hibernation_prepare,
319 .enter = acpi_hibernation_enter,
Rafael J. Wysockic7e08312007-10-18 03:04:55 -0700320 .leave = acpi_hibernation_leave,
Rafael J. Wysockia634cc12007-07-19 01:47:30 -0700321 .pre_restore = acpi_hibernation_pre_restore,
322 .restore_cleanup = acpi_hibernation_restore_cleanup,
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700323};
Rafael J. Wysockib0cb1a12007-07-29 23:24:36 +0200324#endif /* CONFIG_HIBERNATION */
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700325
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200326int acpi_suspend(u32 acpi_state)
327{
328 suspend_state_t states[] = {
329 [1] = PM_SUSPEND_STANDBY,
330 [3] = PM_SUSPEND_MEM,
331 [5] = PM_SUSPEND_MAX
332 };
333
334 if (acpi_state < 6 && states[acpi_state])
335 return pm_suspend(states[acpi_state]);
336 if (acpi_state == 4)
337 return hibernate();
338 return -EINVAL;
339}
340
Alexey Starikovskiy853298b2007-09-25 18:45:15 +0400341#ifdef CONFIG_PM_SLEEP
Shaohua Lifd4aff12007-07-17 22:40:25 +0200342/**
343 * acpi_pm_device_sleep_state - return preferred power state of ACPI device
344 * in the system sleep state given by %acpi_target_sleep_state
345 * @dev: device to examine
346 * @wake: if set, the device should be able to wake up the system
347 * @d_min_p: used to store the upper limit of allowed states range
348 * Return value: preferred power state of the device on success, -ENODEV on
349 * failure (ie. if there's no 'struct acpi_device' for @dev)
350 *
351 * Find the lowest power (highest number) ACPI device power state that
352 * device @dev can be in while the system is in the sleep state represented
353 * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
354 * able to wake up the system from this sleep state. If @d_min_p is set,
355 * the highest power (lowest number) device power state of @dev allowed
356 * in this system sleep state is stored at the location pointed to by it.
357 *
358 * The caller must ensure that @dev is valid before using this function.
359 * The caller is also responsible for figuring out if the device is
360 * supposed to be able to wake up the system and passing this information
361 * via @wake.
362 */
363
364int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
365{
366 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
367 struct acpi_device *adev;
368 char acpi_method[] = "_SxD";
369 unsigned long d_min, d_max;
370
371 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
Shaohua Liead77592007-08-23 15:01:13 +0800372 printk(KERN_DEBUG "ACPI handle has no context!\n");
Shaohua Lifd4aff12007-07-17 22:40:25 +0200373 return -ENODEV;
374 }
375
376 acpi_method[2] = '0' + acpi_target_sleep_state;
377 /*
378 * If the sleep state is S0, we will return D3, but if the device has
379 * _S0W, we will use the value from _S0W
380 */
381 d_min = ACPI_STATE_D0;
382 d_max = ACPI_STATE_D3;
383
384 /*
385 * If present, _SxD methods return the minimum D-state (highest power
386 * state) we can use for the corresponding S-states. Otherwise, the
387 * minimum D-state is D0 (ACPI 3.x).
388 *
389 * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
390 * provided -- that's our fault recovery, we ignore retval.
391 */
392 if (acpi_target_sleep_state > ACPI_STATE_S0)
393 acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
394
395 /*
396 * If _PRW says we can wake up the system from the target sleep state,
397 * the D-state returned by _SxD is sufficient for that (we assume a
398 * wakeup-aware driver if wake is set). Still, if _SxW exists
399 * (ACPI 3.x), it should return the maximum (lowest power) D-state that
400 * can wake the system. _S0W may be valid, too.
401 */
402 if (acpi_target_sleep_state == ACPI_STATE_S0 ||
403 (wake && adev->wakeup.state.enabled &&
404 adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
405 acpi_method[3] = 'W';
406 acpi_evaluate_integer(handle, acpi_method, NULL, &d_max);
407 /* Sanity check */
408 if (d_max < d_min)
409 d_min = d_max;
410 }
411
412 if (d_min_p)
413 *d_min_p = d_min;
414 return d_max;
415}
Alexey Starikovskiy853298b2007-09-25 18:45:15 +0400416#endif
Shaohua Lifd4aff12007-07-17 22:40:25 +0200417
Alexey Starikovskiyf216cc32007-09-20 21:32:35 +0400418static void acpi_power_off_prepare(void)
419{
420 /* Prepare to power off the system */
421 acpi_sleep_prepare(ACPI_STATE_S5);
422}
423
424static void acpi_power_off(void)
425{
426 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
427 printk("%s called\n", __FUNCTION__);
428 local_irq_disable();
Alexey Starikovskiy9c1c6a12007-10-22 14:18:06 +0400429 acpi_enable_wakeup_device(ACPI_STATE_S5);
Alexey Starikovskiyf216cc32007-09-20 21:32:35 +0400430 acpi_enter_sleep_state(ACPI_STATE_S5);
431}
432
Alexey Starikovskiyaafbcd12007-02-10 01:32:16 -0500433int __init acpi_sleep_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200435 acpi_status status;
436 u8 type_a, type_b;
437#ifdef CONFIG_SUSPEND
Alexey Starikovskiye2a5b422005-03-18 16:20:46 -0500438 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440 dmi_check_system(acpisleep_dmi_table);
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200441#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443 if (acpi_disabled)
444 return 0;
445
Frans Pop5a50fe72007-09-20 22:27:44 +0200446 sleep_states[ACPI_STATE_S0] = 1;
447 printk(KERN_INFO PREFIX "(supports S0");
448
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200449#ifdef CONFIG_SUSPEND
Frans Pop5a50fe72007-09-20 22:27:44 +0200450 for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
452 if (ACPI_SUCCESS(status)) {
453 sleep_states[i] = 1;
454 printk(" S%d", i);
455 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
Rafael J. Wysocki26398a72007-10-18 03:04:40 -0700458 suspend_set_ops(&acpi_pm_ops);
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200459#endif
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700460
Rafael J. Wysockib0cb1a12007-07-29 23:24:36 +0200461#ifdef CONFIG_HIBERNATION
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200462 status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b);
463 if (ACPI_SUCCESS(status)) {
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700464 hibernation_set_ops(&acpi_hibernation_ops);
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200465 sleep_states[ACPI_STATE_S4] = 1;
Alexey Starikovskiyf216cc32007-09-20 21:32:35 +0400466 printk(" S4");
Rafael J. Wysocki296699d2007-07-29 23:27:18 +0200467 }
Rafael J. Wysockia3d25c22007-05-09 02:33:18 -0700468#endif
Alexey Starikovskiyf216cc32007-09-20 21:32:35 +0400469 status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
470 if (ACPI_SUCCESS(status)) {
471 sleep_states[ACPI_STATE_S5] = 1;
472 printk(" S5");
473 pm_power_off_prepare = acpi_power_off_prepare;
474 pm_power_off = acpi_power_off;
475 }
476 printk(")\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 return 0;
478}