hwgpe.c revision 117521
171867Smsmith
267754Smsmith/******************************************************************************
367754Smsmith *
467754Smsmith * Module Name: hwgpe - Low level GPE enable/disable/clear functions
5117521Snjl *              $Revision: 53 $
667754Smsmith *
767754Smsmith *****************************************************************************/
867754Smsmith
967754Smsmith/******************************************************************************
1067754Smsmith *
1167754Smsmith * 1. Copyright Notice
1267754Smsmith *
13114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
1470243Smsmith * All rights reserved.
1567754Smsmith *
1667754Smsmith * 2. License
1767754Smsmith *
1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1967754Smsmith * rights.  You may have additional license terms from the party that provided
2067754Smsmith * you this software, covering your right to use that party's intellectual
2167754Smsmith * property rights.
2267754Smsmith *
2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2867754Smsmith * Code in any form, with the right to sublicense such rights; and
2967754Smsmith *
3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3167754Smsmith * license (with the right to sublicense), under only those claims of Intel
3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3567754Smsmith * license, and in no event shall the patent license extend to any additions
3667754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3767754Smsmith * is granted directly or by implication, estoppel or otherwise;
3867754Smsmith *
3967754Smsmith * The above copyright and patent license is granted only if the following
4067754Smsmith * conditions are met:
4167754Smsmith *
4267754Smsmith * 3. Conditions
4367754Smsmith *
4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4567754Smsmith * Redistribution of source code of any substantial portion of the Covered
4667754Smsmith * Code or modification with rights to further distribute source must include
4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4867754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5167754Smsmith * Code and the date of any change.  Licensee must include in that file the
5267754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5367754Smsmith * must include a prominent statement that the modification is derived,
5467754Smsmith * directly or indirectly, from Original Intel Code.
5567754Smsmith *
5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5767754Smsmith * Redistribution of source code of any substantial portion of the Covered
5867754Smsmith * Code or modification without rights to further distribute source must
5967754Smsmith * include the following Disclaimer and Export Compliance provision in the
6067754Smsmith * documentation and/or other materials provided with distribution.  In
6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6367754Smsmith * license from Licensee to its licensee is limited to the intellectual
6467754Smsmith * property embodied in the software Licensee provides to its licensee, and
6567754Smsmith * not to intellectual property embodied in modifications its licensee may
6667754Smsmith * make.
6767754Smsmith *
6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the
7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7167754Smsmith * provision in the documentation and/or other materials provided with the
7267754Smsmith * distribution.
7367754Smsmith *
7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7567754Smsmith * Intel Code.
7667754Smsmith *
7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7967754Smsmith * other dealings in products derived from or relating to the Covered Code
8067754Smsmith * without prior written authorization from Intel.
8167754Smsmith *
8267754Smsmith * 4. Disclaimer and Export Compliance
8367754Smsmith *
8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8567754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9067754Smsmith * PARTICULAR PURPOSE.
9167754Smsmith *
9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9967754Smsmith * LIMITED REMEDY.
10067754Smsmith *
10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10267754Smsmith * software or system incorporating such software without first obtaining any
10367754Smsmith * required license or other approval from the U. S. Department of Commerce or
10467754Smsmith * any other agency or department of the United States Government.  In the
10567754Smsmith * event Licensee exports any such software from the United States or
10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10767754Smsmith * ensure that the distribution and export/re-export of the software is in
10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11167754Smsmith * software, or service, directly or indirectly, to any country for which the
11267754Smsmith * United States government or any agency thereof requires an export license,
11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11467754Smsmith * such license, approval or letter.
11567754Smsmith *
11667754Smsmith *****************************************************************************/
11767754Smsmith
11867754Smsmith#include "acpi.h"
11967754Smsmith#include "acevents.h"
12067754Smsmith
12177424Smsmith#define _COMPONENT          ACPI_HARDWARE
12291116Smsmith        ACPI_MODULE_NAME    ("hwgpe")
12367754Smsmith
12467754Smsmith
12567754Smsmith/******************************************************************************
12667754Smsmith *
12767754Smsmith * FUNCTION:    AcpiHwEnableGpe
12867754Smsmith *
12967754Smsmith * PARAMETERS:  GpeNumber       - The GPE
13067754Smsmith *
13167754Smsmith * RETURN:      None
13267754Smsmith *
13367754Smsmith * DESCRIPTION: Enable a single GPE.
13467754Smsmith *
13567754Smsmith ******************************************************************************/
13667754Smsmith
13799679SiwasakiACPI_STATUS
13867754SmsmithAcpiHwEnableGpe (
139114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
14067754Smsmith{
14180062Smsmith    UINT32                  InByte;
14299679Siwasaki    ACPI_STATUS             Status;
14367754Smsmith
14483174Smsmith
14591116Smsmith    ACPI_FUNCTION_ENTRY ();
14683174Smsmith
14783174Smsmith
14867754Smsmith    /*
14967754Smsmith     * Read the current value of the register, set the appropriate bit
15067754Smsmith     * to enable the GPE, and write out the new register.
15167754Smsmith     */
152102550Siwasaki    Status = AcpiHwLowLevelRead (8, &InByte,
153117521Snjl                    &GpeEventInfo->RegisterInfo->EnableAddress);
15499679Siwasaki    if (ACPI_FAILURE (Status))
15599679Siwasaki    {
15699679Siwasaki        return (Status);
15799679Siwasaki    }
15899679Siwasaki
159114237Snjl    /* Write with the new GPE bit enabled */
16099679Siwasaki
161114237Snjl    Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask),
162117521Snjl                    &GpeEventInfo->RegisterInfo->EnableAddress);
163114237Snjl
16499679Siwasaki    return (Status);
16567754Smsmith}
16667754Smsmith
16791116Smsmith
16884491Smsmith/******************************************************************************
16984491Smsmith *
17084491Smsmith * FUNCTION:    AcpiHwEnableGpeForWakeup
17184491Smsmith *
17284491Smsmith * PARAMETERS:  GpeNumber       - The GPE
17384491Smsmith *
17484491Smsmith * RETURN:      None
17584491Smsmith *
17684491Smsmith * DESCRIPTION: Keep track of which GPEs the OS has requested not be
17784491Smsmith *              disabled when going to sleep.
17884491Smsmith *
17984491Smsmith ******************************************************************************/
18067754Smsmith
18184491Smsmithvoid
18284491SmsmithAcpiHwEnableGpeForWakeup (
183114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
18484491Smsmith{
185114237Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
18684491Smsmith
18784491Smsmith
18891116Smsmith    ACPI_FUNCTION_ENTRY ();
18984491Smsmith
19084491Smsmith
191114237Snjl    /* Get the info block for the entire GPE register */
19284491Smsmith
193114237Snjl    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
194114237Snjl    if (!GpeRegisterInfo)
195114237Snjl    {
196114237Snjl        return;
197114237Snjl    }
19884491Smsmith
19984491Smsmith    /*
20084491Smsmith     * Set the bit so we will not disable this when sleeping
20184491Smsmith     */
202114237Snjl    GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask;
20384491Smsmith}
20484491Smsmith
20591116Smsmith
20667754Smsmith/******************************************************************************
20767754Smsmith *
20867754Smsmith * FUNCTION:    AcpiHwDisableGpe
20967754Smsmith *
21067754Smsmith * PARAMETERS:  GpeNumber       - The GPE
21167754Smsmith *
21267754Smsmith * RETURN:      None
21367754Smsmith *
21467754Smsmith * DESCRIPTION: Disable a single GPE.
21567754Smsmith *
21667754Smsmith ******************************************************************************/
21767754Smsmith
21899679SiwasakiACPI_STATUS
21967754SmsmithAcpiHwDisableGpe (
220114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
22167754Smsmith{
22280062Smsmith    UINT32                  InByte;
22399679Siwasaki    ACPI_STATUS             Status;
224114237Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
22567754Smsmith
22683174Smsmith
22791116Smsmith    ACPI_FUNCTION_ENTRY ();
22883174Smsmith
22983174Smsmith
230114237Snjl    /* Get the info block for the entire GPE register */
23167754Smsmith
232114237Snjl    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
233114237Snjl    if (!GpeRegisterInfo)
234114237Snjl    {
235114237Snjl        return (AE_BAD_PARAMETER);
236114237Snjl    }
23767754Smsmith
23867754Smsmith    /*
23967754Smsmith     * Read the current value of the register, clear the appropriate bit,
24067754Smsmith     * and write out the new register value to disable the GPE.
24167754Smsmith     */
24299679Siwasaki    Status = AcpiHwLowLevelRead (8, &InByte,
243117521Snjl                    &GpeRegisterInfo->EnableAddress);
24499679Siwasaki    if (ACPI_FAILURE (Status))
24599679Siwasaki    {
24699679Siwasaki        return (Status);
24799679Siwasaki    }
24884491Smsmith
249114237Snjl    /* Write the byte with this GPE bit cleared */
250114237Snjl
251114237Snjl    Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)),
252117521Snjl                    &GpeRegisterInfo->EnableAddress);
25399679Siwasaki    if (ACPI_FAILURE (Status))
25499679Siwasaki    {
25599679Siwasaki        return (Status);
25699679Siwasaki    }
25799679Siwasaki
258114237Snjl    AcpiHwDisableGpeForWakeup (GpeEventInfo);
25999679Siwasaki    return (AE_OK);
26067754Smsmith}
26167754Smsmith
26291116Smsmith
26384491Smsmith/******************************************************************************
26484491Smsmith *
26584491Smsmith * FUNCTION:    AcpiHwDisableGpeForWakeup
26684491Smsmith *
26784491Smsmith * PARAMETERS:  GpeNumber       - The GPE
26884491Smsmith *
26984491Smsmith * RETURN:      None
27084491Smsmith *
27184491Smsmith * DESCRIPTION: Keep track of which GPEs the OS has requested not be
27284491Smsmith *              disabled when going to sleep.
27384491Smsmith *
27484491Smsmith ******************************************************************************/
27567754Smsmith
27684491Smsmithvoid
27784491SmsmithAcpiHwDisableGpeForWakeup (
278114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
27984491Smsmith{
280114237Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
28184491Smsmith
28284491Smsmith
28391116Smsmith    ACPI_FUNCTION_ENTRY ();
28484491Smsmith
28584491Smsmith
286114237Snjl    /* Get the info block for the entire GPE register */
28784491Smsmith
288114237Snjl    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
289114237Snjl    if (!GpeRegisterInfo)
290114237Snjl    {
291114237Snjl        return;
292114237Snjl    }
29384491Smsmith
29484491Smsmith    /*
29584491Smsmith     * Clear the bit so we will disable this when sleeping
29684491Smsmith     */
297114237Snjl    GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask);
29884491Smsmith}
29984491Smsmith
30091116Smsmith
30167754Smsmith/******************************************************************************
30267754Smsmith *
30367754Smsmith * FUNCTION:    AcpiHwClearGpe
30467754Smsmith *
30567754Smsmith * PARAMETERS:  GpeNumber       - The GPE
30667754Smsmith *
30767754Smsmith * RETURN:      None
30867754Smsmith *
30967754Smsmith * DESCRIPTION: Clear a single GPE.
31067754Smsmith *
31167754Smsmith ******************************************************************************/
31267754Smsmith
31399679SiwasakiACPI_STATUS
31467754SmsmithAcpiHwClearGpe (
315114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
31667754Smsmith{
31799679Siwasaki    ACPI_STATUS             Status;
31867754Smsmith
31980062Smsmith
32091116Smsmith    ACPI_FUNCTION_ENTRY ();
32183174Smsmith
32283174Smsmith
32367754Smsmith    /*
32467754Smsmith     * Write a one to the appropriate bit in the status register to
32567754Smsmith     * clear this GPE.
32667754Smsmith     */
327114237Snjl    Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask,
328117521Snjl                    &GpeEventInfo->RegisterInfo->StatusAddress);
32999679Siwasaki
33099679Siwasaki    return (Status);
33167754Smsmith}
33267754Smsmith
33367754Smsmith
33467754Smsmith/******************************************************************************
33567754Smsmith *
33667754Smsmith * FUNCTION:    AcpiHwGetGpeStatus
33767754Smsmith *
33867754Smsmith * PARAMETERS:  GpeNumber       - The GPE
33967754Smsmith *
34067754Smsmith * RETURN:      None
34167754Smsmith *
34267754Smsmith * DESCRIPTION: Return the status of a single GPE.
34367754Smsmith *
34467754Smsmith ******************************************************************************/
34567754Smsmith
34699679SiwasakiACPI_STATUS
34767754SmsmithAcpiHwGetGpeStatus (
348117521Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
34967754Smsmith    ACPI_EVENT_STATUS       *EventStatus)
35067754Smsmith{
351114237Snjl    UINT32                  InByte;
352114237Snjl    UINT8                   BitMask;
35391116Smsmith    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
35499679Siwasaki    ACPI_STATUS             Status;
355114237Snjl    ACPI_EVENT_STATUS       LocalEventStatus = 0;
35667754Smsmith
35780062Smsmith
35891116Smsmith    ACPI_FUNCTION_ENTRY ();
35983174Smsmith
36083174Smsmith
36167754Smsmith    if (!EventStatus)
36267754Smsmith    {
36399679Siwasaki        return (AE_BAD_PARAMETER);
36467754Smsmith    }
36567754Smsmith
366114237Snjl    /* Get the info block for the entire GPE register */
36767754Smsmith
368114237Snjl    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
36967754Smsmith
37091116Smsmith    /* Get the register bitmask for this GPE */
37191116Smsmith
372114237Snjl    BitMask = GpeEventInfo->BitMask;
37391116Smsmith
37491116Smsmith    /* GPE Enabled? */
37591116Smsmith
376117521Snjl    Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress);
37799679Siwasaki    if (ACPI_FAILURE (Status))
37899679Siwasaki    {
379117521Snjl        goto UnlockAndExit;
38099679Siwasaki    }
38199679Siwasaki
38267754Smsmith    if (BitMask & InByte)
38367754Smsmith    {
384114237Snjl        LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
38567754Smsmith    }
38667754Smsmith
38791116Smsmith    /* GPE Enabled for wake? */
38891116Smsmith
38991116Smsmith    if (BitMask & GpeRegisterInfo->WakeEnable)
39084491Smsmith    {
391114237Snjl        LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
39284491Smsmith    }
39384491Smsmith
39491116Smsmith    /* GPE active (set)? */
39591116Smsmith
396117521Snjl    Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress);
39799679Siwasaki    if (ACPI_FAILURE (Status))
39899679Siwasaki    {
399117521Snjl        goto UnlockAndExit;
40099679Siwasaki    }
40199679Siwasaki
40267754Smsmith    if (BitMask & InByte)
40367754Smsmith    {
404114237Snjl        LocalEventStatus |= ACPI_EVENT_FLAG_SET;
40567754Smsmith    }
406114237Snjl
407114237Snjl    /* Set return value */
408114237Snjl
409114237Snjl    (*EventStatus) = LocalEventStatus;
410117521Snjl
411117521Snjl
412117521SnjlUnlockAndExit:
413117521Snjl    return (Status);
414117521Snjl}
415117521Snjl
416117521Snjl
417117521Snjl/******************************************************************************
418117521Snjl *
419117521Snjl * FUNCTION:    AcpiHwDisableGpeBlock
420117521Snjl *
421117521Snjl * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
422117521Snjl *              GpeBlock            - Gpe Block info
423117521Snjl *
424117521Snjl * RETURN:      Status
425117521Snjl *
426117521Snjl * DESCRIPTION: Disable all GPEs within a GPE block
427117521Snjl *
428117521Snjl ******************************************************************************/
429117521Snjl
430117521SnjlACPI_STATUS
431117521SnjlAcpiHwDisableGpeBlock (
432117521Snjl    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
433117521Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock)
434117521Snjl{
435117521Snjl    UINT32                  i;
436117521Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
437117521Snjl    ACPI_STATUS             Status;
438117521Snjl
439117521Snjl
440117521Snjl    /* Get the register info for the entire GPE block */
441117521Snjl
442117521Snjl    GpeRegisterInfo = GpeBlock->RegisterInfo;
443117521Snjl
444117521Snjl    /* Examine each GPE Register within the block */
445117521Snjl
446117521Snjl    for (i = 0; i < GpeBlock->RegisterCount; i++)
447117521Snjl    {
448117521Snjl        Status = AcpiHwLowLevelWrite (8, 0x00,
449117521Snjl                    &GpeBlock->RegisterInfo[i].EnableAddress);
450117521Snjl        if (ACPI_FAILURE (Status))
451117521Snjl        {
452117521Snjl            return (Status);
453117521Snjl        }
454117521Snjl    }
455117521Snjl
45699679Siwasaki    return (AE_OK);
45767754Smsmith}
45884491Smsmith
45991116Smsmith
46084491Smsmith/******************************************************************************
46184491Smsmith *
462117521Snjl * FUNCTION:    AcpiHwClearGpeBlock
463117521Snjl *
464117521Snjl * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
465117521Snjl *              GpeBlock            - Gpe Block info
466117521Snjl *
467117521Snjl * RETURN:      Status
468117521Snjl *
469117521Snjl * DESCRIPTION: Clear all GPEs within a GPE block
470117521Snjl *
471117521Snjl ******************************************************************************/
472117521Snjl
473117521SnjlACPI_STATUS
474117521SnjlAcpiHwClearGpeBlock (
475117521Snjl    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
476117521Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock)
477117521Snjl{
478117521Snjl    UINT32                  i;
479117521Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
480117521Snjl    ACPI_STATUS             Status;
481117521Snjl
482117521Snjl
483117521Snjl    /* Get the register info for the entire GPE block */
484117521Snjl
485117521Snjl    GpeRegisterInfo = GpeBlock->RegisterInfo;
486117521Snjl
487117521Snjl    /* Examine each GPE Register within the block */
488117521Snjl
489117521Snjl    for (i = 0; i < GpeBlock->RegisterCount; i++)
490117521Snjl    {
491117521Snjl        Status = AcpiHwLowLevelWrite (8, 0xFF,
492117521Snjl                    &GpeBlock->RegisterInfo[i].StatusAddress);
493117521Snjl        if (ACPI_FAILURE (Status))
494117521Snjl        {
495117521Snjl            return (Status);
496117521Snjl        }
497117521Snjl    }
498117521Snjl
499117521Snjl    return (AE_OK);
500117521Snjl}
501117521Snjl
502117521Snjl
503117521Snjl/******************************************************************************
504117521Snjl *
505117521Snjl * FUNCTION:    AcpiHwDisableNonWakeupGpeBlock
506117521Snjl *
507117521Snjl * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
508117521Snjl *              GpeBlock            - Gpe Block info
509117521Snjl *
510117521Snjl * RETURN:      Status
511117521Snjl *
512117521Snjl * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block
513117521Snjl *
514117521Snjl ******************************************************************************/
515117521Snjl
516117521Snjlstatic ACPI_STATUS
517117521SnjlAcpiHwDisableNonWakeupGpeBlock (
518117521Snjl    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
519117521Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock)
520117521Snjl{
521117521Snjl    UINT32                  i;
522117521Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
523117521Snjl    UINT32                  InValue;
524117521Snjl    ACPI_STATUS             Status;
525117521Snjl
526117521Snjl
527117521Snjl    /* Get the register info for the entire GPE block */
528117521Snjl
529117521Snjl    GpeRegisterInfo = GpeBlock->RegisterInfo;
530117521Snjl
531117521Snjl    /* Examine each GPE Register within the block */
532117521Snjl
533117521Snjl    for (i = 0; i < GpeBlock->RegisterCount; i++)
534117521Snjl    {
535117521Snjl        /*
536117521Snjl         * Read the enabled status of all GPEs. We
537117521Snjl         * will be using it to restore all the GPEs later.
538117521Snjl         */
539117521Snjl        Status = AcpiHwLowLevelRead (8, &InValue,
540117521Snjl                    &GpeRegisterInfo->EnableAddress);
541117521Snjl        if (ACPI_FAILURE (Status))
542117521Snjl        {
543117521Snjl            return (Status);
544117521Snjl        }
545117521Snjl
546117521Snjl        GpeRegisterInfo->Enable = (UINT8) InValue;
547117521Snjl
548117521Snjl        /*
549117521Snjl         * Disable all GPEs except wakeup GPEs.
550117521Snjl         */
551117521Snjl        Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable,
552117521Snjl                &GpeRegisterInfo->EnableAddress);
553117521Snjl        if (ACPI_FAILURE (Status))
554117521Snjl        {
555117521Snjl            return (Status);
556117521Snjl        }
557117521Snjl
558117521Snjl        GpeRegisterInfo++;
559117521Snjl    }
560117521Snjl
561117521Snjl    return (AE_OK);
562117521Snjl}
563117521Snjl
564117521Snjl
565117521Snjl/******************************************************************************
566117521Snjl *
56784491Smsmith * FUNCTION:    AcpiHwDisableNonWakeupGpes
56884491Smsmith *
56984491Smsmith * PARAMETERS:  None
57084491Smsmith *
57184491Smsmith * RETURN:      None
57284491Smsmith *
57384491Smsmith * DESCRIPTION: Disable all non-wakeup GPEs
574117521Snjl *              Called with interrupts disabled. The interrupt handler also
575114237Snjl *              modifies GpeRegisterInfo->Enable, so it should not be
57684491Smsmith *              given the chance to run until after non-wake GPEs are
57784491Smsmith *              re-enabled.
57884491Smsmith *
57984491Smsmith ******************************************************************************/
58084491Smsmith
58199679SiwasakiACPI_STATUS
58284491SmsmithAcpiHwDisableNonWakeupGpes (
58384491Smsmith    void)
58484491Smsmith{
58599679Siwasaki    ACPI_STATUS             Status;
58684491Smsmith
58784491Smsmith
58891116Smsmith    ACPI_FUNCTION_ENTRY ();
58991116Smsmith
59091116Smsmith
591117521Snjl    Status = AcpiEvWalkGpeList (AcpiHwDisableNonWakeupGpeBlock);
59291116Smsmith
593117521Snjl    return (Status);
594117521Snjl}
59584491Smsmith
59699679Siwasaki
597117521Snjl/******************************************************************************
598117521Snjl *
599117521Snjl * FUNCTION:    AcpiHwEnableNonWakeupGpeBlock
600117521Snjl *
601117521Snjl * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
602117521Snjl *              GpeBlock            - Gpe Block info
603117521Snjl *
604117521Snjl * RETURN:      Status
605117521Snjl *
606117521Snjl * DESCRIPTION: Enable a single GPE.
607117521Snjl *
608117521Snjl ******************************************************************************/
609114237Snjl
610117521Snjlstatic ACPI_STATUS
611117521SnjlAcpiHwEnableNonWakeupGpeBlock (
612117521Snjl    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
613117521Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock)
614117521Snjl{
615117521Snjl    UINT32                  i;
616117521Snjl    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
617117521Snjl    ACPI_STATUS             Status;
618114237Snjl
619117521Snjl
620117521Snjl    /* This callback processes one entire GPE block */
621117521Snjl
622117521Snjl    /* Get the register info for the entire GPE block */
623117521Snjl
624117521Snjl    GpeRegisterInfo = GpeBlock->RegisterInfo;
625117521Snjl
626117521Snjl    /* Examine each GPE register within the block */
627117521Snjl
628117521Snjl    for (i = 0; i < GpeBlock->RegisterCount; i++)
629117521Snjl    {
630117521Snjl        /*
631117521Snjl         * We previously stored the enabled status of all GPEs.
632117521Snjl         * Blast them back in.
633117521Snjl         */
634117521Snjl        Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable,
635117521Snjl                    &GpeRegisterInfo->EnableAddress);
636117521Snjl        if (ACPI_FAILURE (Status))
637117521Snjl        {
638117521Snjl            return (Status);
63999679Siwasaki        }
640114237Snjl
641117521Snjl        GpeRegisterInfo++;
64284491Smsmith    }
643114237Snjl
644117521Snjl
64599679Siwasaki    return (AE_OK);
64684491Smsmith}
64784491Smsmith
64891116Smsmith
64984491Smsmith/******************************************************************************
65084491Smsmith *
65184491Smsmith * FUNCTION:    AcpiHwEnableNonWakeupGpes
65284491Smsmith *
65384491Smsmith * PARAMETERS:  None
65484491Smsmith *
65584491Smsmith * RETURN:      None
65684491Smsmith *
65784491Smsmith * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
65884491Smsmith *
65984491Smsmith ******************************************************************************/
66084491Smsmith
66199679SiwasakiACPI_STATUS
66284491SmsmithAcpiHwEnableNonWakeupGpes (
66384491Smsmith    void)
66484491Smsmith{
66599679Siwasaki    ACPI_STATUS             Status;
66684491Smsmith
66784491Smsmith
66891116Smsmith    ACPI_FUNCTION_ENTRY ();
66991116Smsmith
67091116Smsmith
671117521Snjl    Status = AcpiEvWalkGpeList (AcpiHwEnableNonWakeupGpeBlock);
67291116Smsmith
673117521Snjl    return (Status);
67484491Smsmith}
675