blob: 0ed85cac32314f956de3092f7087e3ab011b5ba7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
Bob Moore70958572012-02-14 18:47:42 +08003 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * original/legacy sleep/PM registers.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 *****************************************************************************/
7
8/*
Bob Moore77848132012-01-12 13:27:23 +08009 * Copyright (C) 2000 - 2012, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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 Torvalds1da177e2005-04-16 15:20:36 -070045#include <acpi/acpi.h>
Tang Liang09f98a82011-12-09 10:05:54 +080046#include <linux/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050047#include "accommon.h"
Paul Gortmakercc4b8592011-07-01 14:30:49 -040048#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#define _COMPONENT ACPI_HARDWARE
Len Brown4be44fc2005-08-05 00:44:28 -040051ACPI_MODULE_NAME("hwsleep")
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Bob Moore70958572012-02-14 18:47:42 +080053#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
Bob Moore2feec472012-02-14 15:00:53 +080054/*******************************************************************************
55 *
56 * FUNCTION: acpi_hw_legacy_sleep
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 *
58 * PARAMETERS: sleep_state - Which sleep state to enter
Lin Ming8a73b172012-03-21 10:01:49 +080059 * Flags - ACPI_EXECUTE_GTS to run optional method
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
61 * RETURN: Status
62 *
Bob Moore2feec472012-02-14 15:00:53 +080063 * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
65 *
66 ******************************************************************************/
Lin Ming8a73b172012-03-21 10:01:49 +080067acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Len Brown4be44fc2005-08-05 00:44:28 -040069 struct acpi_bit_register_info *sleep_type_reg_info;
70 struct acpi_bit_register_info *sleep_enable_reg_info;
Bob Moore2feec472012-02-14 15:00:53 +080071 u32 pm1a_control;
72 u32 pm1b_control;
Len Brown4be44fc2005-08-05 00:44:28 -040073 u32 in_value;
74 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Bob Moore2feec472012-02-14 15:00:53 +080076 ACPI_FUNCTION_TRACE(hw_legacy_sleep);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Len Brown4be44fc2005-08-05 00:44:28 -040078 sleep_type_reg_info =
Bob Moore82d79b82009-02-18 14:31:05 +080079 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
Len Brown4be44fc2005-08-05 00:44:28 -040080 sleep_enable_reg_info =
81 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 /* Clear wake status */
84
Bob Moore768aaaf2009-03-06 09:49:25 +080085 status =
86 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
Len Brown4be44fc2005-08-05 00:44:28 -040087 if (ACPI_FAILURE(status)) {
88 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90
91 /* Clear all fixed and general purpose status bits */
92
Bob Moored8c71b62007-02-02 19:48:21 +030093 status = acpi_hw_clear_acpi_status();
Len Brown4be44fc2005-08-05 00:44:28 -040094 if (ACPI_FAILURE(status)) {
95 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 }
97
Bob Moore2feec472012-02-14 15:00:53 +080098 if (sleep_state != ACPI_STATE_S5) {
99 /*
100 * Disable BM arbitration. This feature is contained within an
101 * optional register (PM2 Control), so ignore a BAD_ADDRESS
102 * exception.
103 */
104 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1);
105 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
106 return_ACPI_STATUS(status);
107 }
108 }
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 /*
Pavel Machek23b168d2008-02-05 19:27:12 +0100111 * 1) Disable/Clear all GPEs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 * 2) Enable all wakeup GPEs
113 */
Alexey Starikovskiy1d999672007-03-12 14:49:26 -0400114 status = acpi_hw_disable_all_gpes();
115 if (ACPI_FAILURE(status)) {
116 return_ACPI_STATUS(status);
117 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 acpi_gbl_system_awake_and_running = FALSE;
119
Len Brown4be44fc2005-08-05 00:44:28 -0400120 status = acpi_hw_enable_all_wakeup_gpes();
121 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 }
124
Lin Ming8a73b172012-03-21 10:01:49 +0800125 /* Optionally execute _GTS (Going To Sleep) */
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100126
Lin Ming8a73b172012-03-21 10:01:49 +0800127 if (flags & ACPI_EXECUTE_GTS) {
128 acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state);
129 }
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 /* Get current value of PM1A control */
132
Bob Moore32c9ef92009-02-18 14:36:05 +0800133 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
134 &pm1a_control);
Len Brown4be44fc2005-08-05 00:44:28 -0400135 if (ACPI_FAILURE(status)) {
136 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 }
Len Brown4be44fc2005-08-05 00:44:28 -0400138 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
Bob Mooreb27d6592010-05-26 11:47:13 +0800139 "Entering sleep state [S%u]\n", sleep_state));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Bob Moore32c9ef92009-02-18 14:36:05 +0800141 /* Clear the SLP_EN and SLP_TYP fields */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Bob Moore32c9ef92009-02-18 14:36:05 +0800143 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
144 sleep_enable_reg_info->access_bit_mask);
145 pm1b_control = pm1a_control;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Bob Moore32c9ef92009-02-18 14:36:05 +0800147 /* Insert the SLP_TYP bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Bob Moore32c9ef92009-02-18 14:36:05 +0800149 pm1a_control |=
Len Brown4be44fc2005-08-05 00:44:28 -0400150 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
Bob Moore32c9ef92009-02-18 14:36:05 +0800151 pm1b_control |=
Len Brown4be44fc2005-08-05 00:44:28 -0400152 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154 /*
155 * We split the writes of SLP_TYP and SLP_EN to workaround
156 * poorly implemented hardware.
157 */
158
Bob Moore32c9ef92009-02-18 14:36:05 +0800159 /* Write #1: write the SLP_TYP data to the PM1 Control registers */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Bob Moore32c9ef92009-02-18 14:36:05 +0800161 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
Len Brown4be44fc2005-08-05 00:44:28 -0400162 if (ACPI_FAILURE(status)) {
163 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 }
165
Bob Moore32c9ef92009-02-18 14:36:05 +0800166 /* Insert the sleep enable (SLP_EN) bit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Bob Moore32c9ef92009-02-18 14:36:05 +0800168 pm1a_control |= sleep_enable_reg_info->access_bit_mask;
169 pm1b_control |= sleep_enable_reg_info->access_bit_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Bob Moore32c9ef92009-02-18 14:36:05 +0800171 /* Flush caches, as per ACPI specification */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Len Brown4be44fc2005-08-05 00:44:28 -0400173 ACPI_FLUSH_CPU_CACHE();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Tang Liang09f98a82011-12-09 10:05:54 +0800175 status = acpi_os_prepare_sleep(sleep_state, pm1a_control,
176 pm1b_control);
177 if (ACPI_SKIP(status))
178 return_ACPI_STATUS(AE_OK);
179 if (ACPI_FAILURE(status))
180 return_ACPI_STATUS(status);
Bob Moore32c9ef92009-02-18 14:36:05 +0800181 /* Write #2: Write both SLP_TYP + SLP_EN */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Bob Moore32c9ef92009-02-18 14:36:05 +0800183 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
Len Brown4be44fc2005-08-05 00:44:28 -0400184 if (ACPI_FAILURE(status)) {
185 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 }
187
188 if (sleep_state > ACPI_STATE_S3) {
189 /*
Robert Moore44f6c012005-04-18 22:49:35 -0400190 * We wanted to sleep > S3, but it didn't happen (by virtue of the
191 * fact that we are still executing!)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 *
Robert Moore44f6c012005-04-18 22:49:35 -0400193 * Wait ten seconds, then try again. This is to get S4/S5 to work on
194 * all machines.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 *
Bob Moored4913dc2009-03-06 10:05:18 +0800196 * We wait so long to allow chipsets that poll this reg very slowly
197 * to still read the right value. Ideally, this block would go
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 * away entirely.
199 */
Len Brown4be44fc2005-08-05 00:44:28 -0400200 acpi_os_stall(10000000);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400202 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
Len Brown4be44fc2005-08-05 00:44:28 -0400203 sleep_enable_reg_info->
204 access_bit_mask);
205 if (ACPI_FAILURE(status)) {
206 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 }
208 }
209
Bob Moore2feec472012-02-14 15:00:53 +0800210 /* Wait for transition back to Working State */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
212 do {
Bob Moore50ffba12009-02-23 15:02:07 +0800213 status =
214 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
Len Brown4be44fc2005-08-05 00:44:28 -0400215 if (ACPI_FAILURE(status)) {
216 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 }
Bob Moore2feec472012-02-14 15:00:53 +0800218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 } while (!in_value);
220
Len Brown4be44fc2005-08-05 00:44:28 -0400221 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Robert Moore44f6c012005-04-18 22:49:35 -0400224/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 *
Bob Moore2feec472012-02-14 15:00:53 +0800226 * FUNCTION: acpi_hw_legacy_wake_prep
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 *
Bob Moore2feec472012-02-14 15:00:53 +0800228 * PARAMETERS: sleep_state - Which sleep state we just exited
Lin Ming8a73b172012-03-21 10:01:49 +0800229 * Flags - ACPI_EXECUTE_BFS to run optional method
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 *
231 * RETURN: Status
232 *
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100233 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
234 * sleep.
Bob Moore2feec472012-02-14 15:00:53 +0800235 * Called with interrupts ENABLED.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 *
237 ******************************************************************************/
Bob Moore2feec472012-02-14 15:00:53 +0800238
Lin Ming8a73b172012-03-21 10:01:49 +0800239acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240{
Len Brown4be44fc2005-08-05 00:44:28 -0400241 acpi_status status;
242 struct acpi_bit_register_info *sleep_type_reg_info;
243 struct acpi_bit_register_info *sleep_enable_reg_info;
Bob Moore32c9ef92009-02-18 14:36:05 +0800244 u32 pm1a_control;
245 u32 pm1b_control;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
Bob Moore2feec472012-02-14 15:00:53 +0800247 ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
249 /*
250 * Set SLP_TYPE and SLP_EN to state S0.
251 * This is unclear from the ACPI Spec, but it is required
252 * by some machines.
253 */
Len Brown4be44fc2005-08-05 00:44:28 -0400254 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
255 &acpi_gbl_sleep_type_a,
256 &acpi_gbl_sleep_type_b);
257 if (ACPI_SUCCESS(status)) {
258 sleep_type_reg_info =
Bob Moore82d79b82009-02-18 14:31:05 +0800259 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
Len Brown4be44fc2005-08-05 00:44:28 -0400260 sleep_enable_reg_info =
261 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
263 /* Get current value of PM1A control */
264
Alexey Starikovskiyd30dc9ab2007-09-30 22:39:36 +0400265 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
Bob Moore32c9ef92009-02-18 14:36:05 +0800266 &pm1a_control);
Len Brown4be44fc2005-08-05 00:44:28 -0400267 if (ACPI_SUCCESS(status)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400268
Bob Moore32c9ef92009-02-18 14:36:05 +0800269 /* Clear the SLP_EN and SLP_TYP fields */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Bob Moore32c9ef92009-02-18 14:36:05 +0800271 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
272 sleep_enable_reg_info->
273 access_bit_mask);
274 pm1b_control = pm1a_control;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Bob Moore32c9ef92009-02-18 14:36:05 +0800276 /* Insert the SLP_TYP bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Bob Moored4913dc2009-03-06 10:05:18 +0800278 pm1a_control |= (acpi_gbl_sleep_type_a <<
279 sleep_type_reg_info->bit_position);
280 pm1b_control |= (acpi_gbl_sleep_type_b <<
281 sleep_type_reg_info->bit_position);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Bob Moore32c9ef92009-02-18 14:36:05 +0800283 /* Write the control registers and ignore any errors */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Bob Moore32c9ef92009-02-18 14:36:05 +0800285 (void)acpi_hw_write_pm1_control(pm1a_control,
286 pm1b_control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 }
288 }
289
Lin Ming8a73b172012-03-21 10:01:49 +0800290 /* Optionally execute _BFS (Back From Sleep) */
291
292 if (flags & ACPI_EXECUTE_BFS) {
293 acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state);
294 }
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100295 return_ACPI_STATUS(status);
296}
297
298/*******************************************************************************
299 *
Bob Moore2feec472012-02-14 15:00:53 +0800300 * FUNCTION: acpi_hw_legacy_wake
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100301 *
302 * PARAMETERS: sleep_state - Which sleep state we just exited
Lin Ming8a73b172012-03-21 10:01:49 +0800303 * Flags - Reserved, set to zero
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100304 *
305 * RETURN: Status
306 *
307 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
308 * Called with interrupts ENABLED.
309 *
310 ******************************************************************************/
Bob Moore2feec472012-02-14 15:00:53 +0800311
Lin Ming8a73b172012-03-21 10:01:49 +0800312acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags)
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100313{
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100314 acpi_status status;
315
Bob Moore2feec472012-02-14 15:00:53 +0800316 ACPI_FUNCTION_TRACE(hw_legacy_wake);
Rafael J. Wysockic95d47a2008-01-08 00:05:21 +0100317
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
319
320 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
Bob Moore4efeeec2012-03-21 09:42:45 +0800321 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 /*
Thomas Renninger79d2dfa2007-08-24 01:24:47 -0400324 * GPEs must be enabled before _WAK is called as GPEs
325 * might get fired there
326 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 * Restore the GPEs:
328 * 1) Disable/Clear all GPEs
329 * 2) Enable all runtime GPEs
330 */
Len Brown4be44fc2005-08-05 00:44:28 -0400331 status = acpi_hw_disable_all_gpes();
332 if (ACPI_FAILURE(status)) {
333 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 }
Bob Moore2feec472012-02-14 15:00:53 +0800335
Len Brown4be44fc2005-08-05 00:44:28 -0400336 status = acpi_hw_enable_all_runtime_gpes();
337 if (ACPI_FAILURE(status)) {
338 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 }
340
Bob Moore2feec472012-02-14 15:00:53 +0800341 /*
342 * Now we can execute _WAK, etc. Some machines require that the GPEs
343 * are enabled before the wake methods are executed.
344 */
Bob Moore4efeeec2012-03-21 09:42:45 +0800345 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
Thomas Renninger79d2dfa2007-08-24 01:24:47 -0400346
Matthew Garretta68823e2008-08-06 19:12:04 +0100347 /*
Bob Moore2feec472012-02-14 15:00:53 +0800348 * Some BIOS code assumes that WAK_STS will be cleared on resume
349 * and use it to determine whether the system is rebooting or
350 * resuming. Clear WAK_STS for compatibility.
Matthew Garretta68823e2008-08-06 19:12:04 +0100351 */
Bob Moore50ffba12009-02-23 15:02:07 +0800352 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
Thomas Renninger79d2dfa2007-08-24 01:24:47 -0400353 acpi_gbl_system_awake_and_running = TRUE;
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 /* Enable power button */
356
Len Brown4be44fc2005-08-05 00:44:28 -0400357 (void)
Bob Moore50ffba12009-02-23 15:02:07 +0800358 acpi_write_bit_register(acpi_gbl_fixed_event_info
Bob Moore2feec472012-02-14 15:00:53 +0800359 [ACPI_EVENT_POWER_BUTTON].
360 enable_register_id, ACPI_ENABLE_EVENT);
Robert Moore44f6c012005-04-18 22:49:35 -0400361
Len Brown4be44fc2005-08-05 00:44:28 -0400362 (void)
Bob Moore50ffba12009-02-23 15:02:07 +0800363 acpi_write_bit_register(acpi_gbl_fixed_event_info
Bob Moore2feec472012-02-14 15:00:53 +0800364 [ACPI_EVENT_POWER_BUTTON].
365 status_register_id, ACPI_CLEAR_STATUS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
Bob Moore2feec472012-02-14 15:00:53 +0800367 /*
368 * Enable BM arbitration. This feature is contained within an
369 * optional register (PM2 Control), so ignore a BAD_ADDRESS
370 * exception.
371 */
372 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0);
373 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
374 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 }
376
Bob Moore4efeeec2012-03-21 09:42:45 +0800377 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
Len Brown4be44fc2005-08-05 00:44:28 -0400378 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379}
Bob Moore83135242006-10-03 00:00:00 -0400380
Bob Moore33620c52012-02-14 18:14:27 +0800381#endif /* !ACPI_REDUCED_HARDWARE */