Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface |
| 5 | * |
| 6 | *****************************************************************************/ |
| 7 | |
| 8 | /* |
Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2008, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions, and the following disclaimer, |
| 17 | * without modification. |
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 21 | * including a substantially similar Disclaimer requirement for further |
| 22 | * binary redistribution. |
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 24 | * of any contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * Alternatively, this software may be distributed under the terms of the |
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 29 | * Software Foundation. |
| 30 | * |
| 31 | * NO WARRANTY |
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 | * POSSIBILITY OF SUCH DAMAGES. |
| 43 | */ |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 46 | #include <acpi/actables.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | #define _COMPONENT ACPI_HARDWARE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("hwsleep") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | * |
| 53 | * FUNCTION: acpi_set_firmware_waking_vector |
| 54 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 55 | * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | * entry point. |
| 57 | * |
| 58 | * RETURN: Status |
| 59 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 60 | * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | * |
| 62 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | acpi_status |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 64 | acpi_set_firmware_waking_vector(u32 physical_address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 66 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 68 | |
Rafael J. Wysocki | a662910 | 2008-09-06 13:13:01 +0200 | [diff] [blame] | 69 | /* |
| 70 | * According to the ACPI specification 2.0c and later, the 64-bit |
| 71 | * waking vector should be cleared and the 32-bit waking vector should |
| 72 | * be used, unless we want the wake-up code to be called by the BIOS in |
| 73 | * Protected Mode. Some systems (for example HP dv5-1004nr) are known |
| 74 | * to fail to resume if the 64-bit vector is used. |
| 75 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 77 | /* Set the 32-bit vector */ |
| 78 | |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame^] | 79 | acpi_gbl_FACS->firmware_waking_vector = physical_address; |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 80 | |
| 81 | /* Clear the 64-bit vector if it exists */ |
| 82 | |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame^] | 83 | if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) { |
| 84 | acpi_gbl_FACS->xfirmware_waking_vector = 0; |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 85 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 87 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 90 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector) |
| 91 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 92 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 94 | * FUNCTION: acpi_set_firmware_waking_vector64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 96 | * PARAMETERS: physical_address - 64-bit physical address of ACPI protected |
| 97 | * mode entry point. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 99 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | * |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 101 | * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if |
| 102 | * it exists in the table. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | * |
| 104 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | acpi_status |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 106 | acpi_set_firmware_waking_vector64(u64 physical_address) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 108 | ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 111 | /* Determine if the 64-bit vector actually exists */ |
| 112 | |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame^] | 113 | if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) { |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 114 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 115 | } |
| 116 | |
| 117 | /* Clear 32-bit vector, set the 64-bit X_ vector */ |
| 118 | |
Bob Moore | 009c4cbe | 2008-11-12 15:34:52 +0800 | [diff] [blame^] | 119 | acpi_gbl_FACS->firmware_waking_vector = 0; |
| 120 | acpi_gbl_FACS->xfirmware_waking_vector = physical_address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 122 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 124 | |
Bob Moore | d85988f | 2008-11-12 14:54:05 +0800 | [diff] [blame] | 125 | ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64) |
| 126 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 127 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | * |
| 129 | * FUNCTION: acpi_enter_sleep_state_prep |
| 130 | * |
| 131 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 132 | * |
| 133 | * RETURN: Status |
| 134 | * |
| 135 | * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) |
| 136 | * This function must execute with interrupts enabled. |
| 137 | * We break sleeping into 2 stages so that OSPM can handle |
| 138 | * various OS-specific tasks between the two steps. |
| 139 | * |
| 140 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | acpi_status status; |
| 144 | struct acpi_object_list arg_list; |
| 145 | union acpi_object arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 147 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
| 149 | /* |
| 150 | * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. |
| 151 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | status = acpi_get_sleep_type_data(sleep_state, |
| 153 | &acpi_gbl_sleep_type_a, |
| 154 | &acpi_gbl_sleep_type_b); |
| 155 | if (ACPI_FAILURE(status)) { |
| 156 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /* Setup parameter object */ |
| 160 | |
| 161 | arg_list.count = 1; |
| 162 | arg_list.pointer = &arg; |
| 163 | |
| 164 | arg.type = ACPI_TYPE_INTEGER; |
| 165 | arg.integer.value = sleep_state; |
| 166 | |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 167 | /* Run the _PTS method */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 169 | status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL); |
| 170 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 171 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | /* Setup the argument to _SST */ |
| 175 | |
| 176 | switch (sleep_state) { |
| 177 | case ACPI_STATE_S0: |
| 178 | arg.integer.value = ACPI_SST_WORKING; |
| 179 | break; |
| 180 | |
| 181 | case ACPI_STATE_S1: |
| 182 | case ACPI_STATE_S2: |
| 183 | case ACPI_STATE_S3: |
| 184 | arg.integer.value = ACPI_SST_SLEEPING; |
| 185 | break; |
| 186 | |
| 187 | case ACPI_STATE_S4: |
| 188 | arg.integer.value = ACPI_SST_SLEEP_CONTEXT; |
| 189 | break; |
| 190 | |
| 191 | default: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 192 | arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | break; |
| 194 | } |
| 195 | |
Bob Moore | d52c79a | 2008-06-10 14:26:57 +0800 | [diff] [blame] | 196 | /* |
| 197 | * Set the system indicators to show the desired sleep state. |
| 198 | * _SST is an optional method (return no error if not found) |
| 199 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 200 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); |
| 201 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 202 | ACPI_EXCEPTION((AE_INFO, status, |
| 203 | "While executing method _SST")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | } |
| 205 | |
Bob Moore | d52c79a | 2008-06-10 14:26:57 +0800 | [diff] [blame] | 206 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 209 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep) |
| 210 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 211 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | * |
| 213 | * FUNCTION: acpi_enter_sleep_state |
| 214 | * |
| 215 | * PARAMETERS: sleep_state - Which sleep state to enter |
| 216 | * |
| 217 | * RETURN: Status |
| 218 | * |
| 219 | * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231) |
| 220 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 221 | * |
| 222 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 225 | u32 PM1Acontrol; |
| 226 | u32 PM1Bcontrol; |
| 227 | struct acpi_bit_register_info *sleep_type_reg_info; |
| 228 | struct acpi_bit_register_info *sleep_enable_reg_info; |
| 229 | u32 in_value; |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 230 | struct acpi_object_list arg_list; |
| 231 | union acpi_object arg; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 234 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
| 236 | if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 237 | (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 238 | ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X", |
| 239 | acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | return_ACPI_STATUS(AE_AML_OPERAND_VALUE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | sleep_type_reg_info = |
| 244 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); |
| 245 | sleep_enable_reg_info = |
| 246 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
| 248 | /* Clear wake status */ |
| 249 | |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 250 | status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 251 | if (ACPI_FAILURE(status)) { |
| 252 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /* Clear all fixed and general purpose status bits */ |
| 256 | |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 257 | status = acpi_hw_clear_acpi_status(); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 258 | if (ACPI_FAILURE(status)) { |
| 259 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* |
Pavel Machek | 23b168d | 2008-02-05 19:27:12 +0100 | [diff] [blame] | 263 | * 1) Disable/Clear all GPEs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | * 2) Enable all wakeup GPEs |
| 265 | */ |
Alexey Starikovskiy | 1d99967 | 2007-03-12 14:49:26 -0400 | [diff] [blame] | 266 | status = acpi_hw_disable_all_gpes(); |
| 267 | if (ACPI_FAILURE(status)) { |
| 268 | return_ACPI_STATUS(status); |
| 269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | acpi_gbl_system_awake_and_running = FALSE; |
| 271 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | status = acpi_hw_enable_all_wakeup_gpes(); |
| 273 | if (ACPI_FAILURE(status)) { |
| 274 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 277 | /* Execute the _GTS method */ |
| 278 | |
| 279 | arg_list.count = 1; |
| 280 | arg_list.pointer = &arg; |
| 281 | arg.type = ACPI_TYPE_INTEGER; |
| 282 | arg.integer.value = sleep_state; |
| 283 | |
| 284 | status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL); |
| 285 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 286 | return_ACPI_STATUS(status); |
| 287 | } |
| 288 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | /* Get current value of PM1A control */ |
| 290 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 291 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 292 | if (ACPI_FAILURE(status)) { |
| 293 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 295 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 296 | "Entering sleep state [S%d]\n", sleep_state)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | |
| 298 | /* Clear SLP_EN and SLP_TYP fields */ |
| 299 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 300 | PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 301 | sleep_enable_reg_info->access_bit_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | PM1Bcontrol = PM1Acontrol; |
| 303 | |
| 304 | /* Insert SLP_TYP bits */ |
| 305 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 306 | PM1Acontrol |= |
| 307 | (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); |
| 308 | PM1Bcontrol |= |
| 309 | (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
| 311 | /* |
| 312 | * We split the writes of SLP_TYP and SLP_EN to workaround |
| 313 | * poorly implemented hardware. |
| 314 | */ |
| 315 | |
| 316 | /* Write #1: fill in SLP_TYP data */ |
| 317 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 318 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | PM1Acontrol); |
| 320 | if (ACPI_FAILURE(status)) { |
| 321 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 324 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 325 | PM1Bcontrol); |
| 326 | if (ACPI_FAILURE(status)) { |
| 327 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | /* Insert SLP_ENABLE bit */ |
| 331 | |
| 332 | PM1Acontrol |= sleep_enable_reg_info->access_bit_mask; |
| 333 | PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask; |
| 334 | |
| 335 | /* Write #2: SLP_TYP + SLP_EN */ |
| 336 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 337 | ACPI_FLUSH_CPU_CACHE(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 339 | status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | PM1Acontrol); |
| 341 | if (ACPI_FAILURE(status)) { |
| 342 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 345 | status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 346 | PM1Bcontrol); |
| 347 | if (ACPI_FAILURE(status)) { |
| 348 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | if (sleep_state > ACPI_STATE_S3) { |
| 352 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 353 | * We wanted to sleep > S3, but it didn't happen (by virtue of the |
| 354 | * fact that we are still executing!) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 356 | * Wait ten seconds, then try again. This is to get S4/S5 to work on |
| 357 | * all machines. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * |
| 359 | * We wait so long to allow chipsets that poll this reg very slowly to |
| 360 | * still read the right value. Ideally, this block would go |
| 361 | * away entirely. |
| 362 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | acpi_os_stall(10000000); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 365 | status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 366 | sleep_enable_reg_info-> |
| 367 | access_bit_mask); |
| 368 | if (ACPI_FAILURE(status)) { |
| 369 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
| 373 | /* Wait until we enter sleep state */ |
| 374 | |
| 375 | do { |
Alexey Starikovskiy | 2d571b3 | 2007-09-30 22:39:42 +0400 | [diff] [blame] | 376 | status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS, |
| 377 | &in_value); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | if (ACPI_FAILURE(status)) { |
| 379 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /* Spin until we wake */ |
| 383 | |
| 384 | } while (!in_value); |
| 385 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 386 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 389 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 391 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | * |
| 393 | * FUNCTION: acpi_enter_sleep_state_s4bios |
| 394 | * |
| 395 | * PARAMETERS: None |
| 396 | * |
| 397 | * RETURN: Status |
| 398 | * |
| 399 | * DESCRIPTION: Perform a S4 bios request. |
| 400 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
| 401 | * |
| 402 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 403 | acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 405 | u32 in_value; |
| 406 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 408 | ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 410 | status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | if (ACPI_FAILURE(status)) { |
| 412 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | } |
| 414 | |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 415 | status = acpi_hw_clear_acpi_status(); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 416 | if (ACPI_FAILURE(status)) { |
| 417 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | /* |
| 421 | * 1) Disable/Clear all GPEs |
| 422 | * 2) Enable all wakeup GPEs |
| 423 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 424 | status = acpi_hw_disable_all_gpes(); |
| 425 | if (ACPI_FAILURE(status)) { |
| 426 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | } |
| 428 | acpi_gbl_system_awake_and_running = FALSE; |
| 429 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 430 | status = acpi_hw_enable_all_wakeup_gpes(); |
| 431 | if (ACPI_FAILURE(status)) { |
| 432 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 435 | ACPI_FLUSH_CPU_CACHE(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 437 | status = acpi_os_write_port(acpi_gbl_FADT.smi_command, |
| 438 | (u32) acpi_gbl_FADT.S4bios_request, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
| 440 | do { |
| 441 | acpi_os_stall(1000); |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 442 | status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 443 | if (ACPI_FAILURE(status)) { |
| 444 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | } |
| 446 | } while (!in_value); |
| 447 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 448 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 451 | ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 453 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | * |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 455 | * FUNCTION: acpi_leave_sleep_state_prep |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | * |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 457 | * PARAMETERS: sleep_state - Which sleep state we are exiting |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | * |
| 459 | * RETURN: Status |
| 460 | * |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 461 | * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a |
| 462 | * sleep. |
| 463 | * Called with interrupts DISABLED. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | * |
| 465 | ******************************************************************************/ |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 466 | acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 468 | struct acpi_object_list arg_list; |
| 469 | union acpi_object arg; |
| 470 | acpi_status status; |
| 471 | struct acpi_bit_register_info *sleep_type_reg_info; |
| 472 | struct acpi_bit_register_info *sleep_enable_reg_info; |
| 473 | u32 PM1Acontrol; |
| 474 | u32 PM1Bcontrol; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 476 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | /* |
| 479 | * Set SLP_TYPE and SLP_EN to state S0. |
| 480 | * This is unclear from the ACPI Spec, but it is required |
| 481 | * by some machines. |
| 482 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 483 | status = acpi_get_sleep_type_data(ACPI_STATE_S0, |
| 484 | &acpi_gbl_sleep_type_a, |
| 485 | &acpi_gbl_sleep_type_b); |
| 486 | if (ACPI_SUCCESS(status)) { |
| 487 | sleep_type_reg_info = |
| 488 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A); |
| 489 | sleep_enable_reg_info = |
| 490 | acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
| 492 | /* Get current value of PM1A control */ |
| 493 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 494 | status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 495 | &PM1Acontrol); |
| 496 | if (ACPI_SUCCESS(status)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 497 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | /* Clear SLP_EN and SLP_TYP fields */ |
| 499 | |
| 500 | PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 501 | sleep_enable_reg_info-> |
| 502 | access_bit_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | PM1Bcontrol = PM1Acontrol; |
| 504 | |
| 505 | /* Insert SLP_TYP bits */ |
| 506 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 507 | PM1Acontrol |= |
| 508 | (acpi_gbl_sleep_type_a << sleep_type_reg_info-> |
| 509 | bit_position); |
| 510 | PM1Bcontrol |= |
| 511 | (acpi_gbl_sleep_type_b << sleep_type_reg_info-> |
| 512 | bit_position); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
| 514 | /* Just ignore any errors */ |
| 515 | |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 516 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 517 | PM1Acontrol); |
Alexey Starikovskiy | d30dc9ab | 2007-09-30 22:39:36 +0400 | [diff] [blame] | 518 | (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 519 | PM1Bcontrol); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | } |
| 521 | } |
| 522 | |
Rafael J. Wysocki | c95d47a | 2008-01-08 00:05:21 +0100 | [diff] [blame] | 523 | /* Execute the _BFS method */ |
| 524 | |
| 525 | arg_list.count = 1; |
| 526 | arg_list.pointer = &arg; |
| 527 | arg.type = ACPI_TYPE_INTEGER; |
| 528 | arg.integer.value = sleep_state; |
| 529 | |
| 530 | status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL); |
| 531 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 532 | ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); |
| 533 | } |
| 534 | |
| 535 | return_ACPI_STATUS(status); |
| 536 | } |
| 537 | |
| 538 | /******************************************************************************* |
| 539 | * |
| 540 | * FUNCTION: acpi_leave_sleep_state |
| 541 | * |
| 542 | * PARAMETERS: sleep_state - Which sleep state we just exited |
| 543 | * |
| 544 | * RETURN: Status |
| 545 | * |
| 546 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
| 547 | * Called with interrupts ENABLED. |
| 548 | * |
| 549 | ******************************************************************************/ |
| 550 | acpi_status acpi_leave_sleep_state(u8 sleep_state) |
| 551 | { |
| 552 | struct acpi_object_list arg_list; |
| 553 | union acpi_object arg; |
| 554 | acpi_status status; |
| 555 | |
| 556 | ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); |
| 557 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ |
| 559 | |
| 560 | acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; |
| 561 | |
| 562 | /* Setup parameter object */ |
| 563 | |
| 564 | arg_list.count = 1; |
| 565 | arg_list.pointer = &arg; |
| 566 | arg.type = ACPI_TYPE_INTEGER; |
| 567 | |
| 568 | /* Ignore any errors from these methods */ |
| 569 | |
| 570 | arg.integer.value = ACPI_SST_WAKING; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 571 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); |
| 572 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 573 | ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | /* |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 577 | * GPEs must be enabled before _WAK is called as GPEs |
| 578 | * might get fired there |
| 579 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | * Restore the GPEs: |
| 581 | * 1) Disable/Clear all GPEs |
| 582 | * 2) Enable all runtime GPEs |
| 583 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 584 | status = acpi_hw_disable_all_gpes(); |
| 585 | if (ACPI_FAILURE(status)) { |
| 586 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 588 | status = acpi_hw_enable_all_runtime_gpes(); |
| 589 | if (ACPI_FAILURE(status)) { |
| 590 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Rafael J. Wysocki | 314ccd6 | 2008-02-13 00:32:16 +0100 | [diff] [blame] | 593 | arg.integer.value = sleep_state; |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 594 | status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); |
| 595 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
| 596 | ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); |
| 597 | } |
| 598 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ |
| 599 | |
Matthew Garrett | a68823e | 2008-08-06 19:12:04 +0100 | [diff] [blame] | 600 | /* |
| 601 | * Some BIOSes assume that WAK_STS will be cleared on resume and use |
| 602 | * it to determine whether the system is rebooting or resuming. Clear |
| 603 | * it for compatibility. |
| 604 | */ |
| 605 | acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1); |
| 606 | |
Thomas Renninger | 79d2dfa | 2007-08-24 01:24:47 -0400 | [diff] [blame] | 607 | acpi_gbl_system_awake_and_running = TRUE; |
| 608 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | /* Enable power button */ |
| 610 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | (void) |
| 612 | acpi_set_register(acpi_gbl_fixed_event_info |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 613 | [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 614 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 615 | (void) |
| 616 | acpi_set_register(acpi_gbl_fixed_event_info |
Bob Moore | d8c71b6 | 2007-02-02 19:48:21 +0300 | [diff] [blame] | 617 | [ACPI_EVENT_POWER_BUTTON].status_register_id, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
| 619 | arg.integer.value = ACPI_SST_WORKING; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); |
| 621 | if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 622 | ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 625 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | } |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 627 | |
| 628 | ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) |