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