Home | History | Annotate | Line # | Download | only in hardware
hwgpe.c revision 1.1.1.5
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.5  christos  * Copyright (C) 2000 - 2015, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13  1.1.1.2    jruoho  * are met:
     14  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2    jruoho  *    without modification.
     17  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2    jruoho  *    binary redistribution.
     22  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25  1.1.1.2    jruoho  *
     26  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2    jruoho  * Software Foundation.
     29  1.1.1.2    jruoho  *
     30  1.1.1.2    jruoho  * NO WARRANTY
     31  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2    jruoho  */
     43      1.1    jruoho 
     44      1.1    jruoho #include "acpi.h"
     45      1.1    jruoho #include "accommon.h"
     46      1.1    jruoho #include "acevents.h"
     47      1.1    jruoho 
     48      1.1    jruoho #define _COMPONENT          ACPI_HARDWARE
     49      1.1    jruoho         ACPI_MODULE_NAME    ("hwgpe")
     50      1.1    jruoho 
     51  1.1.1.3  christos #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
     52  1.1.1.3  christos 
     53      1.1    jruoho /* Local prototypes */
     54      1.1    jruoho 
     55      1.1    jruoho static ACPI_STATUS
     56      1.1    jruoho AcpiHwEnableWakeupGpeBlock (
     57      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
     58      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
     59      1.1    jruoho     void                    *Context);
     60      1.1    jruoho 
     61  1.1.1.5  christos static ACPI_STATUS
     62  1.1.1.5  christos AcpiHwGpeEnableWrite (
     63  1.1.1.5  christos     UINT8                   EnableMask,
     64  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo);
     65  1.1.1.5  christos 
     66      1.1    jruoho 
     67      1.1    jruoho /******************************************************************************
     68      1.1    jruoho  *
     69  1.1.1.2    jruoho  * FUNCTION:    AcpiHwGetGpeRegisterBit
     70  1.1.1.2    jruoho  *
     71  1.1.1.2    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE
     72  1.1.1.2    jruoho  *
     73  1.1.1.2    jruoho  * RETURN:      Register mask with a one in the GPE bit position
     74  1.1.1.2    jruoho  *
     75  1.1.1.2    jruoho  * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
     76  1.1.1.2    jruoho  *              correct position for the input GPE.
     77  1.1.1.2    jruoho  *
     78  1.1.1.2    jruoho  ******************************************************************************/
     79  1.1.1.2    jruoho 
     80  1.1.1.2    jruoho UINT32
     81  1.1.1.2    jruoho AcpiHwGetGpeRegisterBit (
     82  1.1.1.3  christos     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
     83  1.1.1.2    jruoho {
     84  1.1.1.2    jruoho 
     85  1.1.1.2    jruoho     return ((UINT32) 1 <<
     86  1.1.1.3  christos         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
     87  1.1.1.2    jruoho }
     88  1.1.1.2    jruoho 
     89  1.1.1.2    jruoho 
     90  1.1.1.2    jruoho /******************************************************************************
     91  1.1.1.2    jruoho  *
     92  1.1.1.2    jruoho  * FUNCTION:    AcpiHwLowSetGpe
     93      1.1    jruoho  *
     94      1.1    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
     95  1.1.1.2    jruoho  *              Action              - Enable or disable
     96      1.1    jruoho  *
     97      1.1    jruoho  * RETURN:      Status
     98      1.1    jruoho  *
     99  1.1.1.2    jruoho  * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
    100      1.1    jruoho  *
    101      1.1    jruoho  ******************************************************************************/
    102      1.1    jruoho 
    103      1.1    jruoho ACPI_STATUS
    104  1.1.1.2    jruoho AcpiHwLowSetGpe (
    105  1.1.1.2    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
    106  1.1.1.2    jruoho     UINT32                  Action)
    107      1.1    jruoho {
    108      1.1    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    109      1.1    jruoho     ACPI_STATUS             Status;
    110      1.1    jruoho     UINT32                  EnableMask;
    111  1.1.1.2    jruoho     UINT32                  RegisterBit;
    112  1.1.1.2    jruoho 
    113  1.1.1.2    jruoho 
    114  1.1.1.2    jruoho     ACPI_FUNCTION_ENTRY ();
    115      1.1    jruoho 
    116      1.1    jruoho 
    117      1.1    jruoho     /* Get the info block for the entire GPE register */
    118      1.1    jruoho 
    119      1.1    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    120      1.1    jruoho     if (!GpeRegisterInfo)
    121      1.1    jruoho     {
    122      1.1    jruoho         return (AE_NOT_EXIST);
    123      1.1    jruoho     }
    124      1.1    jruoho 
    125      1.1    jruoho     /* Get current value of the enable register that contains this GPE */
    126      1.1    jruoho 
    127      1.1    jruoho     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
    128      1.1    jruoho     if (ACPI_FAILURE (Status))
    129      1.1    jruoho     {
    130      1.1    jruoho         return (Status);
    131      1.1    jruoho     }
    132      1.1    jruoho 
    133  1.1.1.2    jruoho     /* Set or clear just the bit that corresponds to this GPE */
    134      1.1    jruoho 
    135  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    136  1.1.1.5  christos     switch (Action & ~ACPI_GPE_SAVE_MASK)
    137  1.1.1.2    jruoho     {
    138  1.1.1.2    jruoho     case ACPI_GPE_CONDITIONAL_ENABLE:
    139      1.1    jruoho 
    140  1.1.1.5  christos         /* Only enable if the corresponding EnableMask bit is set */
    141      1.1    jruoho 
    142  1.1.1.5  christos         if (!(RegisterBit & GpeRegisterInfo->EnableMask))
    143  1.1.1.2    jruoho         {
    144  1.1.1.2    jruoho             return (AE_BAD_PARAMETER);
    145  1.1.1.2    jruoho         }
    146      1.1    jruoho 
    147  1.1.1.2    jruoho         /*lint -fallthrough */
    148      1.1    jruoho 
    149  1.1.1.2    jruoho     case ACPI_GPE_ENABLE:
    150  1.1.1.3  christos 
    151  1.1.1.2    jruoho         ACPI_SET_BIT (EnableMask, RegisterBit);
    152  1.1.1.2    jruoho         break;
    153  1.1.1.2    jruoho 
    154  1.1.1.2    jruoho     case ACPI_GPE_DISABLE:
    155  1.1.1.3  christos 
    156  1.1.1.2    jruoho         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
    157  1.1.1.2    jruoho         break;
    158      1.1    jruoho 
    159  1.1.1.2    jruoho     default:
    160  1.1.1.3  christos 
    161  1.1.1.3  christos         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
    162  1.1.1.2    jruoho         return (AE_BAD_PARAMETER);
    163      1.1    jruoho     }
    164      1.1    jruoho 
    165  1.1.1.2    jruoho     /* Write the updated enable mask */
    166      1.1    jruoho 
    167  1.1.1.2    jruoho     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
    168  1.1.1.5  christos     if (ACPI_SUCCESS (Status) && (Action & ACPI_GPE_SAVE_MASK))
    169  1.1.1.5  christos     {
    170  1.1.1.5  christos         GpeRegisterInfo->EnableMask = (UINT8) EnableMask;
    171  1.1.1.5  christos     }
    172      1.1    jruoho     return (Status);
    173      1.1    jruoho }
    174      1.1    jruoho 
    175      1.1    jruoho 
    176      1.1    jruoho /******************************************************************************
    177      1.1    jruoho  *
    178      1.1    jruoho  * FUNCTION:    AcpiHwClearGpe
    179      1.1    jruoho  *
    180      1.1    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
    181      1.1    jruoho  *
    182      1.1    jruoho  * RETURN:      Status
    183      1.1    jruoho  *
    184      1.1    jruoho  * DESCRIPTION: Clear the status bit for a single GPE.
    185      1.1    jruoho  *
    186      1.1    jruoho  ******************************************************************************/
    187      1.1    jruoho 
    188      1.1    jruoho ACPI_STATUS
    189      1.1    jruoho AcpiHwClearGpe (
    190      1.1    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
    191      1.1    jruoho {
    192  1.1.1.2    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    193      1.1    jruoho     ACPI_STATUS             Status;
    194  1.1.1.2    jruoho     UINT32                  RegisterBit;
    195      1.1    jruoho 
    196      1.1    jruoho 
    197      1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    198      1.1    jruoho 
    199  1.1.1.2    jruoho     /* Get the info block for the entire GPE register */
    200      1.1    jruoho 
    201  1.1.1.2    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    202  1.1.1.2    jruoho     if (!GpeRegisterInfo)
    203  1.1.1.2    jruoho     {
    204  1.1.1.2    jruoho         return (AE_NOT_EXIST);
    205  1.1.1.2    jruoho     }
    206      1.1    jruoho 
    207      1.1    jruoho     /*
    208      1.1    jruoho      * Write a one to the appropriate bit in the status register to
    209      1.1    jruoho      * clear this GPE.
    210      1.1    jruoho      */
    211  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    212  1.1.1.2    jruoho 
    213      1.1    jruoho     Status = AcpiHwWrite (RegisterBit,
    214  1.1.1.2    jruoho                     &GpeRegisterInfo->StatusAddress);
    215      1.1    jruoho 
    216      1.1    jruoho     return (Status);
    217      1.1    jruoho }
    218      1.1    jruoho 
    219      1.1    jruoho 
    220      1.1    jruoho /******************************************************************************
    221      1.1    jruoho  *
    222      1.1    jruoho  * FUNCTION:    AcpiHwGetGpeStatus
    223      1.1    jruoho  *
    224      1.1    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
    225      1.1    jruoho  *              EventStatus         - Where the GPE status is returned
    226      1.1    jruoho  *
    227      1.1    jruoho  * RETURN:      Status
    228      1.1    jruoho  *
    229      1.1    jruoho  * DESCRIPTION: Return the status of a single GPE.
    230      1.1    jruoho  *
    231      1.1    jruoho  ******************************************************************************/
    232      1.1    jruoho 
    233      1.1    jruoho ACPI_STATUS
    234      1.1    jruoho AcpiHwGetGpeStatus (
    235      1.1    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
    236      1.1    jruoho     ACPI_EVENT_STATUS       *EventStatus)
    237      1.1    jruoho {
    238      1.1    jruoho     UINT32                  InByte;
    239  1.1.1.2    jruoho     UINT32                  RegisterBit;
    240      1.1    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    241      1.1    jruoho     ACPI_EVENT_STATUS       LocalEventStatus = 0;
    242  1.1.1.2    jruoho     ACPI_STATUS             Status;
    243      1.1    jruoho 
    244      1.1    jruoho 
    245      1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    246      1.1    jruoho 
    247      1.1    jruoho 
    248      1.1    jruoho     if (!EventStatus)
    249      1.1    jruoho     {
    250      1.1    jruoho         return (AE_BAD_PARAMETER);
    251      1.1    jruoho     }
    252      1.1    jruoho 
    253  1.1.1.4  christos     /* GPE currently handled? */
    254  1.1.1.4  christos 
    255  1.1.1.5  christos     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) !=
    256  1.1.1.4  christos             ACPI_GPE_DISPATCH_NONE)
    257  1.1.1.4  christos     {
    258  1.1.1.4  christos         LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
    259  1.1.1.4  christos     }
    260  1.1.1.4  christos 
    261      1.1    jruoho     /* Get the info block for the entire GPE register */
    262      1.1    jruoho 
    263      1.1    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    264      1.1    jruoho 
    265      1.1    jruoho     /* Get the register bitmask for this GPE */
    266      1.1    jruoho 
    267  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    268      1.1    jruoho 
    269      1.1    jruoho     /* GPE currently enabled? (enabled for runtime?) */
    270      1.1    jruoho 
    271      1.1    jruoho     if (RegisterBit & GpeRegisterInfo->EnableForRun)
    272      1.1    jruoho     {
    273      1.1    jruoho         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
    274      1.1    jruoho     }
    275      1.1    jruoho 
    276      1.1    jruoho     /* GPE enabled for wake? */
    277      1.1    jruoho 
    278      1.1    jruoho     if (RegisterBit & GpeRegisterInfo->EnableForWake)
    279      1.1    jruoho     {
    280      1.1    jruoho         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
    281      1.1    jruoho     }
    282      1.1    jruoho 
    283  1.1.1.5  christos     /* GPE currently enabled (enable bit == 1)? */
    284  1.1.1.5  christos 
    285  1.1.1.5  christos     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->EnableAddress);
    286  1.1.1.5  christos     if (ACPI_FAILURE (Status))
    287  1.1.1.5  christos     {
    288  1.1.1.5  christos         return (Status);
    289  1.1.1.5  christos     }
    290  1.1.1.5  christos 
    291  1.1.1.5  christos     if (RegisterBit & InByte)
    292  1.1.1.5  christos     {
    293  1.1.1.5  christos         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLE_SET;
    294  1.1.1.5  christos     }
    295  1.1.1.5  christos 
    296      1.1    jruoho     /* GPE currently active (status bit == 1)? */
    297      1.1    jruoho 
    298      1.1    jruoho     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
    299      1.1    jruoho     if (ACPI_FAILURE (Status))
    300      1.1    jruoho     {
    301      1.1    jruoho         return (Status);
    302      1.1    jruoho     }
    303      1.1    jruoho 
    304      1.1    jruoho     if (RegisterBit & InByte)
    305      1.1    jruoho     {
    306  1.1.1.5  christos         LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
    307      1.1    jruoho     }
    308      1.1    jruoho 
    309      1.1    jruoho     /* Set return value */
    310      1.1    jruoho 
    311      1.1    jruoho     (*EventStatus) = LocalEventStatus;
    312      1.1    jruoho     return (AE_OK);
    313      1.1    jruoho }
    314      1.1    jruoho 
    315      1.1    jruoho 
    316      1.1    jruoho /******************************************************************************
    317      1.1    jruoho  *
    318  1.1.1.5  christos  * FUNCTION:    AcpiHwGpeEnableWrite
    319  1.1.1.5  christos  *
    320  1.1.1.5  christos  * PARAMETERS:  EnableMask          - Bit mask to write to the GPE register
    321  1.1.1.5  christos  *              GpeRegisterInfo     - Gpe Register info
    322  1.1.1.5  christos  *
    323  1.1.1.5  christos  * RETURN:      Status
    324  1.1.1.5  christos  *
    325  1.1.1.5  christos  * DESCRIPTION: Write the enable mask byte to the given GPE register.
    326  1.1.1.5  christos  *
    327  1.1.1.5  christos  ******************************************************************************/
    328  1.1.1.5  christos 
    329  1.1.1.5  christos static ACPI_STATUS
    330  1.1.1.5  christos AcpiHwGpeEnableWrite (
    331  1.1.1.5  christos     UINT8                   EnableMask,
    332  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo)
    333  1.1.1.5  christos {
    334  1.1.1.5  christos     ACPI_STATUS             Status;
    335  1.1.1.5  christos 
    336  1.1.1.5  christos 
    337  1.1.1.5  christos     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
    338  1.1.1.5  christos     if (ACPI_SUCCESS (Status))
    339  1.1.1.5  christos     {
    340  1.1.1.5  christos         GpeRegisterInfo->EnableMask = EnableMask;
    341  1.1.1.5  christos     }
    342  1.1.1.5  christos 
    343  1.1.1.5  christos     return (Status);
    344  1.1.1.5  christos }
    345  1.1.1.5  christos 
    346  1.1.1.5  christos 
    347  1.1.1.5  christos /******************************************************************************
    348  1.1.1.5  christos  *
    349      1.1    jruoho  * FUNCTION:    AcpiHwDisableGpeBlock
    350      1.1    jruoho  *
    351      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    352      1.1    jruoho  *              GpeBlock            - Gpe Block info
    353      1.1    jruoho  *
    354      1.1    jruoho  * RETURN:      Status
    355      1.1    jruoho  *
    356      1.1    jruoho  * DESCRIPTION: Disable all GPEs within a single GPE block
    357      1.1    jruoho  *
    358      1.1    jruoho  ******************************************************************************/
    359      1.1    jruoho 
    360      1.1    jruoho ACPI_STATUS
    361      1.1    jruoho AcpiHwDisableGpeBlock (
    362      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    363      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    364      1.1    jruoho     void                    *Context)
    365      1.1    jruoho {
    366      1.1    jruoho     UINT32                  i;
    367      1.1    jruoho     ACPI_STATUS             Status;
    368      1.1    jruoho 
    369      1.1    jruoho 
    370      1.1    jruoho     /* Examine each GPE Register within the block */
    371      1.1    jruoho 
    372      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    373      1.1    jruoho     {
    374      1.1    jruoho         /* Disable all GPEs in this register */
    375      1.1    jruoho 
    376  1.1.1.5  christos         Status = AcpiHwGpeEnableWrite (0x00, &GpeBlock->RegisterInfo[i]);
    377      1.1    jruoho         if (ACPI_FAILURE (Status))
    378      1.1    jruoho         {
    379      1.1    jruoho             return (Status);
    380      1.1    jruoho         }
    381      1.1    jruoho     }
    382      1.1    jruoho 
    383      1.1    jruoho     return (AE_OK);
    384      1.1    jruoho }
    385      1.1    jruoho 
    386      1.1    jruoho 
    387      1.1    jruoho /******************************************************************************
    388      1.1    jruoho  *
    389      1.1    jruoho  * FUNCTION:    AcpiHwClearGpeBlock
    390      1.1    jruoho  *
    391      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    392      1.1    jruoho  *              GpeBlock            - Gpe Block info
    393      1.1    jruoho  *
    394      1.1    jruoho  * RETURN:      Status
    395      1.1    jruoho  *
    396      1.1    jruoho  * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
    397      1.1    jruoho  *
    398      1.1    jruoho  ******************************************************************************/
    399      1.1    jruoho 
    400      1.1    jruoho ACPI_STATUS
    401      1.1    jruoho AcpiHwClearGpeBlock (
    402      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    403      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    404      1.1    jruoho     void                    *Context)
    405      1.1    jruoho {
    406      1.1    jruoho     UINT32                  i;
    407      1.1    jruoho     ACPI_STATUS             Status;
    408      1.1    jruoho 
    409      1.1    jruoho 
    410      1.1    jruoho     /* Examine each GPE Register within the block */
    411      1.1    jruoho 
    412      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    413      1.1    jruoho     {
    414      1.1    jruoho         /* Clear status on all GPEs in this register */
    415      1.1    jruoho 
    416      1.1    jruoho         Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
    417      1.1    jruoho         if (ACPI_FAILURE (Status))
    418      1.1    jruoho         {
    419      1.1    jruoho             return (Status);
    420      1.1    jruoho         }
    421      1.1    jruoho     }
    422      1.1    jruoho 
    423      1.1    jruoho     return (AE_OK);
    424      1.1    jruoho }
    425      1.1    jruoho 
    426      1.1    jruoho 
    427      1.1    jruoho /******************************************************************************
    428      1.1    jruoho  *
    429      1.1    jruoho  * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
    430      1.1    jruoho  *
    431      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    432      1.1    jruoho  *              GpeBlock            - Gpe Block info
    433      1.1    jruoho  *
    434      1.1    jruoho  * RETURN:      Status
    435      1.1    jruoho  *
    436      1.1    jruoho  * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
    437      1.1    jruoho  *              combination wake/run GPEs.
    438      1.1    jruoho  *
    439      1.1    jruoho  ******************************************************************************/
    440      1.1    jruoho 
    441      1.1    jruoho ACPI_STATUS
    442      1.1    jruoho AcpiHwEnableRuntimeGpeBlock (
    443      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    444      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    445      1.1    jruoho     void                    *Context)
    446      1.1    jruoho {
    447      1.1    jruoho     UINT32                  i;
    448      1.1    jruoho     ACPI_STATUS             Status;
    449  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    450      1.1    jruoho 
    451      1.1    jruoho 
    452      1.1    jruoho     /* NOTE: assumes that all GPEs are currently disabled */
    453      1.1    jruoho 
    454      1.1    jruoho     /* Examine each GPE Register within the block */
    455      1.1    jruoho 
    456      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    457      1.1    jruoho     {
    458  1.1.1.5  christos         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
    459  1.1.1.5  christos         if (!GpeRegisterInfo->EnableForRun)
    460      1.1    jruoho         {
    461      1.1    jruoho             continue;
    462      1.1    jruoho         }
    463      1.1    jruoho 
    464      1.1    jruoho         /* Enable all "runtime" GPEs in this register */
    465      1.1    jruoho 
    466  1.1.1.5  christos         Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForRun,
    467  1.1.1.5  christos                     GpeRegisterInfo);
    468      1.1    jruoho         if (ACPI_FAILURE (Status))
    469      1.1    jruoho         {
    470      1.1    jruoho             return (Status);
    471      1.1    jruoho         }
    472      1.1    jruoho     }
    473      1.1    jruoho 
    474      1.1    jruoho     return (AE_OK);
    475      1.1    jruoho }
    476      1.1    jruoho 
    477      1.1    jruoho 
    478      1.1    jruoho /******************************************************************************
    479      1.1    jruoho  *
    480      1.1    jruoho  * FUNCTION:    AcpiHwEnableWakeupGpeBlock
    481      1.1    jruoho  *
    482      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    483      1.1    jruoho  *              GpeBlock            - Gpe Block info
    484      1.1    jruoho  *
    485      1.1    jruoho  * RETURN:      Status
    486      1.1    jruoho  *
    487      1.1    jruoho  * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
    488      1.1    jruoho  *              combination wake/run GPEs.
    489      1.1    jruoho  *
    490      1.1    jruoho  ******************************************************************************/
    491      1.1    jruoho 
    492      1.1    jruoho static ACPI_STATUS
    493      1.1    jruoho AcpiHwEnableWakeupGpeBlock (
    494      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    495      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    496      1.1    jruoho     void                    *Context)
    497      1.1    jruoho {
    498      1.1    jruoho     UINT32                  i;
    499      1.1    jruoho     ACPI_STATUS             Status;
    500  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    501      1.1    jruoho 
    502      1.1    jruoho 
    503      1.1    jruoho     /* Examine each GPE Register within the block */
    504      1.1    jruoho 
    505      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    506      1.1    jruoho     {
    507  1.1.1.5  christos         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
    508      1.1    jruoho 
    509  1.1.1.5  christos         /*
    510  1.1.1.5  christos          * Enable all "wake" GPEs in this register and disable the
    511  1.1.1.5  christos          * remaining ones.
    512  1.1.1.5  christos          */
    513  1.1.1.5  christos         Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake,
    514  1.1.1.5  christos                     GpeRegisterInfo);
    515      1.1    jruoho         if (ACPI_FAILURE (Status))
    516      1.1    jruoho         {
    517      1.1    jruoho             return (Status);
    518      1.1    jruoho         }
    519      1.1    jruoho     }
    520      1.1    jruoho 
    521      1.1    jruoho     return (AE_OK);
    522      1.1    jruoho }
    523      1.1    jruoho 
    524      1.1    jruoho 
    525      1.1    jruoho /******************************************************************************
    526      1.1    jruoho  *
    527      1.1    jruoho  * FUNCTION:    AcpiHwDisableAllGpes
    528      1.1    jruoho  *
    529      1.1    jruoho  * PARAMETERS:  None
    530      1.1    jruoho  *
    531      1.1    jruoho  * RETURN:      Status
    532      1.1    jruoho  *
    533      1.1    jruoho  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
    534      1.1    jruoho  *
    535      1.1    jruoho  ******************************************************************************/
    536      1.1    jruoho 
    537      1.1    jruoho ACPI_STATUS
    538      1.1    jruoho AcpiHwDisableAllGpes (
    539      1.1    jruoho     void)
    540      1.1    jruoho {
    541      1.1    jruoho     ACPI_STATUS             Status;
    542      1.1    jruoho 
    543      1.1    jruoho 
    544      1.1    jruoho     ACPI_FUNCTION_TRACE (HwDisableAllGpes);
    545      1.1    jruoho 
    546      1.1    jruoho 
    547      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
    548      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
    549      1.1    jruoho     return_ACPI_STATUS (Status);
    550      1.1    jruoho }
    551      1.1    jruoho 
    552      1.1    jruoho 
    553      1.1    jruoho /******************************************************************************
    554      1.1    jruoho  *
    555      1.1    jruoho  * FUNCTION:    AcpiHwEnableAllRuntimeGpes
    556      1.1    jruoho  *
    557      1.1    jruoho  * PARAMETERS:  None
    558      1.1    jruoho  *
    559      1.1    jruoho  * RETURN:      Status
    560      1.1    jruoho  *
    561      1.1    jruoho  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
    562      1.1    jruoho  *
    563      1.1    jruoho  ******************************************************************************/
    564      1.1    jruoho 
    565      1.1    jruoho ACPI_STATUS
    566      1.1    jruoho AcpiHwEnableAllRuntimeGpes (
    567      1.1    jruoho     void)
    568      1.1    jruoho {
    569      1.1    jruoho     ACPI_STATUS             Status;
    570      1.1    jruoho 
    571      1.1    jruoho 
    572      1.1    jruoho     ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
    573      1.1    jruoho 
    574      1.1    jruoho 
    575      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
    576      1.1    jruoho     return_ACPI_STATUS (Status);
    577      1.1    jruoho }
    578      1.1    jruoho 
    579      1.1    jruoho 
    580      1.1    jruoho /******************************************************************************
    581      1.1    jruoho  *
    582      1.1    jruoho  * FUNCTION:    AcpiHwEnableAllWakeupGpes
    583      1.1    jruoho  *
    584      1.1    jruoho  * PARAMETERS:  None
    585      1.1    jruoho  *
    586      1.1    jruoho  * RETURN:      Status
    587      1.1    jruoho  *
    588      1.1    jruoho  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
    589      1.1    jruoho  *
    590      1.1    jruoho  ******************************************************************************/
    591      1.1    jruoho 
    592      1.1    jruoho ACPI_STATUS
    593      1.1    jruoho AcpiHwEnableAllWakeupGpes (
    594      1.1    jruoho     void)
    595      1.1    jruoho {
    596      1.1    jruoho     ACPI_STATUS             Status;
    597      1.1    jruoho 
    598      1.1    jruoho 
    599      1.1    jruoho     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
    600      1.1    jruoho 
    601      1.1    jruoho 
    602      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
    603      1.1    jruoho     return_ACPI_STATUS (Status);
    604      1.1    jruoho }
    605      1.1    jruoho 
    606  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    607