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