Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 3 | * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support Functions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | 7784813 | 2012-01-12 13:27:23 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2012, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
Shane Wang | 69575d3 | 2009-09-01 18:25:07 -0700 | [diff] [blame] | 46 | #include <linux/tboot.h> |
Paul Gortmaker | cc4b859 | 2011-07-01 14:30:49 -0400 | [diff] [blame] | 47 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | #define _COMPONENT ACPI_HARDWARE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("hwsleep") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 52 | /* Local prototypes */ |
| 53 | static void acpi_hw_execute_GTS(u8 sleep_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 55 | static void acpi_hw_execute_BFS(u8 sleep_state); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 56 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 57 | static void acpi_hw_execute_WAK(u8 sleep_state); |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 58 | |
Len Brown | 96f15ef | 2009-04-17 23:32:20 -0400 | [diff] [blame] | 59 | static unsigned int gts, bfs; |
| 60 | module_param(gts, uint, 0644); |
| 61 | module_param(bfs, uint, 0644); |
| 62 | MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend."); |
| 63 | MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); |
| 64 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 65 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 67 | * FUNCTION: acpi_hw_execute_GTS |
| 68 | * |
| 69 | * PARAMETERS: sleep_state - Sleep state that will be entered |
| 70 | * |
| 71 | * RETURN: None |
| 72 | * |
| 73 | * DESCRIPTION: Execute the optional _GTS method (Going To Sleep) |
| 74 | * |
| 75 | ******************************************************************************/ |
| 76 | |
| 77 | static void acpi_hw_execute_GTS(u8 sleep_state) |
| 78 | { |
| 79 | struct acpi_object_list arg_list; |
| 80 | union acpi_object arg; |
| 81 | acpi_status status; |
| 82 | |
| 83 | if (!gts) |
| 84 | return; |
| 85 | |
| 86 | /* One argument, sleep_state */ |
| 87 | |
| 88 | arg_list.count = 1; |
| 89 | arg_list.pointer = &arg; |
| 90 | arg.type = ACPI_TYPE_INTEGER; |
| 91 | arg.integer.value = sleep_state; |
| 92 | |
| 93 | status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); |
| 94 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 95 | ACPI_EXCEPTION((AE_INFO, status, |
| 96 | "While executing method _GTS")); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /******************************************************************************* |
| 101 | * |
| 102 | * FUNCTION: acpi_hw_execute_BFS |
| 103 | * |
| 104 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 105 | * |
| 106 | * RETURN: None |
| 107 | * |
| 108 | * DESCRIPTION: Execute the optional _BFS method (Back From Sleep) |
| 109 | * |
| 110 | ******************************************************************************/ |
| 111 | |
| 112 | static void acpi_hw_execute_BFS(u8 sleep_state) |
| 113 | { |
| 114 | struct acpi_object_list arg_list; |
| 115 | union acpi_object arg; |
| 116 | acpi_status status; |
| 117 | |
| 118 | if (!bfs) |
| 119 | return; |
| 120 | |
| 121 | /* One argument, sleep_state */ |
| 122 | |
| 123 | arg_list.count = 1; |
| 124 | arg_list.pointer = &arg; |
| 125 | arg.type = ACPI_TYPE_INTEGER; |
| 126 | arg.integer.value = sleep_state; |
| 127 | |
| 128 | status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); |
| 129 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 130 | ACPI_EXCEPTION((AE_INFO, status, |
| 131 | "While executing method _BFS")); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /******************************************************************************* |
| 136 | * |
| 137 | * FUNCTION: acpi_hw_execute_WAK |
| 138 | * |
| 139 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 140 | * |
| 141 | * RETURN: None |
| 142 | * |
| 143 | * DESCRIPTION: Execute the _WAK method (System Wake) |
| 144 | * |
| 145 | ******************************************************************************/ |
| 146 | |
| 147 | static void acpi_hw_execute_WAK(u8 sleep_state) |
| 148 | { |
| 149 | struct acpi_object_list arg_list; |
| 150 | union acpi_object arg; |
| 151 | acpi_status status; |
| 152 | |
| 153 | /* One argument, sleep_state */ |
| 154 | |
| 155 | arg_list.count = 1; |
| 156 | arg_list.pointer = &arg; |
| 157 | arg.type = ACPI_TYPE_INTEGER; |
| 158 | arg.integer.value = sleep_state; |
| 159 | |
| 160 | status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); |
| 161 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 162 | ACPI_EXCEPTION((AE_INFO, status, |
| 163 | "While executing method _WAK")); |
| 164 | } |
| 165 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ |
| 166 | } |
| 167 | |
| 168 | /******************************************************************************* |
| 169 | * |
| 170 | * FUNCTION: acpi_hw_execute_SST |
| 171 | * |
| 172 | * PARAMETERS: indicator_id - Value to be passed to the _SST method |
| 173 | * |
| 174 | * RETURN: None |
| 175 | * |
| 176 | * DESCRIPTION: Execute the optional _SST method (System Status) |
| 177 | * |
| 178 | ******************************************************************************/ |
| 179 | |
| 180 | void acpi_hw_execute_SST(u32 indicator_id) |
| 181 | { |
| 182 | struct acpi_object_list arg_list; |
| 183 | union acpi_object arg; |
| 184 | acpi_status status; |
| 185 | |
| 186 | /* One argument, status indicator ID */ |
| 187 | |
| 188 | arg_list.count = 1; |
| 189 | arg_list.pointer = &arg; |
| 190 | arg.type = ACPI_TYPE_INTEGER; |
| 191 | |
| 192 | arg.integer.value = indicator_id; |
| 193 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); |
| 194 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 195 | ACPI_EXCEPTION((AE_INFO, status, |
| 196 | "While executing method _SST")); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /******************************************************************************* |
| 201 | * |
| 202 | * FUNCTION: acpi_hw_legacy_sleep |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | * |
| 204 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 205 | * |
| 206 | * RETURN: Status |
| 207 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 208 | * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 210 | * |
| 211 | ******************************************************************************/ |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 212 | |
| 213 | acpi_status acpi_hw_legacy_sleep(u8 sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 215 | struct acpi_bit_register_info *sleep_type_reg_info; |
| 216 | struct acpi_bit_register_info *sleep_enable_reg_info; |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 217 | u32 pm1a_control; |
| 218 | u32 pm1b_control; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 219 | u32 in_value; |
| 220 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 222 | ACPI_FUNCTION_TRACE(hw_legacy_sleep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 224 | sleep_type_reg_info = |
Bob Moore | 82d79b8 | 2009-02-18 14:31:05 +0800 | [diff] [blame] | 225 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | sleep_enable_reg_info = |
| 227 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /* Clear wake status */ |
| 230 | |
Bob Moore | 768aaaf | 2009-03-06 09:49:25 +0800 | [diff] [blame] | 231 | status = |
| 232 | acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 233 | if (ACPI_FAILURE(status)) { |
| 234 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /* Clear all fixed and general purpose status bits */ |
| 238 | |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 239 | status = acpi_hw_clear_acpi_status(); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | if (ACPI_FAILURE(status)) { |
| 241 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 244 | if (sleep_state != ACPI_STATE_S5) { |
| 245 | /* |
| 246 | * Disable BM arbitration. This feature is contained within an |
| 247 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
| 248 | * exception. |
| 249 | */ |
| 250 | status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1); |
| 251 | if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) { |
| 252 | return_ACPI_STATUS(status); |
| 253 | } |
| 254 | } |
| 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | /* |
Pavel Machek | 23b168d | 2008-02-05 19:27:12 +0100 | [diff] [blame] | 257 | * 1) Disable/Clear all GPEs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | * 2) Enable all wakeup GPEs |
| 259 | */ |
Alexey Starikovskiy | 1d99967 | 2007-03-12 14:49:26 -0400 | [diff] [blame] | 260 | status = acpi_hw_disable_all_gpes(); |
| 261 | if (ACPI_FAILURE(status)) { |
| 262 | return_ACPI_STATUS(status); |
| 263 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | acpi_gbl_system_awake_and_running = FALSE; |
| 265 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 266 | status = acpi_hw_enable_all_wakeup_gpes(); |
| 267 | if (ACPI_FAILURE(status)) { |
| 268 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 271 | /* Execute the _GTS method (Going To Sleep) */ |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 272 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 273 | acpi_hw_execute_GTS(sleep_state); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | /* Get current value of PM1A control */ |
| 276 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 277 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, |
| 278 | &pm1a_control); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | if (ACPI_FAILURE(status)) { |
| 280 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
Bob Moore | b27d659 | 2010-05-26 11:47:13 +0800 | [diff] [blame] | 283 | "Entering sleep state [S%u]\n", sleep_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 285 | /* Clear the SLP_EN and SLP_TYP fields */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 287 | pm1a_control &= ~(sleep_type_reg_info->access_bit_mask | |
| 288 | sleep_enable_reg_info->access_bit_mask); |
| 289 | pm1b_control = pm1a_control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 291 | /* Insert the SLP_TYP bits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 293 | pm1a_control |= |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 295 | pm1b_control |= |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
| 298 | /* |
| 299 | * We split the writes of SLP_TYP and SLP_EN to workaround |
| 300 | * poorly implemented hardware. |
| 301 | */ |
| 302 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 303 | /* Write #1: write the SLP_TYP data to the PM1 Control registers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 305 | status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 306 | if (ACPI_FAILURE(status)) { |
| 307 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 310 | /* Insert the sleep enable (SLP_EN) bit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 312 | pm1a_control |= sleep_enable_reg_info->access_bit_mask; |
| 313 | pm1b_control |= sleep_enable_reg_info->access_bit_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 315 | /* Flush caches, as per ACPI specification */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 317 | ACPI_FLUSH_CPU_CACHE(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Joseph Cihula | 86886e5 | 2009-06-30 19:31:07 -0700 | [diff] [blame] | 319 | tboot_sleep(sleep_state, pm1a_control, pm1b_control); |
| 320 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 321 | /* Write #2: Write both SLP_TYP + SLP_EN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 323 | status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 324 | if (ACPI_FAILURE(status)) { |
| 325 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | if (sleep_state > ACPI_STATE_S3) { |
| 329 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 330 | * We wanted to sleep > S3, but it didn't happen (by virtue of the |
| 331 | * fact that we are still executing!) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 333 | * Wait ten seconds, then try again. This is to get S4/S5 to work on |
| 334 | * all machines. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | * |
Bob Moore | d4913dc | 2009-03-06 10:05:18 +0800 | [diff] [blame] | 336 | * We wait so long to allow chipsets that poll this reg very slowly |
| 337 | * to still read the right value. Ideally, this block would go |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | * away entirely. |
| 339 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | acpi_os_stall(10000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 342 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | sleep_enable_reg_info-> |
| 344 | access_bit_mask); |
| 345 | if (ACPI_FAILURE(status)) { |
| 346 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 350 | /* Wait for transition back to Working State */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
| 352 | do { |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 353 | status = |
| 354 | acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 355 | if (ACPI_FAILURE(status)) { |
| 356 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | } while (!in_value); |
| 360 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 361 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 364 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 366 | * FUNCTION: acpi_hw_legacy_wake_prep |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 368 | * PARAMETERS: sleep_state - Which sleep state we just exited |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | * |
| 370 | * RETURN: Status |
| 371 | * |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 372 | * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a |
| 373 | * sleep. |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 374 | * Called with interrupts ENABLED. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | * |
| 376 | ******************************************************************************/ |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 377 | |
| 378 | acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 380 | acpi_status status; |
| 381 | struct acpi_bit_register_info *sleep_type_reg_info; |
| 382 | struct acpi_bit_register_info *sleep_enable_reg_info; |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 383 | u32 pm1a_control; |
| 384 | u32 pm1b_control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 386 | ACPI_FUNCTION_TRACE(hw_legacy_wake_prep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | |
| 388 | /* |
| 389 | * Set SLP_TYPE and SLP_EN to state S0. |
| 390 | * This is unclear from the ACPI Spec, but it is required |
| 391 | * by some machines. |
| 392 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 393 | status = acpi_get_sleep_type_data(ACPI_STATE_S0, |
| 394 | &acpi_gbl_sleep_type_a, |
| 395 | &acpi_gbl_sleep_type_b); |
| 396 | if (ACPI_SUCCESS(status)) { |
| 397 | sleep_type_reg_info = |
Bob Moore | 82d79b8 | 2009-02-18 14:31:05 +0800 | [diff] [blame] | 398 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 399 | sleep_enable_reg_info = |
| 400 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | |
| 402 | /* Get current value of PM1A control */ |
| 403 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 404 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 405 | &pm1a_control); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 406 | if (ACPI_SUCCESS(status)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 407 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 408 | /* Clear the SLP_EN and SLP_TYP fields */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 410 | pm1a_control &= ~(sleep_type_reg_info->access_bit_mask | |
| 411 | sleep_enable_reg_info-> |
| 412 | access_bit_mask); |
| 413 | pm1b_control = pm1a_control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 415 | /* Insert the SLP_TYP bits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
Bob Moore | d4913dc | 2009-03-06 10:05:18 +0800 | [diff] [blame] | 417 | pm1a_control |= (acpi_gbl_sleep_type_a << |
| 418 | sleep_type_reg_info->bit_position); |
| 419 | pm1b_control |= (acpi_gbl_sleep_type_b << |
| 420 | sleep_type_reg_info->bit_position); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 422 | /* Write the control registers and ignore any errors */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Bob Moore | 32c9ef9 | 2009-02-18 14:36:05 +0800 | [diff] [blame] | 424 | (void)acpi_hw_write_pm1_control(pm1a_control, |
| 425 | pm1b_control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 429 | acpi_hw_execute_BFS(sleep_state); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 430 | return_ACPI_STATUS(status); |
| 431 | } |
| 432 | |
| 433 | /******************************************************************************* |
| 434 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 435 | * FUNCTION: acpi_hw_legacy_wake |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 436 | * |
| 437 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 438 | * |
| 439 | * RETURN: Status |
| 440 | * |
| 441 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
| 442 | * Called with interrupts ENABLED. |
| 443 | * |
| 444 | ******************************************************************************/ |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 445 | |
| 446 | acpi_status acpi_hw_legacy_wake(u8 sleep_state) |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 447 | { |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 448 | acpi_status status; |
| 449 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 450 | ACPI_FUNCTION_TRACE(hw_legacy_wake); |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 451 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ |
| 453 | |
| 454 | acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 455 | acpi_hw_execute_SST(ACPI_SST_WAKING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | /* |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 458 | * GPEs must be enabled before _WAK is called as GPEs |
| 459 | * might get fired there |
| 460 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | * Restore the GPEs: |
| 462 | * 1) Disable/Clear all GPEs |
| 463 | * 2) Enable all runtime GPEs |
| 464 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 465 | status = acpi_hw_disable_all_gpes(); |
| 466 | if (ACPI_FAILURE(status)) { |
| 467 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | } |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 469 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 | status = acpi_hw_enable_all_runtime_gpes(); |
| 471 | if (ACPI_FAILURE(status)) { |
| 472 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 475 | /* |
| 476 | * Now we can execute _WAK, etc. Some machines require that the GPEs |
| 477 | * are enabled before the wake methods are executed. |
| 478 | */ |
| 479 | acpi_hw_execute_WAK(sleep_state); |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 480 | |
Matthew Garrett | a68823e | 2008-08-06 19:12:04 +0100 | [diff] [blame] | 481 | /* |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 482 | * Some BIOS code assumes that WAK_STS will be cleared on resume |
| 483 | * and use it to determine whether the system is rebooting or |
| 484 | * resuming. Clear WAK_STS for compatibility. |
Matthew Garrett | a68823e | 2008-08-06 19:12:04 +0100 | [diff] [blame] | 485 | */ |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 486 | acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 487 | acpi_gbl_system_awake_and_running = TRUE; |
| 488 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | /* Enable power button */ |
| 490 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | (void) |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 492 | acpi_write_bit_register(acpi_gbl_fixed_event_info |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 493 | [ACPI_EVENT_POWER_BUTTON]. |
| 494 | enable_register_id, ACPI_ENABLE_EVENT); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 495 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 496 | (void) |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 497 | acpi_write_bit_register(acpi_gbl_fixed_event_info |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 498 | [ACPI_EVENT_POWER_BUTTON]. |
| 499 | status_register_id, ACPI_CLEAR_STATUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 501 | /* |
| 502 | * Enable BM arbitration. This feature is contained within an |
| 503 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
| 504 | * exception. |
| 505 | */ |
| 506 | status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0); |
| 507 | if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) { |
| 508 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | } |
| 510 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 511 | acpi_hw_execute_SST(ACPI_SST_WORKING); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 512 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 514 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame^] | 515 | |
| 516 | /******************************************************************************* |
| 517 | * |
| 518 | * FUNCTION: acpi_hw_extended_sleep |
| 519 | * |
| 520 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 521 | * |
| 522 | * RETURN: Status |
| 523 | * |
| 524 | * DESCRIPTION: Enter a system sleep state via the extended FADT sleep |
| 525 | * registers (V5 FADT). |
| 526 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 527 | * |
| 528 | ******************************************************************************/ |
| 529 | |
| 530 | acpi_status acpi_hw_extended_sleep(u8 sleep_state) |
| 531 | { |
| 532 | acpi_status status; |
| 533 | u8 sleep_type_value; |
| 534 | u64 sleep_status; |
| 535 | |
| 536 | ACPI_FUNCTION_TRACE(hw_extended_sleep); |
| 537 | |
| 538 | /* Extended sleep registers must be valid */ |
| 539 | |
| 540 | if (!acpi_gbl_FADT.sleep_control.address || |
| 541 | !acpi_gbl_FADT.sleep_status.address) { |
| 542 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 543 | } |
| 544 | |
| 545 | /* Clear wake status (WAK_STS) */ |
| 546 | |
| 547 | status = acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); |
| 548 | if (ACPI_FAILURE(status)) { |
| 549 | return_ACPI_STATUS(status); |
| 550 | } |
| 551 | |
| 552 | acpi_gbl_system_awake_and_running = FALSE; |
| 553 | |
| 554 | /* Execute the _GTS method (Going To Sleep) */ |
| 555 | |
| 556 | acpi_hw_execute_GTS(sleep_state); |
| 557 | |
| 558 | /* Flush caches, as per ACPI specification */ |
| 559 | |
| 560 | ACPI_FLUSH_CPU_CACHE(); |
| 561 | |
| 562 | /* |
| 563 | * Set the SLP_TYP and SLP_EN bits. |
| 564 | * |
| 565 | * Note: We only use the first value returned by the \_Sx method |
| 566 | * (acpi_gbl_sleep_type_a) - As per ACPI specification. |
| 567 | */ |
| 568 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 569 | "Entering sleep state [S%u]\n", sleep_state)); |
| 570 | |
| 571 | sleep_type_value = |
| 572 | ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & |
| 573 | ACPI_X_SLEEP_TYPE_MASK); |
| 574 | |
| 575 | status = acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE), |
| 576 | &acpi_gbl_FADT.sleep_control); |
| 577 | if (ACPI_FAILURE(status)) { |
| 578 | return_ACPI_STATUS(status); |
| 579 | } |
| 580 | |
| 581 | /* Wait for transition back to Working State */ |
| 582 | |
| 583 | do { |
| 584 | status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status); |
| 585 | if (ACPI_FAILURE(status)) { |
| 586 | return_ACPI_STATUS(status); |
| 587 | } |
| 588 | |
| 589 | } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS)); |
| 590 | |
| 591 | return_ACPI_STATUS(AE_OK); |
| 592 | } |
| 593 | |
| 594 | /******************************************************************************* |
| 595 | * |
| 596 | * FUNCTION: acpi_hw_extended_wake_prep |
| 597 | * |
| 598 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 599 | * |
| 600 | * RETURN: Status |
| 601 | * |
| 602 | * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after |
| 603 | * a sleep. Called with interrupts ENABLED. |
| 604 | * |
| 605 | ******************************************************************************/ |
| 606 | |
| 607 | acpi_status acpi_hw_extended_wake_prep(u8 sleep_state) |
| 608 | { |
| 609 | acpi_status status; |
| 610 | u8 sleep_type_value; |
| 611 | |
| 612 | ACPI_FUNCTION_TRACE(hw_extended_wake_prep); |
| 613 | |
| 614 | status = acpi_get_sleep_type_data(ACPI_STATE_S0, |
| 615 | &acpi_gbl_sleep_type_a, |
| 616 | &acpi_gbl_sleep_type_b); |
| 617 | if (ACPI_SUCCESS(status)) { |
| 618 | sleep_type_value = |
| 619 | ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) & |
| 620 | ACPI_X_SLEEP_TYPE_MASK); |
| 621 | |
| 622 | (void)acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE), |
| 623 | &acpi_gbl_FADT.sleep_control); |
| 624 | } |
| 625 | |
| 626 | acpi_hw_execute_BFS(sleep_state); |
| 627 | return_ACPI_STATUS(AE_OK); |
| 628 | } |
| 629 | |
| 630 | /******************************************************************************* |
| 631 | * |
| 632 | * FUNCTION: acpi_hw_extended_wake |
| 633 | * |
| 634 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 635 | * |
| 636 | * RETURN: Status |
| 637 | * |
| 638 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
| 639 | * Called with interrupts ENABLED. |
| 640 | * |
| 641 | ******************************************************************************/ |
| 642 | |
| 643 | acpi_status acpi_hw_extended_wake(u8 sleep_state) |
| 644 | { |
| 645 | ACPI_FUNCTION_TRACE(hw_extended_wake); |
| 646 | |
| 647 | /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ |
| 648 | |
| 649 | acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; |
| 650 | |
| 651 | /* Execute the wake methods */ |
| 652 | |
| 653 | acpi_hw_execute_SST(ACPI_SST_WAKING); |
| 654 | acpi_hw_execute_WAK(sleep_state); |
| 655 | |
| 656 | /* |
| 657 | * Some BIOS code assumes that WAK_STS will be cleared on resume |
| 658 | * and use it to determine whether the system is rebooting or |
| 659 | * resuming. Clear WAK_STS for compatibility. |
| 660 | */ |
| 661 | (void)acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status); |
| 662 | acpi_gbl_system_awake_and_running = TRUE; |
| 663 | |
| 664 | acpi_hw_execute_SST(ACPI_SST_WORKING); |
| 665 | return_ACPI_STATUS(AE_OK); |
| 666 | } |