evxfevnt.c revision 193267
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
767754Smsmith/******************************************************************************
867754Smsmith *
967754Smsmith * 1. Copyright Notice
1067754Smsmith *
11193267Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
1270243Smsmith * All rights reserved.
1367754Smsmith *
1467754Smsmith * 2. License
1567754Smsmith *
1667754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1767754Smsmith * rights.  You may have additional license terms from the party that provided
1867754Smsmith * you this software, covering your right to use that party's intellectual
1967754Smsmith * property rights.
2067754Smsmith *
2167754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2267754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2367754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2467754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2567754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2667754Smsmith * Code in any form, with the right to sublicense such rights; and
2767754Smsmith *
2867754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
2967754Smsmith * license (with the right to sublicense), under only those claims of Intel
3067754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3167754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3267754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3367754Smsmith * license, and in no event shall the patent license extend to any additions
3467754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3567754Smsmith * is granted directly or by implication, estoppel or otherwise;
3667754Smsmith *
3767754Smsmith * The above copyright and patent license is granted only if the following
3867754Smsmith * conditions are met:
3967754Smsmith *
4067754Smsmith * 3. Conditions
4167754Smsmith *
4267754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43167802Sjkim * Redistribution of source code of any substantial portion of the Covered
4467754Smsmith * Code or modification with rights to further distribute source must include
4567754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4667754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4767754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4867754Smsmith * contain a file documenting the changes Licensee made to create that Covered
4967754Smsmith * Code and the date of any change.  Licensee must include in that file the
5067754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5167754Smsmith * must include a prominent statement that the modification is derived,
5267754Smsmith * directly or indirectly, from Original Intel Code.
5367754Smsmith *
5467754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5567754Smsmith * Redistribution of source code of any substantial portion of the Covered
5667754Smsmith * Code or modification without rights to further distribute source must
5767754Smsmith * include the following Disclaimer and Export Compliance provision in the
5867754Smsmith * documentation and/or other materials provided with distribution.  In
5967754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6067754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6167754Smsmith * license from Licensee to its licensee is limited to the intellectual
6267754Smsmith * property embodied in the software Licensee provides to its licensee, and
6367754Smsmith * not to intellectual property embodied in modifications its licensee may
6467754Smsmith * make.
6567754Smsmith *
6667754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6767754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6867754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
6967754Smsmith * provision in the documentation and/or other materials provided with the
7067754Smsmith * distribution.
7167754Smsmith *
7267754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7367754Smsmith * Intel Code.
7467754Smsmith *
7567754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7667754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7767754Smsmith * other dealings in products derived from or relating to the Covered Code
7867754Smsmith * without prior written authorization from Intel.
7967754Smsmith *
8067754Smsmith * 4. Disclaimer and Export Compliance
8167754Smsmith *
8267754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8367754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8467754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8567754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8667754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8767754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8867754Smsmith * PARTICULAR PURPOSE.
8967754Smsmith *
9067754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9167754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9267754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9367754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9467754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9567754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9667754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9767754Smsmith * LIMITED REMEDY.
9867754Smsmith *
9967754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10067754Smsmith * software or system incorporating such software without first obtaining any
10167754Smsmith * required license or other approval from the U. S. Department of Commerce or
10267754Smsmith * any other agency or department of the United States Government.  In the
10367754Smsmith * event Licensee exports any such software from the United States or
10467754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10567754Smsmith * ensure that the distribution and export/re-export of the software is in
10667754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10767754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10867754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
10967754Smsmith * software, or service, directly or indirectly, to any country for which the
11067754Smsmith * United States government or any agency thereof requires an export license,
11167754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11267754Smsmith * such license, approval or letter.
11367754Smsmith *
11467754Smsmith *****************************************************************************/
11567754Smsmith
11667754Smsmith
11767754Smsmith#define __EVXFEVNT_C__
11867754Smsmith
119193251Sjkim#include "acpi.h"
120193267Sjkim#include "accommon.h"
121193251Sjkim#include "acevents.h"
122193251Sjkim#include "acnamesp.h"
123193251Sjkim#include "actables.h"
12467754Smsmith
12577424Smsmith#define _COMPONENT          ACPI_EVENTS
12691116Smsmith        ACPI_MODULE_NAME    ("evxfevnt")
12767754Smsmith
128193267Sjkim/* Local prototypes */
12967754Smsmith
130193267Sjkimstatic ACPI_STATUS
131193267SjkimAcpiEvGetGpeDevice (
132193267Sjkim    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
133193267Sjkim    ACPI_GPE_BLOCK_INFO     *GpeBlock,
134193267Sjkim    void                    *Context);
135193267Sjkim
136193267Sjkim
13777424Smsmith/*******************************************************************************
13867754Smsmith *
13967754Smsmith * FUNCTION:    AcpiEnable
14067754Smsmith *
14167754Smsmith * PARAMETERS:  None
14267754Smsmith *
14367754Smsmith * RETURN:      Status
14467754Smsmith *
14567754Smsmith * DESCRIPTION: Transfers the system into ACPI mode.
14667754Smsmith *
14777424Smsmith ******************************************************************************/
14867754Smsmith
14967754SmsmithACPI_STATUS
150151937SjkimAcpiEnable (
151151937Sjkim    void)
15267754Smsmith{
15387031Smsmith    ACPI_STATUS             Status = AE_OK;
15467754Smsmith
15567754Smsmith
156167802Sjkim    ACPI_FUNCTION_TRACE (AcpiEnable);
15767754Smsmith
15867754Smsmith
159167802Sjkim    /* ACPI tables must be present */
16067754Smsmith
161167802Sjkim    if (!AcpiTbTablesLoaded ())
16267754Smsmith    {
16367754Smsmith        return_ACPI_STATUS (AE_NO_ACPI_TABLES);
16467754Smsmith    }
16567754Smsmith
166167802Sjkim    /* Check current mode */
167167802Sjkim
168102550Siwasaki    if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
16967754Smsmith    {
170114237Snjl        ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
17167754Smsmith    }
17287031Smsmith    else
17387031Smsmith    {
17487031Smsmith        /* Transition to ACPI mode */
17567754Smsmith
17691116Smsmith        Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
17787031Smsmith        if (ACPI_FAILURE (Status))
17887031Smsmith        {
179167802Sjkim            ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
18087031Smsmith            return_ACPI_STATUS (Status);
18187031Smsmith        }
18287031Smsmith
183151937Sjkim        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
184151937Sjkim            "Transition to ACPI mode successful\n"));
18567754Smsmith    }
18667754Smsmith
18767754Smsmith    return_ACPI_STATUS (Status);
18867754Smsmith}
18967754Smsmith
190167802SjkimACPI_EXPORT_SYMBOL (AcpiEnable)
19167754Smsmith
192167802Sjkim
19377424Smsmith/*******************************************************************************
19467754Smsmith *
19567754Smsmith * FUNCTION:    AcpiDisable
19667754Smsmith *
19767754Smsmith * PARAMETERS:  None
19867754Smsmith *
19967754Smsmith * RETURN:      Status
20067754Smsmith *
201151937Sjkim * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
20267754Smsmith *
20377424Smsmith ******************************************************************************/
20467754Smsmith
20567754SmsmithACPI_STATUS
206151937SjkimAcpiDisable (
207151937Sjkim    void)
20867754Smsmith{
20987031Smsmith    ACPI_STATUS             Status = AE_OK;
21067754Smsmith
21167754Smsmith
212167802Sjkim    ACPI_FUNCTION_TRACE (AcpiDisable);
21367754Smsmith
214117521Snjl
215102550Siwasaki    if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
21667754Smsmith    {
217151937Sjkim        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
218151937Sjkim            "System is already in legacy (non-ACPI) mode\n"));
219102550Siwasaki    }
220102550Siwasaki    else
221102550Siwasaki    {
222102550Siwasaki        /* Transition to LEGACY mode */
223114237Snjl
224102550Siwasaki        Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
22591116Smsmith
22687031Smsmith        if (ACPI_FAILURE (Status))
22787031Smsmith        {
228167802Sjkim            ACPI_ERROR ((AE_INFO,
229151937Sjkim                "Could not exit ACPI mode to legacy mode"));
23087031Smsmith            return_ACPI_STATUS (Status);
23187031Smsmith        }
232102550Siwasaki
233114237Snjl        ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
23467754Smsmith    }
23567754Smsmith
23667754Smsmith    return_ACPI_STATUS (Status);
23767754Smsmith}
23867754Smsmith
239167802SjkimACPI_EXPORT_SYMBOL (AcpiDisable)
24067754Smsmith
241167802Sjkim
24277424Smsmith/*******************************************************************************
24367754Smsmith *
24467754Smsmith * FUNCTION:    AcpiEnableEvent
24567754Smsmith *
246117521Snjl * PARAMETERS:  Event           - The fixed eventto be enabled
247117521Snjl *              Flags           - Reserved
24867754Smsmith *
24967754Smsmith * RETURN:      Status
25067754Smsmith *
251117521Snjl * DESCRIPTION: Enable an ACPI event (fixed)
25267754Smsmith *
25367754Smsmith ******************************************************************************/
25467754Smsmith
25567754SmsmithACPI_STATUS
25667754SmsmithAcpiEnableEvent (
25767754Smsmith    UINT32                  Event,
25884491Smsmith    UINT32                  Flags)
25967754Smsmith{
26067754Smsmith    ACPI_STATUS             Status = AE_OK;
26199679Siwasaki    UINT32                  Value;
26267754Smsmith
26367754Smsmith
264167802Sjkim    ACPI_FUNCTION_TRACE (AcpiEnableEvent);
26567754Smsmith
26667754Smsmith
267117521Snjl    /* Decode the Fixed Event */
26867754Smsmith
269117521Snjl    if (Event > ACPI_EVENT_MAX)
27067754Smsmith    {
271117521Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
272117521Snjl    }
27367754Smsmith
274117521Snjl    /*
275193267Sjkim     * Enable the requested fixed event (by writing a one to the enable
276193267Sjkim     * register bit)
277117521Snjl     */
278193267Sjkim    Status = AcpiWriteBitRegister (
279193267Sjkim                AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
280193267Sjkim                ACPI_ENABLE_EVENT);
281117521Snjl    if (ACPI_FAILURE (Status))
282117521Snjl    {
283117521Snjl        return_ACPI_STATUS (Status);
284117521Snjl    }
28567754Smsmith
286117521Snjl    /* Make sure that the hardware responded */
28767754Smsmith
288193267Sjkim    Status = AcpiReadBitRegister (
289193267Sjkim                AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
290117521Snjl    if (ACPI_FAILURE (Status))
291117521Snjl    {
292117521Snjl        return_ACPI_STATUS (Status);
293117521Snjl    }
29469450Smsmith
295117521Snjl    if (Value != 1)
296117521Snjl    {
297167802Sjkim        ACPI_ERROR ((AE_INFO,
298167802Sjkim            "Could not enable %s event", AcpiUtGetEventName (Event)));
299117521Snjl        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
300117521Snjl    }
30191116Smsmith
302117521Snjl    return_ACPI_STATUS (Status);
303117521Snjl}
30499679Siwasaki
305167802SjkimACPI_EXPORT_SYMBOL (AcpiEnableEvent)
30667754Smsmith
307167802Sjkim
308117521Snjl/*******************************************************************************
309117521Snjl *
310129684Snjl * FUNCTION:    AcpiSetGpeType
311117521Snjl *
312117521Snjl * PARAMETERS:  GpeDevice       - Parent GPE Device
313117521Snjl *              GpeNumber       - GPE level within the GPE block
314129684Snjl *              Type            - New GPE type
315117521Snjl *
316117521Snjl * RETURN:      Status
317117521Snjl *
318151937Sjkim * DESCRIPTION: Set the type of an individual GPE
319117521Snjl *
320117521Snjl ******************************************************************************/
32167754Smsmith
322117521SnjlACPI_STATUS
323129684SnjlAcpiSetGpeType (
324117521Snjl    ACPI_HANDLE             GpeDevice,
325117521Snjl    UINT32                  GpeNumber,
326129684Snjl    UINT8                   Type)
327117521Snjl{
328117521Snjl    ACPI_STATUS             Status = AE_OK;
329117521Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
33067754Smsmith
33167754Smsmith
332167802Sjkim    ACPI_FUNCTION_TRACE (AcpiSetGpeType);
33367754Smsmith
33467754Smsmith
335117521Snjl    /* Ensure that we have a valid GPE number */
33667754Smsmith
337117521Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
338117521Snjl    if (!GpeEventInfo)
339117521Snjl    {
340117521Snjl        Status = AE_BAD_PARAMETER;
341117521Snjl        goto UnlockAndExit;
342117521Snjl    }
34367754Smsmith
344129684Snjl    if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type)
345117521Snjl    {
346129684Snjl        return_ACPI_STATUS (AE_OK);
347117521Snjl    }
348117521Snjl
349129684Snjl    /* Set the new type (will disable GPE if currently enabled) */
350128212Snjl
351129684Snjl    Status = AcpiEvSetGpeType (GpeEventInfo, Type);
352128212Snjl
353117521SnjlUnlockAndExit:
35467754Smsmith    return_ACPI_STATUS (Status);
35567754Smsmith}
35667754Smsmith
357167802SjkimACPI_EXPORT_SYMBOL (AcpiSetGpeType)
35867754Smsmith
359167802Sjkim
36077424Smsmith/*******************************************************************************
36167754Smsmith *
362129684Snjl * FUNCTION:    AcpiEnableGpe
36367754Smsmith *
364129684Snjl * PARAMETERS:  GpeDevice       - Parent GPE Device
365129684Snjl *              GpeNumber       - GPE level within the GPE block
366129684Snjl *              Flags           - Just enable, or also wake enable?
367129684Snjl *                                Called from ISR or not
36867754Smsmith *
36967754Smsmith * RETURN:      Status
37067754Smsmith *
371129684Snjl * DESCRIPTION: Enable an ACPI event (general purpose)
37267754Smsmith *
37367754Smsmith ******************************************************************************/
37467754Smsmith
37567754SmsmithACPI_STATUS
376129684SnjlAcpiEnableGpe (
377129684Snjl    ACPI_HANDLE             GpeDevice,
378129684Snjl    UINT32                  GpeNumber,
37984491Smsmith    UINT32                  Flags)
38067754Smsmith{
38167754Smsmith    ACPI_STATUS             Status = AE_OK;
382129684Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
38367754Smsmith
38467754Smsmith
385167802Sjkim    ACPI_FUNCTION_TRACE (AcpiEnableGpe);
38667754Smsmith
38767754Smsmith
388129684Snjl    /* Use semaphore lock if not executing at interrupt level */
38967754Smsmith
390129684Snjl    if (Flags & ACPI_NOT_ISR)
39167754Smsmith    {
392129684Snjl        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
393129684Snjl        if (ACPI_FAILURE (Status))
394129684Snjl        {
395129684Snjl            return_ACPI_STATUS (Status);
396129684Snjl        }
397117521Snjl    }
39867754Smsmith
399129684Snjl    /* Ensure that we have a valid GPE number */
40067754Smsmith
401129684Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
402129684Snjl    if (!GpeEventInfo)
403117521Snjl    {
404129684Snjl        Status = AE_BAD_PARAMETER;
405129684Snjl        goto UnlockAndExit;
406117521Snjl    }
40767754Smsmith
408129684Snjl    /* Perform the enable */
409129684Snjl
410129684Snjl    Status = AcpiEvEnableGpe (GpeEventInfo, TRUE);
411129684Snjl
412129684SnjlUnlockAndExit:
413129684Snjl    if (Flags & ACPI_NOT_ISR)
414117521Snjl    {
415129684Snjl        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
416117521Snjl    }
417117521Snjl    return_ACPI_STATUS (Status);
418117521Snjl}
41999679Siwasaki
420167802SjkimACPI_EXPORT_SYMBOL (AcpiEnableGpe)
42167754Smsmith
422167802Sjkim
423117521Snjl/*******************************************************************************
424117521Snjl *
425117521Snjl * FUNCTION:    AcpiDisableGpe
426117521Snjl *
427117521Snjl * PARAMETERS:  GpeDevice       - Parent GPE Device
428117521Snjl *              GpeNumber       - GPE level within the GPE block
429129684Snjl *              Flags           - Just disable, or also wake disable?
430117521Snjl *                                Called from ISR or not
431117521Snjl *
432117521Snjl * RETURN:      Status
433117521Snjl *
434117521Snjl * DESCRIPTION: Disable an ACPI event (general purpose)
435117521Snjl *
436117521Snjl ******************************************************************************/
43767754Smsmith
438117521SnjlACPI_STATUS
439117521SnjlAcpiDisableGpe (
440117521Snjl    ACPI_HANDLE             GpeDevice,
441117521Snjl    UINT32                  GpeNumber,
442117521Snjl    UINT32                  Flags)
443117521Snjl{
444117521Snjl    ACPI_STATUS             Status = AE_OK;
445117521Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
44667754Smsmith
44767754Smsmith
448167802Sjkim    ACPI_FUNCTION_TRACE (AcpiDisableGpe);
44967754Smsmith
45067754Smsmith
451117521Snjl    /* Use semaphore lock if not executing at interrupt level */
452117521Snjl
453117521Snjl    if (Flags & ACPI_NOT_ISR)
454117521Snjl    {
455117521Snjl        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
456117521Snjl        if (ACPI_FAILURE (Status))
45784491Smsmith        {
458117521Snjl            return_ACPI_STATUS (Status);
45984491Smsmith        }
460117521Snjl    }
46167754Smsmith
462117521Snjl    /* Ensure that we have a valid GPE number */
46367754Smsmith
464117521Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
465117521Snjl    if (!GpeEventInfo)
466117521Snjl    {
46767754Smsmith        Status = AE_BAD_PARAMETER;
468117521Snjl        goto UnlockAndExit;
46967754Smsmith    }
47067754Smsmith
471129684Snjl    Status = AcpiEvDisableGpe (GpeEventInfo);
472129684Snjl
473129684SnjlUnlockAndExit:
474129684Snjl    if (Flags & ACPI_NOT_ISR)
475129684Snjl    {
476129684Snjl        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
477129684Snjl    }
478129684Snjl    return_ACPI_STATUS (Status);
479129684Snjl}
480129684Snjl
481167802SjkimACPI_EXPORT_SYMBOL (AcpiDisableGpe)
482129684Snjl
483167802Sjkim
484129684Snjl/*******************************************************************************
485129684Snjl *
486129684Snjl * FUNCTION:    AcpiDisableEvent
487129684Snjl *
488129684Snjl * PARAMETERS:  Event           - The fixed eventto be enabled
489129684Snjl *              Flags           - Reserved
490129684Snjl *
491129684Snjl * RETURN:      Status
492129684Snjl *
493129684Snjl * DESCRIPTION: Disable an ACPI event (fixed)
494129684Snjl *
495129684Snjl ******************************************************************************/
496129684Snjl
497129684SnjlACPI_STATUS
498129684SnjlAcpiDisableEvent (
499129684Snjl    UINT32                  Event,
500129684Snjl    UINT32                  Flags)
501129684Snjl{
502129684Snjl    ACPI_STATUS             Status = AE_OK;
503129684Snjl    UINT32                  Value;
504129684Snjl
505129684Snjl
506167802Sjkim    ACPI_FUNCTION_TRACE (AcpiDisableEvent);
507129684Snjl
508129684Snjl
509129684Snjl    /* Decode the Fixed Event */
510129684Snjl
511129684Snjl    if (Event > ACPI_EVENT_MAX)
512129684Snjl    {
513129684Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
514129684Snjl    }
515129684Snjl
516117521Snjl    /*
517193267Sjkim     * Disable the requested fixed event (by writing a zero to the enable
518193267Sjkim     * register bit)
519117521Snjl     */
520193267Sjkim    Status = AcpiWriteBitRegister (
521193267Sjkim                AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
522193267Sjkim                ACPI_DISABLE_EVENT);
523129684Snjl    if (ACPI_FAILURE (Status))
524117521Snjl    {
525129684Snjl        return_ACPI_STATUS (Status);
526117521Snjl    }
527129684Snjl
528193267Sjkim    Status = AcpiReadBitRegister (
529193267Sjkim                AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
530129684Snjl    if (ACPI_FAILURE (Status))
531117521Snjl    {
532129684Snjl        return_ACPI_STATUS (Status);
533117521Snjl    }
534117521Snjl
535129684Snjl    if (Value != 0)
536117521Snjl    {
537167802Sjkim        ACPI_ERROR ((AE_INFO,
538167802Sjkim            "Could not disable %s events", AcpiUtGetEventName (Event)));
539129684Snjl        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
540117521Snjl    }
541129684Snjl
54267754Smsmith    return_ACPI_STATUS (Status);
54367754Smsmith}
54467754Smsmith
545167802SjkimACPI_EXPORT_SYMBOL (AcpiDisableEvent)
54667754Smsmith
547167802Sjkim
54877424Smsmith/*******************************************************************************
54967754Smsmith *
55067754Smsmith * FUNCTION:    AcpiClearEvent
55167754Smsmith *
552117521Snjl * PARAMETERS:  Event           - The fixed event to be cleared
55367754Smsmith *
55467754Smsmith * RETURN:      Status
55567754Smsmith *
556117521Snjl * DESCRIPTION: Clear an ACPI event (fixed)
55767754Smsmith *
55867754Smsmith ******************************************************************************/
55967754Smsmith
56067754SmsmithACPI_STATUS
56167754SmsmithAcpiClearEvent (
562117521Snjl    UINT32                  Event)
56367754Smsmith{
56467754Smsmith    ACPI_STATUS             Status = AE_OK;
56567754Smsmith
56667754Smsmith
567167802Sjkim    ACPI_FUNCTION_TRACE (AcpiClearEvent);
56867754Smsmith
56967754Smsmith
570117521Snjl    /* Decode the Fixed Event */
57167754Smsmith
572117521Snjl    if (Event > ACPI_EVENT_MAX)
57367754Smsmith    {
574117521Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
575117521Snjl    }
57667754Smsmith
577117521Snjl    /*
578193267Sjkim     * Clear the requested fixed event (By writing a one to the status
579193267Sjkim     * register bit)
580117521Snjl     */
581193267Sjkim    Status = AcpiWriteBitRegister (
582193267Sjkim                AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
583193267Sjkim                ACPI_CLEAR_STATUS);
58467754Smsmith
585117521Snjl    return_ACPI_STATUS (Status);
586117521Snjl}
58767754Smsmith
588167802SjkimACPI_EXPORT_SYMBOL (AcpiClearEvent)
58967754Smsmith
590167802Sjkim
591117521Snjl/*******************************************************************************
592117521Snjl *
593117521Snjl * FUNCTION:    AcpiClearGpe
594117521Snjl *
595117521Snjl * PARAMETERS:  GpeDevice       - Parent GPE Device
596117521Snjl *              GpeNumber       - GPE level within the GPE block
597117521Snjl *              Flags           - Called from an ISR or not
598117521Snjl *
599117521Snjl * RETURN:      Status
600117521Snjl *
601117521Snjl * DESCRIPTION: Clear an ACPI event (general purpose)
602117521Snjl *
603117521Snjl ******************************************************************************/
60467754Smsmith
605117521SnjlACPI_STATUS
606117521SnjlAcpiClearGpe (
607117521Snjl    ACPI_HANDLE             GpeDevice,
608117521Snjl    UINT32                  GpeNumber,
609117521Snjl    UINT32                  Flags)
610117521Snjl{
611117521Snjl    ACPI_STATUS             Status = AE_OK;
612117521Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
61367754Smsmith
61467754Smsmith
615167802Sjkim    ACPI_FUNCTION_TRACE (AcpiClearGpe);
616117521Snjl
617117521Snjl
618117521Snjl    /* Use semaphore lock if not executing at interrupt level */
619117521Snjl
620117521Snjl    if (Flags & ACPI_NOT_ISR)
621117521Snjl    {
622117521Snjl        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
623117521Snjl        if (ACPI_FAILURE (Status))
62467754Smsmith        {
625117521Snjl            return_ACPI_STATUS (Status);
62667754Smsmith        }
627117521Snjl    }
62867754Smsmith
629117521Snjl    /* Ensure that we have a valid GPE number */
63067754Smsmith
631117521Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
632117521Snjl    if (!GpeEventInfo)
633117521Snjl    {
634117521Snjl        Status = AE_BAD_PARAMETER;
635117521Snjl        goto UnlockAndExit;
636117521Snjl    }
63767754Smsmith
638117521Snjl    Status = AcpiHwClearGpe (GpeEventInfo);
63967754Smsmith
640117521SnjlUnlockAndExit:
641117521Snjl    if (Flags & ACPI_NOT_ISR)
642117521Snjl    {
643117521Snjl        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
64467754Smsmith    }
64567754Smsmith    return_ACPI_STATUS (Status);
64667754Smsmith}
64767754Smsmith
648167802SjkimACPI_EXPORT_SYMBOL (AcpiClearGpe)
64967754Smsmith
650167802Sjkim
65177424Smsmith/*******************************************************************************
65267754Smsmith *
65367754Smsmith * FUNCTION:    AcpiGetEventStatus
65467754Smsmith *
655117521Snjl * PARAMETERS:  Event           - The fixed event
656151937Sjkim *              EventStatus     - Where the current status of the event will
65767754Smsmith *                                be returned
65867754Smsmith *
65967754Smsmith * RETURN:      Status
66067754Smsmith *
66167754Smsmith * DESCRIPTION: Obtains and returns the current status of the event
66267754Smsmith *
66367754Smsmith ******************************************************************************/
66467754Smsmith
66567754SmsmithACPI_STATUS
66667754SmsmithAcpiGetEventStatus (
66767754Smsmith    UINT32                  Event,
66867754Smsmith    ACPI_EVENT_STATUS       *EventStatus)
66967754Smsmith{
67067754Smsmith    ACPI_STATUS             Status = AE_OK;
67167754Smsmith
67267754Smsmith
673167802Sjkim    ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
67467754Smsmith
67567754Smsmith
67667754Smsmith    if (!EventStatus)
67767754Smsmith    {
67867754Smsmith        return_ACPI_STATUS (AE_BAD_PARAMETER);
67967754Smsmith    }
68067754Smsmith
681117521Snjl    /* Decode the Fixed Event */
68267754Smsmith
683117521Snjl    if (Event > ACPI_EVENT_MAX)
68467754Smsmith    {
685117521Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
686117521Snjl    }
68767754Smsmith
688117521Snjl    /* Get the status of the requested fixed event */
68967754Smsmith
690193267Sjkim    Status = AcpiReadBitRegister (
691193267Sjkim                AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
692117521Snjl
693117521Snjl    return_ACPI_STATUS (Status);
694117521Snjl}
695117521Snjl
696167802SjkimACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
697117521Snjl
698167802Sjkim
699117521Snjl/*******************************************************************************
700117521Snjl *
701117521Snjl * FUNCTION:    AcpiGetGpeStatus
702117521Snjl *
703117521Snjl * PARAMETERS:  GpeDevice       - Parent GPE Device
704117521Snjl *              GpeNumber       - GPE level within the GPE block
705117521Snjl *              Flags           - Called from an ISR or not
706151937Sjkim *              EventStatus     - Where the current status of the event will
707117521Snjl *                                be returned
708117521Snjl *
709117521Snjl * RETURN:      Status
710117521Snjl *
711117521Snjl * DESCRIPTION: Get status of an event (general purpose)
712117521Snjl *
713117521Snjl ******************************************************************************/
714117521Snjl
715117521SnjlACPI_STATUS
716117521SnjlAcpiGetGpeStatus (
717117521Snjl    ACPI_HANDLE             GpeDevice,
718117521Snjl    UINT32                  GpeNumber,
719117521Snjl    UINT32                  Flags,
720117521Snjl    ACPI_EVENT_STATUS       *EventStatus)
721117521Snjl{
722117521Snjl    ACPI_STATUS             Status = AE_OK;
723117521Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
724117521Snjl
725117521Snjl
726167802Sjkim    ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
727117521Snjl
728117521Snjl
729117521Snjl    /* Use semaphore lock if not executing at interrupt level */
730117521Snjl
731117521Snjl    if (Flags & ACPI_NOT_ISR)
732117521Snjl    {
733117521Snjl        Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
734117521Snjl        if (ACPI_FAILURE (Status))
73567754Smsmith        {
736117521Snjl            return_ACPI_STATUS (Status);
73767754Smsmith        }
738117521Snjl    }
73967754Smsmith
740117521Snjl    /* Ensure that we have a valid GPE number */
74167754Smsmith
742117521Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
743117521Snjl    if (!GpeEventInfo)
744117521Snjl    {
745117521Snjl        Status = AE_BAD_PARAMETER;
746117521Snjl        goto UnlockAndExit;
747117521Snjl    }
74867754Smsmith
749117521Snjl    /* Obtain status on the requested GPE number */
75067754Smsmith
751117521Snjl    Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
75267754Smsmith
753117521SnjlUnlockAndExit:
754117521Snjl    if (Flags & ACPI_NOT_ISR)
755117521Snjl    {
756117521Snjl        (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
757117521Snjl    }
758117521Snjl    return_ACPI_STATUS (Status);
759117521Snjl}
76067754Smsmith
761167802SjkimACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
762117521Snjl
763167802Sjkim
764117521Snjl/*******************************************************************************
765117521Snjl *
766117521Snjl * FUNCTION:    AcpiInstallGpeBlock
767117521Snjl *
768117521Snjl * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
769117521Snjl *              GpeBlockAddress     - Address and SpaceID
770117521Snjl *              RegisterCount       - Number of GPE register pairs in the block
771151937Sjkim *              InterruptNumber     - H/W interrupt for the block
772117521Snjl *
773117521Snjl * RETURN:      Status
774117521Snjl *
775117521Snjl * DESCRIPTION: Create and Install a block of GPE registers
776117521Snjl *
777117521Snjl ******************************************************************************/
778117521Snjl
779117521SnjlACPI_STATUS
780117521SnjlAcpiInstallGpeBlock (
781117521Snjl    ACPI_HANDLE             GpeDevice,
782117521Snjl    ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
783117521Snjl    UINT32                  RegisterCount,
784151937Sjkim    UINT32                  InterruptNumber)
785117521Snjl{
786117521Snjl    ACPI_STATUS             Status;
787117521Snjl    ACPI_OPERAND_OBJECT     *ObjDesc;
788117521Snjl    ACPI_NAMESPACE_NODE     *Node;
789117521Snjl    ACPI_GPE_BLOCK_INFO     *GpeBlock;
790117521Snjl
791117521Snjl
792167802Sjkim    ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
793117521Snjl
794117521Snjl
795117521Snjl    if ((!GpeDevice)       ||
796117521Snjl        (!GpeBlockAddress) ||
797117521Snjl        (!RegisterCount))
798117521Snjl    {
799117521Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
800117521Snjl    }
801117521Snjl
802117521Snjl    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
803117521Snjl    if (ACPI_FAILURE (Status))
804117521Snjl    {
805117521Snjl        return (Status);
806117521Snjl    }
807117521Snjl
808117521Snjl    Node = AcpiNsMapHandleToNode (GpeDevice);
809117521Snjl    if (!Node)
810117521Snjl    {
811117521Snjl        Status = AE_BAD_PARAMETER;
812117521Snjl        goto UnlockAndExit;
813117521Snjl    }
814117521Snjl
815117521Snjl    /*
816117521Snjl     * For user-installed GPE Block Devices, the GpeBlockBaseNumber
817117521Snjl     * is always zero
818117521Snjl     */
819117521Snjl    Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
820193267Sjkim                0, InterruptNumber, &GpeBlock);
821117521Snjl    if (ACPI_FAILURE (Status))
822117521Snjl    {
823117521Snjl        goto UnlockAndExit;
824117521Snjl    }
825117521Snjl
826167802Sjkim    /* Run the _PRW methods and enable the GPEs */
827167802Sjkim
828167802Sjkim    Status = AcpiEvInitializeGpeBlock (Node, GpeBlock);
829167802Sjkim    if (ACPI_FAILURE (Status))
830167802Sjkim    {
831167802Sjkim        goto UnlockAndExit;
832167802Sjkim    }
833167802Sjkim
834117521Snjl    /* Get the DeviceObject attached to the node */
835117521Snjl
836117521Snjl    ObjDesc = AcpiNsGetAttachedObject (Node);
837117521Snjl    if (!ObjDesc)
838117521Snjl    {
839117521Snjl        /* No object, create a new one */
840117521Snjl
841117521Snjl        ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
842117521Snjl        if (!ObjDesc)
84367754Smsmith        {
844117521Snjl            Status = AE_NO_MEMORY;
845117521Snjl            goto UnlockAndExit;
84667754Smsmith        }
84767754Smsmith
848117521Snjl        Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
84967754Smsmith
850117521Snjl        /* Remove local reference to the object */
85167754Smsmith
852117521Snjl        AcpiUtRemoveReference (ObjDesc);
85367754Smsmith
854117521Snjl        if (ACPI_FAILURE (Status))
855117521Snjl        {
856117521Snjl            goto UnlockAndExit;
857117521Snjl        }
858117521Snjl    }
859117521Snjl
860117521Snjl    /* Install the GPE block in the DeviceObject */
861117521Snjl
862117521Snjl    ObjDesc->Device.GpeBlock = GpeBlock;
863117521Snjl
864117521Snjl
865117521SnjlUnlockAndExit:
866117521Snjl    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
867117521Snjl    return_ACPI_STATUS (Status);
868117521Snjl}
869117521Snjl
870167802SjkimACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
871117521Snjl
872167802Sjkim
873117521Snjl/*******************************************************************************
874117521Snjl *
875117521Snjl * FUNCTION:    AcpiRemoveGpeBlock
876117521Snjl *
877117521Snjl * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
878117521Snjl *
879117521Snjl * RETURN:      Status
880117521Snjl *
881117521Snjl * DESCRIPTION: Remove a previously installed block of GPE registers
882117521Snjl *
883117521Snjl ******************************************************************************/
884117521Snjl
885117521SnjlACPI_STATUS
886117521SnjlAcpiRemoveGpeBlock (
887117521Snjl    ACPI_HANDLE             GpeDevice)
888117521Snjl{
889117521Snjl    ACPI_OPERAND_OBJECT     *ObjDesc;
890117521Snjl    ACPI_STATUS             Status;
891117521Snjl    ACPI_NAMESPACE_NODE     *Node;
892117521Snjl
893117521Snjl
894167802Sjkim    ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
895117521Snjl
896117521Snjl
897117521Snjl    if (!GpeDevice)
898117521Snjl    {
899117521Snjl        return_ACPI_STATUS (AE_BAD_PARAMETER);
900117521Snjl    }
901117521Snjl
902117521Snjl    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
903117521Snjl    if (ACPI_FAILURE (Status))
904117521Snjl    {
905117521Snjl        return (Status);
906117521Snjl    }
907117521Snjl
908117521Snjl    Node = AcpiNsMapHandleToNode (GpeDevice);
909117521Snjl    if (!Node)
910117521Snjl    {
91167754Smsmith        Status = AE_BAD_PARAMETER;
912117521Snjl        goto UnlockAndExit;
91367754Smsmith    }
91467754Smsmith
915117521Snjl    /* Get the DeviceObject attached to the node */
916117521Snjl
917117521Snjl    ObjDesc = AcpiNsGetAttachedObject (Node);
918117521Snjl    if (!ObjDesc ||
919117521Snjl        !ObjDesc->Device.GpeBlock)
920117521Snjl    {
921117521Snjl        return_ACPI_STATUS (AE_NULL_OBJECT);
922117521Snjl    }
923117521Snjl
924117521Snjl    /* Delete the GPE block (but not the DeviceObject) */
925117521Snjl
926117521Snjl    Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
927117521Snjl    if (ACPI_SUCCESS (Status))
928117521Snjl    {
929117521Snjl        ObjDesc->Device.GpeBlock = NULL;
930117521Snjl    }
931117521Snjl
932117521SnjlUnlockAndExit:
933117521Snjl    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
93467754Smsmith    return_ACPI_STATUS (Status);
93567754Smsmith}
93667754Smsmith
937167802SjkimACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
938167802Sjkim
939193267Sjkim
940193267Sjkim/*******************************************************************************
941193267Sjkim *
942193267Sjkim * FUNCTION:    AcpiGetGpeDevice
943193267Sjkim *
944193267Sjkim * PARAMETERS:  Index               - System GPE index (0-CurrentGpeCount)
945193267Sjkim *              GpeDevice           - Where the parent GPE Device is returned
946193267Sjkim *
947193267Sjkim * RETURN:      Status
948193267Sjkim *
949193267Sjkim * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
950193267Sjkim *              gpe device indicates that the gpe number is contained in one of
951193267Sjkim *              the FADT-defined gpe blocks. Otherwise, the GPE block device.
952193267Sjkim *
953193267Sjkim ******************************************************************************/
954193267Sjkim
955193267SjkimACPI_STATUS
956193267SjkimAcpiGetGpeDevice (
957193267Sjkim    UINT32                  Index,
958193267Sjkim    ACPI_HANDLE             *GpeDevice)
959193267Sjkim{
960193267Sjkim    ACPI_GPE_DEVICE_INFO    Info;
961193267Sjkim    ACPI_STATUS             Status;
962193267Sjkim
963193267Sjkim
964193267Sjkim    ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
965193267Sjkim
966193267Sjkim
967193267Sjkim    if (!GpeDevice)
968193267Sjkim    {
969193267Sjkim        return_ACPI_STATUS (AE_BAD_PARAMETER);
970193267Sjkim    }
971193267Sjkim
972193267Sjkim    if (Index >= AcpiCurrentGpeCount)
973193267Sjkim    {
974193267Sjkim        return_ACPI_STATUS (AE_NOT_EXIST);
975193267Sjkim    }
976193267Sjkim
977193267Sjkim    /* Setup and walk the GPE list */
978193267Sjkim
979193267Sjkim    Info.Index = Index;
980193267Sjkim    Info.Status = AE_NOT_EXIST;
981193267Sjkim    Info.GpeDevice = NULL;
982193267Sjkim    Info.NextBlockBaseIndex = 0;
983193267Sjkim
984193267Sjkim    Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
985193267Sjkim    if (ACPI_FAILURE (Status))
986193267Sjkim    {
987193267Sjkim        return_ACPI_STATUS (Status);
988193267Sjkim    }
989193267Sjkim
990193267Sjkim    *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
991193267Sjkim    return_ACPI_STATUS (Info.Status);
992193267Sjkim}
993193267Sjkim
994193267SjkimACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
995193267Sjkim
996193267Sjkim
997193267Sjkim/*******************************************************************************
998193267Sjkim *
999193267Sjkim * FUNCTION:    AcpiEvGetGpeDevice
1000193267Sjkim *
1001193267Sjkim * PARAMETERS:  GPE_WALK_CALLBACK
1002193267Sjkim *
1003193267Sjkim * RETURN:      Status
1004193267Sjkim *
1005193267Sjkim * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
1006193267Sjkim *              block device. NULL if the GPE is one of the FADT-defined GPEs.
1007193267Sjkim *
1008193267Sjkim ******************************************************************************/
1009193267Sjkim
1010193267Sjkimstatic ACPI_STATUS
1011193267SjkimAcpiEvGetGpeDevice (
1012193267Sjkim    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
1013193267Sjkim    ACPI_GPE_BLOCK_INFO     *GpeBlock,
1014193267Sjkim    void                    *Context)
1015193267Sjkim{
1016193267Sjkim    ACPI_GPE_DEVICE_INFO    *Info = Context;
1017193267Sjkim
1018193267Sjkim
1019193267Sjkim    /* Increment Index by the number of GPEs in this block */
1020193267Sjkim
1021193267Sjkim    Info->NextBlockBaseIndex +=
1022193267Sjkim        (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH);
1023193267Sjkim
1024193267Sjkim    if (Info->Index < Info->NextBlockBaseIndex)
1025193267Sjkim    {
1026193267Sjkim        /*
1027193267Sjkim         * The GPE index is within this block, get the node. Leave the node
1028193267Sjkim         * NULL for the FADT-defined GPEs
1029193267Sjkim         */
1030193267Sjkim        if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
1031193267Sjkim        {
1032193267Sjkim            Info->GpeDevice = GpeBlock->Node;
1033193267Sjkim        }
1034193267Sjkim
1035193267Sjkim        Info->Status = AE_OK;
1036193267Sjkim        return (AE_CTRL_END);
1037193267Sjkim    }
1038193267Sjkim
1039193267Sjkim    return (AE_OK);
1040193267Sjkim}
1041193267Sjkim
1042193267Sjkim
1043193267Sjkim/******************************************************************************
1044193267Sjkim *
1045193267Sjkim * FUNCTION:    AcpiDisableAllGpes
1046193267Sjkim *
1047193267Sjkim * PARAMETERS:  None
1048193267Sjkim *
1049193267Sjkim * RETURN:      Status
1050193267Sjkim *
1051193267Sjkim * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
1052193267Sjkim *
1053193267Sjkim ******************************************************************************/
1054193267Sjkim
1055193267SjkimACPI_STATUS
1056193267SjkimAcpiDisableAllGpes (
1057193267Sjkim    void)
1058193267Sjkim{
1059193267Sjkim    ACPI_STATUS             Status;
1060193267Sjkim
1061193267Sjkim
1062193267Sjkim    ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
1063193267Sjkim
1064193267Sjkim
1065193267Sjkim    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1066193267Sjkim    if (ACPI_FAILURE (Status))
1067193267Sjkim    {
1068193267Sjkim        return_ACPI_STATUS (Status);
1069193267Sjkim    }
1070193267Sjkim
1071193267Sjkim    Status = AcpiHwDisableAllGpes ();
1072193267Sjkim    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1073193267Sjkim
1074193267Sjkim    return_ACPI_STATUS (Status);
1075193267Sjkim}
1076193267Sjkim
1077193267Sjkim
1078193267Sjkim/******************************************************************************
1079193267Sjkim *
1080193267Sjkim * FUNCTION:    AcpiEnableAllRuntimeGpes
1081193267Sjkim *
1082193267Sjkim * PARAMETERS:  None
1083193267Sjkim *
1084193267Sjkim * RETURN:      Status
1085193267Sjkim *
1086193267Sjkim * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
1087193267Sjkim *
1088193267Sjkim ******************************************************************************/
1089193267Sjkim
1090193267SjkimACPI_STATUS
1091193267SjkimAcpiEnableAllRuntimeGpes (
1092193267Sjkim    void)
1093193267Sjkim{
1094193267Sjkim    ACPI_STATUS             Status;
1095193267Sjkim
1096193267Sjkim
1097193267Sjkim    ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
1098193267Sjkim
1099193267Sjkim
1100193267Sjkim    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1101193267Sjkim    if (ACPI_FAILURE (Status))
1102193267Sjkim    {
1103193267Sjkim        return_ACPI_STATUS (Status);
1104193267Sjkim    }
1105193267Sjkim
1106193267Sjkim    Status = AcpiHwEnableAllRuntimeGpes ();
1107193267Sjkim    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1108193267Sjkim
1109193267Sjkim    return_ACPI_STATUS (Status);
1110193267Sjkim}
1111193267Sjkim
1112193267Sjkim
1113