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