Import acpica-unix-20061109 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / hardware / hwsleep.c
blobecf8d54cf7d776654e059811b7be46b3ec1bb5ba
2 /******************************************************************************
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
5 * $Revision: 1.85 $
7 *****************************************************************************/
9 /******************************************************************************
11 * 1. Copyright Notice
13 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
14 * All rights reserved.
16 * 2. License
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
42 * 3. Conditions
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
118 #include "acpi.h"
119 #include "actables.h"
121 #define _COMPONENT ACPI_HARDWARE
122 ACPI_MODULE_NAME ("hwsleep")
125 /*******************************************************************************
127 * FUNCTION: AcpiSetFirmwareWakingVector
129 * PARAMETERS: PhysicalAddress - Physical address of ACPI real mode
130 * entry point.
132 * RETURN: Status
134 * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS
136 ******************************************************************************/
138 ACPI_STATUS
139 AcpiSetFirmwareWakingVector (
140 ACPI_PHYSICAL_ADDRESS PhysicalAddress)
142 ACPI_TABLE_FACS *Facs;
143 ACPI_STATUS Status;
146 ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector);
148 /* Get the FACS */
150 Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, (ACPI_TABLE_HEADER **) &Facs);
151 if (ACPI_FAILURE (Status))
153 return_ACPI_STATUS (Status);
156 /* Set the vector */
158 if ((Facs->Length < 32) ||
159 (!(ACPI_GET_ADDRESS (Facs->XFirmwareWakingVector))))
162 * ACPI 1.0 FACS or short table or optional X_ field is zero
164 Facs->FirmwareWakingVector = (UINT32) PhysicalAddress;
166 else
169 * ACPI 2.0 FACS with valid X_ field
171 Facs->XFirmwareWakingVector = PhysicalAddress;
174 return_ACPI_STATUS (AE_OK);
177 ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector)
180 /*******************************************************************************
182 * FUNCTION: AcpiGetFirmwareWakingVector
184 * PARAMETERS: *PhysicalAddress - Where the contents of
185 * the FirmwareWakingVector field of
186 * the FACS will be returned.
188 * RETURN: Status, vector
190 * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS
192 ******************************************************************************/
194 ACPI_STATUS
195 AcpiGetFirmwareWakingVector (
196 ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
198 ACPI_TABLE_FACS *Facs;
199 ACPI_STATUS Status;
202 ACPI_FUNCTION_TRACE (AcpiGetFirmwareWakingVector);
205 if (!PhysicalAddress)
207 return_ACPI_STATUS (AE_BAD_PARAMETER);
210 /* Get the FACS */
212 Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, (ACPI_TABLE_HEADER **) &Facs);
213 if (ACPI_FAILURE (Status))
215 return_ACPI_STATUS (Status);
218 /* Get the vector */
220 if ((Facs->Length < 32) ||
221 (!(ACPI_GET_ADDRESS (Facs->XFirmwareWakingVector))))
224 * ACPI 1.0 FACS or short table or optional X_ field is zero
226 *PhysicalAddress =
227 (ACPI_PHYSICAL_ADDRESS) Facs->FirmwareWakingVector;
229 else
232 * ACPI 2.0 FACS with valid X_ field
234 *PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) Facs->XFirmwareWakingVector;
237 return_ACPI_STATUS (AE_OK);
240 ACPI_EXPORT_SYMBOL (AcpiGetFirmwareWakingVector)
243 /*******************************************************************************
245 * FUNCTION: AcpiEnterSleepStatePrep
247 * PARAMETERS: SleepState - Which sleep state to enter
249 * RETURN: Status
251 * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
252 * This function must execute with interrupts enabled.
253 * We break sleeping into 2 stages so that OSPM can handle
254 * various OS-specific tasks between the two steps.
256 ******************************************************************************/
258 ACPI_STATUS
259 AcpiEnterSleepStatePrep (
260 UINT8 SleepState)
262 ACPI_STATUS Status;
263 ACPI_OBJECT_LIST ArgList;
264 ACPI_OBJECT Arg;
267 ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep);
271 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
273 Status = AcpiGetSleepTypeData (SleepState,
274 &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
275 if (ACPI_FAILURE (Status))
277 return_ACPI_STATUS (Status);
280 /* Setup parameter object */
282 ArgList.Count = 1;
283 ArgList.Pointer = &Arg;
285 Arg.Type = ACPI_TYPE_INTEGER;
286 Arg.Integer.Value = SleepState;
288 /* Run the _PTS and _GTS methods */
290 Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL);
291 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
293 return_ACPI_STATUS (Status);
296 Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL);
297 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
299 return_ACPI_STATUS (Status);
302 /* Setup the argument to _SST */
304 switch (SleepState)
306 case ACPI_STATE_S0:
307 Arg.Integer.Value = ACPI_SST_WORKING;
308 break;
310 case ACPI_STATE_S1:
311 case ACPI_STATE_S2:
312 case ACPI_STATE_S3:
313 Arg.Integer.Value = ACPI_SST_SLEEPING;
314 break;
316 case ACPI_STATE_S4:
317 Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT;
318 break;
320 default:
321 Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */
322 break;
325 /* Set the system indicators to show the desired sleep state. */
327 Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
328 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
330 ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST"));
333 return_ACPI_STATUS (AE_OK);
336 ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep)
339 /*******************************************************************************
341 * FUNCTION: AcpiEnterSleepState
343 * PARAMETERS: SleepState - Which sleep state to enter
345 * RETURN: Status
347 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
348 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
350 ******************************************************************************/
352 ACPI_STATUS
353 AcpiEnterSleepState (
354 UINT8 SleepState)
356 UINT32 PM1AControl;
357 UINT32 PM1BControl;
358 ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
359 ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
360 UINT32 InValue;
361 ACPI_STATUS Status;
364 ACPI_FUNCTION_TRACE (AcpiEnterSleepState);
367 if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
368 (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX))
370 ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=%X B=%X",
371 AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB));
372 return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
375 SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A);
376 SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
378 /* Clear wake status */
380 Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1);
381 if (ACPI_FAILURE (Status))
383 return_ACPI_STATUS (Status);
386 /* Clear all fixed and general purpose status bits */
388 Status = AcpiHwClearAcpiStatus ();
389 if (ACPI_FAILURE (Status))
391 return_ACPI_STATUS (Status);
394 if (SleepState != ACPI_STATE_S5)
396 /* Disable BM arbitration */
398 Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1);
399 if (ACPI_FAILURE (Status))
401 return_ACPI_STATUS (Status);
406 * 1) Disable/Clear all GPEs
407 * 2) Enable all wakeup GPEs
409 Status = AcpiHwDisableAllGpes ();
410 if (ACPI_FAILURE (Status))
412 return_ACPI_STATUS (Status);
414 AcpiGbl_SystemAwakeAndRunning = FALSE;
416 Status = AcpiHwEnableAllWakeupGpes ();
417 if (ACPI_FAILURE (Status))
419 return_ACPI_STATUS (Status);
422 /* Get current value of PM1A control */
424 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
425 ACPI_REGISTER_PM1_CONTROL, &PM1AControl);
426 if (ACPI_FAILURE (Status))
428 return_ACPI_STATUS (Status);
430 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
431 "Entering sleep state [S%d]\n", SleepState));
433 /* Clear SLP_EN and SLP_TYP fields */
435 PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask |
436 SleepEnableRegInfo->AccessBitMask);
437 PM1BControl = PM1AControl;
439 /* Insert SLP_TYP bits */
441 PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
442 PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
445 * We split the writes of SLP_TYP and SLP_EN to workaround
446 * poorly implemented hardware.
449 /* Write #1: fill in SLP_TYP data */
451 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
452 ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
453 if (ACPI_FAILURE (Status))
455 return_ACPI_STATUS (Status);
458 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
459 ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
460 if (ACPI_FAILURE (Status))
462 return_ACPI_STATUS (Status);
465 /* Insert SLP_ENABLE bit */
467 PM1AControl |= SleepEnableRegInfo->AccessBitMask;
468 PM1BControl |= SleepEnableRegInfo->AccessBitMask;
470 /* Write #2: SLP_TYP + SLP_EN */
472 ACPI_FLUSH_CPU_CACHE ();
474 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
475 ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
476 if (ACPI_FAILURE (Status))
478 return_ACPI_STATUS (Status);
481 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
482 ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
483 if (ACPI_FAILURE (Status))
485 return_ACPI_STATUS (Status);
488 if (SleepState > ACPI_STATE_S3)
491 * We wanted to sleep > S3, but it didn't happen (by virtue of the
492 * fact that we are still executing!)
494 * Wait ten seconds, then try again. This is to get S4/S5 to work on
495 * all machines.
497 * We wait so long to allow chipsets that poll this reg very slowly to
498 * still read the right value. Ideally, this block would go
499 * away entirely.
501 AcpiOsStall (10000000);
503 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
504 ACPI_REGISTER_PM1_CONTROL,
505 SleepEnableRegInfo->AccessBitMask);
506 if (ACPI_FAILURE (Status))
508 return_ACPI_STATUS (Status);
512 /* Wait until we enter sleep state */
516 Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
517 if (ACPI_FAILURE (Status))
519 return_ACPI_STATUS (Status);
522 /* Spin until we wake */
524 } while (!InValue);
526 return_ACPI_STATUS (AE_OK);
529 ACPI_EXPORT_SYMBOL (AcpiEnterSleepState)
532 /*******************************************************************************
534 * FUNCTION: AcpiEnterSleepStateS4bios
536 * PARAMETERS: None
538 * RETURN: Status
540 * DESCRIPTION: Perform a S4 bios request.
541 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
543 ******************************************************************************/
545 ACPI_STATUS
546 AcpiEnterSleepStateS4bios (
547 void)
549 UINT32 InValue;
550 ACPI_STATUS Status;
553 ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios);
556 Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1);
557 if (ACPI_FAILURE (Status))
559 return_ACPI_STATUS (Status);
562 Status = AcpiHwClearAcpiStatus ();
563 if (ACPI_FAILURE (Status))
565 return_ACPI_STATUS (Status);
569 * 1) Disable/Clear all GPEs
570 * 2) Enable all wakeup GPEs
572 Status = AcpiHwDisableAllGpes ();
573 if (ACPI_FAILURE (Status))
575 return_ACPI_STATUS (Status);
577 AcpiGbl_SystemAwakeAndRunning = FALSE;
579 Status = AcpiHwEnableAllWakeupGpes ();
580 if (ACPI_FAILURE (Status))
582 return_ACPI_STATUS (Status);
585 ACPI_FLUSH_CPU_CACHE ();
587 Status = AcpiOsWritePort (AcpiGbl_FADT.SmiCommand,
588 (UINT32) AcpiGbl_FADT.S4BiosRequest, 8);
590 do {
591 AcpiOsStall(1000);
592 Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue);
593 if (ACPI_FAILURE (Status))
595 return_ACPI_STATUS (Status);
597 } while (!InValue);
599 return_ACPI_STATUS (AE_OK);
602 ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios)
605 /*******************************************************************************
607 * FUNCTION: AcpiLeaveSleepState
609 * PARAMETERS: SleepState - Which sleep state we just exited
611 * RETURN: Status
613 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
614 * Called with interrupts ENABLED.
616 ******************************************************************************/
618 ACPI_STATUS
619 AcpiLeaveSleepState (
620 UINT8 SleepState)
622 ACPI_OBJECT_LIST ArgList;
623 ACPI_OBJECT Arg;
624 ACPI_STATUS Status;
625 ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
626 ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
627 UINT32 PM1AControl;
628 UINT32 PM1BControl;
631 ACPI_FUNCTION_TRACE (AcpiLeaveSleepState);
635 * Set SLP_TYPE and SLP_EN to state S0.
636 * This is unclear from the ACPI Spec, but it is required
637 * by some machines.
639 Status = AcpiGetSleepTypeData (ACPI_STATE_S0,
640 &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
641 if (ACPI_SUCCESS (Status))
643 SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A);
644 SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
646 /* Get current value of PM1A control */
648 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
649 ACPI_REGISTER_PM1_CONTROL, &PM1AControl);
650 if (ACPI_SUCCESS (Status))
652 /* Clear SLP_EN and SLP_TYP fields */
654 PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask |
655 SleepEnableRegInfo->AccessBitMask);
656 PM1BControl = PM1AControl;
658 /* Insert SLP_TYP bits */
660 PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
661 PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
663 /* Just ignore any errors */
665 (void) AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
666 ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
667 (void) AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
668 ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
672 /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
674 AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
676 /* Setup parameter object */
678 ArgList.Count = 1;
679 ArgList.Pointer = &Arg;
680 Arg.Type = ACPI_TYPE_INTEGER;
682 /* Ignore any errors from these methods */
684 Arg.Integer.Value = ACPI_SST_WAKING;
685 Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
686 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
688 ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST"));
691 Arg.Integer.Value = SleepState;
692 Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL);
693 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
695 ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS"));
698 Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL);
699 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
701 ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK"));
703 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
706 * Restore the GPEs:
707 * 1) Disable/Clear all GPEs
708 * 2) Enable all runtime GPEs
710 Status = AcpiHwDisableAllGpes ();
711 if (ACPI_FAILURE (Status))
713 return_ACPI_STATUS (Status);
715 AcpiGbl_SystemAwakeAndRunning = TRUE;
717 Status = AcpiHwEnableAllRuntimeGpes ();
718 if (ACPI_FAILURE (Status))
720 return_ACPI_STATUS (Status);
723 /* Enable power button */
725 (void) AcpiSetRegister(
726 AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1);
728 (void) AcpiSetRegister(
729 AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1);
731 /* Enable BM arbitration */
733 Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0);
734 if (ACPI_FAILURE (Status))
736 return_ACPI_STATUS (Status);
739 Arg.Integer.Value = ACPI_SST_WORKING;
740 Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL);
741 if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
743 ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST"));
746 return_ACPI_STATUS (Status);
749 ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState)