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