Home | History | Annotate | Line # | Download | only in hardware
hwgpe.c revision 1.1.1.8
      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.7  christos  * Copyright (C) 2000 - 2016, 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.1.6  christos  *              The EnableMask field of the involved GPE register must be
    101  1.1.1.6  christos  *              updated by the caller if necessary.
    102      1.1    jruoho  *
    103      1.1    jruoho  ******************************************************************************/
    104      1.1    jruoho 
    105      1.1    jruoho ACPI_STATUS
    106  1.1.1.2    jruoho AcpiHwLowSetGpe (
    107  1.1.1.2    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
    108  1.1.1.2    jruoho     UINT32                  Action)
    109      1.1    jruoho {
    110      1.1    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    111  1.1.1.8  christos     ACPI_STATUS             Status = AE_OK;
    112      1.1    jruoho     UINT32                  EnableMask;
    113  1.1.1.2    jruoho     UINT32                  RegisterBit;
    114  1.1.1.2    jruoho 
    115  1.1.1.2    jruoho 
    116  1.1.1.2    jruoho     ACPI_FUNCTION_ENTRY ();
    117      1.1    jruoho 
    118      1.1    jruoho 
    119      1.1    jruoho     /* Get the info block for the entire GPE register */
    120      1.1    jruoho 
    121      1.1    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    122      1.1    jruoho     if (!GpeRegisterInfo)
    123      1.1    jruoho     {
    124      1.1    jruoho         return (AE_NOT_EXIST);
    125      1.1    jruoho     }
    126      1.1    jruoho 
    127      1.1    jruoho     /* Get current value of the enable register that contains this GPE */
    128      1.1    jruoho 
    129      1.1    jruoho     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
    130      1.1    jruoho     if (ACPI_FAILURE (Status))
    131      1.1    jruoho     {
    132      1.1    jruoho         return (Status);
    133      1.1    jruoho     }
    134      1.1    jruoho 
    135  1.1.1.2    jruoho     /* Set or clear just the bit that corresponds to this GPE */
    136      1.1    jruoho 
    137  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    138  1.1.1.6  christos     switch (Action)
    139  1.1.1.2    jruoho     {
    140  1.1.1.2    jruoho     case ACPI_GPE_CONDITIONAL_ENABLE:
    141      1.1    jruoho 
    142  1.1.1.5  christos         /* Only enable if the corresponding EnableMask bit is set */
    143      1.1    jruoho 
    144  1.1.1.5  christos         if (!(RegisterBit & GpeRegisterInfo->EnableMask))
    145  1.1.1.2    jruoho         {
    146  1.1.1.2    jruoho             return (AE_BAD_PARAMETER);
    147  1.1.1.2    jruoho         }
    148      1.1    jruoho 
    149  1.1.1.2    jruoho         /*lint -fallthrough */
    150      1.1    jruoho 
    151  1.1.1.2    jruoho     case ACPI_GPE_ENABLE:
    152  1.1.1.3  christos 
    153  1.1.1.2    jruoho         ACPI_SET_BIT (EnableMask, RegisterBit);
    154  1.1.1.2    jruoho         break;
    155  1.1.1.2    jruoho 
    156  1.1.1.2    jruoho     case ACPI_GPE_DISABLE:
    157  1.1.1.3  christos 
    158  1.1.1.2    jruoho         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
    159  1.1.1.2    jruoho         break;
    160      1.1    jruoho 
    161  1.1.1.2    jruoho     default:
    162  1.1.1.3  christos 
    163  1.1.1.3  christos         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
    164  1.1.1.2    jruoho         return (AE_BAD_PARAMETER);
    165      1.1    jruoho     }
    166      1.1    jruoho 
    167  1.1.1.8  christos     if (!(RegisterBit & GpeRegisterInfo->MaskForRun))
    168  1.1.1.8  christos     {
    169  1.1.1.8  christos         /* Write the updated enable mask */
    170      1.1    jruoho 
    171  1.1.1.8  christos         Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
    172  1.1.1.8  christos     }
    173      1.1    jruoho     return (Status);
    174      1.1    jruoho }
    175      1.1    jruoho 
    176      1.1    jruoho 
    177      1.1    jruoho /******************************************************************************
    178      1.1    jruoho  *
    179      1.1    jruoho  * FUNCTION:    AcpiHwClearGpe
    180      1.1    jruoho  *
    181      1.1    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
    182      1.1    jruoho  *
    183      1.1    jruoho  * RETURN:      Status
    184      1.1    jruoho  *
    185      1.1    jruoho  * DESCRIPTION: Clear the status bit for a single GPE.
    186      1.1    jruoho  *
    187      1.1    jruoho  ******************************************************************************/
    188      1.1    jruoho 
    189      1.1    jruoho ACPI_STATUS
    190      1.1    jruoho AcpiHwClearGpe (
    191      1.1    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
    192      1.1    jruoho {
    193  1.1.1.2    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    194      1.1    jruoho     ACPI_STATUS             Status;
    195  1.1.1.2    jruoho     UINT32                  RegisterBit;
    196      1.1    jruoho 
    197      1.1    jruoho 
    198      1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    199      1.1    jruoho 
    200  1.1.1.2    jruoho     /* Get the info block for the entire GPE register */
    201      1.1    jruoho 
    202  1.1.1.2    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    203  1.1.1.2    jruoho     if (!GpeRegisterInfo)
    204  1.1.1.2    jruoho     {
    205  1.1.1.2    jruoho         return (AE_NOT_EXIST);
    206  1.1.1.2    jruoho     }
    207      1.1    jruoho 
    208      1.1    jruoho     /*
    209      1.1    jruoho      * Write a one to the appropriate bit in the status register to
    210      1.1    jruoho      * clear this GPE.
    211      1.1    jruoho      */
    212  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    213  1.1.1.2    jruoho 
    214  1.1.1.7  christos     Status = AcpiHwWrite (RegisterBit, &GpeRegisterInfo->StatusAddress);
    215      1.1    jruoho     return (Status);
    216      1.1    jruoho }
    217      1.1    jruoho 
    218      1.1    jruoho 
    219      1.1    jruoho /******************************************************************************
    220      1.1    jruoho  *
    221      1.1    jruoho  * FUNCTION:    AcpiHwGetGpeStatus
    222      1.1    jruoho  *
    223      1.1    jruoho  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
    224      1.1    jruoho  *              EventStatus         - Where the GPE status is returned
    225      1.1    jruoho  *
    226      1.1    jruoho  * RETURN:      Status
    227      1.1    jruoho  *
    228      1.1    jruoho  * DESCRIPTION: Return the status of a single GPE.
    229      1.1    jruoho  *
    230      1.1    jruoho  ******************************************************************************/
    231      1.1    jruoho 
    232      1.1    jruoho ACPI_STATUS
    233      1.1    jruoho AcpiHwGetGpeStatus (
    234      1.1    jruoho     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
    235      1.1    jruoho     ACPI_EVENT_STATUS       *EventStatus)
    236      1.1    jruoho {
    237      1.1    jruoho     UINT32                  InByte;
    238  1.1.1.2    jruoho     UINT32                  RegisterBit;
    239      1.1    jruoho     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    240      1.1    jruoho     ACPI_EVENT_STATUS       LocalEventStatus = 0;
    241  1.1.1.2    jruoho     ACPI_STATUS             Status;
    242      1.1    jruoho 
    243      1.1    jruoho 
    244      1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    245      1.1    jruoho 
    246      1.1    jruoho 
    247      1.1    jruoho     if (!EventStatus)
    248      1.1    jruoho     {
    249      1.1    jruoho         return (AE_BAD_PARAMETER);
    250      1.1    jruoho     }
    251      1.1    jruoho 
    252  1.1.1.4  christos     /* GPE currently handled? */
    253  1.1.1.4  christos 
    254  1.1.1.5  christos     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) !=
    255  1.1.1.7  christos         ACPI_GPE_DISPATCH_NONE)
    256  1.1.1.4  christos     {
    257  1.1.1.4  christos         LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
    258  1.1.1.4  christos     }
    259  1.1.1.4  christos 
    260      1.1    jruoho     /* Get the info block for the entire GPE register */
    261      1.1    jruoho 
    262      1.1    jruoho     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
    263      1.1    jruoho 
    264      1.1    jruoho     /* Get the register bitmask for this GPE */
    265      1.1    jruoho 
    266  1.1.1.3  christos     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
    267      1.1    jruoho 
    268      1.1    jruoho     /* GPE currently enabled? (enabled for runtime?) */
    269      1.1    jruoho 
    270      1.1    jruoho     if (RegisterBit & GpeRegisterInfo->EnableForRun)
    271      1.1    jruoho     {
    272      1.1    jruoho         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
    273      1.1    jruoho     }
    274      1.1    jruoho 
    275  1.1.1.8  christos     /* GPE currently masked? (masked for runtime?) */
    276  1.1.1.8  christos 
    277  1.1.1.8  christos     if (RegisterBit & GpeRegisterInfo->MaskForRun)
    278  1.1.1.8  christos     {
    279  1.1.1.8  christos         LocalEventStatus |= ACPI_EVENT_FLAG_MASKED;
    280  1.1.1.8  christos     }
    281  1.1.1.8  christos 
    282      1.1    jruoho     /* GPE enabled for wake? */
    283      1.1    jruoho 
    284      1.1    jruoho     if (RegisterBit & GpeRegisterInfo->EnableForWake)
    285      1.1    jruoho     {
    286      1.1    jruoho         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
    287      1.1    jruoho     }
    288      1.1    jruoho 
    289  1.1.1.5  christos     /* GPE currently enabled (enable bit == 1)? */
    290  1.1.1.5  christos 
    291  1.1.1.5  christos     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->EnableAddress);
    292  1.1.1.5  christos     if (ACPI_FAILURE (Status))
    293  1.1.1.5  christos     {
    294  1.1.1.5  christos         return (Status);
    295  1.1.1.5  christos     }
    296  1.1.1.5  christos 
    297  1.1.1.5  christos     if (RegisterBit & InByte)
    298  1.1.1.5  christos     {
    299  1.1.1.5  christos         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLE_SET;
    300  1.1.1.5  christos     }
    301  1.1.1.5  christos 
    302      1.1    jruoho     /* GPE currently active (status bit == 1)? */
    303      1.1    jruoho 
    304      1.1    jruoho     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
    305      1.1    jruoho     if (ACPI_FAILURE (Status))
    306      1.1    jruoho     {
    307      1.1    jruoho         return (Status);
    308      1.1    jruoho     }
    309      1.1    jruoho 
    310      1.1    jruoho     if (RegisterBit & InByte)
    311      1.1    jruoho     {
    312  1.1.1.5  christos         LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
    313      1.1    jruoho     }
    314      1.1    jruoho 
    315      1.1    jruoho     /* Set return value */
    316      1.1    jruoho 
    317      1.1    jruoho     (*EventStatus) = LocalEventStatus;
    318      1.1    jruoho     return (AE_OK);
    319      1.1    jruoho }
    320      1.1    jruoho 
    321      1.1    jruoho 
    322      1.1    jruoho /******************************************************************************
    323      1.1    jruoho  *
    324  1.1.1.5  christos  * FUNCTION:    AcpiHwGpeEnableWrite
    325  1.1.1.5  christos  *
    326  1.1.1.5  christos  * PARAMETERS:  EnableMask          - Bit mask to write to the GPE register
    327  1.1.1.5  christos  *              GpeRegisterInfo     - Gpe Register info
    328  1.1.1.5  christos  *
    329  1.1.1.5  christos  * RETURN:      Status
    330  1.1.1.5  christos  *
    331  1.1.1.5  christos  * DESCRIPTION: Write the enable mask byte to the given GPE register.
    332  1.1.1.5  christos  *
    333  1.1.1.5  christos  ******************************************************************************/
    334  1.1.1.5  christos 
    335  1.1.1.5  christos static ACPI_STATUS
    336  1.1.1.5  christos AcpiHwGpeEnableWrite (
    337  1.1.1.5  christos     UINT8                   EnableMask,
    338  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo)
    339  1.1.1.5  christos {
    340  1.1.1.5  christos     ACPI_STATUS             Status;
    341  1.1.1.5  christos 
    342  1.1.1.5  christos 
    343  1.1.1.6  christos     GpeRegisterInfo->EnableMask = EnableMask;
    344  1.1.1.5  christos 
    345  1.1.1.7  christos     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
    346  1.1.1.5  christos     return (Status);
    347  1.1.1.5  christos }
    348  1.1.1.5  christos 
    349  1.1.1.5  christos 
    350  1.1.1.5  christos /******************************************************************************
    351  1.1.1.5  christos  *
    352      1.1    jruoho  * FUNCTION:    AcpiHwDisableGpeBlock
    353      1.1    jruoho  *
    354      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    355      1.1    jruoho  *              GpeBlock            - Gpe Block info
    356      1.1    jruoho  *
    357      1.1    jruoho  * RETURN:      Status
    358      1.1    jruoho  *
    359      1.1    jruoho  * DESCRIPTION: Disable all GPEs within a single GPE block
    360      1.1    jruoho  *
    361      1.1    jruoho  ******************************************************************************/
    362      1.1    jruoho 
    363      1.1    jruoho ACPI_STATUS
    364      1.1    jruoho AcpiHwDisableGpeBlock (
    365      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    366      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    367      1.1    jruoho     void                    *Context)
    368      1.1    jruoho {
    369      1.1    jruoho     UINT32                  i;
    370      1.1    jruoho     ACPI_STATUS             Status;
    371      1.1    jruoho 
    372      1.1    jruoho 
    373      1.1    jruoho     /* Examine each GPE Register within the block */
    374      1.1    jruoho 
    375      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    376      1.1    jruoho     {
    377      1.1    jruoho         /* Disable all GPEs in this register */
    378      1.1    jruoho 
    379  1.1.1.5  christos         Status = AcpiHwGpeEnableWrite (0x00, &GpeBlock->RegisterInfo[i]);
    380      1.1    jruoho         if (ACPI_FAILURE (Status))
    381      1.1    jruoho         {
    382      1.1    jruoho             return (Status);
    383      1.1    jruoho         }
    384      1.1    jruoho     }
    385      1.1    jruoho 
    386      1.1    jruoho     return (AE_OK);
    387      1.1    jruoho }
    388      1.1    jruoho 
    389      1.1    jruoho 
    390      1.1    jruoho /******************************************************************************
    391      1.1    jruoho  *
    392      1.1    jruoho  * FUNCTION:    AcpiHwClearGpeBlock
    393      1.1    jruoho  *
    394      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    395      1.1    jruoho  *              GpeBlock            - Gpe Block info
    396      1.1    jruoho  *
    397      1.1    jruoho  * RETURN:      Status
    398      1.1    jruoho  *
    399      1.1    jruoho  * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
    400      1.1    jruoho  *
    401      1.1    jruoho  ******************************************************************************/
    402      1.1    jruoho 
    403      1.1    jruoho ACPI_STATUS
    404      1.1    jruoho AcpiHwClearGpeBlock (
    405      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    406      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    407      1.1    jruoho     void                    *Context)
    408      1.1    jruoho {
    409      1.1    jruoho     UINT32                  i;
    410      1.1    jruoho     ACPI_STATUS             Status;
    411      1.1    jruoho 
    412      1.1    jruoho 
    413      1.1    jruoho     /* Examine each GPE Register within the block */
    414      1.1    jruoho 
    415      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    416      1.1    jruoho     {
    417      1.1    jruoho         /* Clear status on all GPEs in this register */
    418      1.1    jruoho 
    419      1.1    jruoho         Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
    420      1.1    jruoho         if (ACPI_FAILURE (Status))
    421      1.1    jruoho         {
    422      1.1    jruoho             return (Status);
    423      1.1    jruoho         }
    424      1.1    jruoho     }
    425      1.1    jruoho 
    426      1.1    jruoho     return (AE_OK);
    427      1.1    jruoho }
    428      1.1    jruoho 
    429      1.1    jruoho 
    430      1.1    jruoho /******************************************************************************
    431      1.1    jruoho  *
    432      1.1    jruoho  * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
    433      1.1    jruoho  *
    434      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    435      1.1    jruoho  *              GpeBlock            - Gpe Block info
    436      1.1    jruoho  *
    437      1.1    jruoho  * RETURN:      Status
    438      1.1    jruoho  *
    439      1.1    jruoho  * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
    440      1.1    jruoho  *              combination wake/run GPEs.
    441      1.1    jruoho  *
    442      1.1    jruoho  ******************************************************************************/
    443      1.1    jruoho 
    444      1.1    jruoho ACPI_STATUS
    445      1.1    jruoho AcpiHwEnableRuntimeGpeBlock (
    446      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    447      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    448      1.1    jruoho     void                    *Context)
    449      1.1    jruoho {
    450      1.1    jruoho     UINT32                  i;
    451      1.1    jruoho     ACPI_STATUS             Status;
    452  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    453  1.1.1.8  christos     UINT8                   EnableMask;
    454      1.1    jruoho 
    455      1.1    jruoho 
    456      1.1    jruoho     /* NOTE: assumes that all GPEs are currently disabled */
    457      1.1    jruoho 
    458      1.1    jruoho     /* Examine each GPE Register within the block */
    459      1.1    jruoho 
    460      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    461      1.1    jruoho     {
    462  1.1.1.5  christos         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
    463  1.1.1.5  christos         if (!GpeRegisterInfo->EnableForRun)
    464      1.1    jruoho         {
    465      1.1    jruoho             continue;
    466      1.1    jruoho         }
    467      1.1    jruoho 
    468      1.1    jruoho         /* Enable all "runtime" GPEs in this register */
    469      1.1    jruoho 
    470  1.1.1.8  christos         EnableMask = GpeRegisterInfo->EnableForRun &
    471  1.1.1.8  christos             ~GpeRegisterInfo->MaskForRun;
    472  1.1.1.8  christos         Status = AcpiHwGpeEnableWrite (EnableMask, GpeRegisterInfo);
    473      1.1    jruoho         if (ACPI_FAILURE (Status))
    474      1.1    jruoho         {
    475      1.1    jruoho             return (Status);
    476      1.1    jruoho         }
    477      1.1    jruoho     }
    478      1.1    jruoho 
    479      1.1    jruoho     return (AE_OK);
    480      1.1    jruoho }
    481      1.1    jruoho 
    482      1.1    jruoho 
    483      1.1    jruoho /******************************************************************************
    484      1.1    jruoho  *
    485      1.1    jruoho  * FUNCTION:    AcpiHwEnableWakeupGpeBlock
    486      1.1    jruoho  *
    487      1.1    jruoho  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
    488      1.1    jruoho  *              GpeBlock            - Gpe Block info
    489      1.1    jruoho  *
    490      1.1    jruoho  * RETURN:      Status
    491      1.1    jruoho  *
    492      1.1    jruoho  * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
    493      1.1    jruoho  *              combination wake/run GPEs.
    494      1.1    jruoho  *
    495      1.1    jruoho  ******************************************************************************/
    496      1.1    jruoho 
    497      1.1    jruoho static ACPI_STATUS
    498      1.1    jruoho AcpiHwEnableWakeupGpeBlock (
    499      1.1    jruoho     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
    500      1.1    jruoho     ACPI_GPE_BLOCK_INFO     *GpeBlock,
    501      1.1    jruoho     void                    *Context)
    502      1.1    jruoho {
    503      1.1    jruoho     UINT32                  i;
    504      1.1    jruoho     ACPI_STATUS             Status;
    505  1.1.1.5  christos     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
    506      1.1    jruoho 
    507      1.1    jruoho 
    508      1.1    jruoho     /* Examine each GPE Register within the block */
    509      1.1    jruoho 
    510      1.1    jruoho     for (i = 0; i < GpeBlock->RegisterCount; i++)
    511      1.1    jruoho     {
    512  1.1.1.5  christos         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
    513      1.1    jruoho 
    514  1.1.1.5  christos         /*
    515  1.1.1.5  christos          * Enable all "wake" GPEs in this register and disable the
    516  1.1.1.5  christos          * remaining ones.
    517  1.1.1.5  christos          */
    518  1.1.1.5  christos         Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake,
    519  1.1.1.7  christos             GpeRegisterInfo);
    520      1.1    jruoho         if (ACPI_FAILURE (Status))
    521      1.1    jruoho         {
    522      1.1    jruoho             return (Status);
    523      1.1    jruoho         }
    524      1.1    jruoho     }
    525      1.1    jruoho 
    526      1.1    jruoho     return (AE_OK);
    527      1.1    jruoho }
    528      1.1    jruoho 
    529      1.1    jruoho 
    530      1.1    jruoho /******************************************************************************
    531      1.1    jruoho  *
    532      1.1    jruoho  * FUNCTION:    AcpiHwDisableAllGpes
    533      1.1    jruoho  *
    534      1.1    jruoho  * PARAMETERS:  None
    535      1.1    jruoho  *
    536      1.1    jruoho  * RETURN:      Status
    537      1.1    jruoho  *
    538      1.1    jruoho  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
    539      1.1    jruoho  *
    540      1.1    jruoho  ******************************************************************************/
    541      1.1    jruoho 
    542      1.1    jruoho ACPI_STATUS
    543      1.1    jruoho AcpiHwDisableAllGpes (
    544      1.1    jruoho     void)
    545      1.1    jruoho {
    546      1.1    jruoho     ACPI_STATUS             Status;
    547      1.1    jruoho 
    548      1.1    jruoho 
    549      1.1    jruoho     ACPI_FUNCTION_TRACE (HwDisableAllGpes);
    550      1.1    jruoho 
    551      1.1    jruoho 
    552      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
    553      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
    554      1.1    jruoho     return_ACPI_STATUS (Status);
    555      1.1    jruoho }
    556      1.1    jruoho 
    557      1.1    jruoho 
    558      1.1    jruoho /******************************************************************************
    559      1.1    jruoho  *
    560      1.1    jruoho  * FUNCTION:    AcpiHwEnableAllRuntimeGpes
    561      1.1    jruoho  *
    562      1.1    jruoho  * PARAMETERS:  None
    563      1.1    jruoho  *
    564      1.1    jruoho  * RETURN:      Status
    565      1.1    jruoho  *
    566      1.1    jruoho  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
    567      1.1    jruoho  *
    568      1.1    jruoho  ******************************************************************************/
    569      1.1    jruoho 
    570      1.1    jruoho ACPI_STATUS
    571      1.1    jruoho AcpiHwEnableAllRuntimeGpes (
    572      1.1    jruoho     void)
    573      1.1    jruoho {
    574      1.1    jruoho     ACPI_STATUS             Status;
    575      1.1    jruoho 
    576      1.1    jruoho 
    577      1.1    jruoho     ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
    578      1.1    jruoho 
    579      1.1    jruoho 
    580      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
    581      1.1    jruoho     return_ACPI_STATUS (Status);
    582      1.1    jruoho }
    583      1.1    jruoho 
    584      1.1    jruoho 
    585      1.1    jruoho /******************************************************************************
    586      1.1    jruoho  *
    587      1.1    jruoho  * FUNCTION:    AcpiHwEnableAllWakeupGpes
    588      1.1    jruoho  *
    589      1.1    jruoho  * PARAMETERS:  None
    590      1.1    jruoho  *
    591      1.1    jruoho  * RETURN:      Status
    592      1.1    jruoho  *
    593      1.1    jruoho  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
    594      1.1    jruoho  *
    595      1.1    jruoho  ******************************************************************************/
    596      1.1    jruoho 
    597      1.1    jruoho ACPI_STATUS
    598      1.1    jruoho AcpiHwEnableAllWakeupGpes (
    599      1.1    jruoho     void)
    600      1.1    jruoho {
    601      1.1    jruoho     ACPI_STATUS             Status;
    602      1.1    jruoho 
    603      1.1    jruoho 
    604      1.1    jruoho     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
    605      1.1    jruoho 
    606      1.1    jruoho 
    607      1.1    jruoho     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
    608      1.1    jruoho     return_ACPI_STATUS (Status);
    609      1.1    jruoho }
    610      1.1    jruoho 
    611  1.1.1.3  christos #endif /* !ACPI_REDUCED_HARDWARE */
    612