Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sleep.c - ACPI sleep support. |
| 3 | * |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 4 | * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <acpi/acpi_bus.h> |
| 19 | #include <acpi/acpi_drivers.h> |
| 20 | #include "sleep.h" |
| 21 | |
| 22 | u8 sleep_states[ACPI_S_STATE_COUNT]; |
| 23 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 24 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
| 25 | |
| 26 | #ifdef CONFIG_SUSPEND |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | static struct pm_ops acpi_pm_ops; |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | extern void do_suspend_lowlevel(void); |
| 30 | |
| 31 | static u32 acpi_suspend_states[] = { |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 32 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
| 33 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, |
| 34 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 35 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | static int init_8259A_after_S1; |
| 39 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 40 | /** |
| 41 | * acpi_pm_set_target - Set the target system sleep state to the state |
| 42 | * associated with given @pm_state, if supported. |
| 43 | */ |
| 44 | |
| 45 | static int acpi_pm_set_target(suspend_state_t pm_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
| 47 | u32 acpi_state = acpi_suspend_states[pm_state]; |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 48 | int error = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 50 | if (sleep_states[acpi_state]) { |
| 51 | acpi_target_sleep_state = acpi_state; |
| 52 | } else { |
| 53 | printk(KERN_ERR "ACPI does not support this state: %d\n", |
| 54 | pm_state); |
| 55 | error = -ENOSYS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | } |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 57 | return error; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * acpi_pm_prepare - Do preliminary suspend work. |
| 62 | * @pm_state: ignored |
| 63 | * |
| 64 | * If necessary, set the firmware waking vector and do arch-specific |
| 65 | * nastiness to get the wakeup code to the waking vector. |
| 66 | */ |
| 67 | |
| 68 | static int acpi_pm_prepare(suspend_state_t pm_state) |
| 69 | { |
| 70 | int error = acpi_sleep_prepare(acpi_target_sleep_state); |
| 71 | |
| 72 | if (error) |
| 73 | acpi_target_sleep_state = ACPI_STATE_S0; |
| 74 | |
| 75 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | /** |
| 79 | * acpi_pm_enter - Actually enter a sleep state. |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 80 | * @pm_state: ignored |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | * |
Rafael J. Wysocki | 50ad147 | 2007-07-24 11:58:39 +0200 | [diff] [blame] | 82 | * Flush caches and go to sleep. For STR we have to call arch-specific |
| 83 | * assembly, which in turn call acpi_enter_sleep_state(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | * It's unfortunate, but it works. Please fix if you're feeling frisky. |
| 85 | */ |
| 86 | |
| 87 | static int acpi_pm_enter(suspend_state_t pm_state) |
| 88 | { |
| 89 | acpi_status status = AE_OK; |
| 90 | unsigned long flags = 0; |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 91 | u32 acpi_state = acpi_target_sleep_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | |
| 93 | ACPI_FLUSH_CPU_CACHE(); |
| 94 | |
| 95 | /* Do arch specific saving of state. */ |
Rafael J. Wysocki | 50ad147 | 2007-07-24 11:58:39 +0200 | [diff] [blame] | 96 | if (acpi_state == ACPI_STATE_S3) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | int error = acpi_save_state_mem(); |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 98 | |
| 99 | if (error) { |
| 100 | acpi_target_sleep_state = ACPI_STATE_S0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | return error; |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 102 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | local_irq_save(flags); |
| 106 | acpi_enable_wakeup_device(acpi_state); |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 107 | switch (acpi_state) { |
| 108 | case ACPI_STATE_S1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | barrier(); |
| 110 | status = acpi_enter_sleep_state(acpi_state); |
| 111 | break; |
| 112 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 113 | case ACPI_STATE_S3: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | do_suspend_lowlevel(); |
| 115 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | } |
Arnaud Patard | 872d83d | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 117 | |
| 118 | /* ACPI 3.0 specs (P62) says that it's the responsabilty |
| 119 | * of the OSPM to clear the status bit [ implying that the |
| 120 | * POWER_BUTTON event should not reach userspace ] |
| 121 | */ |
| 122 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) |
| 123 | acpi_clear_event(ACPI_EVENT_POWER_BUTTON); |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | local_irq_restore(flags); |
| 126 | printk(KERN_DEBUG "Back to C!\n"); |
| 127 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 128 | /* restore processor state */ |
Rafael J. Wysocki | 50ad147 | 2007-07-24 11:58:39 +0200 | [diff] [blame] | 129 | if (acpi_state == ACPI_STATE_S3) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | acpi_restore_state_mem(); |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 133 | } |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | /** |
| 136 | * acpi_pm_finish - Finish up suspend sequence. |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 137 | * @pm_state: ignored |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | * |
| 139 | * This is called after we wake back up (or if entering the sleep state |
| 140 | * failed). |
| 141 | */ |
| 142 | |
| 143 | static int acpi_pm_finish(suspend_state_t pm_state) |
| 144 | { |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 145 | u32 acpi_state = acpi_target_sleep_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | acpi_leave_sleep_state(acpi_state); |
| 148 | acpi_disable_wakeup_device(acpi_state); |
| 149 | |
| 150 | /* reset firmware waking vector */ |
| 151 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); |
| 152 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 153 | acpi_target_sleep_state = ACPI_STATE_S0; |
| 154 | |
Len Brown | e8b2fd0 | 2007-07-24 22:26:33 -0400 | [diff] [blame] | 155 | #ifdef CONFIG_X86 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | if (init_8259A_after_S1) { |
| 157 | printk("Broken toshiba laptop -> kicking interrupts\n"); |
| 158 | init_8259A(0); |
| 159 | } |
Len Brown | e8b2fd0 | 2007-07-24 22:26:33 -0400 | [diff] [blame] | 160 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | return 0; |
| 162 | } |
| 163 | |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 164 | static int acpi_pm_state_valid(suspend_state_t pm_state) |
| 165 | { |
Johannes Berg | e8c9c50 | 2007-04-30 15:09:54 -0700 | [diff] [blame] | 166 | u32 acpi_state; |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 167 | |
Johannes Berg | e8c9c50 | 2007-04-30 15:09:54 -0700 | [diff] [blame] | 168 | switch (pm_state) { |
| 169 | case PM_SUSPEND_ON: |
| 170 | case PM_SUSPEND_STANDBY: |
| 171 | case PM_SUSPEND_MEM: |
| 172 | acpi_state = acpi_suspend_states[pm_state]; |
| 173 | |
| 174 | return sleep_states[acpi_state]; |
| 175 | default: |
| 176 | return 0; |
| 177 | } |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 178 | } |
| 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | static struct pm_ops acpi_pm_ops = { |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 181 | .valid = acpi_pm_state_valid, |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 182 | .set_target = acpi_pm_set_target, |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 183 | .prepare = acpi_pm_prepare, |
| 184 | .enter = acpi_pm_enter, |
| 185 | .finish = acpi_pm_finish, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | }; |
| 187 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 188 | /* |
| 189 | * Toshiba fails to preserve interrupts over S1, reinitialization |
| 190 | * of 8259 is needed after S1 resume. |
| 191 | */ |
| 192 | static int __init init_ints_after_s1(struct dmi_system_id *d) |
| 193 | { |
| 194 | printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident); |
| 195 | init_8259A_after_S1 = 1; |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { |
| 200 | { |
| 201 | .callback = init_ints_after_s1, |
| 202 | .ident = "Toshiba Satellite 4030cdt", |
| 203 | .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),}, |
| 204 | }, |
| 205 | {}, |
| 206 | }; |
| 207 | #endif /* CONFIG_SUSPEND */ |
| 208 | |
Rafael J. Wysocki | b0cb1a1 | 2007-07-29 23:24:36 +0200 | [diff] [blame] | 209 | #ifdef CONFIG_HIBERNATION |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 210 | static int acpi_hibernation_prepare(void) |
| 211 | { |
| 212 | return acpi_sleep_prepare(ACPI_STATE_S4); |
| 213 | } |
| 214 | |
| 215 | static int acpi_hibernation_enter(void) |
| 216 | { |
| 217 | acpi_status status = AE_OK; |
| 218 | unsigned long flags = 0; |
| 219 | |
| 220 | ACPI_FLUSH_CPU_CACHE(); |
| 221 | |
| 222 | local_irq_save(flags); |
| 223 | acpi_enable_wakeup_device(ACPI_STATE_S4); |
| 224 | /* This shouldn't return. If it returns, we have a problem */ |
| 225 | status = acpi_enter_sleep_state(ACPI_STATE_S4); |
| 226 | local_irq_restore(flags); |
| 227 | |
| 228 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 229 | } |
| 230 | |
| 231 | static void acpi_hibernation_finish(void) |
| 232 | { |
| 233 | acpi_leave_sleep_state(ACPI_STATE_S4); |
| 234 | acpi_disable_wakeup_device(ACPI_STATE_S4); |
| 235 | |
| 236 | /* reset firmware waking vector */ |
| 237 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Rafael J. Wysocki | a634cc1 | 2007-07-19 01:47:30 -0700 | [diff] [blame] | 240 | static int acpi_hibernation_pre_restore(void) |
| 241 | { |
| 242 | acpi_status status; |
| 243 | |
| 244 | status = acpi_hw_disable_all_gpes(); |
| 245 | |
| 246 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 247 | } |
| 248 | |
| 249 | static void acpi_hibernation_restore_cleanup(void) |
| 250 | { |
| 251 | acpi_hw_enable_all_runtime_gpes(); |
| 252 | } |
| 253 | |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 254 | static struct hibernation_ops acpi_hibernation_ops = { |
| 255 | .prepare = acpi_hibernation_prepare, |
| 256 | .enter = acpi_hibernation_enter, |
| 257 | .finish = acpi_hibernation_finish, |
Rafael J. Wysocki | a634cc1 | 2007-07-19 01:47:30 -0700 | [diff] [blame] | 258 | .pre_restore = acpi_hibernation_pre_restore, |
| 259 | .restore_cleanup = acpi_hibernation_restore_cleanup, |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 260 | }; |
Rafael J. Wysocki | b0cb1a1 | 2007-07-29 23:24:36 +0200 | [diff] [blame] | 261 | #endif /* CONFIG_HIBERNATION */ |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 262 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 263 | int acpi_suspend(u32 acpi_state) |
| 264 | { |
| 265 | suspend_state_t states[] = { |
| 266 | [1] = PM_SUSPEND_STANDBY, |
| 267 | [3] = PM_SUSPEND_MEM, |
| 268 | [5] = PM_SUSPEND_MAX |
| 269 | }; |
| 270 | |
| 271 | if (acpi_state < 6 && states[acpi_state]) |
| 272 | return pm_suspend(states[acpi_state]); |
| 273 | if (acpi_state == 4) |
| 274 | return hibernate(); |
| 275 | return -EINVAL; |
| 276 | } |
| 277 | |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 278 | /** |
| 279 | * acpi_pm_device_sleep_state - return preferred power state of ACPI device |
| 280 | * in the system sleep state given by %acpi_target_sleep_state |
| 281 | * @dev: device to examine |
| 282 | * @wake: if set, the device should be able to wake up the system |
| 283 | * @d_min_p: used to store the upper limit of allowed states range |
| 284 | * Return value: preferred power state of the device on success, -ENODEV on |
| 285 | * failure (ie. if there's no 'struct acpi_device' for @dev) |
| 286 | * |
| 287 | * Find the lowest power (highest number) ACPI device power state that |
| 288 | * device @dev can be in while the system is in the sleep state represented |
| 289 | * by %acpi_target_sleep_state. If @wake is nonzero, the device should be |
| 290 | * able to wake up the system from this sleep state. If @d_min_p is set, |
| 291 | * the highest power (lowest number) device power state of @dev allowed |
| 292 | * in this system sleep state is stored at the location pointed to by it. |
| 293 | * |
| 294 | * The caller must ensure that @dev is valid before using this function. |
| 295 | * The caller is also responsible for figuring out if the device is |
| 296 | * supposed to be able to wake up the system and passing this information |
| 297 | * via @wake. |
| 298 | */ |
| 299 | |
| 300 | int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p) |
| 301 | { |
| 302 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); |
| 303 | struct acpi_device *adev; |
| 304 | char acpi_method[] = "_SxD"; |
| 305 | unsigned long d_min, d_max; |
| 306 | |
| 307 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { |
| 308 | printk(KERN_ERR "ACPI handle has no context!\n"); |
| 309 | return -ENODEV; |
| 310 | } |
| 311 | |
| 312 | acpi_method[2] = '0' + acpi_target_sleep_state; |
| 313 | /* |
| 314 | * If the sleep state is S0, we will return D3, but if the device has |
| 315 | * _S0W, we will use the value from _S0W |
| 316 | */ |
| 317 | d_min = ACPI_STATE_D0; |
| 318 | d_max = ACPI_STATE_D3; |
| 319 | |
| 320 | /* |
| 321 | * If present, _SxD methods return the minimum D-state (highest power |
| 322 | * state) we can use for the corresponding S-states. Otherwise, the |
| 323 | * minimum D-state is D0 (ACPI 3.x). |
| 324 | * |
| 325 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer |
| 326 | * provided -- that's our fault recovery, we ignore retval. |
| 327 | */ |
| 328 | if (acpi_target_sleep_state > ACPI_STATE_S0) |
| 329 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_min); |
| 330 | |
| 331 | /* |
| 332 | * If _PRW says we can wake up the system from the target sleep state, |
| 333 | * the D-state returned by _SxD is sufficient for that (we assume a |
| 334 | * wakeup-aware driver if wake is set). Still, if _SxW exists |
| 335 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that |
| 336 | * can wake the system. _S0W may be valid, too. |
| 337 | */ |
| 338 | if (acpi_target_sleep_state == ACPI_STATE_S0 || |
| 339 | (wake && adev->wakeup.state.enabled && |
| 340 | adev->wakeup.sleep_state <= acpi_target_sleep_state)) { |
| 341 | acpi_method[3] = 'W'; |
| 342 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_max); |
| 343 | /* Sanity check */ |
| 344 | if (d_max < d_min) |
| 345 | d_min = d_max; |
| 346 | } |
| 347 | |
| 348 | if (d_min_p) |
| 349 | *d_min_p = d_min; |
| 350 | return d_max; |
| 351 | } |
| 352 | |
Alexey Starikovskiy | aafbcd1 | 2007-02-10 01:32:16 -0500 | [diff] [blame] | 353 | int __init acpi_sleep_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | { |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 355 | acpi_status status; |
| 356 | u8 type_a, type_b; |
| 357 | #ifdef CONFIG_SUSPEND |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 358 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
| 360 | dmi_check_system(acpisleep_dmi_table); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 361 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
| 363 | if (acpi_disabled) |
| 364 | return 0; |
| 365 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 366 | #ifdef CONFIG_SUSPEND |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | printk(KERN_INFO PREFIX "(supports"); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 368 | for (i = ACPI_STATE_S0; i < ACPI_STATE_S4; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); |
| 370 | if (ACPI_SUCCESS(status)) { |
| 371 | sleep_states[i] = 1; |
| 372 | printk(" S%d", i); |
| 373 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
| 375 | printk(")\n"); |
| 376 | |
| 377 | pm_set_ops(&acpi_pm_ops); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 378 | #endif |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 379 | |
Rafael J. Wysocki | b0cb1a1 | 2007-07-29 23:24:36 +0200 | [diff] [blame] | 380 | #ifdef CONFIG_HIBERNATION |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 381 | status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b); |
| 382 | if (ACPI_SUCCESS(status)) { |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 383 | hibernation_set_ops(&acpi_hibernation_ops); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame^] | 384 | sleep_states[ACPI_STATE_S4] = 1; |
| 385 | } |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 386 | #else |
| 387 | sleep_states[ACPI_STATE_S4] = 0; |
| 388 | #endif |
| 389 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | return 0; |
| 391 | } |