xref: /freebsd-src/sys/contrib/dev/acpica/components/hardware/hwgpe.c (revision 804fe2660352e090f4481f2c1d646b508859e79a)
1a159c266SJung-uk Kim /******************************************************************************
2a159c266SJung-uk Kim  *
3a159c266SJung-uk Kim  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
4a159c266SJung-uk Kim  *
5a159c266SJung-uk Kim  *****************************************************************************/
6a159c266SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
11*804fe266SJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12a159c266SJung-uk Kim  * All rights reserved.
13a159c266SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119a159c266SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120a159c266SJung-uk Kim  * modification, are permitted provided that the following conditions
121a159c266SJung-uk Kim  * are met:
122a159c266SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123a159c266SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124a159c266SJung-uk Kim  *    without modification.
125a159c266SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126a159c266SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127a159c266SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128a159c266SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129a159c266SJung-uk Kim  *    binary redistribution.
130a159c266SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131a159c266SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132a159c266SJung-uk Kim  *    from this software without specific prior written permission.
133a159c266SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147a159c266SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148a159c266SJung-uk Kim  * Software Foundation.
149a159c266SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151a159c266SJung-uk Kim 
152a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
153a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
154a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acevents.h>
155a159c266SJung-uk Kim 
156a159c266SJung-uk Kim #define _COMPONENT          ACPI_HARDWARE
157a159c266SJung-uk Kim         ACPI_MODULE_NAME    ("hwgpe")
158a159c266SJung-uk Kim 
159a159c266SJung-uk Kim #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
160a159c266SJung-uk Kim 
161a159c266SJung-uk Kim /* Local prototypes */
162a159c266SJung-uk Kim 
163a159c266SJung-uk Kim static ACPI_STATUS
164a159c266SJung-uk Kim AcpiHwEnableWakeupGpeBlock (
165a159c266SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
166a159c266SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
167a159c266SJung-uk Kim     void                    *Context);
168a159c266SJung-uk Kim 
1691c0e1b6dSJung-uk Kim static ACPI_STATUS
1701c0e1b6dSJung-uk Kim AcpiHwGpeEnableWrite (
1711c0e1b6dSJung-uk Kim     UINT8                   EnableMask,
1721c0e1b6dSJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo);
1731c0e1b6dSJung-uk Kim 
174a159c266SJung-uk Kim 
175a159c266SJung-uk Kim /******************************************************************************
176a159c266SJung-uk Kim  *
177a159c266SJung-uk Kim  * FUNCTION:    AcpiHwGetGpeRegisterBit
178a159c266SJung-uk Kim  *
179a159c266SJung-uk Kim  * PARAMETERS:  GpeEventInfo        - Info block for the GPE
180a159c266SJung-uk Kim  *
181a159c266SJung-uk Kim  * RETURN:      Register mask with a one in the GPE bit position
182a159c266SJung-uk Kim  *
183a159c266SJung-uk Kim  * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
184a159c266SJung-uk Kim  *              correct position for the input GPE.
185a159c266SJung-uk Kim  *
186a159c266SJung-uk Kim  ******************************************************************************/
187a159c266SJung-uk Kim 
188a159c266SJung-uk Kim UINT32
189a159c266SJung-uk Kim AcpiHwGetGpeRegisterBit (
1901df130f1SJung-uk Kim     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
191a159c266SJung-uk Kim {
192a159c266SJung-uk Kim 
193a159c266SJung-uk Kim     return ((UINT32) 1 <<
1941df130f1SJung-uk Kim         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
195a159c266SJung-uk Kim }
196a159c266SJung-uk Kim 
197a159c266SJung-uk Kim 
198a159c266SJung-uk Kim /******************************************************************************
199a159c266SJung-uk Kim  *
200a159c266SJung-uk Kim  * FUNCTION:    AcpiHwLowSetGpe
201a159c266SJung-uk Kim  *
202a159c266SJung-uk Kim  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
203a159c266SJung-uk Kim  *              Action              - Enable or disable
204a159c266SJung-uk Kim  *
205a159c266SJung-uk Kim  * RETURN:      Status
206a159c266SJung-uk Kim  *
207a159c266SJung-uk Kim  * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
2085ef50723SJung-uk Kim  *              The EnableMask field of the involved GPE register must be
2095ef50723SJung-uk Kim  *              updated by the caller if necessary.
210a159c266SJung-uk Kim  *
211a159c266SJung-uk Kim  ******************************************************************************/
212a159c266SJung-uk Kim 
213a159c266SJung-uk Kim ACPI_STATUS
214a159c266SJung-uk Kim AcpiHwLowSetGpe (
215a159c266SJung-uk Kim     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
216a159c266SJung-uk Kim     UINT32                  Action)
217a159c266SJung-uk Kim {
218a159c266SJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
219493deb39SJung-uk Kim     ACPI_STATUS             Status = AE_OK;
2202f6a1a81SJung-uk Kim     UINT64                  EnableMask;
221a159c266SJung-uk Kim     UINT32                  RegisterBit;
222a159c266SJung-uk Kim 
223a159c266SJung-uk Kim 
224a159c266SJung-uk Kim     ACPI_FUNCTION_ENTRY ();
225a159c266SJung-uk Kim 
226a159c266SJung-uk Kim 
227a159c266SJung-uk Kim     /* Get the info block for the entire GPE register */
228a159c266SJung-uk Kim 
229a159c266SJung-uk Kim     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
230a159c266SJung-uk Kim     if (!GpeRegisterInfo)
231a159c266SJung-uk Kim     {
232a159c266SJung-uk Kim         return (AE_NOT_EXIST);
233a159c266SJung-uk Kim     }
234a159c266SJung-uk Kim 
235a159c266SJung-uk Kim     /* Get current value of the enable register that contains this GPE */
236a159c266SJung-uk Kim 
237a159c266SJung-uk Kim     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
238a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
239a159c266SJung-uk Kim     {
240a159c266SJung-uk Kim         return (Status);
241a159c266SJung-uk Kim     }
242a159c266SJung-uk Kim 
243a159c266SJung-uk Kim     /* Set or clear just the bit that corresponds to this GPE */
244a159c266SJung-uk Kim 
2451df130f1SJung-uk Kim     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
2465ef50723SJung-uk Kim     switch (Action)
247a159c266SJung-uk Kim     {
248a159c266SJung-uk Kim     case ACPI_GPE_CONDITIONAL_ENABLE:
249a159c266SJung-uk Kim 
2501c0e1b6dSJung-uk Kim         /* Only enable if the corresponding EnableMask bit is set */
251a159c266SJung-uk Kim 
2521c0e1b6dSJung-uk Kim         if (!(RegisterBit & GpeRegisterInfo->EnableMask))
253a159c266SJung-uk Kim         {
254a159c266SJung-uk Kim             return (AE_BAD_PARAMETER);
255a159c266SJung-uk Kim         }
256a159c266SJung-uk Kim 
257385fb5d9SJung-uk Kim         ACPI_FALLTHROUGH;
258a159c266SJung-uk Kim 
259a159c266SJung-uk Kim     case ACPI_GPE_ENABLE:
260a9d8d09cSJung-uk Kim 
261a159c266SJung-uk Kim         ACPI_SET_BIT (EnableMask, RegisterBit);
262a159c266SJung-uk Kim         break;
263a159c266SJung-uk Kim 
264a159c266SJung-uk Kim     case ACPI_GPE_DISABLE:
265a9d8d09cSJung-uk Kim 
266a159c266SJung-uk Kim         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
267a159c266SJung-uk Kim         break;
268a159c266SJung-uk Kim 
269a159c266SJung-uk Kim     default:
270a9d8d09cSJung-uk Kim 
271efcc2a30SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
272a159c266SJung-uk Kim         return (AE_BAD_PARAMETER);
273a159c266SJung-uk Kim     }
274a159c266SJung-uk Kim 
275493deb39SJung-uk Kim     if (!(RegisterBit & GpeRegisterInfo->MaskForRun))
276493deb39SJung-uk Kim     {
277a159c266SJung-uk Kim         /* Write the updated enable mask */
278a159c266SJung-uk Kim 
279a159c266SJung-uk Kim         Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
280493deb39SJung-uk Kim     }
281a159c266SJung-uk Kim     return (Status);
282a159c266SJung-uk Kim }
283a159c266SJung-uk Kim 
284a159c266SJung-uk Kim 
285a159c266SJung-uk Kim /******************************************************************************
286a159c266SJung-uk Kim  *
287a159c266SJung-uk Kim  * FUNCTION:    AcpiHwClearGpe
288a159c266SJung-uk Kim  *
289a159c266SJung-uk Kim  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
290a159c266SJung-uk Kim  *
291a159c266SJung-uk Kim  * RETURN:      Status
292a159c266SJung-uk Kim  *
293a159c266SJung-uk Kim  * DESCRIPTION: Clear the status bit for a single GPE.
294a159c266SJung-uk Kim  *
295a159c266SJung-uk Kim  ******************************************************************************/
296a159c266SJung-uk Kim 
297a159c266SJung-uk Kim ACPI_STATUS
298a159c266SJung-uk Kim AcpiHwClearGpe (
299a159c266SJung-uk Kim     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
300a159c266SJung-uk Kim {
301a159c266SJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
302a159c266SJung-uk Kim     ACPI_STATUS             Status;
303a159c266SJung-uk Kim     UINT32                  RegisterBit;
304a159c266SJung-uk Kim 
305a159c266SJung-uk Kim 
306a159c266SJung-uk Kim     ACPI_FUNCTION_ENTRY ();
307a159c266SJung-uk Kim 
308a159c266SJung-uk Kim     /* Get the info block for the entire GPE register */
309a159c266SJung-uk Kim 
310a159c266SJung-uk Kim     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
311a159c266SJung-uk Kim     if (!GpeRegisterInfo)
312a159c266SJung-uk Kim     {
313a159c266SJung-uk Kim         return (AE_NOT_EXIST);
314a159c266SJung-uk Kim     }
315a159c266SJung-uk Kim 
316a159c266SJung-uk Kim     /*
317a159c266SJung-uk Kim      * Write a one to the appropriate bit in the status register to
318a159c266SJung-uk Kim      * clear this GPE.
319a159c266SJung-uk Kim      */
3201df130f1SJung-uk Kim     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
321a159c266SJung-uk Kim 
322f8146b88SJung-uk Kim     Status = AcpiHwWrite (RegisterBit, &GpeRegisterInfo->StatusAddress);
323a159c266SJung-uk Kim     return (Status);
324a159c266SJung-uk Kim }
325a159c266SJung-uk Kim 
326a159c266SJung-uk Kim 
327a159c266SJung-uk Kim /******************************************************************************
328a159c266SJung-uk Kim  *
329a159c266SJung-uk Kim  * FUNCTION:    AcpiHwGetGpeStatus
330a159c266SJung-uk Kim  *
331a159c266SJung-uk Kim  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
332a159c266SJung-uk Kim  *              EventStatus         - Where the GPE status is returned
333a159c266SJung-uk Kim  *
334a159c266SJung-uk Kim  * RETURN:      Status
335a159c266SJung-uk Kim  *
336a159c266SJung-uk Kim  * DESCRIPTION: Return the status of a single GPE.
337a159c266SJung-uk Kim  *
338a159c266SJung-uk Kim  ******************************************************************************/
339a159c266SJung-uk Kim 
340a159c266SJung-uk Kim ACPI_STATUS
341a159c266SJung-uk Kim AcpiHwGetGpeStatus (
342a159c266SJung-uk Kim     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
343a159c266SJung-uk Kim     ACPI_EVENT_STATUS       *EventStatus)
344a159c266SJung-uk Kim {
3452f6a1a81SJung-uk Kim     UINT64                  InByte;
346a159c266SJung-uk Kim     UINT32                  RegisterBit;
347a159c266SJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
348a159c266SJung-uk Kim     ACPI_EVENT_STATUS       LocalEventStatus = 0;
349a159c266SJung-uk Kim     ACPI_STATUS             Status;
350a159c266SJung-uk Kim 
351a159c266SJung-uk Kim 
352a159c266SJung-uk Kim     ACPI_FUNCTION_ENTRY ();
353a159c266SJung-uk Kim 
354a159c266SJung-uk Kim 
355a159c266SJung-uk Kim     if (!EventStatus)
356a159c266SJung-uk Kim     {
357a159c266SJung-uk Kim         return (AE_BAD_PARAMETER);
358a159c266SJung-uk Kim     }
359a159c266SJung-uk Kim 
360313a0c13SJung-uk Kim     /* GPE currently handled? */
361313a0c13SJung-uk Kim 
3621c0e1b6dSJung-uk Kim     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) !=
363313a0c13SJung-uk Kim         ACPI_GPE_DISPATCH_NONE)
364313a0c13SJung-uk Kim     {
365313a0c13SJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
366313a0c13SJung-uk Kim     }
367313a0c13SJung-uk Kim 
368a159c266SJung-uk Kim     /* Get the info block for the entire GPE register */
369a159c266SJung-uk Kim 
370a159c266SJung-uk Kim     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
371a159c266SJung-uk Kim 
372a159c266SJung-uk Kim     /* Get the register bitmask for this GPE */
373a159c266SJung-uk Kim 
3741df130f1SJung-uk Kim     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
375a159c266SJung-uk Kim 
376a159c266SJung-uk Kim     /* GPE currently enabled? (enabled for runtime?) */
377a159c266SJung-uk Kim 
378a159c266SJung-uk Kim     if (RegisterBit & GpeRegisterInfo->EnableForRun)
379a159c266SJung-uk Kim     {
380a159c266SJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
381a159c266SJung-uk Kim     }
382a159c266SJung-uk Kim 
383493deb39SJung-uk Kim     /* GPE currently masked? (masked for runtime?) */
384493deb39SJung-uk Kim 
385493deb39SJung-uk Kim     if (RegisterBit & GpeRegisterInfo->MaskForRun)
386493deb39SJung-uk Kim     {
387493deb39SJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_MASKED;
388493deb39SJung-uk Kim     }
389493deb39SJung-uk Kim 
390a159c266SJung-uk Kim     /* GPE enabled for wake? */
391a159c266SJung-uk Kim 
392a159c266SJung-uk Kim     if (RegisterBit & GpeRegisterInfo->EnableForWake)
393a159c266SJung-uk Kim     {
394a159c266SJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
395a159c266SJung-uk Kim     }
396a159c266SJung-uk Kim 
3977cf3e94aSJung-uk Kim     /* GPE currently enabled (enable bit == 1)? */
3987cf3e94aSJung-uk Kim 
3997cf3e94aSJung-uk Kim     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->EnableAddress);
4007cf3e94aSJung-uk Kim     if (ACPI_FAILURE (Status))
4017cf3e94aSJung-uk Kim     {
4027cf3e94aSJung-uk Kim         return (Status);
4037cf3e94aSJung-uk Kim     }
4047cf3e94aSJung-uk Kim 
4057cf3e94aSJung-uk Kim     if (RegisterBit & InByte)
4067cf3e94aSJung-uk Kim     {
4077cf3e94aSJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLE_SET;
4087cf3e94aSJung-uk Kim     }
4097cf3e94aSJung-uk Kim 
410a159c266SJung-uk Kim     /* GPE currently active (status bit == 1)? */
411a159c266SJung-uk Kim 
412a159c266SJung-uk Kim     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
413a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
414a159c266SJung-uk Kim     {
415a159c266SJung-uk Kim         return (Status);
416a159c266SJung-uk Kim     }
417a159c266SJung-uk Kim 
418a159c266SJung-uk Kim     if (RegisterBit & InByte)
419a159c266SJung-uk Kim     {
4207cf3e94aSJung-uk Kim         LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
421a159c266SJung-uk Kim     }
422a159c266SJung-uk Kim 
423a159c266SJung-uk Kim     /* Set return value */
424a159c266SJung-uk Kim 
425a159c266SJung-uk Kim     (*EventStatus) = LocalEventStatus;
426a159c266SJung-uk Kim     return (AE_OK);
427a159c266SJung-uk Kim }
428a159c266SJung-uk Kim 
429a159c266SJung-uk Kim 
430a159c266SJung-uk Kim /******************************************************************************
431a159c266SJung-uk Kim  *
4321c0e1b6dSJung-uk Kim  * FUNCTION:    AcpiHwGpeEnableWrite
4331c0e1b6dSJung-uk Kim  *
4341c0e1b6dSJung-uk Kim  * PARAMETERS:  EnableMask          - Bit mask to write to the GPE register
4351c0e1b6dSJung-uk Kim  *              GpeRegisterInfo     - Gpe Register info
4361c0e1b6dSJung-uk Kim  *
4371c0e1b6dSJung-uk Kim  * RETURN:      Status
4381c0e1b6dSJung-uk Kim  *
4391c0e1b6dSJung-uk Kim  * DESCRIPTION: Write the enable mask byte to the given GPE register.
4401c0e1b6dSJung-uk Kim  *
4411c0e1b6dSJung-uk Kim  ******************************************************************************/
4421c0e1b6dSJung-uk Kim 
4431c0e1b6dSJung-uk Kim static ACPI_STATUS
4441c0e1b6dSJung-uk Kim AcpiHwGpeEnableWrite (
4451c0e1b6dSJung-uk Kim     UINT8                   EnableMask,
4461c0e1b6dSJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo)
4471c0e1b6dSJung-uk Kim {
4481c0e1b6dSJung-uk Kim     ACPI_STATUS             Status;
4491c0e1b6dSJung-uk Kim 
4501c0e1b6dSJung-uk Kim 
4511c0e1b6dSJung-uk Kim     GpeRegisterInfo->EnableMask = EnableMask;
4521c0e1b6dSJung-uk Kim 
453f8146b88SJung-uk Kim     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
4541c0e1b6dSJung-uk Kim     return (Status);
4551c0e1b6dSJung-uk Kim }
4561c0e1b6dSJung-uk Kim 
4571c0e1b6dSJung-uk Kim 
4581c0e1b6dSJung-uk Kim /******************************************************************************
4591c0e1b6dSJung-uk Kim  *
460a159c266SJung-uk Kim  * FUNCTION:    AcpiHwDisableGpeBlock
461a159c266SJung-uk Kim  *
462a159c266SJung-uk Kim  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
463a159c266SJung-uk Kim  *              GpeBlock            - Gpe Block info
464a159c266SJung-uk Kim  *
465a159c266SJung-uk Kim  * RETURN:      Status
466a159c266SJung-uk Kim  *
467a159c266SJung-uk Kim  * DESCRIPTION: Disable all GPEs within a single GPE block
468a159c266SJung-uk Kim  *
469a159c266SJung-uk Kim  ******************************************************************************/
470a159c266SJung-uk Kim 
471a159c266SJung-uk Kim ACPI_STATUS
472a159c266SJung-uk Kim AcpiHwDisableGpeBlock (
473a159c266SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
474a159c266SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
475a159c266SJung-uk Kim     void                    *Context)
476a159c266SJung-uk Kim {
477a159c266SJung-uk Kim     UINT32                  i;
478a159c266SJung-uk Kim     ACPI_STATUS             Status;
479a159c266SJung-uk Kim 
480a159c266SJung-uk Kim 
481a159c266SJung-uk Kim     /* Examine each GPE Register within the block */
482a159c266SJung-uk Kim 
483a159c266SJung-uk Kim     for (i = 0; i < GpeBlock->RegisterCount; i++)
484a159c266SJung-uk Kim     {
485a159c266SJung-uk Kim         /* Disable all GPEs in this register */
486a159c266SJung-uk Kim 
4871c0e1b6dSJung-uk Kim         Status = AcpiHwGpeEnableWrite (0x00, &GpeBlock->RegisterInfo[i]);
488a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
489a159c266SJung-uk Kim         {
490a159c266SJung-uk Kim             return (Status);
491a159c266SJung-uk Kim         }
492a159c266SJung-uk Kim     }
493a159c266SJung-uk Kim 
494a159c266SJung-uk Kim     return (AE_OK);
495a159c266SJung-uk Kim }
496a159c266SJung-uk Kim 
497a159c266SJung-uk Kim 
498a159c266SJung-uk Kim /******************************************************************************
499a159c266SJung-uk Kim  *
500a159c266SJung-uk Kim  * FUNCTION:    AcpiHwClearGpeBlock
501a159c266SJung-uk Kim  *
502a159c266SJung-uk Kim  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
503a159c266SJung-uk Kim  *              GpeBlock            - Gpe Block info
504a159c266SJung-uk Kim  *
505a159c266SJung-uk Kim  * RETURN:      Status
506a159c266SJung-uk Kim  *
507a159c266SJung-uk Kim  * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
508a159c266SJung-uk Kim  *
509a159c266SJung-uk Kim  ******************************************************************************/
510a159c266SJung-uk Kim 
511a159c266SJung-uk Kim ACPI_STATUS
512a159c266SJung-uk Kim AcpiHwClearGpeBlock (
513a159c266SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
514a159c266SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
515a159c266SJung-uk Kim     void                    *Context)
516a159c266SJung-uk Kim {
517a159c266SJung-uk Kim     UINT32                  i;
518a159c266SJung-uk Kim     ACPI_STATUS             Status;
519a159c266SJung-uk Kim 
520a159c266SJung-uk Kim 
521a159c266SJung-uk Kim     /* Examine each GPE Register within the block */
522a159c266SJung-uk Kim 
523a159c266SJung-uk Kim     for (i = 0; i < GpeBlock->RegisterCount; i++)
524a159c266SJung-uk Kim     {
525a159c266SJung-uk Kim         /* Clear status on all GPEs in this register */
526a159c266SJung-uk Kim 
527a159c266SJung-uk Kim         Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
528a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
529a159c266SJung-uk Kim         {
530a159c266SJung-uk Kim             return (Status);
531a159c266SJung-uk Kim         }
532a159c266SJung-uk Kim     }
533a159c266SJung-uk Kim 
534a159c266SJung-uk Kim     return (AE_OK);
535a159c266SJung-uk Kim }
536a159c266SJung-uk Kim 
537a159c266SJung-uk Kim 
538a159c266SJung-uk Kim /******************************************************************************
539a159c266SJung-uk Kim  *
540a159c266SJung-uk Kim  * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
541a159c266SJung-uk Kim  *
542a159c266SJung-uk Kim  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
543a159c266SJung-uk Kim  *              GpeBlock            - Gpe Block info
544a159c266SJung-uk Kim  *
545a159c266SJung-uk Kim  * RETURN:      Status
546a159c266SJung-uk Kim  *
547a159c266SJung-uk Kim  * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
548a159c266SJung-uk Kim  *              combination wake/run GPEs.
549a159c266SJung-uk Kim  *
550a159c266SJung-uk Kim  ******************************************************************************/
551a159c266SJung-uk Kim 
552a159c266SJung-uk Kim ACPI_STATUS
553a159c266SJung-uk Kim AcpiHwEnableRuntimeGpeBlock (
554a159c266SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
555a159c266SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
556a159c266SJung-uk Kim     void                    *Context)
557a159c266SJung-uk Kim {
558a159c266SJung-uk Kim     UINT32                  i;
559a159c266SJung-uk Kim     ACPI_STATUS             Status;
5601c0e1b6dSJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
561493deb39SJung-uk Kim     UINT8                   EnableMask;
562a159c266SJung-uk Kim 
563a159c266SJung-uk Kim 
564a159c266SJung-uk Kim     /* NOTE: assumes that all GPEs are currently disabled */
565a159c266SJung-uk Kim 
566a159c266SJung-uk Kim     /* Examine each GPE Register within the block */
567a159c266SJung-uk Kim 
568a159c266SJung-uk Kim     for (i = 0; i < GpeBlock->RegisterCount; i++)
569a159c266SJung-uk Kim     {
5701c0e1b6dSJung-uk Kim         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
5711c0e1b6dSJung-uk Kim         if (!GpeRegisterInfo->EnableForRun)
572a159c266SJung-uk Kim         {
573a159c266SJung-uk Kim             continue;
574a159c266SJung-uk Kim         }
575a159c266SJung-uk Kim 
576a159c266SJung-uk Kim         /* Enable all "runtime" GPEs in this register */
577a159c266SJung-uk Kim 
578493deb39SJung-uk Kim         EnableMask = GpeRegisterInfo->EnableForRun &
579493deb39SJung-uk Kim             ~GpeRegisterInfo->MaskForRun;
580493deb39SJung-uk Kim         Status = AcpiHwGpeEnableWrite (EnableMask, GpeRegisterInfo);
581a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
582a159c266SJung-uk Kim         {
583a159c266SJung-uk Kim             return (Status);
584a159c266SJung-uk Kim         }
585a159c266SJung-uk Kim     }
586a159c266SJung-uk Kim 
587a159c266SJung-uk Kim     return (AE_OK);
588a159c266SJung-uk Kim }
589a159c266SJung-uk Kim 
590a159c266SJung-uk Kim 
591a159c266SJung-uk Kim /******************************************************************************
592a159c266SJung-uk Kim  *
593a159c266SJung-uk Kim  * FUNCTION:    AcpiHwEnableWakeupGpeBlock
594a159c266SJung-uk Kim  *
595a159c266SJung-uk Kim  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
596a159c266SJung-uk Kim  *              GpeBlock            - Gpe Block info
597a159c266SJung-uk Kim  *
598a159c266SJung-uk Kim  * RETURN:      Status
599a159c266SJung-uk Kim  *
600a159c266SJung-uk Kim  * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
601a159c266SJung-uk Kim  *              combination wake/run GPEs.
602a159c266SJung-uk Kim  *
603a159c266SJung-uk Kim  ******************************************************************************/
604a159c266SJung-uk Kim 
605a159c266SJung-uk Kim static ACPI_STATUS
606a159c266SJung-uk Kim AcpiHwEnableWakeupGpeBlock (
607a159c266SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
608a159c266SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
609a159c266SJung-uk Kim     void                    *Context)
610a159c266SJung-uk Kim {
611a159c266SJung-uk Kim     UINT32                  i;
612a159c266SJung-uk Kim     ACPI_STATUS             Status;
6131c0e1b6dSJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
614a159c266SJung-uk Kim 
615a159c266SJung-uk Kim 
616a159c266SJung-uk Kim     /* Examine each GPE Register within the block */
617a159c266SJung-uk Kim 
618a159c266SJung-uk Kim     for (i = 0; i < GpeBlock->RegisterCount; i++)
619a159c266SJung-uk Kim     {
6201c0e1b6dSJung-uk Kim         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
621a159c266SJung-uk Kim 
6221c0e1b6dSJung-uk Kim         /*
6231c0e1b6dSJung-uk Kim          * Enable all "wake" GPEs in this register and disable the
6241c0e1b6dSJung-uk Kim          * remaining ones.
6251c0e1b6dSJung-uk Kim          */
6261c0e1b6dSJung-uk Kim         Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake,
6271c0e1b6dSJung-uk Kim             GpeRegisterInfo);
628a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
629a159c266SJung-uk Kim         {
630a159c266SJung-uk Kim             return (Status);
631a159c266SJung-uk Kim         }
632a159c266SJung-uk Kim     }
633a159c266SJung-uk Kim 
634a159c266SJung-uk Kim     return (AE_OK);
635a159c266SJung-uk Kim }
636a159c266SJung-uk Kim 
637a159c266SJung-uk Kim 
638a159c266SJung-uk Kim /******************************************************************************
639a159c266SJung-uk Kim  *
640ec0234b4SJung-uk Kim  * FUNCTION:    AcpiHwGetGpeBlockStatus
641ec0234b4SJung-uk Kim  *
642ec0234b4SJung-uk Kim  * PARAMETERS:  GpeXruptInfo    - GPE Interrupt info
643ec0234b4SJung-uk Kim  *              GpeBlock        - Gpe Block info
644ec0234b4SJung-uk Kim  *
645ec0234b4SJung-uk Kim  * RETURN:      Success
646ec0234b4SJung-uk Kim  *
647ec0234b4SJung-uk Kim  * DESCRIPTION: Produce a combined GPE status bits mask for the given block.
648ec0234b4SJung-uk Kim  *
649ec0234b4SJung-uk Kim  ******************************************************************************/
650ec0234b4SJung-uk Kim 
651ec0234b4SJung-uk Kim static ACPI_STATUS
652ec0234b4SJung-uk Kim AcpiHwGetGpeBlockStatus(
653ec0234b4SJung-uk Kim     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
654ec0234b4SJung-uk Kim     ACPI_GPE_BLOCK_INFO     *GpeBlock,
655ec0234b4SJung-uk Kim     void *RetPtr)
656ec0234b4SJung-uk Kim {
657ec0234b4SJung-uk Kim     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
658ec0234b4SJung-uk Kim     UINT64                  InEnable;
659ec0234b4SJung-uk Kim     UINT64                  InStatus;
660ec0234b4SJung-uk Kim     ACPI_STATUS             Status;
661ec0234b4SJung-uk Kim     UINT8                   *Ret = RetPtr;
662ec0234b4SJung-uk Kim     UINT32                  i;
663ec0234b4SJung-uk Kim 
664ec0234b4SJung-uk Kim 
665ec0234b4SJung-uk Kim     /* Examine each GPE Register within the block */
666ec0234b4SJung-uk Kim 
667ec0234b4SJung-uk Kim     for (i = 0; i < GpeBlock->RegisterCount; i++)
668ec0234b4SJung-uk Kim     {
669ec0234b4SJung-uk Kim         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
670ec0234b4SJung-uk Kim 
671ec0234b4SJung-uk Kim         Status = AcpiHwRead (&InEnable, &GpeRegisterInfo->EnableAddress);
672ec0234b4SJung-uk Kim         if (ACPI_FAILURE (Status))
673ec0234b4SJung-uk Kim         {
674ec0234b4SJung-uk Kim             continue;
675ec0234b4SJung-uk Kim         }
676ec0234b4SJung-uk Kim 
677ec0234b4SJung-uk Kim         Status = AcpiHwRead (&InStatus, &GpeRegisterInfo->StatusAddress);
678ec0234b4SJung-uk Kim         if (ACPI_FAILURE (Status))
679ec0234b4SJung-uk Kim         {
680ec0234b4SJung-uk Kim             continue;
681ec0234b4SJung-uk Kim         }
682ec0234b4SJung-uk Kim 
683ec0234b4SJung-uk Kim         *Ret |= InEnable & InStatus;
684ec0234b4SJung-uk Kim     }
685ec0234b4SJung-uk Kim 
686ec0234b4SJung-uk Kim     return (AE_OK);
687ec0234b4SJung-uk Kim }
688ec0234b4SJung-uk Kim 
689ec0234b4SJung-uk Kim 
690ec0234b4SJung-uk Kim /******************************************************************************
691ec0234b4SJung-uk Kim  *
692a159c266SJung-uk Kim  * FUNCTION:    AcpiHwDisableAllGpes
693a159c266SJung-uk Kim  *
694a159c266SJung-uk Kim  * PARAMETERS:  None
695a159c266SJung-uk Kim  *
696a159c266SJung-uk Kim  * RETURN:      Status
697a159c266SJung-uk Kim  *
698a159c266SJung-uk Kim  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
699a159c266SJung-uk Kim  *
700a159c266SJung-uk Kim  ******************************************************************************/
701a159c266SJung-uk Kim 
702a159c266SJung-uk Kim ACPI_STATUS
703a159c266SJung-uk Kim AcpiHwDisableAllGpes (
704a159c266SJung-uk Kim     void)
705a159c266SJung-uk Kim {
706a159c266SJung-uk Kim     ACPI_STATUS             Status;
707a159c266SJung-uk Kim 
708a159c266SJung-uk Kim 
709a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (HwDisableAllGpes);
710a159c266SJung-uk Kim 
711a159c266SJung-uk Kim 
712a159c266SJung-uk Kim     Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
713a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
714a159c266SJung-uk Kim }
715a159c266SJung-uk Kim 
716a159c266SJung-uk Kim 
717a159c266SJung-uk Kim /******************************************************************************
718a159c266SJung-uk Kim  *
719a159c266SJung-uk Kim  * FUNCTION:    AcpiHwEnableAllRuntimeGpes
720a159c266SJung-uk Kim  *
721a159c266SJung-uk Kim  * PARAMETERS:  None
722a159c266SJung-uk Kim  *
723a159c266SJung-uk Kim  * RETURN:      Status
724a159c266SJung-uk Kim  *
725a159c266SJung-uk Kim  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
726a159c266SJung-uk Kim  *
727a159c266SJung-uk Kim  ******************************************************************************/
728a159c266SJung-uk Kim 
729a159c266SJung-uk Kim ACPI_STATUS
730a159c266SJung-uk Kim AcpiHwEnableAllRuntimeGpes (
731a159c266SJung-uk Kim     void)
732a159c266SJung-uk Kim {
733a159c266SJung-uk Kim     ACPI_STATUS             Status;
734a159c266SJung-uk Kim 
735a159c266SJung-uk Kim 
736a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
737a159c266SJung-uk Kim 
738a159c266SJung-uk Kim 
739a159c266SJung-uk Kim     Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
740a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
741a159c266SJung-uk Kim }
742a159c266SJung-uk Kim 
743a159c266SJung-uk Kim 
744a159c266SJung-uk Kim /******************************************************************************
745a159c266SJung-uk Kim  *
746a159c266SJung-uk Kim  * FUNCTION:    AcpiHwEnableAllWakeupGpes
747a159c266SJung-uk Kim  *
748a159c266SJung-uk Kim  * PARAMETERS:  None
749a159c266SJung-uk Kim  *
750a159c266SJung-uk Kim  * RETURN:      Status
751a159c266SJung-uk Kim  *
752a159c266SJung-uk Kim  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
753a159c266SJung-uk Kim  *
754a159c266SJung-uk Kim  ******************************************************************************/
755a159c266SJung-uk Kim 
756a159c266SJung-uk Kim ACPI_STATUS
757a159c266SJung-uk Kim AcpiHwEnableAllWakeupGpes (
758a159c266SJung-uk Kim     void)
759a159c266SJung-uk Kim {
760a159c266SJung-uk Kim     ACPI_STATUS             Status;
761a159c266SJung-uk Kim 
762a159c266SJung-uk Kim 
763a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
764a159c266SJung-uk Kim 
765a159c266SJung-uk Kim 
766a159c266SJung-uk Kim     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
767a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
768a159c266SJung-uk Kim }
769a159c266SJung-uk Kim 
770ec0234b4SJung-uk Kim 
771ec0234b4SJung-uk Kim /******************************************************************************
772ec0234b4SJung-uk Kim  *
773ec0234b4SJung-uk Kim  * FUNCTION:    AcpiHwCheckAllGpes
774ec0234b4SJung-uk Kim  *
775ec0234b4SJung-uk Kim  * PARAMETERS:  None
776ec0234b4SJung-uk Kim  *
777ec0234b4SJung-uk Kim  * RETURN:      Combined status of all GPEs
778ec0234b4SJung-uk Kim  *
779ec0234b4SJung-uk Kim  * DESCRIPTION: Check all enabled GPEs in all GPE blocks and return TRUE if the
780ec0234b4SJung-uk Kim  *              status bit is set for at least one of them of FALSE otherwise.
781ec0234b4SJung-uk Kim  *
782ec0234b4SJung-uk Kim  ******************************************************************************/
783ec0234b4SJung-uk Kim 
784ec0234b4SJung-uk Kim UINT8
785ec0234b4SJung-uk Kim AcpiHwCheckAllGpes (
786ec0234b4SJung-uk Kim     void)
787ec0234b4SJung-uk Kim {
788ec0234b4SJung-uk Kim     UINT8                      Ret = 0;
789ec0234b4SJung-uk Kim 
790ec0234b4SJung-uk Kim 
791ec0234b4SJung-uk Kim     ACPI_FUNCTION_TRACE (AcpiHwCheckAllGpes);
792ec0234b4SJung-uk Kim 
793ec0234b4SJung-uk Kim     (void) AcpiEvWalkGpeList (AcpiHwGetGpeBlockStatus, &Ret);
794ec0234b4SJung-uk Kim     return (Ret != 0);
795ec0234b4SJung-uk Kim }
796ec0234b4SJung-uk Kim 
797a159c266SJung-uk Kim #endif /* !ACPI_REDUCED_HARDWARE */
798