Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
David E. Box | 82a8094 | 2015-02-05 15:20:45 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2015, Intel Corp. |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [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 | |
Lv Zheng | 839e928 | 2013-10-29 09:29:51 +0800 | [diff] [blame] | 44 | #define EXPORT_ACPI_INTERFACES |
| 45 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 46 | #include <acpi/acpi.h> |
| 47 | #include "accommon.h" |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 48 | |
| 49 | #define _COMPONENT ACPI_HARDWARE |
| 50 | ACPI_MODULE_NAME("hwxfsleep") |
| 51 | |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 52 | /* Local prototypes */ |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 53 | static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id); |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | * Dispatch table used to efficiently branch to the various sleep |
| 57 | * functions. |
| 58 | */ |
Lin Ming | 8a73b17 | 2012-03-21 10:01:49 +0800 | [diff] [blame] | 59 | #define ACPI_SLEEP_FUNCTION_ID 0 |
| 60 | #define ACPI_WAKE_PREP_FUNCTION_ID 1 |
| 61 | #define ACPI_WAKE_FUNCTION_ID 2 |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 62 | |
| 63 | /* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */ |
| 64 | |
| 65 | static struct acpi_sleep_functions acpi_sleep_dispatch[] = { |
| 66 | {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep), |
| 67 | acpi_hw_extended_sleep}, |
| 68 | {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep), |
| 69 | acpi_hw_extended_wake_prep}, |
| 70 | {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake} |
| 71 | }; |
| 72 | |
| 73 | /* |
| 74 | * These functions are removed for the ACPI_REDUCED_HARDWARE case: |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 75 | * acpi_set_firmware_waking_vectors |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 76 | * acpi_set_firmware_waking_vector |
| 77 | * acpi_set_firmware_waking_vector64 |
| 78 | * acpi_enter_sleep_state_s4bios |
| 79 | */ |
| 80 | |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 81 | #if (!ACPI_REDUCED_HARDWARE) |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 82 | /******************************************************************************* |
| 83 | * |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 84 | * FUNCTION: acpi_set_firmware_waking_vectors |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 85 | * |
| 86 | * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode |
| 87 | * entry point. |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 88 | * physical_address64 - 64-bit physical address of ACPI protected |
| 89 | * mode entry point. |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 90 | * |
| 91 | * RETURN: Status |
| 92 | * |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 93 | * DESCRIPTION: Sets the firmware_waking_vector fields of the FACS |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 94 | * |
| 95 | ******************************************************************************/ |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 96 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 97 | acpi_status |
| 98 | acpi_set_firmware_waking_vectors(acpi_physical_address physical_address, |
| 99 | acpi_physical_address physical_address64) |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 100 | { |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 101 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vectors); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 102 | |
| 103 | |
| 104 | /* |
| 105 | * According to the ACPI specification 2.0c and later, the 64-bit |
| 106 | * waking vector should be cleared and the 32-bit waking vector should |
| 107 | * be used, unless we want the wake-up code to be called by the BIOS in |
| 108 | * Protected Mode. Some systems (for example HP dv5-1004nr) are known |
| 109 | * to fail to resume if the 64-bit vector is used. |
| 110 | */ |
| 111 | |
| 112 | /* Set the 32-bit vector */ |
| 113 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 114 | acpi_gbl_FACS->firmware_waking_vector = (u32)physical_address; |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 115 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 116 | if (acpi_gbl_FACS->length > 32) { |
| 117 | if (acpi_gbl_FACS->version >= 1) { |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 118 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 119 | /* Set the 64-bit vector */ |
| 120 | |
| 121 | acpi_gbl_FACS->xfirmware_waking_vector = |
| 122 | physical_address64; |
| 123 | } else { |
| 124 | /* Clear the 64-bit vector if it exists */ |
| 125 | |
| 126 | acpi_gbl_FACS->xfirmware_waking_vector = 0; |
| 127 | } |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | return_ACPI_STATUS(AE_OK); |
| 131 | } |
| 132 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 133 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vectors) |
| 134 | |
| 135 | /******************************************************************************* |
| 136 | * |
| 137 | * FUNCTION: acpi_set_firmware_waking_vector |
| 138 | * |
| 139 | * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode |
| 140 | * entry point. |
| 141 | * |
| 142 | * RETURN: Status |
| 143 | * |
| 144 | * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS |
| 145 | * |
| 146 | ******************************************************************************/ |
| 147 | acpi_status acpi_set_firmware_waking_vector(u32 physical_address) |
| 148 | { |
| 149 | acpi_status status; |
| 150 | |
| 151 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); |
| 152 | |
| 153 | status = acpi_set_firmware_waking_vectors((acpi_physical_address) |
| 154 | physical_address, 0); |
| 155 | |
| 156 | return_ACPI_STATUS(status); |
| 157 | } |
| 158 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 159 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) |
| 160 | |
| 161 | #if ACPI_MACHINE_WIDTH == 64 |
| 162 | /******************************************************************************* |
| 163 | * |
| 164 | * FUNCTION: acpi_set_firmware_waking_vector64 |
| 165 | * |
| 166 | * PARAMETERS: physical_address - 64-bit physical address of ACPI protected |
| 167 | * mode entry point. |
| 168 | * |
| 169 | * RETURN: Status |
| 170 | * |
| 171 | * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if |
| 172 | * it exists in the table. This function is intended for use with |
| 173 | * 64-bit host operating systems. |
| 174 | * |
| 175 | ******************************************************************************/ |
| 176 | acpi_status acpi_set_firmware_waking_vector64(u64 physical_address) |
| 177 | { |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 178 | acpi_status status; |
| 179 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 180 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64); |
| 181 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 182 | status = acpi_set_firmware_waking_vectors(0, |
| 183 | (acpi_physical_address) |
| 184 | physical_address); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 185 | |
Lv Zheng | aca2a5d | 2015-07-01 14:43:04 +0800 | [diff] [blame^] | 186 | return_ACPI_STATUS(status); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) |
| 190 | #endif |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 191 | /******************************************************************************* |
| 192 | * |
| 193 | * FUNCTION: acpi_enter_sleep_state_s4bios |
| 194 | * |
| 195 | * PARAMETERS: None |
| 196 | * |
| 197 | * RETURN: Status |
| 198 | * |
| 199 | * DESCRIPTION: Perform a S4 bios request. |
| 200 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 201 | * |
| 202 | ******************************************************************************/ |
Lv Zheng | 40bce10 | 2013-10-31 09:31:18 +0800 | [diff] [blame] | 203 | acpi_status acpi_enter_sleep_state_s4bios(void) |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 204 | { |
| 205 | u32 in_value; |
| 206 | acpi_status status; |
| 207 | |
| 208 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); |
| 209 | |
| 210 | /* Clear the wake status bit (PM1) */ |
| 211 | |
| 212 | status = |
| 213 | acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
| 214 | if (ACPI_FAILURE(status)) { |
| 215 | return_ACPI_STATUS(status); |
| 216 | } |
| 217 | |
| 218 | status = acpi_hw_clear_acpi_status(); |
| 219 | if (ACPI_FAILURE(status)) { |
| 220 | return_ACPI_STATUS(status); |
| 221 | } |
| 222 | |
| 223 | /* |
| 224 | * 1) Disable/Clear all GPEs |
| 225 | * 2) Enable all wakeup GPEs |
| 226 | */ |
| 227 | status = acpi_hw_disable_all_gpes(); |
| 228 | if (ACPI_FAILURE(status)) { |
| 229 | return_ACPI_STATUS(status); |
| 230 | } |
| 231 | acpi_gbl_system_awake_and_running = FALSE; |
| 232 | |
| 233 | status = acpi_hw_enable_all_wakeup_gpes(); |
| 234 | if (ACPI_FAILURE(status)) { |
| 235 | return_ACPI_STATUS(status); |
| 236 | } |
| 237 | |
| 238 | ACPI_FLUSH_CPU_CACHE(); |
| 239 | |
| 240 | status = acpi_hw_write_port(acpi_gbl_FADT.smi_command, |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 241 | (u32)acpi_gbl_FADT.s4_bios_request, 8); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 242 | |
| 243 | do { |
Bob Moore | c41679a | 2012-12-31 00:05:46 +0000 | [diff] [blame] | 244 | acpi_os_stall(ACPI_USEC_PER_MSEC); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 245 | status = |
| 246 | acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); |
| 247 | if (ACPI_FAILURE(status)) { |
| 248 | return_ACPI_STATUS(status); |
| 249 | } |
| 250 | } while (!in_value); |
| 251 | |
| 252 | return_ACPI_STATUS(AE_OK); |
| 253 | } |
| 254 | |
| 255 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 256 | #endif /* !ACPI_REDUCED_HARDWARE */ |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 257 | /******************************************************************************* |
| 258 | * |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 259 | * FUNCTION: acpi_hw_sleep_dispatch |
| 260 | * |
| 261 | * PARAMETERS: sleep_state - Which sleep state to enter/exit |
| 262 | * function_id - Sleep, wake_prep, or Wake |
| 263 | * |
| 264 | * RETURN: Status from the invoked sleep handling function. |
| 265 | * |
| 266 | * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling |
| 267 | * function. |
| 268 | * |
| 269 | ******************************************************************************/ |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 270 | static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id) |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 271 | { |
| 272 | acpi_status status; |
| 273 | struct acpi_sleep_functions *sleep_functions = |
| 274 | &acpi_sleep_dispatch[function_id]; |
| 275 | |
| 276 | #if (!ACPI_REDUCED_HARDWARE) |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 277 | /* |
| 278 | * If the Hardware Reduced flag is set (from the FADT), we must |
Lv Zheng | 7cec704 | 2013-06-08 00:59:18 +0000 | [diff] [blame] | 279 | * use the extended sleep registers (FADT). Note: As per the ACPI |
| 280 | * specification, these extended registers are to be used for HW-reduced |
| 281 | * platforms only. They are not general-purpose replacements for the |
| 282 | * legacy PM register sleep support. |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 283 | */ |
Lv Zheng | 7cec704 | 2013-06-08 00:59:18 +0000 | [diff] [blame] | 284 | if (acpi_gbl_reduced_hardware) { |
Len Brown | 3f6f49c | 2012-07-26 20:08:54 -0400 | [diff] [blame] | 285 | status = sleep_functions->extended_function(sleep_state); |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 286 | } else { |
| 287 | /* Legacy sleep */ |
| 288 | |
Len Brown | 3f6f49c | 2012-07-26 20:08:54 -0400 | [diff] [blame] | 289 | status = sleep_functions->legacy_function(sleep_state); |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | return (status); |
| 293 | |
| 294 | #else |
| 295 | /* |
| 296 | * For the case where reduced-hardware-only code is being generated, |
| 297 | * we know that only the extended sleep registers are available |
| 298 | */ |
Len Brown | 3f6f49c | 2012-07-26 20:08:54 -0400 | [diff] [blame] | 299 | status = sleep_functions->extended_function(sleep_state); |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 300 | return (status); |
| 301 | |
| 302 | #endif /* !ACPI_REDUCED_HARDWARE */ |
| 303 | } |
| 304 | |
| 305 | /******************************************************************************* |
| 306 | * |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 307 | * FUNCTION: acpi_enter_sleep_state_prep |
| 308 | * |
| 309 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 310 | * |
| 311 | * RETURN: Status |
| 312 | * |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 313 | * DESCRIPTION: Prepare to enter a system sleep state. |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 314 | * This function must execute with interrupts enabled. |
| 315 | * We break sleeping into 2 stages so that OSPM can handle |
| 316 | * various OS-specific tasks between the two steps. |
| 317 | * |
| 318 | ******************************************************************************/ |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 319 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 320 | acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) |
| 321 | { |
| 322 | acpi_status status; |
| 323 | struct acpi_object_list arg_list; |
| 324 | union acpi_object arg; |
| 325 | u32 sst_value; |
| 326 | |
| 327 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); |
| 328 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 329 | status = acpi_get_sleep_type_data(sleep_state, |
| 330 | &acpi_gbl_sleep_type_a, |
| 331 | &acpi_gbl_sleep_type_b); |
| 332 | if (ACPI_FAILURE(status)) { |
| 333 | return_ACPI_STATUS(status); |
| 334 | } |
| 335 | |
| 336 | /* Execute the _PTS method (Prepare To Sleep) */ |
| 337 | |
| 338 | arg_list.count = 1; |
| 339 | arg_list.pointer = &arg; |
| 340 | arg.type = ACPI_TYPE_INTEGER; |
| 341 | arg.integer.value = sleep_state; |
| 342 | |
Bob Moore | 4efeeec | 2012-03-21 09:42:45 +0800 | [diff] [blame] | 343 | status = |
| 344 | acpi_evaluate_object(NULL, METHOD_PATHNAME__PTS, &arg_list, NULL); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 345 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 346 | return_ACPI_STATUS(status); |
| 347 | } |
| 348 | |
| 349 | /* Setup the argument to the _SST method (System STatus) */ |
| 350 | |
| 351 | switch (sleep_state) { |
| 352 | case ACPI_STATE_S0: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 353 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 354 | sst_value = ACPI_SST_WORKING; |
| 355 | break; |
| 356 | |
| 357 | case ACPI_STATE_S1: |
| 358 | case ACPI_STATE_S2: |
| 359 | case ACPI_STATE_S3: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 360 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 361 | sst_value = ACPI_SST_SLEEPING; |
| 362 | break; |
| 363 | |
| 364 | case ACPI_STATE_S4: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 365 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 366 | sst_value = ACPI_SST_SLEEP_CONTEXT; |
| 367 | break; |
| 368 | |
| 369 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 370 | |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 371 | sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */ |
| 372 | break; |
| 373 | } |
| 374 | |
| 375 | /* |
| 376 | * Set the system indicators to show the desired sleep state. |
| 377 | * _SST is an optional method (return no error if not found) |
| 378 | */ |
Bob Moore | 4efeeec | 2012-03-21 09:42:45 +0800 | [diff] [blame] | 379 | acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, sst_value); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 380 | return_ACPI_STATUS(AE_OK); |
| 381 | } |
| 382 | |
| 383 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) |
| 384 | |
| 385 | /******************************************************************************* |
| 386 | * |
| 387 | * FUNCTION: acpi_enter_sleep_state |
| 388 | * |
| 389 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 390 | * |
| 391 | * RETURN: Status |
| 392 | * |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 393 | * DESCRIPTION: Enter a system sleep state |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 394 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 395 | * |
| 396 | ******************************************************************************/ |
Lv Zheng | 40bce10 | 2013-10-31 09:31:18 +0800 | [diff] [blame] | 397 | acpi_status acpi_enter_sleep_state(u8 sleep_state) |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 398 | { |
| 399 | acpi_status status; |
| 400 | |
| 401 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); |
| 402 | |
| 403 | if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || |
| 404 | (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { |
| 405 | ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", |
| 406 | acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); |
| 407 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); |
| 408 | } |
| 409 | |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 410 | status = acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION_ID); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 411 | return_ACPI_STATUS(status); |
| 412 | } |
| 413 | |
| 414 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) |
| 415 | |
| 416 | /******************************************************************************* |
| 417 | * |
| 418 | * FUNCTION: acpi_leave_sleep_state_prep |
| 419 | * |
| 420 | * PARAMETERS: sleep_state - Which sleep state we are exiting |
| 421 | * |
| 422 | * RETURN: Status |
| 423 | * |
| 424 | * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 425 | * sleep. Called with interrupts DISABLED. |
| 426 | * We break wake/resume into 2 stages so that OSPM can handle |
| 427 | * various OS-specific tasks between the two steps. |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 428 | * |
| 429 | ******************************************************************************/ |
Len Brown | 3f6f49c | 2012-07-26 20:08:54 -0400 | [diff] [blame] | 430 | acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 431 | { |
| 432 | acpi_status status; |
| 433 | |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 434 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 435 | |
Lin Ming | 8a73b17 | 2012-03-21 10:01:49 +0800 | [diff] [blame] | 436 | status = |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 437 | acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_PREP_FUNCTION_ID); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 438 | return_ACPI_STATUS(status); |
| 439 | } |
| 440 | |
| 441 | ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state_prep) |
| 442 | |
| 443 | /******************************************************************************* |
| 444 | * |
| 445 | * FUNCTION: acpi_leave_sleep_state |
| 446 | * |
Bob Moore | 72a8887 | 2012-02-14 18:57:13 +0800 | [diff] [blame] | 447 | * PARAMETERS: sleep_state - Which sleep state we are exiting |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 448 | * |
| 449 | * RETURN: Status |
| 450 | * |
| 451 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
| 452 | * Called with interrupts ENABLED. |
| 453 | * |
| 454 | ******************************************************************************/ |
| 455 | acpi_status acpi_leave_sleep_state(u8 sleep_state) |
| 456 | { |
| 457 | acpi_status status; |
| 458 | |
| 459 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); |
| 460 | |
Len Brown | 3f6f49c | 2012-07-26 20:08:54 -0400 | [diff] [blame] | 461 | status = acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_FUNCTION_ID); |
Bob Moore | 2feec47 | 2012-02-14 15:00:53 +0800 | [diff] [blame] | 462 | return_ACPI_STATUS(status); |
| 463 | } |
| 464 | |
| 465 | ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) |