evxfevnt.c revision 77424
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
477424Smsmith *              $Revision: 33 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
1271867Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
1370243Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial prton of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11667754Smsmith
11767754Smsmith
11867754Smsmith#define __EVXFEVNT_C__
11967754Smsmith
12067754Smsmith#include "acpi.h"
12167754Smsmith#include "achware.h"
12267754Smsmith#include "acnamesp.h"
12367754Smsmith#include "acevents.h"
12467754Smsmith#include "amlcode.h"
12567754Smsmith#include "acinterp.h"
12667754Smsmith
12777424Smsmith#define _COMPONENT          ACPI_EVENTS
12867754Smsmith        MODULE_NAME         ("evxfevnt")
12967754Smsmith
13067754Smsmith
13177424Smsmith/*******************************************************************************
13267754Smsmith *
13367754Smsmith * FUNCTION:    AcpiEnable
13467754Smsmith *
13567754Smsmith * PARAMETERS:  None
13667754Smsmith *
13767754Smsmith * RETURN:      Status
13867754Smsmith *
13967754Smsmith * DESCRIPTION: Transfers the system into ACPI mode.
14067754Smsmith *
14177424Smsmith ******************************************************************************/
14267754Smsmith
14367754SmsmithACPI_STATUS
14467754SmsmithAcpiEnable (void)
14567754Smsmith{
14667754Smsmith    ACPI_STATUS             Status;
14767754Smsmith
14867754Smsmith
14967754Smsmith    FUNCTION_TRACE ("AcpiEnable");
15067754Smsmith
15167754Smsmith
15267754Smsmith    /* Make sure we've got ACPI tables */
15367754Smsmith
15467754Smsmith    if (!AcpiGbl_DSDT)
15567754Smsmith    {
15677424Smsmith        DEBUG_PRINTP (ACPI_WARN, ("No ACPI tables present!\n"));
15767754Smsmith        return_ACPI_STATUS (AE_NO_ACPI_TABLES);
15867754Smsmith    }
15967754Smsmith
16067754Smsmith    /* Make sure the BIOS supports ACPI mode */
16167754Smsmith
16267754Smsmith    if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities())
16367754Smsmith    {
16477424Smsmith        DEBUG_PRINTP (ACPI_WARN, ("Only legacy mode supported!\n"));
16567754Smsmith        return_ACPI_STATUS (AE_ERROR);
16667754Smsmith    }
16767754Smsmith
16867754Smsmith    /* Transition to ACPI mode */
16967754Smsmith
17067754Smsmith    Status = AcpiHwSetMode (SYS_MODE_ACPI);
17167754Smsmith    if (ACPI_FAILURE (Status))
17267754Smsmith    {
17377424Smsmith        DEBUG_PRINTP (ACPI_FATAL, ("Could not transition to ACPI mode.\n"));
17467754Smsmith        return_ACPI_STATUS (Status);
17567754Smsmith    }
17667754Smsmith
17777424Smsmith    DEBUG_PRINTP (ACPI_OK, ("Transition to ACPI mode successful\n"));
17867754Smsmith
17967754Smsmith    return_ACPI_STATUS (Status);
18067754Smsmith}
18167754Smsmith
18267754Smsmith
18377424Smsmith/*******************************************************************************
18467754Smsmith *
18567754Smsmith * FUNCTION:    AcpiDisable
18667754Smsmith *
18767754Smsmith * PARAMETERS:  None
18867754Smsmith *
18967754Smsmith * RETURN:      Status
19067754Smsmith *
19167754Smsmith * DESCRIPTION: Returns the system to original ACPI/legacy mode, and
19267754Smsmith *              uninstalls the SCI interrupt handler.
19367754Smsmith *
19477424Smsmith ******************************************************************************/
19567754Smsmith
19667754SmsmithACPI_STATUS
19767754SmsmithAcpiDisable (void)
19867754Smsmith{
19967754Smsmith    ACPI_STATUS             Status;
20067754Smsmith
20167754Smsmith
20267754Smsmith    FUNCTION_TRACE ("AcpiDisable");
20367754Smsmith
20467754Smsmith
20577424Smsmith    /* Ensure that ACPI has been initialized */
20677424Smsmith
20777424Smsmith    ACPI_IS_INITIALIZATION_COMPLETE (Status);
20877424Smsmith    if (ACPI_FAILURE (Status))
20977424Smsmith    {
21077424Smsmith        return_ACPI_STATUS (Status);
21177424Smsmith    }
21277424Smsmith
21367754Smsmith    /* Restore original mode  */
21467754Smsmith
21567754Smsmith    Status = AcpiHwSetMode (AcpiGbl_OriginalMode);
21667754Smsmith    if (ACPI_FAILURE (Status))
21767754Smsmith    {
21877424Smsmith        DEBUG_PRINTP (ACPI_ERROR, ("Unable to transition to original mode"));
21967754Smsmith        return_ACPI_STATUS (Status);
22067754Smsmith    }
22167754Smsmith
22267754Smsmith    /* Unload the SCI interrupt handler  */
22367754Smsmith
22467754Smsmith    AcpiEvRemoveSciHandler ();
22567754Smsmith    AcpiEvRestoreAcpiState ();
22667754Smsmith
22767754Smsmith    return_ACPI_STATUS (Status);
22867754Smsmith}
22967754Smsmith
23067754Smsmith
23177424Smsmith/*******************************************************************************
23267754Smsmith *
23367754Smsmith * FUNCTION:    AcpiEnableEvent
23467754Smsmith *
23567754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be enabled
23667754Smsmith *              Type            - The type of event
23767754Smsmith *
23867754Smsmith * RETURN:      Status
23967754Smsmith *
24067754Smsmith * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
24167754Smsmith *
24267754Smsmith ******************************************************************************/
24367754Smsmith
24467754SmsmithACPI_STATUS
24567754SmsmithAcpiEnableEvent (
24667754Smsmith    UINT32                  Event,
24767754Smsmith    UINT32                  Type)
24867754Smsmith{
24967754Smsmith    ACPI_STATUS             Status = AE_OK;
25067754Smsmith    UINT32                  RegisterId;
25167754Smsmith
25267754Smsmith
25367754Smsmith    FUNCTION_TRACE ("AcpiEnableEvent");
25467754Smsmith
25567754Smsmith
25677424Smsmith    /* Ensure that ACPI has been initialized */
25777424Smsmith
25877424Smsmith    ACPI_IS_INITIALIZATION_COMPLETE (Status);
25977424Smsmith    if (ACPI_FAILURE (Status))
26077424Smsmith    {
26177424Smsmith        return_ACPI_STATUS (Status);
26277424Smsmith    }
26377424Smsmith
26467754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
26567754Smsmith
26667754Smsmith    switch (Type)
26767754Smsmith    {
26867754Smsmith
26967754Smsmith    case ACPI_EVENT_FIXED:
27067754Smsmith
27167754Smsmith        /* Decode the Fixed AcpiEvent */
27267754Smsmith
27367754Smsmith        switch (Event)
27467754Smsmith        {
27567754Smsmith        case ACPI_EVENT_PMTIMER:
27667754Smsmith            RegisterId = TMR_EN;
27767754Smsmith            break;
27867754Smsmith
27967754Smsmith        case ACPI_EVENT_GLOBAL:
28067754Smsmith            RegisterId = GBL_EN;
28167754Smsmith            break;
28267754Smsmith
28367754Smsmith        case ACPI_EVENT_POWER_BUTTON:
28467754Smsmith            RegisterId = PWRBTN_EN;
28567754Smsmith            break;
28667754Smsmith
28767754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
28867754Smsmith            RegisterId = SLPBTN_EN;
28967754Smsmith            break;
29067754Smsmith
29167754Smsmith        case ACPI_EVENT_RTC:
29267754Smsmith            RegisterId = RTC_EN;
29367754Smsmith            break;
29467754Smsmith
29567754Smsmith        default:
29667754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
29767754Smsmith            break;
29867754Smsmith        }
29967754Smsmith
30067754Smsmith        /*
30167754Smsmith         * Enable the requested fixed event (by writing a one to the
30267754Smsmith         * enable register bit)
30367754Smsmith         */
30467754Smsmith
30569450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1);
30669450Smsmith
30769450Smsmith        if (1 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId))
30869450Smsmith        {
30977424Smsmith            DEBUG_PRINTP (ACPI_ERROR,
31077424Smsmith                ("Fixed event bit clear when it should be set\n"));
31177424Smsmith            return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
31269450Smsmith        }
31369450Smsmith
31467754Smsmith        break;
31567754Smsmith
31667754Smsmith
31767754Smsmith    case ACPI_EVENT_GPE:
31867754Smsmith
31967754Smsmith        /* Ensure that we have a valid GPE number */
32067754Smsmith
32177424Smsmith        if ((Event > ACPI_GPE_MAX) ||
32267754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
32367754Smsmith        {
32467754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
32567754Smsmith        }
32667754Smsmith
32767754Smsmith
32867754Smsmith        /* Enable the requested GPE number */
32967754Smsmith
33067754Smsmith        AcpiHwEnableGpe (Event);
33167754Smsmith        break;
33267754Smsmith
33367754Smsmith
33467754Smsmith    default:
33567754Smsmith
33667754Smsmith        Status = AE_BAD_PARAMETER;
33767754Smsmith    }
33867754Smsmith
33967754Smsmith
34067754Smsmith    return_ACPI_STATUS (Status);
34167754Smsmith}
34267754Smsmith
34367754Smsmith
34477424Smsmith/*******************************************************************************
34567754Smsmith *
34667754Smsmith * FUNCTION:    AcpiDisableEvent
34767754Smsmith *
34867754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be enabled
34967754Smsmith *              Type            - The type of event
35067754Smsmith *
35167754Smsmith * RETURN:      Status
35267754Smsmith *
35367754Smsmith * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
35467754Smsmith *
35567754Smsmith ******************************************************************************/
35667754Smsmith
35767754SmsmithACPI_STATUS
35867754SmsmithAcpiDisableEvent (
35967754Smsmith    UINT32                  Event,
36067754Smsmith    UINT32                  Type)
36167754Smsmith{
36267754Smsmith    ACPI_STATUS             Status = AE_OK;
36367754Smsmith    UINT32                  RegisterId;
36467754Smsmith
36567754Smsmith
36667754Smsmith    FUNCTION_TRACE ("AcpiDisableEvent");
36767754Smsmith
36867754Smsmith
36977424Smsmith    /* Ensure that ACPI has been initialized */
37077424Smsmith
37177424Smsmith    ACPI_IS_INITIALIZATION_COMPLETE (Status);
37277424Smsmith    if (ACPI_FAILURE (Status))
37377424Smsmith    {
37477424Smsmith        return_ACPI_STATUS (Status);
37577424Smsmith    }
37677424Smsmith
37767754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
37867754Smsmith
37967754Smsmith    switch (Type)
38067754Smsmith    {
38167754Smsmith
38267754Smsmith    case ACPI_EVENT_FIXED:
38367754Smsmith
38467754Smsmith        /* Decode the Fixed AcpiEvent */
38567754Smsmith
38667754Smsmith        switch (Event)
38767754Smsmith        {
38867754Smsmith        case ACPI_EVENT_PMTIMER:
38967754Smsmith            RegisterId = TMR_EN;
39067754Smsmith            break;
39167754Smsmith
39267754Smsmith        case ACPI_EVENT_GLOBAL:
39367754Smsmith            RegisterId = GBL_EN;
39467754Smsmith            break;
39567754Smsmith
39667754Smsmith        case ACPI_EVENT_POWER_BUTTON:
39767754Smsmith            RegisterId = PWRBTN_EN;
39867754Smsmith            break;
39967754Smsmith
40067754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
40167754Smsmith            RegisterId = SLPBTN_EN;
40267754Smsmith            break;
40367754Smsmith
40467754Smsmith        case ACPI_EVENT_RTC:
40567754Smsmith            RegisterId = RTC_EN;
40667754Smsmith            break;
40767754Smsmith
40867754Smsmith        default:
40967754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
41067754Smsmith            break;
41167754Smsmith        }
41267754Smsmith
41367754Smsmith        /*
41467754Smsmith         * Disable the requested fixed event (by writing a zero to the
41567754Smsmith         * enable register bit)
41667754Smsmith         */
41767754Smsmith
41869450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 0);
41969450Smsmith
42069450Smsmith        if (0 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId))
42169450Smsmith        {
42277424Smsmith            DEBUG_PRINTP (ACPI_ERROR,
42377424Smsmith                ("Fixed event bit set when it should be clear,\n"));
42477424Smsmith            return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
42569450Smsmith        }
42669450Smsmith
42767754Smsmith        break;
42867754Smsmith
42967754Smsmith
43067754Smsmith    case ACPI_EVENT_GPE:
43167754Smsmith
43267754Smsmith        /* Ensure that we have a valid GPE number */
43367754Smsmith
43477424Smsmith        if ((Event > ACPI_GPE_MAX) ||
43567754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
43667754Smsmith        {
43767754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
43867754Smsmith        }
43967754Smsmith
44067754Smsmith        /* Disable the requested GPE number */
44167754Smsmith
44267754Smsmith        AcpiHwDisableGpe (Event);
44367754Smsmith        break;
44467754Smsmith
44567754Smsmith
44667754Smsmith    default:
44767754Smsmith        Status = AE_BAD_PARAMETER;
44867754Smsmith    }
44967754Smsmith
45067754Smsmith    return_ACPI_STATUS (Status);
45167754Smsmith}
45267754Smsmith
45367754Smsmith
45477424Smsmith/*******************************************************************************
45567754Smsmith *
45667754Smsmith * FUNCTION:    AcpiClearEvent
45767754Smsmith *
45867754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be cleared
45967754Smsmith *              Type            - The type of event
46067754Smsmith *
46167754Smsmith * RETURN:      Status
46267754Smsmith *
46367754Smsmith * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
46467754Smsmith *
46567754Smsmith ******************************************************************************/
46667754Smsmith
46767754SmsmithACPI_STATUS
46867754SmsmithAcpiClearEvent (
46967754Smsmith    UINT32                  Event,
47067754Smsmith    UINT32                  Type)
47167754Smsmith{
47267754Smsmith    ACPI_STATUS             Status = AE_OK;
47367754Smsmith    UINT32                  RegisterId;
47467754Smsmith
47567754Smsmith
47667754Smsmith    FUNCTION_TRACE ("AcpiClearEvent");
47767754Smsmith
47867754Smsmith
47977424Smsmith    /* Ensure that ACPI has been initialized */
48077424Smsmith
48177424Smsmith    ACPI_IS_INITIALIZATION_COMPLETE (Status);
48277424Smsmith    if (ACPI_FAILURE (Status))
48377424Smsmith    {
48477424Smsmith        return_ACPI_STATUS (Status);
48577424Smsmith    }
48677424Smsmith
48767754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
48867754Smsmith
48967754Smsmith    switch (Type)
49067754Smsmith    {
49167754Smsmith
49267754Smsmith    case ACPI_EVENT_FIXED:
49367754Smsmith
49467754Smsmith        /* Decode the Fixed AcpiEvent */
49567754Smsmith
49667754Smsmith        switch (Event)
49767754Smsmith        {
49867754Smsmith        case ACPI_EVENT_PMTIMER:
49967754Smsmith            RegisterId = TMR_STS;
50067754Smsmith            break;
50167754Smsmith
50267754Smsmith        case ACPI_EVENT_GLOBAL:
50367754Smsmith            RegisterId = GBL_STS;
50467754Smsmith            break;
50567754Smsmith
50667754Smsmith        case ACPI_EVENT_POWER_BUTTON:
50767754Smsmith            RegisterId = PWRBTN_STS;
50867754Smsmith            break;
50967754Smsmith
51067754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
51167754Smsmith            RegisterId = SLPBTN_STS;
51267754Smsmith            break;
51367754Smsmith
51467754Smsmith        case ACPI_EVENT_RTC:
51567754Smsmith            RegisterId = RTC_STS;
51667754Smsmith            break;
51767754Smsmith
51867754Smsmith        default:
51967754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
52067754Smsmith            break;
52167754Smsmith        }
52267754Smsmith
52367754Smsmith        /*
52467754Smsmith         * Clear the requested fixed event (By writing a one to the
52567754Smsmith         * status register bit)
52667754Smsmith         */
52767754Smsmith
52869450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1);
52967754Smsmith        break;
53067754Smsmith
53167754Smsmith
53267754Smsmith    case ACPI_EVENT_GPE:
53367754Smsmith
53467754Smsmith        /* Ensure that we have a valid GPE number */
53567754Smsmith
53677424Smsmith        if ((Event > ACPI_GPE_MAX) ||
53767754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
53867754Smsmith        {
53967754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
54067754Smsmith        }
54167754Smsmith
54267754Smsmith
54367754Smsmith        AcpiHwClearGpe (Event);
54467754Smsmith        break;
54567754Smsmith
54667754Smsmith
54767754Smsmith    default:
54867754Smsmith
54967754Smsmith        Status = AE_BAD_PARAMETER;
55067754Smsmith    }
55167754Smsmith
55267754Smsmith    return_ACPI_STATUS (Status);
55367754Smsmith}
55467754Smsmith
55567754Smsmith
55677424Smsmith/*******************************************************************************
55767754Smsmith *
55867754Smsmith * FUNCTION:    AcpiGetEventStatus
55967754Smsmith *
56067754Smsmith * PARAMETERS:  Event           - The fixed event or GPE
56167754Smsmith *              Type            - The type of event
56267754Smsmith *              Status          - Where the current status of the event will
56367754Smsmith *                                be returned
56467754Smsmith *
56567754Smsmith * RETURN:      Status
56667754Smsmith *
56767754Smsmith * DESCRIPTION: Obtains and returns the current status of the event
56867754Smsmith *
56967754Smsmith ******************************************************************************/
57067754Smsmith
57167754Smsmith
57267754SmsmithACPI_STATUS
57367754SmsmithAcpiGetEventStatus (
57467754Smsmith    UINT32                  Event,
57567754Smsmith    UINT32                  Type,
57667754Smsmith    ACPI_EVENT_STATUS       *EventStatus)
57767754Smsmith{
57867754Smsmith    ACPI_STATUS             Status = AE_OK;
57967754Smsmith    UINT32                  RegisterId;
58067754Smsmith
58167754Smsmith
58267754Smsmith    FUNCTION_TRACE ("AcpiGetEventStatus");
58367754Smsmith
58467754Smsmith
58577424Smsmith    /* Ensure that ACPI has been initialized */
58677424Smsmith
58777424Smsmith    ACPI_IS_INITIALIZATION_COMPLETE (Status);
58877424Smsmith    if (ACPI_FAILURE (Status))
58977424Smsmith    {
59077424Smsmith        return_ACPI_STATUS (Status);
59177424Smsmith    }
59277424Smsmith
59367754Smsmith    if (!EventStatus)
59467754Smsmith    {
59567754Smsmith        return_ACPI_STATUS (AE_BAD_PARAMETER);
59667754Smsmith    }
59767754Smsmith
59867754Smsmith
59967754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
60067754Smsmith
60167754Smsmith    switch (Type)
60267754Smsmith    {
60367754Smsmith
60467754Smsmith    case ACPI_EVENT_FIXED:
60567754Smsmith
60667754Smsmith        /* Decode the Fixed AcpiEvent */
60767754Smsmith
60867754Smsmith        switch (Event)
60967754Smsmith        {
61067754Smsmith        case ACPI_EVENT_PMTIMER:
61167754Smsmith            RegisterId = TMR_STS;
61267754Smsmith            break;
61367754Smsmith
61467754Smsmith        case ACPI_EVENT_GLOBAL:
61567754Smsmith            RegisterId = GBL_STS;
61667754Smsmith            break;
61767754Smsmith
61867754Smsmith        case ACPI_EVENT_POWER_BUTTON:
61967754Smsmith            RegisterId = PWRBTN_STS;
62067754Smsmith            break;
62167754Smsmith
62267754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
62367754Smsmith            RegisterId = SLPBTN_STS;
62467754Smsmith            break;
62567754Smsmith
62667754Smsmith        case ACPI_EVENT_RTC:
62767754Smsmith            RegisterId = RTC_STS;
62867754Smsmith            break;
62967754Smsmith
63067754Smsmith        default:
63167754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
63267754Smsmith            break;
63367754Smsmith        }
63467754Smsmith
63567754Smsmith        /* Get the status of the requested fixed event */
63667754Smsmith
63769450Smsmith        *EventStatus = AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, RegisterId);
63867754Smsmith        break;
63967754Smsmith
64067754Smsmith
64167754Smsmith    case ACPI_EVENT_GPE:
64267754Smsmith
64367754Smsmith        /* Ensure that we have a valid GPE number */
64467754Smsmith
64577424Smsmith        if ((Event > ACPI_GPE_MAX) ||
64667754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
64767754Smsmith        {
64867754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
64967754Smsmith        }
65067754Smsmith
65167754Smsmith
65267754Smsmith        /* Obtain status on the requested GPE number */
65367754Smsmith
65467754Smsmith        AcpiHwGetGpeStatus (Event, EventStatus);
65567754Smsmith        break;
65667754Smsmith
65767754Smsmith
65867754Smsmith    default:
65967754Smsmith        Status = AE_BAD_PARAMETER;
66067754Smsmith    }
66167754Smsmith
66267754Smsmith
66367754Smsmith    return_ACPI_STATUS (Status);
66467754Smsmith}
66567754Smsmith
666