]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/acpi/hardware/hwsleep.c
ACPICA: hw: remove use_lock flag from acpi_hw_register_{read, write}
[mirror_ubuntu-hirsute-kernel.git] / drivers / acpi / hardware / hwsleep.c
CommitLineData
1da177e4
LT
1
2/******************************************************************************
3 *
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
5 *
6 *****************************************************************************/
7
8/*
6c9deb72 9 * Copyright (C) 2000 - 2007, R. Byron Moore
1da177e4
LT
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
1da177e4 45#include <acpi/acpi.h>
f3d2e786 46#include <acpi/actables.h>
1da177e4
LT
47
48#define _COMPONENT ACPI_HARDWARE
4be44fcd 49ACPI_MODULE_NAME("hwsleep")
1da177e4 50
44f6c012 51/*******************************************************************************
1da177e4
LT
52 *
53 * FUNCTION: acpi_set_firmware_waking_vector
54 *
55 * PARAMETERS: physical_address - Physical address of ACPI real mode
56 * entry point.
57 *
58 * RETURN: Status
59 *
44f6c012 60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
1da177e4
LT
61 *
62 ******************************************************************************/
1da177e4 63acpi_status
4be44fcd 64acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
1da177e4 65{
f3d2e786
BM
66 struct acpi_table_facs *facs;
67 acpi_status status;
1da177e4 68
b229cf92 69 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
1da177e4 70
f3d2e786
BM
71 /* Get the FACS */
72
73 status =
74 acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
75 (struct acpi_table_header **)&facs);
76 if (ACPI_FAILURE(status)) {
77 return_ACPI_STATUS(status);
78 }
79
1da177e4
LT
80 /* Set the vector */
81
f3d2e786
BM
82 if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) {
83 /*
84 * ACPI 1.0 FACS or short table or optional X_ field is zero
85 */
86 facs->firmware_waking_vector = (u32) physical_address;
4be44fcd 87 } else {
f3d2e786
BM
88 /*
89 * ACPI 2.0 FACS with valid X_ field
90 */
91 facs->xfirmware_waking_vector = physical_address;
1da177e4
LT
92 }
93
4be44fcd 94 return_ACPI_STATUS(AE_OK);
1da177e4
LT
95}
96
8313524a
BM
97ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
98
44f6c012 99/*******************************************************************************
1da177e4
LT
100 *
101 * FUNCTION: acpi_get_firmware_waking_vector
102 *
44f6c012 103 * PARAMETERS: *physical_address - Where the contents of
1da177e4 104 * the firmware_waking_vector field of
44f6c012 105 * the FACS will be returned.
1da177e4 106 *
44f6c012 107 * RETURN: Status, vector
1da177e4 108 *
44f6c012 109 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
1da177e4
LT
110 *
111 ******************************************************************************/
112#ifdef ACPI_FUTURE_USAGE
113acpi_status
4be44fcd 114acpi_get_firmware_waking_vector(acpi_physical_address * physical_address)
1da177e4 115{
f3d2e786
BM
116 struct acpi_table_facs *facs;
117 acpi_status status;
1da177e4 118
b229cf92 119 ACPI_FUNCTION_TRACE(acpi_get_firmware_waking_vector);
1da177e4
LT
120
121 if (!physical_address) {
4be44fcd 122 return_ACPI_STATUS(AE_BAD_PARAMETER);
1da177e4
LT
123 }
124
f3d2e786
BM
125 /* Get the FACS */
126
127 status =
128 acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
129 (struct acpi_table_header **)&facs);
130 if (ACPI_FAILURE(status)) {
131 return_ACPI_STATUS(status);
132 }
133
1da177e4
LT
134 /* Get the vector */
135
f3d2e786
BM
136 if ((facs->length < 32) || (!(facs->xfirmware_waking_vector))) {
137 /*
138 * ACPI 1.0 FACS or short table or optional X_ field is zero
139 */
140 *physical_address =
141 (acpi_physical_address) facs->firmware_waking_vector;
4be44fcd 142 } else {
f3d2e786
BM
143 /*
144 * ACPI 2.0 FACS with valid X_ field
145 */
1da177e4 146 *physical_address =
f3d2e786 147 (acpi_physical_address) facs->xfirmware_waking_vector;
1da177e4
LT
148 }
149
4be44fcd 150 return_ACPI_STATUS(AE_OK);
1da177e4 151}
8313524a
BM
152
153ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector)
1da177e4 154#endif
44f6c012 155/*******************************************************************************
1da177e4
LT
156 *
157 * FUNCTION: acpi_enter_sleep_state_prep
158 *
159 * PARAMETERS: sleep_state - Which sleep state to enter
160 *
161 * RETURN: Status
162 *
163 * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
164 * This function must execute with interrupts enabled.
165 * We break sleeping into 2 stages so that OSPM can handle
166 * various OS-specific tasks between the two steps.
167 *
168 ******************************************************************************/
4be44fcd 169acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
1da177e4 170{
4be44fcd
LB
171 acpi_status status;
172 struct acpi_object_list arg_list;
173 union acpi_object arg;
1da177e4 174
b229cf92 175 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
1da177e4
LT
176
177 /*
178 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
179 */
4be44fcd
LB
180 status = acpi_get_sleep_type_data(sleep_state,
181 &acpi_gbl_sleep_type_a,
182 &acpi_gbl_sleep_type_b);
183 if (ACPI_FAILURE(status)) {
184 return_ACPI_STATUS(status);
1da177e4
LT
185 }
186
187 /* Setup parameter object */
188
189 arg_list.count = 1;
190 arg_list.pointer = &arg;
191
192 arg.type = ACPI_TYPE_INTEGER;
193 arg.integer.value = sleep_state;
194
195 /* Run the _PTS and _GTS methods */
196
4be44fcd
LB
197 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
198 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
199 return_ACPI_STATUS(status);
1da177e4
LT
200 }
201
4be44fcd
LB
202 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
203 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
204 return_ACPI_STATUS(status);
1da177e4
LT
205 }
206
207 /* Setup the argument to _SST */
208
209 switch (sleep_state) {
210 case ACPI_STATE_S0:
211 arg.integer.value = ACPI_SST_WORKING;
212 break;
213
214 case ACPI_STATE_S1:
215 case ACPI_STATE_S2:
216 case ACPI_STATE_S3:
217 arg.integer.value = ACPI_SST_SLEEPING;
218 break;
219
220 case ACPI_STATE_S4:
221 arg.integer.value = ACPI_SST_SLEEP_CONTEXT;
222 break;
223
224 default:
4be44fcd 225 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
1da177e4
LT
226 break;
227 }
228
229 /* Set the system indicators to show the desired sleep state. */
230
4be44fcd
LB
231 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
232 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
b8e4d893
BM
233 ACPI_EXCEPTION((AE_INFO, status,
234 "While executing method _SST"));
1da177e4
LT
235 }
236
ed41dab9
AS
237 /*
238 * 1) Disable/Clear all GPEs
239 */
240 status = acpi_hw_disable_all_gpes();
241 if (ACPI_FAILURE(status)) {
242 return_ACPI_STATUS(status);
243 }
244
4be44fcd 245 return_ACPI_STATUS(AE_OK);
1da177e4
LT
246}
247
8313524a
BM
248ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
249
44f6c012 250/*******************************************************************************
1da177e4
LT
251 *
252 * FUNCTION: acpi_enter_sleep_state
253 *
254 * PARAMETERS: sleep_state - Which sleep state to enter
255 *
256 * RETURN: Status
257 *
258 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
259 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
260 *
261 ******************************************************************************/
4be44fcd 262acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
1da177e4 263{
4be44fcd
LB
264 u32 PM1Acontrol;
265 u32 PM1Bcontrol;
266 struct acpi_bit_register_info *sleep_type_reg_info;
267 struct acpi_bit_register_info *sleep_enable_reg_info;
268 u32 in_value;
269 acpi_status status;
1da177e4 270
b229cf92 271 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
1da177e4
LT
272
273 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
4be44fcd 274 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
b8e4d893
BM
275 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=%X B=%X",
276 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
4be44fcd 277 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
1da177e4
LT
278 }
279
4be44fcd
LB
280 sleep_type_reg_info =
281 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
282 sleep_enable_reg_info =
283 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
1da177e4
LT
284
285 /* Clear wake status */
286
d8c71b6d 287 status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
4be44fcd
LB
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
1da177e4
LT
290 }
291
292 /* Clear all fixed and general purpose status bits */
293
d8c71b6d 294 status = acpi_hw_clear_acpi_status();
4be44fcd
LB
295 if (ACPI_FAILURE(status)) {
296 return_ACPI_STATUS(status);
1da177e4
LT
297 }
298
299 /*
1da177e4
LT
300 * 2) Enable all wakeup GPEs
301 */
1d99967b
AS
302 status = acpi_hw_disable_all_gpes();
303 if (ACPI_FAILURE(status)) {
304 return_ACPI_STATUS(status);
305 }
306
1da177e4
LT
307 acpi_gbl_system_awake_and_running = FALSE;
308
4be44fcd
LB
309 status = acpi_hw_enable_all_wakeup_gpes();
310 if (ACPI_FAILURE(status)) {
311 return_ACPI_STATUS(status);
1da177e4
LT
312 }
313
314 /* Get current value of PM1A control */
315
d30dc9ab 316 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
4be44fcd
LB
317 if (ACPI_FAILURE(status)) {
318 return_ACPI_STATUS(status);
1da177e4 319 }
4be44fcd
LB
320 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
321 "Entering sleep state [S%d]\n", sleep_state));
1da177e4
LT
322
323 /* Clear SLP_EN and SLP_TYP fields */
324
44f6c012 325 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
4be44fcd 326 sleep_enable_reg_info->access_bit_mask);
1da177e4
LT
327 PM1Bcontrol = PM1Acontrol;
328
329 /* Insert SLP_TYP bits */
330
4be44fcd
LB
331 PM1Acontrol |=
332 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
333 PM1Bcontrol |=
334 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
1da177e4
LT
335
336 /*
337 * We split the writes of SLP_TYP and SLP_EN to workaround
338 * poorly implemented hardware.
339 */
340
341 /* Write #1: fill in SLP_TYP data */
342
d30dc9ab 343 status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
4be44fcd
LB
344 PM1Acontrol);
345 if (ACPI_FAILURE(status)) {
346 return_ACPI_STATUS(status);
1da177e4
LT
347 }
348
d30dc9ab 349 status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
4be44fcd
LB
350 PM1Bcontrol);
351 if (ACPI_FAILURE(status)) {
352 return_ACPI_STATUS(status);
1da177e4
LT
353 }
354
355 /* Insert SLP_ENABLE bit */
356
357 PM1Acontrol |= sleep_enable_reg_info->access_bit_mask;
358 PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;
359
360 /* Write #2: SLP_TYP + SLP_EN */
361
4be44fcd 362 ACPI_FLUSH_CPU_CACHE();
1da177e4 363
d30dc9ab 364 status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
4be44fcd
LB
365 PM1Acontrol);
366 if (ACPI_FAILURE(status)) {
367 return_ACPI_STATUS(status);
1da177e4
LT
368 }
369
d30dc9ab 370 status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
4be44fcd
LB
371 PM1Bcontrol);
372 if (ACPI_FAILURE(status)) {
373 return_ACPI_STATUS(status);
1da177e4
LT
374 }
375
376 if (sleep_state > ACPI_STATE_S3) {
377 /*
44f6c012
RM
378 * We wanted to sleep > S3, but it didn't happen (by virtue of the
379 * fact that we are still executing!)
1da177e4 380 *
44f6c012
RM
381 * Wait ten seconds, then try again. This is to get S4/S5 to work on
382 * all machines.
1da177e4
LT
383 *
384 * We wait so long to allow chipsets that poll this reg very slowly to
385 * still read the right value. Ideally, this block would go
386 * away entirely.
387 */
4be44fcd
LB
388 acpi_os_stall(10000000);
389
d30dc9ab 390 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
4be44fcd
LB
391 sleep_enable_reg_info->
392 access_bit_mask);
393 if (ACPI_FAILURE(status)) {
394 return_ACPI_STATUS(status);
1da177e4
LT
395 }
396 }
397
398 /* Wait until we enter sleep state */
399
400 do {
d8c71b6d 401 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value);
4be44fcd
LB
402 if (ACPI_FAILURE(status)) {
403 return_ACPI_STATUS(status);
1da177e4
LT
404 }
405
406 /* Spin until we wake */
407
408 } while (!in_value);
409
4be44fcd 410 return_ACPI_STATUS(AE_OK);
1da177e4 411}
1da177e4 412
8313524a 413ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
1da177e4 414
44f6c012 415/*******************************************************************************
1da177e4
LT
416 *
417 * FUNCTION: acpi_enter_sleep_state_s4bios
418 *
419 * PARAMETERS: None
420 *
421 * RETURN: Status
422 *
423 * DESCRIPTION: Perform a S4 bios request.
424 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
425 *
426 ******************************************************************************/
4be44fcd 427acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
1da177e4 428{
4be44fcd
LB
429 u32 in_value;
430 acpi_status status;
1da177e4 431
b229cf92 432 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
1da177e4 433
d8c71b6d 434 status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
4be44fcd
LB
435 if (ACPI_FAILURE(status)) {
436 return_ACPI_STATUS(status);
1da177e4
LT
437 }
438
d8c71b6d 439 status = acpi_hw_clear_acpi_status();
4be44fcd
LB
440 if (ACPI_FAILURE(status)) {
441 return_ACPI_STATUS(status);
1da177e4
LT
442 }
443
444 /*
445 * 1) Disable/Clear all GPEs
446 * 2) Enable all wakeup GPEs
447 */
4be44fcd
LB
448 status = acpi_hw_disable_all_gpes();
449 if (ACPI_FAILURE(status)) {
450 return_ACPI_STATUS(status);
1da177e4
LT
451 }
452 acpi_gbl_system_awake_and_running = FALSE;
453
4be44fcd
LB
454 status = acpi_hw_enable_all_wakeup_gpes();
455 if (ACPI_FAILURE(status)) {
456 return_ACPI_STATUS(status);
1da177e4
LT
457 }
458
4be44fcd 459 ACPI_FLUSH_CPU_CACHE();
1da177e4 460
f3d2e786
BM
461 status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
462 (u32) acpi_gbl_FADT.S4bios_request, 8);
1da177e4
LT
463
464 do {
465 acpi_os_stall(1000);
d8c71b6d 466 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value);
4be44fcd
LB
467 if (ACPI_FAILURE(status)) {
468 return_ACPI_STATUS(status);
1da177e4
LT
469 }
470 } while (!in_value);
471
4be44fcd 472 return_ACPI_STATUS(AE_OK);
1da177e4 473}
1da177e4 474
8313524a 475ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
1da177e4 476
44f6c012 477/*******************************************************************************
1da177e4
LT
478 *
479 * FUNCTION: acpi_leave_sleep_state
480 *
481 * PARAMETERS: sleep_state - Which sleep state we just exited
482 *
483 * RETURN: Status
484 *
485 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
486 * Called with interrupts ENABLED.
487 *
488 ******************************************************************************/
4be44fcd 489acpi_status acpi_leave_sleep_state(u8 sleep_state)
1da177e4 490{
4be44fcd
LB
491 struct acpi_object_list arg_list;
492 union acpi_object arg;
493 acpi_status status;
494 struct acpi_bit_register_info *sleep_type_reg_info;
495 struct acpi_bit_register_info *sleep_enable_reg_info;
496 u32 PM1Acontrol;
497 u32 PM1Bcontrol;
1da177e4 498
b229cf92 499 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
1da177e4
LT
500
501 /*
502 * Set SLP_TYPE and SLP_EN to state S0.
503 * This is unclear from the ACPI Spec, but it is required
504 * by some machines.
505 */
4be44fcd
LB
506 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
507 &acpi_gbl_sleep_type_a,
508 &acpi_gbl_sleep_type_b);
509 if (ACPI_SUCCESS(status)) {
510 sleep_type_reg_info =
511 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
512 sleep_enable_reg_info =
513 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
1da177e4
LT
514
515 /* Get current value of PM1A control */
516
d30dc9ab 517 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
4be44fcd
LB
518 &PM1Acontrol);
519 if (ACPI_SUCCESS(status)) {
52fc0b02 520
1da177e4
LT
521 /* Clear SLP_EN and SLP_TYP fields */
522
523 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
4be44fcd
LB
524 sleep_enable_reg_info->
525 access_bit_mask);
1da177e4
LT
526 PM1Bcontrol = PM1Acontrol;
527
528 /* Insert SLP_TYP bits */
529
4be44fcd
LB
530 PM1Acontrol |=
531 (acpi_gbl_sleep_type_a << sleep_type_reg_info->
532 bit_position);
533 PM1Bcontrol |=
534 (acpi_gbl_sleep_type_b << sleep_type_reg_info->
535 bit_position);
1da177e4
LT
536
537 /* Just ignore any errors */
538
d30dc9ab 539 (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
4be44fcd 540 PM1Acontrol);
d30dc9ab 541 (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
4be44fcd 542 PM1Bcontrol);
1da177e4
LT
543 }
544 }
545
546 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
547
548 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
549
550 /* Setup parameter object */
551
552 arg_list.count = 1;
553 arg_list.pointer = &arg;
554 arg.type = ACPI_TYPE_INTEGER;
555
556 /* Ignore any errors from these methods */
557
558 arg.integer.value = ACPI_SST_WAKING;
4be44fcd
LB
559 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
560 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
b8e4d893 561 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
1da177e4
LT
562 }
563
564 arg.integer.value = sleep_state;
4be44fcd
LB
565 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
566 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
b8e4d893 567 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
1da177e4
LT
568 }
569
1da177e4 570 /*
79d2dfaa
TR
571 * GPEs must be enabled before _WAK is called as GPEs
572 * might get fired there
573 *
1da177e4
LT
574 * Restore the GPEs:
575 * 1) Disable/Clear all GPEs
576 * 2) Enable all runtime GPEs
577 */
4be44fcd
LB
578 status = acpi_hw_disable_all_gpes();
579 if (ACPI_FAILURE(status)) {
580 return_ACPI_STATUS(status);
1da177e4 581 }
4be44fcd
LB
582 status = acpi_hw_enable_all_runtime_gpes();
583 if (ACPI_FAILURE(status)) {
584 return_ACPI_STATUS(status);
1da177e4
LT
585 }
586
79d2dfaa
TR
587 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
588 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
589 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
590 }
591 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
592
593 acpi_gbl_system_awake_and_running = TRUE;
594
1da177e4
LT
595 /* Enable power button */
596
4be44fcd
LB
597 (void)
598 acpi_set_register(acpi_gbl_fixed_event_info
d8c71b6d 599 [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1);
44f6c012 600
4be44fcd
LB
601 (void)
602 acpi_set_register(acpi_gbl_fixed_event_info
d8c71b6d 603 [ACPI_EVENT_POWER_BUTTON].status_register_id, 1);
1da177e4
LT
604
605 arg.integer.value = ACPI_SST_WORKING;
4be44fcd
LB
606 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
607 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
b8e4d893 608 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
1da177e4
LT
609 }
610
4be44fcd 611 return_ACPI_STATUS(status);
1da177e4 612}
8313524a
BM
613
614ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)