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