1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
117 #define __EVXFEVNT_C__
120 #include "accommon.h"
121 #include "acevents.h"
122 #include "acnamesp.h"
123 #include "actables.h"
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evxfevnt")
128 /* Local prototypes */
132 ACPI_GPE_XRUPT_INFO
*GpeXruptInfo
,
133 ACPI_GPE_BLOCK_INFO
*GpeBlock
,
137 /*******************************************************************************
139 * FUNCTION: AcpiEnable
145 * DESCRIPTION: Transfers the system into ACPI mode.
147 ******************************************************************************/
153 ACPI_STATUS Status
= AE_OK
;
156 ACPI_FUNCTION_TRACE (AcpiEnable
);
159 /* ACPI tables must be present */
161 if (!AcpiTbTablesLoaded ())
163 return_ACPI_STATUS (AE_NO_ACPI_TABLES
);
166 /* Check current mode */
168 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI
)
170 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
, "System is already in ACPI mode\n"));
174 /* Transition to ACPI mode */
176 Status
= AcpiHwSetMode (ACPI_SYS_MODE_ACPI
);
177 if (ACPI_FAILURE (Status
))
179 ACPI_ERROR ((AE_INFO
, "Could not transition to ACPI mode"));
180 return_ACPI_STATUS (Status
);
183 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
,
184 "Transition to ACPI mode successful\n"));
187 return_ACPI_STATUS (Status
);
190 ACPI_EXPORT_SYMBOL (AcpiEnable
)
193 /*******************************************************************************
195 * FUNCTION: AcpiDisable
201 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
203 ******************************************************************************/
209 ACPI_STATUS Status
= AE_OK
;
212 ACPI_FUNCTION_TRACE (AcpiDisable
);
215 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY
)
217 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
,
218 "System is already in legacy (non-ACPI) mode\n"));
222 /* Transition to LEGACY mode */
224 Status
= AcpiHwSetMode (ACPI_SYS_MODE_LEGACY
);
226 if (ACPI_FAILURE (Status
))
228 ACPI_ERROR ((AE_INFO
,
229 "Could not exit ACPI mode to legacy mode"));
230 return_ACPI_STATUS (Status
);
233 ACPI_DEBUG_PRINT ((ACPI_DB_INIT
, "ACPI mode disabled\n"));
236 return_ACPI_STATUS (Status
);
239 ACPI_EXPORT_SYMBOL (AcpiDisable
)
242 /*******************************************************************************
244 * FUNCTION: AcpiEnableEvent
246 * PARAMETERS: Event - The fixed eventto be enabled
251 * DESCRIPTION: Enable an ACPI event (fixed)
253 ******************************************************************************/
260 ACPI_STATUS Status
= AE_OK
;
264 ACPI_FUNCTION_TRACE (AcpiEnableEvent
);
267 /* Decode the Fixed Event */
269 if (Event
> ACPI_EVENT_MAX
)
271 return_ACPI_STATUS (AE_BAD_PARAMETER
);
275 * Enable the requested fixed event (by writing a one to the enable
278 Status
= AcpiWriteBitRegister (
279 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
281 if (ACPI_FAILURE (Status
))
283 return_ACPI_STATUS (Status
);
286 /* Make sure that the hardware responded */
288 Status
= AcpiReadBitRegister (
289 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
290 if (ACPI_FAILURE (Status
))
292 return_ACPI_STATUS (Status
);
297 ACPI_ERROR ((AE_INFO
,
298 "Could not enable %s event", AcpiUtGetEventName (Event
)));
299 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
302 return_ACPI_STATUS (Status
);
305 ACPI_EXPORT_SYMBOL (AcpiEnableEvent
)
309 /*******************************************************************************
311 * FUNCTION: AcpiGpeWakeup
313 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
314 * GpeNumber - GPE level within the GPE block
315 * Action - Enable or Disable
319 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
321 ******************************************************************************/
325 ACPI_HANDLE GpeDevice
,
329 ACPI_STATUS Status
= AE_OK
;
330 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
331 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
332 ACPI_CPU_FLAGS Flags
;
336 ACPI_FUNCTION_TRACE (AcpiGpeWakeup
);
339 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
341 /* Ensure that we have a valid GPE number */
343 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
346 Status
= AE_BAD_PARAMETER
;
350 GpeRegisterInfo
= GpeEventInfo
->RegisterInfo
;
351 if (!GpeRegisterInfo
)
353 Status
= AE_NOT_EXIST
;
357 RegisterBit
= AcpiHwGetGpeRegisterBit (GpeEventInfo
, GpeRegisterInfo
);
359 /* Perform the action */
363 case ACPI_GPE_ENABLE
:
364 ACPI_SET_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
367 case ACPI_GPE_DISABLE
:
368 ACPI_CLEAR_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
372 ACPI_ERROR ((AE_INFO
, "%u, Invalid action", Action
));
373 Status
= AE_BAD_PARAMETER
;
378 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
379 return_ACPI_STATUS (Status
);
382 ACPI_EXPORT_SYMBOL (AcpiGpeWakeup
)
385 /*******************************************************************************
387 * FUNCTION: AcpiEnableGpe
389 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
390 * GpeNumber - GPE level within the GPE block
394 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
397 ******************************************************************************/
401 ACPI_HANDLE GpeDevice
,
404 ACPI_STATUS Status
= AE_OK
;
405 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
406 ACPI_CPU_FLAGS Flags
;
409 ACPI_FUNCTION_TRACE (AcpiEnableGpe
);
412 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
414 /* Ensure that we have a valid GPE number */
416 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
419 Status
= AE_BAD_PARAMETER
;
423 if (GpeEventInfo
->RuntimeCount
== ACPI_UINT8_MAX
)
425 Status
= AE_LIMIT
; /* Too many references */
429 GpeEventInfo
->RuntimeCount
++;
430 if (GpeEventInfo
->RuntimeCount
== 1)
432 Status
= AcpiEvUpdateGpeEnableMask (GpeEventInfo
);
433 if (ACPI_SUCCESS (Status
))
435 Status
= AcpiEvEnableGpe (GpeEventInfo
);
437 if (ACPI_FAILURE (Status
))
439 GpeEventInfo
->RuntimeCount
--;
444 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
445 return_ACPI_STATUS (Status
);
448 ACPI_EXPORT_SYMBOL (AcpiEnableGpe
)
451 /*******************************************************************************
453 * FUNCTION: AcpiDisableGpe
455 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
456 * GpeNumber - GPE level within the GPE block
460 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
461 * removed, only then is the GPE disabled (for runtime GPEs), or
462 * the GPE mask bit disabled (for wake GPEs)
464 ******************************************************************************/
468 ACPI_HANDLE GpeDevice
,
471 ACPI_STATUS Status
= AE_OK
;
472 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
473 ACPI_CPU_FLAGS Flags
;
476 ACPI_FUNCTION_TRACE (AcpiDisableGpe
);
479 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
481 /* Ensure that we have a valid GPE number */
483 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
486 Status
= AE_BAD_PARAMETER
;
490 /* Hardware-disable a runtime GPE on removal of the last reference */
492 if (!GpeEventInfo
->RuntimeCount
)
494 Status
= AE_LIMIT
; /* There are no references to remove */
498 GpeEventInfo
->RuntimeCount
--;
499 if (!GpeEventInfo
->RuntimeCount
)
501 Status
= AcpiEvUpdateGpeEnableMask (GpeEventInfo
);
502 if (ACPI_SUCCESS (Status
))
504 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
506 if (ACPI_FAILURE (Status
))
508 GpeEventInfo
->RuntimeCount
++;
513 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
514 return_ACPI_STATUS (Status
);
517 ACPI_EXPORT_SYMBOL (AcpiDisableGpe
)
520 /*******************************************************************************
522 * FUNCTION: AcpiSetGpe
524 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
525 * GpeNumber - GPE level within the GPE block
526 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
530 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
531 * the reference count mechanism used in the AcpiEnableGpe and
532 * AcpiDisableGpe interfaces -- and should be used with care.
534 * Note: Typically used to disable a runtime GPE for short period of time,
535 * then re-enable it, without disturbing the existing reference counts. This
536 * is useful, for example, in the Embedded Controller (EC) driver.
538 ******************************************************************************/
542 ACPI_HANDLE GpeDevice
,
546 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
548 ACPI_CPU_FLAGS Flags
;
551 ACPI_FUNCTION_TRACE (AcpiSetGpe
);
554 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
556 /* Ensure that we have a valid GPE number */
558 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
561 Status
= AE_BAD_PARAMETER
;
565 /* Perform the action */
569 case ACPI_GPE_ENABLE
:
570 Status
= AcpiEvEnableGpe (GpeEventInfo
);
573 case ACPI_GPE_DISABLE
:
574 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
578 Status
= AE_BAD_PARAMETER
;
583 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
584 return_ACPI_STATUS (Status
);
587 ACPI_EXPORT_SYMBOL (AcpiSetGpe
)
590 /*******************************************************************************
592 * FUNCTION: AcpiDisableEvent
594 * PARAMETERS: Event - The fixed eventto be enabled
599 * DESCRIPTION: Disable an ACPI event (fixed)
601 ******************************************************************************/
608 ACPI_STATUS Status
= AE_OK
;
612 ACPI_FUNCTION_TRACE (AcpiDisableEvent
);
615 /* Decode the Fixed Event */
617 if (Event
> ACPI_EVENT_MAX
)
619 return_ACPI_STATUS (AE_BAD_PARAMETER
);
623 * Disable the requested fixed event (by writing a zero to the enable
626 Status
= AcpiWriteBitRegister (
627 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
,
629 if (ACPI_FAILURE (Status
))
631 return_ACPI_STATUS (Status
);
634 Status
= AcpiReadBitRegister (
635 AcpiGbl_FixedEventInfo
[Event
].EnableRegisterId
, &Value
);
636 if (ACPI_FAILURE (Status
))
638 return_ACPI_STATUS (Status
);
643 ACPI_ERROR ((AE_INFO
,
644 "Could not disable %s events", AcpiUtGetEventName (Event
)));
645 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE
);
648 return_ACPI_STATUS (Status
);
651 ACPI_EXPORT_SYMBOL (AcpiDisableEvent
)
654 /*******************************************************************************
656 * FUNCTION: AcpiClearEvent
658 * PARAMETERS: Event - The fixed event to be cleared
662 * DESCRIPTION: Clear an ACPI event (fixed)
664 ******************************************************************************/
670 ACPI_STATUS Status
= AE_OK
;
673 ACPI_FUNCTION_TRACE (AcpiClearEvent
);
676 /* Decode the Fixed Event */
678 if (Event
> ACPI_EVENT_MAX
)
680 return_ACPI_STATUS (AE_BAD_PARAMETER
);
684 * Clear the requested fixed event (By writing a one to the status
687 Status
= AcpiWriteBitRegister (
688 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
,
691 return_ACPI_STATUS (Status
);
694 ACPI_EXPORT_SYMBOL (AcpiClearEvent
)
697 /*******************************************************************************
699 * FUNCTION: AcpiClearGpe
701 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
702 * GpeNumber - GPE level within the GPE block
706 * DESCRIPTION: Clear an ACPI event (general purpose)
708 ******************************************************************************/
712 ACPI_HANDLE GpeDevice
,
715 ACPI_STATUS Status
= AE_OK
;
716 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
717 ACPI_CPU_FLAGS Flags
;
720 ACPI_FUNCTION_TRACE (AcpiClearGpe
);
723 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
725 /* Ensure that we have a valid GPE number */
727 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
730 Status
= AE_BAD_PARAMETER
;
734 Status
= AcpiHwClearGpe (GpeEventInfo
);
737 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
738 return_ACPI_STATUS (Status
);
741 ACPI_EXPORT_SYMBOL (AcpiClearGpe
)
744 /*******************************************************************************
746 * FUNCTION: AcpiGetEventStatus
748 * PARAMETERS: Event - The fixed event
749 * EventStatus - Where the current status of the event will
754 * DESCRIPTION: Obtains and returns the current status of the event
756 ******************************************************************************/
761 ACPI_EVENT_STATUS
*EventStatus
)
763 ACPI_STATUS Status
= AE_OK
;
766 ACPI_FUNCTION_TRACE (AcpiGetEventStatus
);
771 return_ACPI_STATUS (AE_BAD_PARAMETER
);
774 /* Decode the Fixed Event */
776 if (Event
> ACPI_EVENT_MAX
)
778 return_ACPI_STATUS (AE_BAD_PARAMETER
);
781 /* Get the status of the requested fixed event */
783 Status
= AcpiReadBitRegister (
784 AcpiGbl_FixedEventInfo
[Event
].StatusRegisterId
, EventStatus
);
786 return_ACPI_STATUS (Status
);
789 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus
)
792 /*******************************************************************************
794 * FUNCTION: AcpiGetGpeStatus
796 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
797 * GpeNumber - GPE level within the GPE block
798 * EventStatus - Where the current status of the event will
803 * DESCRIPTION: Get status of an event (general purpose)
805 ******************************************************************************/
809 ACPI_HANDLE GpeDevice
,
811 ACPI_EVENT_STATUS
*EventStatus
)
813 ACPI_STATUS Status
= AE_OK
;
814 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
815 ACPI_CPU_FLAGS Flags
;
818 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus
);
821 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
823 /* Ensure that we have a valid GPE number */
825 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
828 Status
= AE_BAD_PARAMETER
;
832 /* Obtain status on the requested GPE number */
834 Status
= AcpiHwGetGpeStatus (GpeEventInfo
, EventStatus
);
837 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
838 return_ACPI_STATUS (Status
);
841 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus
)
844 /*******************************************************************************
846 * FUNCTION: AcpiInstallGpeBlock
848 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
849 * GpeBlockAddress - Address and SpaceID
850 * RegisterCount - Number of GPE register pairs in the block
851 * InterruptNumber - H/W interrupt for the block
855 * DESCRIPTION: Create and Install a block of GPE registers
857 ******************************************************************************/
860 AcpiInstallGpeBlock (
861 ACPI_HANDLE GpeDevice
,
862 ACPI_GENERIC_ADDRESS
*GpeBlockAddress
,
863 UINT32 RegisterCount
,
864 UINT32 InterruptNumber
)
867 ACPI_OPERAND_OBJECT
*ObjDesc
;
868 ACPI_NAMESPACE_NODE
*Node
;
869 ACPI_GPE_BLOCK_INFO
*GpeBlock
;
872 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock
);
876 (!GpeBlockAddress
) ||
879 return_ACPI_STATUS (AE_BAD_PARAMETER
);
882 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
883 if (ACPI_FAILURE (Status
))
888 Node
= AcpiNsValidateHandle (GpeDevice
);
891 Status
= AE_BAD_PARAMETER
;
896 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
899 Status
= AcpiEvCreateGpeBlock (Node
, GpeBlockAddress
, RegisterCount
,
900 0, InterruptNumber
, &GpeBlock
);
901 if (ACPI_FAILURE (Status
))
906 /* Install block in the DeviceObject attached to the node */
908 ObjDesc
= AcpiNsGetAttachedObject (Node
);
912 * No object, create a new one (Device nodes do not always have
913 * an attached object)
915 ObjDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE
);
918 Status
= AE_NO_MEMORY
;
922 Status
= AcpiNsAttachObject (Node
, ObjDesc
, ACPI_TYPE_DEVICE
);
924 /* Remove local reference to the object */
926 AcpiUtRemoveReference (ObjDesc
);
927 if (ACPI_FAILURE (Status
))
933 /* Now install the GPE block in the DeviceObject */
935 ObjDesc
->Device
.GpeBlock
= GpeBlock
;
937 /* Run the _PRW methods and enable the runtime GPEs in the new block */
939 Status
= AcpiEvInitializeGpeBlock (Node
, GpeBlock
);
943 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
944 return_ACPI_STATUS (Status
);
947 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock
)
950 /*******************************************************************************
952 * FUNCTION: AcpiRemoveGpeBlock
954 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
958 * DESCRIPTION: Remove a previously installed block of GPE registers
960 ******************************************************************************/
964 ACPI_HANDLE GpeDevice
)
966 ACPI_OPERAND_OBJECT
*ObjDesc
;
968 ACPI_NAMESPACE_NODE
*Node
;
971 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock
);
976 return_ACPI_STATUS (AE_BAD_PARAMETER
);
979 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
980 if (ACPI_FAILURE (Status
))
985 Node
= AcpiNsValidateHandle (GpeDevice
);
988 Status
= AE_BAD_PARAMETER
;
992 /* Get the DeviceObject attached to the node */
994 ObjDesc
= AcpiNsGetAttachedObject (Node
);
996 !ObjDesc
->Device
.GpeBlock
)
998 return_ACPI_STATUS (AE_NULL_OBJECT
);
1001 /* Delete the GPE block (but not the DeviceObject) */
1003 Status
= AcpiEvDeleteGpeBlock (ObjDesc
->Device
.GpeBlock
);
1004 if (ACPI_SUCCESS (Status
))
1006 ObjDesc
->Device
.GpeBlock
= NULL
;
1010 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
1011 return_ACPI_STATUS (Status
);
1014 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock
)
1017 /*******************************************************************************
1019 * FUNCTION: AcpiGetGpeDevice
1021 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1022 * GpeDevice - Where the parent GPE Device is returned
1026 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1027 * gpe device indicates that the gpe number is contained in one of
1028 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1030 ******************************************************************************/
1035 ACPI_HANDLE
*GpeDevice
)
1037 ACPI_GPE_DEVICE_INFO Info
;
1041 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice
);
1046 return_ACPI_STATUS (AE_BAD_PARAMETER
);
1049 if (Index
>= AcpiCurrentGpeCount
)
1051 return_ACPI_STATUS (AE_NOT_EXIST
);
1054 /* Setup and walk the GPE list */
1057 Info
.Status
= AE_NOT_EXIST
;
1058 Info
.GpeDevice
= NULL
;
1059 Info
.NextBlockBaseIndex
= 0;
1061 Status
= AcpiEvWalkGpeList (AcpiEvGetGpeDevice
, &Info
);
1062 if (ACPI_FAILURE (Status
))
1064 return_ACPI_STATUS (Status
);
1067 *GpeDevice
= ACPI_CAST_PTR (ACPI_HANDLE
, Info
.GpeDevice
);
1068 return_ACPI_STATUS (Info
.Status
);
1071 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice
)
1074 /*******************************************************************************
1076 * FUNCTION: AcpiEvGetGpeDevice
1078 * PARAMETERS: GPE_WALK_CALLBACK
1082 * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
1083 * block device. NULL if the GPE is one of the FADT-defined GPEs.
1085 ******************************************************************************/
1088 AcpiEvGetGpeDevice (
1089 ACPI_GPE_XRUPT_INFO
*GpeXruptInfo
,
1090 ACPI_GPE_BLOCK_INFO
*GpeBlock
,
1093 ACPI_GPE_DEVICE_INFO
*Info
= Context
;
1096 /* Increment Index by the number of GPEs in this block */
1098 Info
->NextBlockBaseIndex
+= GpeBlock
->GpeCount
;
1100 if (Info
->Index
< Info
->NextBlockBaseIndex
)
1103 * The GPE index is within this block, get the node. Leave the node
1104 * NULL for the FADT-defined GPEs
1106 if ((GpeBlock
->Node
)->Type
== ACPI_TYPE_DEVICE
)
1108 Info
->GpeDevice
= GpeBlock
->Node
;
1111 Info
->Status
= AE_OK
;
1112 return (AE_CTRL_END
);
1119 /******************************************************************************
1121 * FUNCTION: AcpiDisableAllGpes
1127 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
1129 ******************************************************************************/
1132 AcpiDisableAllGpes (
1138 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes
);
1141 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
1142 if (ACPI_FAILURE (Status
))
1144 return_ACPI_STATUS (Status
);
1147 Status
= AcpiHwDisableAllGpes ();
1148 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
1150 return_ACPI_STATUS (Status
);
1154 /******************************************************************************
1156 * FUNCTION: AcpiEnableAllRuntimeGpes
1162 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
1164 ******************************************************************************/
1167 AcpiEnableAllRuntimeGpes (
1173 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes
);
1176 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
1177 if (ACPI_FAILURE (Status
))
1179 return_ACPI_STATUS (Status
);
1182 Status
= AcpiHwEnableAllRuntimeGpes ();
1183 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
1185 return_ACPI_STATUS (Status
);