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