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> |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 18 | #include <linux/reboot.h> |
H. Peter Anvin | d1ee433 | 2011-02-14 15:42:46 -0800 | [diff] [blame] | 19 | #include <linux/acpi.h> |
Lin Ming | a2ef5c4 | 2012-03-21 10:58:46 +0800 | [diff] [blame] | 20 | #include <linux/module.h> |
Lin Ming | b24e509 | 2012-03-27 15:43:25 +0800 | [diff] [blame] | 21 | #include <linux/pm_runtime.h> |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 22 | |
| 23 | #include <asm/io.h> |
| 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <acpi/acpi_bus.h> |
| 26 | #include <acpi/acpi_drivers.h> |
Bjorn Helgaas | e60cc7a | 2009-03-13 12:08:26 -0600 | [diff] [blame] | 27 | |
| 28 | #include "internal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include "sleep.h" |
| 30 | |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 31 | u8 wake_sleep_flags = ACPI_NO_OPTIONAL_METHODS; |
Lin Ming | a2ef5c4 | 2012-03-21 10:58:46 +0800 | [diff] [blame] | 32 | static unsigned int gts, bfs; |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 33 | static int set_param_wake_flag(const char *val, struct kernel_param *kp) |
| 34 | { |
| 35 | int ret = param_set_int(val, kp); |
| 36 | |
| 37 | if (ret) |
| 38 | return ret; |
| 39 | |
| 40 | if (kp->arg == (const char *)>s) { |
| 41 | if (gts) |
| 42 | wake_sleep_flags |= ACPI_EXECUTE_GTS; |
| 43 | else |
| 44 | wake_sleep_flags &= ~ACPI_EXECUTE_GTS; |
| 45 | } |
| 46 | if (kp->arg == (const char *)&bfs) { |
| 47 | if (bfs) |
| 48 | wake_sleep_flags |= ACPI_EXECUTE_BFS; |
| 49 | else |
| 50 | wake_sleep_flags &= ~ACPI_EXECUTE_BFS; |
| 51 | } |
| 52 | return ret; |
| 53 | } |
| 54 | module_param_call(gts, set_param_wake_flag, param_get_int, >s, 0644); |
| 55 | module_param_call(bfs, set_param_wake_flag, param_get_int, &bfs, 0644); |
Lin Ming | a2ef5c4 | 2012-03-21 10:58:46 +0800 | [diff] [blame] | 56 | MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend."); |
| 57 | MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); |
| 58 | |
Stephen Hemminger | 01eac60 | 2010-10-18 18:47:25 -0700 | [diff] [blame] | 59 | static u8 sleep_states[ACPI_S_STATE_COUNT]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 61 | static void acpi_sleep_tts_switch(u32 acpi_state) |
| 62 | { |
| 63 | union acpi_object in_arg = { ACPI_TYPE_INTEGER }; |
| 64 | struct acpi_object_list arg_list = { 1, &in_arg }; |
| 65 | acpi_status status = AE_OK; |
| 66 | |
| 67 | in_arg.integer.value = acpi_state; |
| 68 | status = acpi_evaluate_object(NULL, "\\_TTS", &arg_list, NULL); |
| 69 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 70 | /* |
| 71 | * OS can't evaluate the _TTS object correctly. Some warning |
| 72 | * message will be printed. But it won't break anything. |
| 73 | */ |
| 74 | printk(KERN_NOTICE "Failure in evaluating _TTS object\n"); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | static int tts_notify_reboot(struct notifier_block *this, |
| 79 | unsigned long code, void *x) |
| 80 | { |
| 81 | acpi_sleep_tts_switch(ACPI_STATE_S5); |
| 82 | return NOTIFY_DONE; |
| 83 | } |
| 84 | |
| 85 | static struct notifier_block tts_notifier = { |
| 86 | .notifier_call = tts_notify_reboot, |
| 87 | .next = NULL, |
| 88 | .priority = 0, |
| 89 | }; |
| 90 | |
Rafael J. Wysocki | c9b6c8f | 2008-01-08 00:10:57 +0100 | [diff] [blame] | 91 | static int acpi_sleep_prepare(u32 acpi_state) |
Alexey Starikovskiy | 2f3f2226 | 2007-09-24 14:33:21 +0200 | [diff] [blame] | 92 | { |
| 93 | #ifdef CONFIG_ACPI_SLEEP |
| 94 | /* do we have a wakeup address for S2 and S3? */ |
| 95 | if (acpi_state == ACPI_STATE_S3) { |
| 96 | if (!acpi_wakeup_address) { |
| 97 | return -EFAULT; |
| 98 | } |
H. Peter Anvin | 4b4f728 | 2008-06-24 23:03:48 +0200 | [diff] [blame] | 99 | acpi_set_firmware_waking_vector( |
| 100 | (acpi_physical_address)acpi_wakeup_address); |
Alexey Starikovskiy | 2f3f2226 | 2007-09-24 14:33:21 +0200 | [diff] [blame] | 101 | |
| 102 | } |
| 103 | ACPI_FLUSH_CPU_CACHE(); |
Alexey Starikovskiy | 2f3f2226 | 2007-09-24 14:33:21 +0200 | [diff] [blame] | 104 | #endif |
Rafael J. Wysocki | c9b6c8f | 2008-01-08 00:10:57 +0100 | [diff] [blame] | 105 | printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", |
| 106 | acpi_state); |
Rafael J. Wysocki | 78f5f02 | 2010-07-06 22:09:38 -0400 | [diff] [blame] | 107 | acpi_enable_wakeup_devices(acpi_state); |
Alexey Starikovskiy | 2f3f2226 | 2007-09-24 14:33:21 +0200 | [diff] [blame] | 108 | acpi_enter_sleep_state_prep(acpi_state); |
| 109 | return 0; |
| 110 | } |
| 111 | |
Rafael J. Wysocki | 5d1e072 | 2008-10-22 14:58:43 -0400 | [diff] [blame] | 112 | #ifdef CONFIG_ACPI_SLEEP |
Jan Beulich | 091aad6 | 2010-12-07 14:52:25 +0000 | [diff] [blame] | 113 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
| 114 | |
Zhang Rui | d7f0eea | 2009-12-30 15:36:42 +0800 | [diff] [blame] | 115 | /* |
Rafael J. Wysocki | 72ad5d7 | 2010-07-23 22:59:09 +0200 | [diff] [blame] | 116 | * The ACPI specification wants us to save NVS memory regions during hibernation |
| 117 | * and to restore them during the subsequent resume. Windows does that also for |
| 118 | * suspend to RAM. However, it is known that this mechanism does not work on |
| 119 | * all machines, so we allow the user to disable it with the help of the |
| 120 | * 'acpi_sleep=nonvs' kernel command line option. |
| 121 | */ |
| 122 | static bool nvs_nosave; |
| 123 | |
| 124 | void __init acpi_nvs_nosave(void) |
| 125 | { |
| 126 | nvs_nosave = true; |
| 127 | } |
| 128 | |
| 129 | /* |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 130 | * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the |
| 131 | * user to request that behavior by using the 'acpi_old_suspend_ordering' |
| 132 | * kernel command line option that causes the following variable to be set. |
| 133 | */ |
| 134 | static bool old_suspend_ordering; |
| 135 | |
| 136 | void __init acpi_old_suspend_ordering(void) |
| 137 | { |
| 138 | old_suspend_ordering = true; |
| 139 | } |
| 140 | |
| 141 | /** |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 142 | * acpi_pm_freeze - Disable the GPEs and suspend EC transactions. |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 143 | */ |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 144 | static int acpi_pm_freeze(void) |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 145 | { |
Lin Ming | 3d97e42 | 2008-12-16 16:57:46 +0800 | [diff] [blame] | 146 | acpi_disable_all_gpes(); |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 147 | acpi_os_wait_events_complete(NULL); |
Rafael J. Wysocki | fe95568 | 2010-04-09 01:40:38 +0200 | [diff] [blame] | 148 | acpi_ec_block_transactions(); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | /** |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 153 | * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS. |
| 154 | */ |
| 155 | static int acpi_pm_pre_suspend(void) |
| 156 | { |
| 157 | acpi_pm_freeze(); |
Jiri Slaby | 26fcaf6 | 2011-01-07 01:42:31 +0100 | [diff] [blame] | 158 | return suspend_nvs_save(); |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /** |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 162 | * __acpi_pm_prepare - Prepare the platform to enter the target state. |
| 163 | * |
| 164 | * If necessary, set the firmware waking vector and do arch-specific |
| 165 | * nastiness to get the wakeup code to the waking vector. |
| 166 | */ |
| 167 | static int __acpi_pm_prepare(void) |
| 168 | { |
| 169 | int error = acpi_sleep_prepare(acpi_target_sleep_state); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 170 | if (error) |
| 171 | acpi_target_sleep_state = ACPI_STATE_S0; |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 172 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 173 | return error; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * acpi_pm_prepare - Prepare the platform to enter the target sleep |
| 178 | * state and disable the GPEs. |
| 179 | */ |
| 180 | static int acpi_pm_prepare(void) |
| 181 | { |
| 182 | int error = __acpi_pm_prepare(); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 183 | if (!error) |
Jiri Slaby | 26fcaf6 | 2011-01-07 01:42:31 +0100 | [diff] [blame] | 184 | error = acpi_pm_pre_suspend(); |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 185 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 186 | return error; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * acpi_pm_finish - Instruct the platform to leave a sleep state. |
| 191 | * |
| 192 | * This is called after we wake back up (or if entering the sleep state |
| 193 | * failed). |
| 194 | */ |
| 195 | static void acpi_pm_finish(void) |
| 196 | { |
| 197 | u32 acpi_state = acpi_target_sleep_state; |
| 198 | |
Len Brown | 42de553 | 2010-06-12 01:15:40 -0400 | [diff] [blame] | 199 | acpi_ec_unblock_transactions(); |
Rafael J. Wysocki | d551d81 | 2011-01-19 22:27:55 +0100 | [diff] [blame] | 200 | suspend_nvs_free(); |
Matthew Garrett | 2a6b697 | 2010-05-28 16:32:15 -0400 | [diff] [blame] | 201 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 202 | if (acpi_state == ACPI_STATE_S0) |
| 203 | return; |
| 204 | |
| 205 | printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n", |
| 206 | acpi_state); |
Rafael J. Wysocki | 78f5f02 | 2010-07-06 22:09:38 -0400 | [diff] [blame] | 207 | acpi_disable_wakeup_devices(acpi_state); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 208 | acpi_leave_sleep_state(acpi_state); |
| 209 | |
| 210 | /* reset firmware waking vector */ |
| 211 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); |
| 212 | |
| 213 | acpi_target_sleep_state = ACPI_STATE_S0; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * acpi_pm_end - Finish up suspend sequence. |
| 218 | */ |
| 219 | static void acpi_pm_end(void) |
| 220 | { |
| 221 | /* |
| 222 | * This is necessary in case acpi_pm_finish() is not called during a |
| 223 | * failing transition to a sleep state. |
| 224 | */ |
| 225 | acpi_target_sleep_state = ACPI_STATE_S0; |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 226 | acpi_sleep_tts_switch(acpi_target_sleep_state); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 227 | } |
Rafael J. Wysocki | 92daa7b | 2008-10-23 21:46:43 +0200 | [diff] [blame] | 228 | #else /* !CONFIG_ACPI_SLEEP */ |
| 229 | #define acpi_target_sleep_state ACPI_STATE_S0 |
Rafael J. Wysocki | 5d1e072 | 2008-10-22 14:58:43 -0400 | [diff] [blame] | 230 | #endif /* CONFIG_ACPI_SLEEP */ |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 231 | |
| 232 | #ifdef CONFIG_SUSPEND |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | static u32 acpi_suspend_states[] = { |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 234 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
| 235 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, |
| 236 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 237 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | }; |
| 239 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 240 | /** |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 241 | * acpi_suspend_begin - Set the target system sleep state to the state |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 242 | * associated with given @pm_state, if supported. |
| 243 | */ |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 244 | static int acpi_suspend_begin(suspend_state_t pm_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
| 246 | u32 acpi_state = acpi_suspend_states[pm_state]; |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 247 | int error = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Rafael J. Wysocki | 72ad5d7 | 2010-07-23 22:59:09 +0200 | [diff] [blame] | 249 | error = nvs_nosave ? 0 : suspend_nvs_alloc(); |
Matthew Garrett | 2a6b697 | 2010-05-28 16:32:15 -0400 | [diff] [blame] | 250 | if (error) |
| 251 | return error; |
| 252 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 253 | if (sleep_states[acpi_state]) { |
| 254 | acpi_target_sleep_state = acpi_state; |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 255 | acpi_sleep_tts_switch(acpi_target_sleep_state); |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 256 | } else { |
| 257 | printk(KERN_ERR "ACPI does not support this state: %d\n", |
| 258 | pm_state); |
| 259 | error = -ENOSYS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 261 | return error; |
| 262 | } |
| 263 | |
| 264 | /** |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 265 | * acpi_suspend_enter - Actually enter a sleep state. |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 266 | * @pm_state: ignored |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | * |
Rafael J. Wysocki | 50ad147 | 2007-07-24 11:58:39 +0200 | [diff] [blame] | 268 | * Flush caches and go to sleep. For STR we have to call arch-specific |
| 269 | * assembly, which in turn call acpi_enter_sleep_state(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | * It's unfortunate, but it works. Please fix if you're feeling frisky. |
| 271 | */ |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 272 | static int acpi_suspend_enter(suspend_state_t pm_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | { |
| 274 | acpi_status status = AE_OK; |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 275 | u32 acpi_state = acpi_target_sleep_state; |
Rafael J. Wysocki | 979f11b | 2011-02-08 23:42:09 +0100 | [diff] [blame] | 276 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
| 278 | ACPI_FLUSH_CPU_CACHE(); |
| 279 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 280 | switch (acpi_state) { |
| 281 | case ACPI_STATE_S1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | barrier(); |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 283 | status = acpi_enter_sleep_state(acpi_state, wake_sleep_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | break; |
| 285 | |
Rafael J. Wysocki | e9b3aba | 2007-07-17 22:40:06 +0200 | [diff] [blame] | 286 | case ACPI_STATE_S3: |
Rafael J. Wysocki | f1a2003 | 2011-02-08 23:42:22 +0100 | [diff] [blame] | 287 | error = acpi_suspend_lowlevel(); |
Rafael J. Wysocki | 979f11b | 2011-02-08 23:42:09 +0100 | [diff] [blame] | 288 | if (error) |
| 289 | return error; |
Rafael J. Wysocki | 7a63f08 | 2011-02-08 23:41:57 +0100 | [diff] [blame] | 290 | pr_info(PREFIX "Low-level resume complete\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | } |
Arnaud Patard | 872d83d | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 293 | |
Matthew Garrett | b6dacf6 | 2010-05-11 13:49:25 -0400 | [diff] [blame] | 294 | /* This violates the spec but is required for bug compatibility. */ |
| 295 | acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); |
Rafael J. Wysocki | 65df784 | 2008-11-26 17:53:13 -0500 | [diff] [blame] | 296 | |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 297 | /* Reprogram control registers and execute _BFS */ |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 298 | acpi_leave_sleep_state_prep(acpi_state, wake_sleep_flags); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 299 | |
Pavel Machek | 23b168d | 2008-02-05 19:27:12 +0100 | [diff] [blame] | 300 | /* ACPI 3.0 specs (P62) says that it's the responsibility |
Arnaud Patard | 872d83d | 2006-04-27 05:25:00 -0400 | [diff] [blame] | 301 | * of the OSPM to clear the status bit [ implying that the |
| 302 | * POWER_BUTTON event should not reach userspace ] |
| 303 | */ |
| 304 | if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) |
| 305 | acpi_clear_event(ACPI_EVENT_POWER_BUTTON); |
| 306 | |
Shaohua Li | a3627f6 | 2007-06-20 09:17:58 +0800 | [diff] [blame] | 307 | /* |
| 308 | * Disable and clear GPE status before interrupt is enabled. Some GPEs |
| 309 | * (like wakeup GPE) haven't handler, this can avoid such GPE misfire. |
| 310 | * acpi_leave_sleep_state will reenable specific GPEs later |
| 311 | */ |
Lin Ming | 3d97e42 | 2008-12-16 16:57:46 +0800 | [diff] [blame] | 312 | acpi_disable_all_gpes(); |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 313 | /* Allow EC transactions to happen. */ |
Rafael J. Wysocki | fe95568 | 2010-04-09 01:40:38 +0200 | [diff] [blame] | 314 | acpi_ec_unblock_transactions_early(); |
Shaohua Li | a3627f6 | 2007-06-20 09:17:58 +0800 | [diff] [blame] | 315 | |
Matthew Garrett | 2a6b697 | 2010-05-28 16:32:15 -0400 | [diff] [blame] | 316 | suspend_nvs_restore(); |
| 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 319 | } |
| 320 | |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 321 | static int acpi_suspend_state_valid(suspend_state_t pm_state) |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 322 | { |
Johannes Berg | e8c9c50 | 2007-04-30 15:09:54 -0700 | [diff] [blame] | 323 | u32 acpi_state; |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 324 | |
Johannes Berg | e8c9c50 | 2007-04-30 15:09:54 -0700 | [diff] [blame] | 325 | switch (pm_state) { |
| 326 | case PM_SUSPEND_ON: |
| 327 | case PM_SUSPEND_STANDBY: |
| 328 | case PM_SUSPEND_MEM: |
| 329 | acpi_state = acpi_suspend_states[pm_state]; |
| 330 | |
| 331 | return sleep_states[acpi_state]; |
| 332 | default: |
| 333 | return 0; |
| 334 | } |
Shaohua Li | eb9289e | 2005-10-30 15:00:01 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Lionel Debroux | 2f55ac0 | 2010-11-16 14:14:02 +0100 | [diff] [blame] | 337 | static const struct platform_suspend_ops acpi_suspend_ops = { |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 338 | .valid = acpi_suspend_state_valid, |
| 339 | .begin = acpi_suspend_begin, |
Rafael J. Wysocki | 6a7c7ea | 2009-04-19 20:08:42 +0200 | [diff] [blame] | 340 | .prepare_late = acpi_pm_prepare, |
Len Brown | 2c6e33c | 2008-04-23 18:02:52 -0400 | [diff] [blame] | 341 | .enter = acpi_suspend_enter, |
Rafael J. Wysocki | 618d7fd | 2010-07-02 00:14:57 +0200 | [diff] [blame] | 342 | .wake = acpi_pm_finish, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 343 | .end = acpi_pm_end, |
| 344 | }; |
| 345 | |
| 346 | /** |
| 347 | * acpi_suspend_begin_old - Set the target system sleep state to the |
| 348 | * state associated with given @pm_state, if supported, and |
| 349 | * execute the _PTS control method. This function is used if the |
| 350 | * pre-ACPI 2.0 suspend ordering has been requested. |
| 351 | */ |
| 352 | static int acpi_suspend_begin_old(suspend_state_t pm_state) |
| 353 | { |
| 354 | int error = acpi_suspend_begin(pm_state); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 355 | if (!error) |
| 356 | error = __acpi_pm_prepare(); |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 357 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 358 | return error; |
| 359 | } |
| 360 | |
| 361 | /* |
| 362 | * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has |
| 363 | * been requested. |
| 364 | */ |
Lionel Debroux | 2f55ac0 | 2010-11-16 14:14:02 +0100 | [diff] [blame] | 365 | static const struct platform_suspend_ops acpi_suspend_ops_old = { |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 366 | .valid = acpi_suspend_state_valid, |
| 367 | .begin = acpi_suspend_begin_old, |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 368 | .prepare_late = acpi_pm_pre_suspend, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 369 | .enter = acpi_suspend_enter, |
Rafael J. Wysocki | 618d7fd | 2010-07-02 00:14:57 +0200 | [diff] [blame] | 370 | .wake = acpi_pm_finish, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 371 | .end = acpi_pm_end, |
| 372 | .recover = acpi_pm_finish, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | }; |
Carlos Corbacho | e41fb7c | 2008-07-23 21:28:43 -0700 | [diff] [blame] | 374 | |
| 375 | static int __init init_old_suspend_ordering(const struct dmi_system_id *d) |
| 376 | { |
| 377 | old_suspend_ordering = true; |
| 378 | return 0; |
| 379 | } |
| 380 | |
Rafael J. Wysocki | 5399864 | 2010-09-24 16:46:14 -0400 | [diff] [blame] | 381 | static int __init init_nvs_nosave(const struct dmi_system_id *d) |
| 382 | { |
| 383 | acpi_nvs_nosave(); |
| 384 | return 0; |
| 385 | } |
| 386 | |
Carlos Corbacho | e41fb7c | 2008-07-23 21:28:43 -0700 | [diff] [blame] | 387 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { |
| 388 | { |
| 389 | .callback = init_old_suspend_ordering, |
| 390 | .ident = "Abit KN9 (nForce4 variant)", |
| 391 | .matches = { |
| 392 | DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"), |
| 393 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), |
| 394 | }, |
| 395 | }, |
Rafael J. Wysocki | 4fb507b | 2008-10-14 22:54:06 +0200 | [diff] [blame] | 396 | { |
| 397 | .callback = init_old_suspend_ordering, |
| 398 | .ident = "HP xw4600 Workstation", |
| 399 | .matches = { |
| 400 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
| 401 | DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), |
| 402 | }, |
| 403 | }, |
Rafael J. Wysocki | 65df784 | 2008-11-26 17:53:13 -0500 | [diff] [blame] | 404 | { |
Andy Whitcroft | a140449 | 2009-02-11 18:11:22 +0000 | [diff] [blame] | 405 | .callback = init_old_suspend_ordering, |
| 406 | .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)", |
| 407 | .matches = { |
| 408 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."), |
| 409 | DMI_MATCH(DMI_BOARD_NAME, "M2N8L"), |
| 410 | }, |
| 411 | }, |
Zhang Rui | 45e7798 | 2009-03-15 22:13:44 -0400 | [diff] [blame] | 412 | { |
Zhao Yakui | 2a9ef8e | 2009-03-18 16:36:25 +0800 | [diff] [blame] | 413 | .callback = init_old_suspend_ordering, |
| 414 | .ident = "Panasonic CF51-2L", |
| 415 | .matches = { |
| 416 | DMI_MATCH(DMI_BOARD_VENDOR, |
| 417 | "Matsushita Electric Industrial Co.,Ltd."), |
| 418 | DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), |
| 419 | }, |
| 420 | }, |
Rafael J. Wysocki | 5399864 | 2010-09-24 16:46:14 -0400 | [diff] [blame] | 421 | { |
| 422 | .callback = init_nvs_nosave, |
Dave Jones | d11c78e | 2011-10-19 23:15:11 +0200 | [diff] [blame] | 423 | .ident = "Sony Vaio VGN-FW21E", |
| 424 | .matches = { |
| 425 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 426 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"), |
| 427 | }, |
| 428 | }, |
| 429 | { |
| 430 | .callback = init_nvs_nosave, |
Dave Jones | ddf6ce4 | 2011-11-03 00:58:59 +0100 | [diff] [blame] | 431 | .ident = "Sony Vaio VPCEB17FX", |
| 432 | .matches = { |
| 433 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 434 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"), |
| 435 | }, |
| 436 | }, |
| 437 | { |
| 438 | .callback = init_nvs_nosave, |
Rafael J. Wysocki | 5399864 | 2010-09-24 16:46:14 -0400 | [diff] [blame] | 439 | .ident = "Sony Vaio VGN-SR11M", |
| 440 | .matches = { |
| 441 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 442 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"), |
| 443 | }, |
| 444 | }, |
| 445 | { |
| 446 | .callback = init_nvs_nosave, |
| 447 | .ident = "Everex StepNote Series", |
| 448 | .matches = { |
| 449 | DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."), |
| 450 | DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"), |
| 451 | }, |
| 452 | }, |
Rafael J. Wysocki | af48931 | 2010-10-17 21:01:21 +0200 | [diff] [blame] | 453 | { |
| 454 | .callback = init_nvs_nosave, |
| 455 | .ident = "Sony Vaio VPCEB1Z1E", |
| 456 | .matches = { |
| 457 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 458 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"), |
| 459 | }, |
| 460 | }, |
Rafael J. Wysocki | 291a73c | 2010-12-12 21:10:42 +0100 | [diff] [blame] | 461 | { |
| 462 | .callback = init_nvs_nosave, |
| 463 | .ident = "Sony Vaio VGN-NW130D", |
| 464 | .matches = { |
| 465 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 466 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"), |
| 467 | }, |
| 468 | }, |
Rafael J. Wysocki | 7b33070 | 2011-01-06 23:37:01 +0100 | [diff] [blame] | 469 | { |
| 470 | .callback = init_nvs_nosave, |
Lan Tianyu | 93f7708 | 2012-01-21 09:23:56 +0800 | [diff] [blame] | 471 | .ident = "Sony Vaio VPCCW29FX", |
| 472 | .matches = { |
| 473 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 474 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"), |
| 475 | }, |
| 476 | }, |
| 477 | { |
| 478 | .callback = init_nvs_nosave, |
Rafael J. Wysocki | 7b33070 | 2011-01-06 23:37:01 +0100 | [diff] [blame] | 479 | .ident = "Averatec AV1020-ED2", |
| 480 | .matches = { |
| 481 | DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"), |
| 482 | DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"), |
| 483 | }, |
| 484 | }, |
Zhang Rui | bb0c5ed | 2011-07-30 01:40:48 -0400 | [diff] [blame] | 485 | { |
| 486 | .callback = init_old_suspend_ordering, |
| 487 | .ident = "Asus A8N-SLI DELUXE", |
| 488 | .matches = { |
| 489 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 490 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"), |
| 491 | }, |
| 492 | }, |
| 493 | { |
| 494 | .callback = init_old_suspend_ordering, |
| 495 | .ident = "Asus A8N-SLI Premium", |
| 496 | .matches = { |
| 497 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), |
| 498 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"), |
| 499 | }, |
| 500 | }, |
Rafael J. Wysocki | 89e8ea1 | 2011-10-06 20:35:03 +0200 | [diff] [blame] | 501 | { |
| 502 | .callback = init_nvs_nosave, |
| 503 | .ident = "Sony Vaio VGN-SR26GN_P", |
| 504 | .matches = { |
| 505 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 506 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"), |
| 507 | }, |
| 508 | }, |
Bogdan Radulescu | 731b25a | 2011-10-06 20:35:12 +0200 | [diff] [blame] | 509 | { |
| 510 | .callback = init_nvs_nosave, |
| 511 | .ident = "Sony Vaio VGN-FW520F", |
| 512 | .matches = { |
| 513 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), |
| 514 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"), |
| 515 | }, |
| 516 | }, |
Keng-Yu Lin | 5a50a7c | 2011-12-02 00:04:23 +0100 | [diff] [blame] | 517 | { |
| 518 | .callback = init_nvs_nosave, |
| 519 | .ident = "Asus K54C", |
| 520 | .matches = { |
| 521 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), |
| 522 | DMI_MATCH(DMI_PRODUCT_NAME, "K54C"), |
| 523 | }, |
| 524 | }, |
| 525 | { |
| 526 | .callback = init_nvs_nosave, |
| 527 | .ident = "Asus K54HR", |
| 528 | .matches = { |
| 529 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), |
| 530 | DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"), |
| 531 | }, |
| 532 | }, |
Carlos Corbacho | e41fb7c | 2008-07-23 21:28:43 -0700 | [diff] [blame] | 533 | {}, |
| 534 | }; |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 535 | #endif /* CONFIG_SUSPEND */ |
| 536 | |
Rafael J. Wysocki | b0cb1a1 | 2007-07-29 23:24:36 +0200 | [diff] [blame] | 537 | #ifdef CONFIG_HIBERNATION |
Shaohua Li | bdfe6b7 | 2008-07-23 21:28:41 -0700 | [diff] [blame] | 538 | static unsigned long s4_hardware_signature; |
| 539 | static struct acpi_table_facs *facs; |
| 540 | static bool nosigcheck; |
| 541 | |
| 542 | void __init acpi_no_s4_hw_signature(void) |
| 543 | { |
| 544 | nosigcheck = true; |
| 545 | } |
| 546 | |
Rafael J. Wysocki | caea99e | 2008-01-08 00:08:44 +0100 | [diff] [blame] | 547 | static int acpi_hibernation_begin(void) |
Rafael J. Wysocki | 74f270a | 2007-10-18 03:04:42 -0700 | [diff] [blame] | 548 | { |
Rafael J. Wysocki | 3f4b0ef | 2008-10-26 20:52:15 +0100 | [diff] [blame] | 549 | int error; |
| 550 | |
Rafael J. Wysocki | 72ad5d7 | 2010-07-23 22:59:09 +0200 | [diff] [blame] | 551 | error = nvs_nosave ? 0 : suspend_nvs_alloc(); |
Rafael J. Wysocki | 3f4b0ef | 2008-10-26 20:52:15 +0100 | [diff] [blame] | 552 | if (!error) { |
| 553 | acpi_target_sleep_state = ACPI_STATE_S4; |
| 554 | acpi_sleep_tts_switch(acpi_target_sleep_state); |
| 555 | } |
| 556 | |
| 557 | return error; |
| 558 | } |
| 559 | |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 560 | static int acpi_hibernation_enter(void) |
| 561 | { |
| 562 | acpi_status status = AE_OK; |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 563 | |
| 564 | ACPI_FLUSH_CPU_CACHE(); |
| 565 | |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 566 | /* This shouldn't return. If it returns, we have a problem */ |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 567 | status = acpi_enter_sleep_state(ACPI_STATE_S4, wake_sleep_flags); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 568 | /* Reprogram control registers and execute _BFS */ |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 569 | acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 570 | |
| 571 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
| 572 | } |
| 573 | |
Rafael J. Wysocki | c7e0831 | 2007-10-18 03:04:55 -0700 | [diff] [blame] | 574 | static void acpi_hibernation_leave(void) |
| 575 | { |
| 576 | /* |
| 577 | * If ACPI is not enabled by the BIOS and the boot kernel, we need to |
| 578 | * enable it here. |
| 579 | */ |
| 580 | acpi_enable(); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 581 | /* Reprogram control registers and execute _BFS */ |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 582 | acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); |
Shaohua Li | bdfe6b7 | 2008-07-23 21:28:41 -0700 | [diff] [blame] | 583 | /* Check the hardware signature */ |
| 584 | if (facs && s4_hardware_signature != facs->hardware_signature) { |
| 585 | printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " |
| 586 | "cannot resume!\n"); |
| 587 | panic("ACPI S4 hardware signature mismatch"); |
| 588 | } |
Rafael J. Wysocki | 3f4b0ef | 2008-10-26 20:52:15 +0100 | [diff] [blame] | 589 | /* Restore the NVS memory area */ |
Matthew Garrett | dd4c4f1 | 2010-05-28 16:32:14 -0400 | [diff] [blame] | 590 | suspend_nvs_restore(); |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 591 | /* Allow EC transactions to happen. */ |
Rafael J. Wysocki | fe95568 | 2010-04-09 01:40:38 +0200 | [diff] [blame] | 592 | acpi_ec_unblock_transactions_early(); |
Rafael J. Wysocki | c7e0831 | 2007-10-18 03:04:55 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 595 | static void acpi_pm_thaw(void) |
Rafael J. Wysocki | f6bb13a | 2010-03-04 01:52:58 +0100 | [diff] [blame] | 596 | { |
Rafael J. Wysocki | fe95568 | 2010-04-09 01:40:38 +0200 | [diff] [blame] | 597 | acpi_ec_unblock_transactions(); |
Lin Ming | 3d97e42 | 2008-12-16 16:57:46 +0800 | [diff] [blame] | 598 | acpi_enable_all_runtime_gpes(); |
Rafael J. Wysocki | a634cc1 | 2007-07-19 01:47:30 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Lionel Debroux | 073ef1f | 2010-11-09 21:48:49 +0100 | [diff] [blame] | 601 | static const struct platform_hibernation_ops acpi_hibernation_ops = { |
Rafael J. Wysocki | caea99e | 2008-01-08 00:08:44 +0100 | [diff] [blame] | 602 | .begin = acpi_hibernation_begin, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 603 | .end = acpi_pm_end, |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 604 | .pre_snapshot = acpi_pm_prepare, |
Matthew Garrett | 2a6b697 | 2010-05-28 16:32:15 -0400 | [diff] [blame] | 605 | .finish = acpi_pm_finish, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 606 | .prepare = acpi_pm_prepare, |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 607 | .enter = acpi_hibernation_enter, |
Rafael J. Wysocki | c7e0831 | 2007-10-18 03:04:55 -0700 | [diff] [blame] | 608 | .leave = acpi_hibernation_leave, |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 609 | .pre_restore = acpi_pm_freeze, |
| 610 | .restore_cleanup = acpi_pm_thaw, |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 611 | }; |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 612 | |
| 613 | /** |
| 614 | * acpi_hibernation_begin_old - Set the target system sleep state to |
| 615 | * ACPI_STATE_S4 and execute the _PTS control method. This |
| 616 | * function is used if the pre-ACPI 2.0 suspend ordering has been |
| 617 | * requested. |
| 618 | */ |
| 619 | static int acpi_hibernation_begin_old(void) |
| 620 | { |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 621 | int error; |
| 622 | /* |
| 623 | * The _TTS object should always be evaluated before the _PTS object. |
| 624 | * When the old_suspended_ordering is true, the _PTS object is |
| 625 | * evaluated in the acpi_sleep_prepare. |
| 626 | */ |
| 627 | acpi_sleep_tts_switch(ACPI_STATE_S4); |
| 628 | |
| 629 | error = acpi_sleep_prepare(ACPI_STATE_S4); |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 630 | |
Rafael J. Wysocki | 3f4b0ef | 2008-10-26 20:52:15 +0100 | [diff] [blame] | 631 | if (!error) { |
Rafael J. Wysocki | 72ad5d7 | 2010-07-23 22:59:09 +0200 | [diff] [blame] | 632 | if (!nvs_nosave) |
Matthew Garrett | dd4c4f1 | 2010-05-28 16:32:14 -0400 | [diff] [blame] | 633 | error = suspend_nvs_alloc(); |
Rafael J. Wysocki | 3f4b0ef | 2008-10-26 20:52:15 +0100 | [diff] [blame] | 634 | if (!error) |
| 635 | acpi_target_sleep_state = ACPI_STATE_S4; |
| 636 | } |
| 637 | return error; |
| 638 | } |
| 639 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 640 | /* |
| 641 | * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has |
| 642 | * been requested. |
| 643 | */ |
Lionel Debroux | 073ef1f | 2010-11-09 21:48:49 +0100 | [diff] [blame] | 644 | static const struct platform_hibernation_ops acpi_hibernation_ops_old = { |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 645 | .begin = acpi_hibernation_begin_old, |
| 646 | .end = acpi_pm_end, |
Rafael J. Wysocki | c5f7a1b | 2010-07-02 00:14:09 +0200 | [diff] [blame] | 647 | .pre_snapshot = acpi_pm_pre_suspend, |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 648 | .prepare = acpi_pm_freeze, |
Matthew Garrett | 2a6b697 | 2010-05-28 16:32:15 -0400 | [diff] [blame] | 649 | .finish = acpi_pm_finish, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 650 | .enter = acpi_hibernation_enter, |
| 651 | .leave = acpi_hibernation_leave, |
Rafael J. Wysocki | d5a6451 | 2010-04-09 01:39:40 +0200 | [diff] [blame] | 652 | .pre_restore = acpi_pm_freeze, |
| 653 | .restore_cleanup = acpi_pm_thaw, |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 654 | .recover = acpi_pm_finish, |
| 655 | }; |
| 656 | #endif /* CONFIG_HIBERNATION */ |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 657 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 658 | int acpi_suspend(u32 acpi_state) |
| 659 | { |
| 660 | suspend_state_t states[] = { |
| 661 | [1] = PM_SUSPEND_STANDBY, |
| 662 | [3] = PM_SUSPEND_MEM, |
| 663 | [5] = PM_SUSPEND_MAX |
| 664 | }; |
| 665 | |
| 666 | if (acpi_state < 6 && states[acpi_state]) |
| 667 | return pm_suspend(states[acpi_state]); |
| 668 | if (acpi_state == 4) |
| 669 | return hibernate(); |
| 670 | return -EINVAL; |
| 671 | } |
| 672 | |
Rafael J. Wysocki | aa33860 | 2011-02-11 00:06:54 +0100 | [diff] [blame] | 673 | #ifdef CONFIG_PM |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 674 | /** |
| 675 | * acpi_pm_device_sleep_state - return preferred power state of ACPI device |
| 676 | * in the system sleep state given by %acpi_target_sleep_state |
David Brownell | 2fe2de5 | 2008-06-05 01:15:40 +0200 | [diff] [blame] | 677 | * @dev: device to examine; its driver model wakeup flags control |
| 678 | * whether it should be able to wake up the system |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 679 | * @d_min_p: used to store the upper limit of allowed states range |
| 680 | * Return value: preferred power state of the device on success, -ENODEV on |
| 681 | * failure (ie. if there's no 'struct acpi_device' for @dev) |
| 682 | * |
| 683 | * Find the lowest power (highest number) ACPI device power state that |
| 684 | * device @dev can be in while the system is in the sleep state represented |
| 685 | * by %acpi_target_sleep_state. If @wake is nonzero, the device should be |
| 686 | * able to wake up the system from this sleep state. If @d_min_p is set, |
| 687 | * the highest power (lowest number) device power state of @dev allowed |
| 688 | * in this system sleep state is stored at the location pointed to by it. |
| 689 | * |
| 690 | * The caller must ensure that @dev is valid before using this function. |
| 691 | * The caller is also responsible for figuring out if the device is |
| 692 | * supposed to be able to wake up the system and passing this information |
| 693 | * via @wake. |
| 694 | */ |
| 695 | |
David Brownell | 2fe2de5 | 2008-06-05 01:15:40 +0200 | [diff] [blame] | 696 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p) |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 697 | { |
| 698 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); |
| 699 | struct acpi_device *adev; |
| 700 | char acpi_method[] = "_SxD"; |
Matthew Wilcox | 27663c5 | 2008-10-10 02:22:59 -0400 | [diff] [blame] | 701 | unsigned long long d_min, d_max; |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 702 | |
| 703 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { |
Shaohua Li | ead7759 | 2007-08-23 15:01:13 +0800 | [diff] [blame] | 704 | printk(KERN_DEBUG "ACPI handle has no context!\n"); |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 705 | return -ENODEV; |
| 706 | } |
| 707 | |
| 708 | acpi_method[2] = '0' + acpi_target_sleep_state; |
| 709 | /* |
| 710 | * If the sleep state is S0, we will return D3, but if the device has |
| 711 | * _S0W, we will use the value from _S0W |
| 712 | */ |
| 713 | d_min = ACPI_STATE_D0; |
| 714 | d_max = ACPI_STATE_D3; |
| 715 | |
| 716 | /* |
| 717 | * If present, _SxD methods return the minimum D-state (highest power |
| 718 | * state) we can use for the corresponding S-states. Otherwise, the |
| 719 | * minimum D-state is D0 (ACPI 3.x). |
| 720 | * |
| 721 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer |
| 722 | * provided -- that's our fault recovery, we ignore retval. |
| 723 | */ |
| 724 | if (acpi_target_sleep_state > ACPI_STATE_S0) |
| 725 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_min); |
| 726 | |
| 727 | /* |
| 728 | * If _PRW says we can wake up the system from the target sleep state, |
| 729 | * the D-state returned by _SxD is sufficient for that (we assume a |
| 730 | * wakeup-aware driver if wake is set). Still, if _SxW exists |
| 731 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that |
| 732 | * can wake the system. _S0W may be valid, too. |
| 733 | */ |
| 734 | if (acpi_target_sleep_state == ACPI_STATE_S0 || |
Rafael J. Wysocki | 761afb8 | 2010-10-14 23:24:13 +0200 | [diff] [blame] | 735 | (device_may_wakeup(dev) && |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 736 | adev->wakeup.sleep_state <= acpi_target_sleep_state)) { |
Rafael J. Wysocki | ad3399c | 2008-01-11 00:10:38 +0100 | [diff] [blame] | 737 | acpi_status status; |
| 738 | |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 739 | acpi_method[3] = 'W'; |
Rafael J. Wysocki | ad3399c | 2008-01-11 00:10:38 +0100 | [diff] [blame] | 740 | status = acpi_evaluate_integer(handle, acpi_method, NULL, |
| 741 | &d_max); |
| 742 | if (ACPI_FAILURE(status)) { |
Rafael J. Wysocki | 761afb8 | 2010-10-14 23:24:13 +0200 | [diff] [blame] | 743 | if (acpi_target_sleep_state != ACPI_STATE_S0 || |
| 744 | status != AE_NOT_FOUND) |
| 745 | d_max = d_min; |
Rafael J. Wysocki | ad3399c | 2008-01-11 00:10:38 +0100 | [diff] [blame] | 746 | } else if (d_max < d_min) { |
| 747 | /* Warn the user of the broken DSDT */ |
| 748 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", |
| 749 | acpi_method); |
| 750 | /* Sanitize it */ |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 751 | d_min = d_max; |
Rafael J. Wysocki | ad3399c | 2008-01-11 00:10:38 +0100 | [diff] [blame] | 752 | } |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | if (d_min_p) |
| 756 | *d_min_p = d_min; |
| 757 | return d_max; |
| 758 | } |
Rafael J. Wysocki | aa33860 | 2011-02-11 00:06:54 +0100 | [diff] [blame] | 759 | #endif /* CONFIG_PM */ |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 760 | |
Rafael J. Wysocki | 761afb8 | 2010-10-14 23:24:13 +0200 | [diff] [blame] | 761 | #ifdef CONFIG_PM_SLEEP |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 762 | /** |
Lin Ming | b24e509 | 2012-03-27 15:43:25 +0800 | [diff] [blame] | 763 | * acpi_pm_device_run_wake - Enable/disable wake-up for given device. |
| 764 | * @phys_dev: Device to enable/disable the platform to wake-up the system for. |
| 765 | * @enable: Whether enable or disable the wake-up functionality. |
| 766 | * |
| 767 | * Find the ACPI device object corresponding to @pci_dev and try to |
| 768 | * enable/disable the GPE associated with it. |
| 769 | */ |
| 770 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) |
| 771 | { |
| 772 | struct acpi_device *dev; |
| 773 | acpi_handle handle; |
| 774 | |
| 775 | if (!device_run_wake(phys_dev)) |
| 776 | return -EINVAL; |
| 777 | |
| 778 | handle = DEVICE_ACPI_HANDLE(phys_dev); |
| 779 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { |
| 780 | dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", |
| 781 | __func__); |
| 782 | return -ENODEV; |
| 783 | } |
| 784 | |
| 785 | if (enable) { |
| 786 | acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); |
| 787 | acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); |
| 788 | } else { |
| 789 | acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); |
| 790 | acpi_disable_wakeup_device_power(dev); |
| 791 | } |
| 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
| 796 | /** |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 797 | * acpi_pm_device_sleep_wake - enable or disable the system wake-up |
| 798 | * capability of given device |
| 799 | * @dev: device to handle |
| 800 | * @enable: 'true' - enable, 'false' - disable the wake-up capability |
| 801 | */ |
| 802 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) |
| 803 | { |
| 804 | acpi_handle handle; |
| 805 | struct acpi_device *adev; |
Rafael J. Wysocki | df8db91 | 2009-09-08 23:13:49 +0200 | [diff] [blame] | 806 | int error; |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 807 | |
Rafael J. Wysocki | 0baed8d | 2009-09-08 23:16:24 +0200 | [diff] [blame] | 808 | if (!device_can_wakeup(dev)) |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 809 | return -EINVAL; |
| 810 | |
| 811 | handle = DEVICE_ACPI_HANDLE(dev); |
| 812 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { |
Rafael J. Wysocki | df8db91 | 2009-09-08 23:13:49 +0200 | [diff] [blame] | 813 | dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__); |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 814 | return -ENODEV; |
| 815 | } |
| 816 | |
Rafael J. Wysocki | e8b6f97 | 2010-06-25 01:18:39 +0200 | [diff] [blame] | 817 | error = enable ? |
| 818 | acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : |
| 819 | acpi_disable_wakeup_device_power(adev); |
Rafael J. Wysocki | df8db91 | 2009-09-08 23:13:49 +0200 | [diff] [blame] | 820 | if (!error) |
| 821 | dev_info(dev, "wake-up capability %s by ACPI\n", |
| 822 | enable ? "enabled" : "disabled"); |
| 823 | |
| 824 | return error; |
Rafael J. Wysocki | eb9d0fe | 2008-07-07 03:34:48 +0200 | [diff] [blame] | 825 | } |
Rafael J. Wysocki | 761afb8 | 2010-10-14 23:24:13 +0200 | [diff] [blame] | 826 | #endif /* CONFIG_PM_SLEEP */ |
Shaohua Li | fd4aff1 | 2007-07-17 22:40:25 +0200 | [diff] [blame] | 827 | |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 828 | static void acpi_power_off_prepare(void) |
| 829 | { |
| 830 | /* Prepare to power off the system */ |
| 831 | acpi_sleep_prepare(ACPI_STATE_S5); |
Lin Ming | 3d97e42 | 2008-12-16 16:57:46 +0800 | [diff] [blame] | 832 | acpi_disable_all_gpes(); |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | static void acpi_power_off(void) |
| 836 | { |
| 837 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ |
Frank Seidel | 4d93915 | 2009-02-04 17:03:07 +0100 | [diff] [blame] | 838 | printk(KERN_DEBUG "%s called\n", __func__); |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 839 | local_irq_disable(); |
Konrad Rzeszutek Wilk | 2a14e54 | 2012-04-22 23:03:17 -0400 | [diff] [blame] | 840 | acpi_enter_sleep_state(ACPI_STATE_S5, wake_sleep_flags); |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 841 | } |
| 842 | |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 843 | /* |
| 844 | * ACPI 2.0 created the optional _GTS and _BFS, |
| 845 | * but industry adoption has been neither rapid nor broad. |
| 846 | * |
| 847 | * Linux gets into trouble when it executes poorly validated |
| 848 | * paths through the BIOS, so disable _GTS and _BFS by default, |
| 849 | * but do speak up and offer the option to enable them. |
| 850 | */ |
Stephen Hemminger | 01eac60 | 2010-10-18 18:47:25 -0700 | [diff] [blame] | 851 | static void __init acpi_gts_bfs_check(void) |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 852 | { |
| 853 | acpi_handle dummy; |
| 854 | |
Bob Moore | 4efeeec | 2012-03-21 09:42:45 +0800 | [diff] [blame] | 855 | if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__GTS, &dummy))) |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 856 | { |
| 857 | printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n"); |
| 858 | printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, " |
| 859 | "please notify linux-acpi@vger.kernel.org\n"); |
| 860 | } |
Bob Moore | 4efeeec | 2012-03-21 09:42:45 +0800 | [diff] [blame] | 861 | if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__BFS, &dummy))) |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 862 | { |
| 863 | printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n"); |
| 864 | printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, " |
| 865 | "please notify linux-acpi@vger.kernel.org\n"); |
| 866 | } |
| 867 | } |
| 868 | |
Alexey Starikovskiy | aafbcd1 | 2007-02-10 01:32:16 -0500 | [diff] [blame] | 869 | int __init acpi_sleep_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | { |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 871 | acpi_status status; |
| 872 | u8 type_a, type_b; |
| 873 | #ifdef CONFIG_SUSPEND |
Alexey Starikovskiy | e2a5b42 | 2005-03-18 16:20:46 -0500 | [diff] [blame] | 874 | int i = 0; |
Carlos Corbacho | e41fb7c | 2008-07-23 21:28:43 -0700 | [diff] [blame] | 875 | |
| 876 | dmi_check_system(acpisleep_dmi_table); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 877 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | |
| 879 | if (acpi_disabled) |
| 880 | return 0; |
| 881 | |
Frans Pop | 5a50fe7 | 2007-09-20 22:27:44 +0200 | [diff] [blame] | 882 | sleep_states[ACPI_STATE_S0] = 1; |
| 883 | printk(KERN_INFO PREFIX "(supports S0"); |
| 884 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 885 | #ifdef CONFIG_SUSPEND |
Frans Pop | 5a50fe7 | 2007-09-20 22:27:44 +0200 | [diff] [blame] | 886 | for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); |
| 888 | if (ACPI_SUCCESS(status)) { |
| 889 | sleep_states[i] = 1; |
| 890 | printk(" S%d", i); |
| 891 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 893 | |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 894 | suspend_set_ops(old_suspend_ordering ? |
| 895 | &acpi_suspend_ops_old : &acpi_suspend_ops); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 896 | #endif |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 897 | |
Rafael J. Wysocki | b0cb1a1 | 2007-07-29 23:24:36 +0200 | [diff] [blame] | 898 | #ifdef CONFIG_HIBERNATION |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 899 | status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b); |
| 900 | if (ACPI_SUCCESS(status)) { |
Rafael J. Wysocki | d8f3de0 | 2008-06-12 23:24:06 +0200 | [diff] [blame] | 901 | hibernation_set_ops(old_suspend_ordering ? |
| 902 | &acpi_hibernation_ops_old : &acpi_hibernation_ops); |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 903 | sleep_states[ACPI_STATE_S4] = 1; |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 904 | printk(" S4"); |
Shaohua Li | bdfe6b7 | 2008-07-23 21:28:41 -0700 | [diff] [blame] | 905 | if (!nosigcheck) { |
Lin Ming | 3d97e42 | 2008-12-16 16:57:46 +0800 | [diff] [blame] | 906 | acpi_get_table(ACPI_SIG_FACS, 1, |
Shaohua Li | bdfe6b7 | 2008-07-23 21:28:41 -0700 | [diff] [blame] | 907 | (struct acpi_table_header **)&facs); |
| 908 | if (facs) |
| 909 | s4_hardware_signature = |
| 910 | facs->hardware_signature; |
| 911 | } |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 912 | } |
Rafael J. Wysocki | a3d25c2 | 2007-05-09 02:33:18 -0700 | [diff] [blame] | 913 | #endif |
Alexey Starikovskiy | f216cc3 | 2007-09-20 21:32:35 +0400 | [diff] [blame] | 914 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
| 915 | if (ACPI_SUCCESS(status)) { |
| 916 | sleep_states[ACPI_STATE_S5] = 1; |
| 917 | printk(" S5"); |
| 918 | pm_power_off_prepare = acpi_power_off_prepare; |
| 919 | pm_power_off = acpi_power_off; |
| 920 | } |
| 921 | printk(")\n"); |
Zhao Yakui | e49f711 | 2008-08-12 10:20:22 +0800 | [diff] [blame] | 922 | /* |
| 923 | * Register the tts_notifier to reboot notifier list so that the _TTS |
| 924 | * object can also be evaluated when the system enters S5. |
| 925 | */ |
| 926 | register_reboot_notifier(&tts_notifier); |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 927 | acpi_gts_bfs_check(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | return 0; |
| 929 | } |