Linux Audio

Check our new training course

Loading...
v3.5.6
 
  1/******************************************************************************
  2 *
  3 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
  4 *                   original/legacy sleep/PM registers.
  5 *
 
 
  6 *****************************************************************************/
  7
  8/*
  9 * Copyright (C) 2000 - 2012, Intel Corp.
 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
 45#include <acpi/acpi.h>
 46#include <linux/acpi.h>
 47#include "accommon.h"
 48#include <linux/module.h>
 49
 50#define _COMPONENT          ACPI_HARDWARE
 51ACPI_MODULE_NAME("hwsleep")
 52
 53#if (!ACPI_REDUCED_HARDWARE)	/* Entire module */
 54/*******************************************************************************
 55 *
 56 * FUNCTION:    acpi_hw_legacy_sleep
 57 *
 58 * PARAMETERS:  sleep_state         - Which sleep state to enter
 59 *              Flags               - ACPI_EXECUTE_GTS to run optional method
 60 *
 61 * RETURN:      Status
 62 *
 63 * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
 64 *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
 65 *
 66 ******************************************************************************/
 67acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags)
 68{
 69	struct acpi_bit_register_info *sleep_type_reg_info;
 70	struct acpi_bit_register_info *sleep_enable_reg_info;
 71	u32 pm1a_control;
 72	u32 pm1b_control;
 73	u32 in_value;
 74	acpi_status status;
 75
 76	ACPI_FUNCTION_TRACE(hw_legacy_sleep);
 77
 78	sleep_type_reg_info =
 79	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
 80	sleep_enable_reg_info =
 81	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
 82
 83	/* Clear wake status */
 84
 85	status =
 86	    acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
 87	if (ACPI_FAILURE(status)) {
 88		return_ACPI_STATUS(status);
 89	}
 90
 91	/* Clear all fixed and general purpose status bits */
 92
 93	status = acpi_hw_clear_acpi_status();
 94	if (ACPI_FAILURE(status)) {
 95		return_ACPI_STATUS(status);
 96	}
 97
 98	/*
 99	 * 1) Disable/Clear all GPEs
100	 * 2) Enable all wakeup GPEs
101	 */
102	status = acpi_hw_disable_all_gpes();
103	if (ACPI_FAILURE(status)) {
104		return_ACPI_STATUS(status);
105	}
106	acpi_gbl_system_awake_and_running = FALSE;
107
108	status = acpi_hw_enable_all_wakeup_gpes();
109	if (ACPI_FAILURE(status)) {
110		return_ACPI_STATUS(status);
111	}
112
113	/* Optionally execute _GTS (Going To Sleep) */
114
115	if (flags & ACPI_EXECUTE_GTS) {
116		acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state);
117	}
118
119	/* Get current value of PM1A control */
120
121	status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
122				       &pm1a_control);
123	if (ACPI_FAILURE(status)) {
124		return_ACPI_STATUS(status);
125	}
126	ACPI_DEBUG_PRINT((ACPI_DB_INIT,
127			  "Entering sleep state [S%u]\n", sleep_state));
128
129	/* Clear the SLP_EN and SLP_TYP fields */
130
131	pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
132			  sleep_enable_reg_info->access_bit_mask);
133	pm1b_control = pm1a_control;
134
135	/* Insert the SLP_TYP bits */
136
137	pm1a_control |=
138	    (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
139	pm1b_control |=
140	    (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
141
142	/*
143	 * We split the writes of SLP_TYP and SLP_EN to workaround
144	 * poorly implemented hardware.
145	 */
146
147	/* Write #1: write the SLP_TYP data to the PM1 Control registers */
148
149	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
150	if (ACPI_FAILURE(status)) {
151		return_ACPI_STATUS(status);
152	}
153
154	/* Insert the sleep enable (SLP_EN) bit */
155
156	pm1a_control |= sleep_enable_reg_info->access_bit_mask;
157	pm1b_control |= sleep_enable_reg_info->access_bit_mask;
158
159	/* Flush caches, as per ACPI specification */
160
161	ACPI_FLUSH_CPU_CACHE();
162
163	status = acpi_os_prepare_sleep(sleep_state, pm1a_control,
164				       pm1b_control);
165	if (ACPI_SKIP(status))
166		return_ACPI_STATUS(AE_OK);
167	if (ACPI_FAILURE(status))
 
168		return_ACPI_STATUS(status);
 
 
169	/* Write #2: Write both SLP_TYP + SLP_EN */
170
171	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
172	if (ACPI_FAILURE(status)) {
173		return_ACPI_STATUS(status);
174	}
175
176	if (sleep_state > ACPI_STATE_S3) {
177		/*
178		 * We wanted to sleep > S3, but it didn't happen (by virtue of the
179		 * fact that we are still executing!)
180		 *
181		 * Wait ten seconds, then try again. This is to get S4/S5 to work on
182		 * all machines.
183		 *
184		 * We wait so long to allow chipsets that poll this reg very slowly
185		 * to still read the right value. Ideally, this block would go
186		 * away entirely.
187		 */
188		acpi_os_stall(10000000);
189
190		status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
191						sleep_enable_reg_info->
192						access_bit_mask);
193		if (ACPI_FAILURE(status)) {
194			return_ACPI_STATUS(status);
195		}
196	}
197
198	/* Wait for transition back to Working State */
199
200	do {
201		status =
202		    acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
203		if (ACPI_FAILURE(status)) {
204			return_ACPI_STATUS(status);
205		}
206
207	} while (!in_value);
208
209	return_ACPI_STATUS(AE_OK);
210}
211
212/*******************************************************************************
213 *
214 * FUNCTION:    acpi_hw_legacy_wake_prep
215 *
216 * PARAMETERS:  sleep_state         - Which sleep state we just exited
217 *              Flags               - ACPI_EXECUTE_BFS to run optional method
218 *
219 * RETURN:      Status
220 *
221 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
222 *              sleep.
223 *              Called with interrupts ENABLED.
224 *
225 ******************************************************************************/
226
227acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags)
228{
229	acpi_status status;
230	struct acpi_bit_register_info *sleep_type_reg_info;
231	struct acpi_bit_register_info *sleep_enable_reg_info;
232	u32 pm1a_control;
233	u32 pm1b_control;
234
235	ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
236
237	/*
238	 * Set SLP_TYPE and SLP_EN to state S0.
239	 * This is unclear from the ACPI Spec, but it is required
240	 * by some machines.
241	 */
242	status = acpi_get_sleep_type_data(ACPI_STATE_S0,
243					  &acpi_gbl_sleep_type_a,
244					  &acpi_gbl_sleep_type_b);
245	if (ACPI_SUCCESS(status)) {
246		sleep_type_reg_info =
247		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
248		sleep_enable_reg_info =
249		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
250
251		/* Get current value of PM1A control */
252
253		status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
254					       &pm1a_control);
255		if (ACPI_SUCCESS(status)) {
256
257			/* Clear the SLP_EN and SLP_TYP fields */
258
259			pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
260					  sleep_enable_reg_info->
261					  access_bit_mask);
262			pm1b_control = pm1a_control;
263
264			/* Insert the SLP_TYP bits */
265
266			pm1a_control |= (acpi_gbl_sleep_type_a <<
267					 sleep_type_reg_info->bit_position);
268			pm1b_control |= (acpi_gbl_sleep_type_b <<
269					 sleep_type_reg_info->bit_position);
270
271			/* Write the control registers and ignore any errors */
272
273			(void)acpi_hw_write_pm1_control(pm1a_control,
274							pm1b_control);
275		}
276	}
277
278	/* Optionally execute _BFS (Back From Sleep) */
279
280	if (flags & ACPI_EXECUTE_BFS) {
281		acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state);
282	}
283	return_ACPI_STATUS(status);
284}
285
286/*******************************************************************************
287 *
288 * FUNCTION:    acpi_hw_legacy_wake
289 *
290 * PARAMETERS:  sleep_state         - Which sleep state we just exited
291 *              Flags               - Reserved, set to zero
292 *
293 * RETURN:      Status
294 *
295 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
296 *              Called with interrupts ENABLED.
297 *
298 ******************************************************************************/
299
300acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags)
301{
302	acpi_status status;
303
304	ACPI_FUNCTION_TRACE(hw_legacy_wake);
305
306	/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
307
308	acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
309	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
310
311	/*
312	 * GPEs must be enabled before _WAK is called as GPEs
313	 * might get fired there
314	 *
315	 * Restore the GPEs:
316	 * 1) Disable/Clear all GPEs
317	 * 2) Enable all runtime GPEs
318	 */
319	status = acpi_hw_disable_all_gpes();
320	if (ACPI_FAILURE(status)) {
321		return_ACPI_STATUS(status);
322	}
323
324	status = acpi_hw_enable_all_runtime_gpes();
325	if (ACPI_FAILURE(status)) {
326		return_ACPI_STATUS(status);
327	}
328
329	/*
330	 * Now we can execute _WAK, etc. Some machines require that the GPEs
331	 * are enabled before the wake methods are executed.
332	 */
333	acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
334
335	/*
336	 * Some BIOS code assumes that WAK_STS will be cleared on resume
337	 * and use it to determine whether the system is rebooting or
338	 * resuming. Clear WAK_STS for compatibility.
339	 */
340	acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
 
341	acpi_gbl_system_awake_and_running = TRUE;
342
343	/* Enable power button */
344
345	(void)
346	    acpi_write_bit_register(acpi_gbl_fixed_event_info
347				    [ACPI_EVENT_POWER_BUTTON].
348				    enable_register_id, ACPI_ENABLE_EVENT);
349
350	(void)
351	    acpi_write_bit_register(acpi_gbl_fixed_event_info
352				    [ACPI_EVENT_POWER_BUTTON].
353				    status_register_id, ACPI_CLEAR_STATUS);
354
355	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
356	return_ACPI_STATUS(status);
357}
358
359#endif				/* !ACPI_REDUCED_HARDWARE */
v4.17
  1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2/******************************************************************************
  3 *
  4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
  5 *                   original/legacy sleep/PM registers.
  6 *
  7 * Copyright (C) 2000 - 2018, Intel Corp.
  8 *
  9 *****************************************************************************/
 10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 11#include <acpi/acpi.h>
 
 12#include "accommon.h"
 
 13
 14#define _COMPONENT          ACPI_HARDWARE
 15ACPI_MODULE_NAME("hwsleep")
 16
 17#if (!ACPI_REDUCED_HARDWARE)	/* Entire module */
 18/*******************************************************************************
 19 *
 20 * FUNCTION:    acpi_hw_legacy_sleep
 21 *
 22 * PARAMETERS:  sleep_state         - Which sleep state to enter
 
 23 *
 24 * RETURN:      Status
 25 *
 26 * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
 27 *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
 28 *
 29 ******************************************************************************/
 30acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
 31{
 32	struct acpi_bit_register_info *sleep_type_reg_info;
 33	struct acpi_bit_register_info *sleep_enable_reg_info;
 34	u32 pm1a_control;
 35	u32 pm1b_control;
 36	u32 in_value;
 37	acpi_status status;
 38
 39	ACPI_FUNCTION_TRACE(hw_legacy_sleep);
 40
 41	sleep_type_reg_info =
 42	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
 43	sleep_enable_reg_info =
 44	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
 45
 46	/* Clear wake status */
 47
 48	status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
 49					 ACPI_CLEAR_STATUS);
 
 
 
 
 
 
 
 50	if (ACPI_FAILURE(status)) {
 51		return_ACPI_STATUS(status);
 52	}
 53
 54	/*
 55	 * 1) Disable all GPEs
 56	 * 2) Enable all wakeup GPEs
 57	 */
 58	status = acpi_hw_disable_all_gpes();
 59	if (ACPI_FAILURE(status)) {
 60		return_ACPI_STATUS(status);
 61	}
 62	acpi_gbl_system_awake_and_running = FALSE;
 63
 64	status = acpi_hw_enable_all_wakeup_gpes();
 65	if (ACPI_FAILURE(status)) {
 66		return_ACPI_STATUS(status);
 67	}
 68
 
 
 
 
 
 
 69	/* Get current value of PM1A control */
 70
 71	status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
 72				       &pm1a_control);
 73	if (ACPI_FAILURE(status)) {
 74		return_ACPI_STATUS(status);
 75	}
 76	ACPI_DEBUG_PRINT((ACPI_DB_INIT,
 77			  "Entering sleep state [S%u]\n", sleep_state));
 78
 79	/* Clear the SLP_EN and SLP_TYP fields */
 80
 81	pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
 82			  sleep_enable_reg_info->access_bit_mask);
 83	pm1b_control = pm1a_control;
 84
 85	/* Insert the SLP_TYP bits */
 86
 87	pm1a_control |=
 88	    (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
 89	pm1b_control |=
 90	    (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
 91
 92	/*
 93	 * We split the writes of SLP_TYP and SLP_EN to workaround
 94	 * poorly implemented hardware.
 95	 */
 96
 97	/* Write #1: write the SLP_TYP data to the PM1 Control registers */
 98
 99	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
100	if (ACPI_FAILURE(status)) {
101		return_ACPI_STATUS(status);
102	}
103
104	/* Insert the sleep enable (SLP_EN) bit */
105
106	pm1a_control |= sleep_enable_reg_info->access_bit_mask;
107	pm1b_control |= sleep_enable_reg_info->access_bit_mask;
108
109	/* Flush caches, as per ACPI specification */
110
111	ACPI_FLUSH_CPU_CACHE();
112
113	status = acpi_os_enter_sleep(sleep_state, pm1a_control, pm1b_control);
114	if (status == AE_CTRL_TERMINATE) {
 
115		return_ACPI_STATUS(AE_OK);
116	}
117	if (ACPI_FAILURE(status)) {
118		return_ACPI_STATUS(status);
119	}
120
121	/* Write #2: Write both SLP_TYP + SLP_EN */
122
123	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
124	if (ACPI_FAILURE(status)) {
125		return_ACPI_STATUS(status);
126	}
127
128	if (sleep_state > ACPI_STATE_S3) {
129		/*
130		 * We wanted to sleep > S3, but it didn't happen (by virtue of the
131		 * fact that we are still executing!)
132		 *
133		 * Wait ten seconds, then try again. This is to get S4/S5 to work on
134		 * all machines.
135		 *
136		 * We wait so long to allow chipsets that poll this reg very slowly
137		 * to still read the right value. Ideally, this block would go
138		 * away entirely.
139		 */
140		acpi_os_stall(10 * ACPI_USEC_PER_SEC);
141
142		status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
143						sleep_enable_reg_info->
144						access_bit_mask);
145		if (ACPI_FAILURE(status)) {
146			return_ACPI_STATUS(status);
147		}
148	}
149
150	/* Wait for transition back to Working State */
151
152	do {
153		status =
154		    acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
155		if (ACPI_FAILURE(status)) {
156			return_ACPI_STATUS(status);
157		}
158
159	} while (!in_value);
160
161	return_ACPI_STATUS(AE_OK);
162}
163
164/*******************************************************************************
165 *
166 * FUNCTION:    acpi_hw_legacy_wake_prep
167 *
168 * PARAMETERS:  sleep_state         - Which sleep state we just exited
 
169 *
170 * RETURN:      Status
171 *
172 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
173 *              sleep.
174 *              Called with interrupts ENABLED.
175 *
176 ******************************************************************************/
177
178acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
179{
180	acpi_status status;
181	struct acpi_bit_register_info *sleep_type_reg_info;
182	struct acpi_bit_register_info *sleep_enable_reg_info;
183	u32 pm1a_control;
184	u32 pm1b_control;
185
186	ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
187
188	/*
189	 * Set SLP_TYPE and SLP_EN to state S0.
190	 * This is unclear from the ACPI Spec, but it is required
191	 * by some machines.
192	 */
193	status = acpi_get_sleep_type_data(ACPI_STATE_S0,
194					  &acpi_gbl_sleep_type_a,
195					  &acpi_gbl_sleep_type_b);
196	if (ACPI_SUCCESS(status)) {
197		sleep_type_reg_info =
198		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
199		sleep_enable_reg_info =
200		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
201
202		/* Get current value of PM1A control */
203
204		status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
205					       &pm1a_control);
206		if (ACPI_SUCCESS(status)) {
207
208			/* Clear the SLP_EN and SLP_TYP fields */
209
210			pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
211					  sleep_enable_reg_info->
212					  access_bit_mask);
213			pm1b_control = pm1a_control;
214
215			/* Insert the SLP_TYP bits */
216
217			pm1a_control |= (acpi_gbl_sleep_type_a <<
218					 sleep_type_reg_info->bit_position);
219			pm1b_control |= (acpi_gbl_sleep_type_b <<
220					 sleep_type_reg_info->bit_position);
221
222			/* Write the control registers and ignore any errors */
223
224			(void)acpi_hw_write_pm1_control(pm1a_control,
225							pm1b_control);
226		}
227	}
228
 
 
 
 
 
229	return_ACPI_STATUS(status);
230}
231
232/*******************************************************************************
233 *
234 * FUNCTION:    acpi_hw_legacy_wake
235 *
236 * PARAMETERS:  sleep_state         - Which sleep state we just exited
 
237 *
238 * RETURN:      Status
239 *
240 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
241 *              Called with interrupts ENABLED.
242 *
243 ******************************************************************************/
244
245acpi_status acpi_hw_legacy_wake(u8 sleep_state)
246{
247	acpi_status status;
248
249	ACPI_FUNCTION_TRACE(hw_legacy_wake);
250
251	/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
252
253	acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
254	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
255
256	/*
257	 * GPEs must be enabled before _WAK is called as GPEs
258	 * might get fired there
259	 *
260	 * Restore the GPEs:
261	 * 1) Disable all GPEs
262	 * 2) Enable all runtime GPEs
263	 */
264	status = acpi_hw_disable_all_gpes();
265	if (ACPI_FAILURE(status)) {
266		return_ACPI_STATUS(status);
267	}
268
269	status = acpi_hw_enable_all_runtime_gpes();
270	if (ACPI_FAILURE(status)) {
271		return_ACPI_STATUS(status);
272	}
273
274	/*
275	 * Now we can execute _WAK, etc. Some machines require that the GPEs
276	 * are enabled before the wake methods are executed.
277	 */
278	acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
279
280	/*
281	 * Some BIOS code assumes that WAK_STS will be cleared on resume
282	 * and use it to determine whether the system is rebooting or
283	 * resuming. Clear WAK_STS for compatibility.
284	 */
285	(void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
286				      ACPI_CLEAR_STATUS);
287	acpi_gbl_system_awake_and_running = TRUE;
288
289	/* Enable power button */
290
291	(void)
292	    acpi_write_bit_register(acpi_gbl_fixed_event_info
293				    [ACPI_EVENT_POWER_BUTTON].
294				    enable_register_id, ACPI_ENABLE_EVENT);
295
296	(void)
297	    acpi_write_bit_register(acpi_gbl_fixed_event_info
298				    [ACPI_EVENT_POWER_BUTTON].
299				    status_register_id, ACPI_CLEAR_STATUS);
300
301	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
302	return_ACPI_STATUS(status);
303}
304
305#endif				/* !ACPI_REDUCED_HARDWARE */