Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 
   2 /******************************************************************************
   3  *
   4  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
   5  *
   6  *****************************************************************************/
   7 
   8 /*
   9  * Copyright (C) 2000 - 2011, Intel Corp.
  10  * All rights reserved.
  11  *
  12  * Redistribution and use in source and binary forms, with or without
  13  * modification, are permitted provided that the following conditions
  14  * are met:
  15  * 1. Redistributions of source code must retain the above copyright
  16  *    notice, this list of conditions, and the following disclaimer,
  17  *    without modification.
  18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19  *    substantially similar to the "NO WARRANTY" disclaimer below
  20  *    ("Disclaimer") and any redistribution must be conditioned upon
  21  *    including a substantially similar Disclaimer requirement for further
  22  *    binary redistribution.
  23  * 3. Neither the names of the above-listed copyright holders nor the names
  24  *    of any contributors may be used to endorse or promote products derived
  25  *    from this software without specific prior written permission.
  26  *
  27  * Alternatively, this software may be distributed under the terms of the
  28  * GNU General Public License ("GPL") version 2 as published by the Free
  29  * Software Foundation.


  32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  42  * POSSIBILITY OF SUCH DAMAGES.
  43  */
  44 
  45 #include "acpi.h"
  46 #include "accommon.h"
  47 #include "acevents.h"
  48 
  49 #define _COMPONENT          ACPI_HARDWARE
  50         ACPI_MODULE_NAME    ("hwgpe")
  51 


  52 /* Local prototypes */
  53 
  54 static ACPI_STATUS
  55 AcpiHwEnableWakeupGpeBlock (
  56     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
  57     ACPI_GPE_BLOCK_INFO     *GpeBlock,
  58     void                    *Context);
  59 
  60 
  61 /******************************************************************************
  62  *
  63  * FUNCTION:    AcpiHwGetGpeRegisterBit
  64  *
  65  * PARAMETERS:  GpeEventInfo        - Info block for the GPE
  66  *              GpeRegisterInfo     - Info block for the GPE register
  67  *
  68  * RETURN:      Register mask with a one in the GPE bit position
  69  *
  70  * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
  71  *              correct position for the input GPE.
  72  *
  73  ******************************************************************************/
  74 
  75 UINT32
  76 AcpiHwGetGpeRegisterBit (
  77     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
  78     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo)
  79 {
  80 
  81     return ((UINT32) 1 <<
  82         (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber));
  83 }
  84 
  85 
  86 /******************************************************************************
  87  *
  88  * FUNCTION:    AcpiHwLowSetGpe
  89  *
  90  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
  91  *              Action              - Enable or disable
  92  *
  93  * RETURN:      Status
  94  *
  95  * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
  96  *
  97  ******************************************************************************/
  98 
  99 ACPI_STATUS
 100 AcpiHwLowSetGpe (
 101     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
 102     UINT32                  Action)


 111 
 112 
 113     /* Get the info block for the entire GPE register */
 114 
 115     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 116     if (!GpeRegisterInfo)
 117     {
 118         return (AE_NOT_EXIST);
 119     }
 120 
 121     /* Get current value of the enable register that contains this GPE */
 122 
 123     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
 124     if (ACPI_FAILURE (Status))
 125     {
 126         return (Status);
 127     }
 128 
 129     /* Set or clear just the bit that corresponds to this GPE */
 130 
 131     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
 132     switch (Action)
 133     {
 134     case ACPI_GPE_CONDITIONAL_ENABLE:
 135 
 136         /* Only enable if the EnableForRun bit is set */
 137 
 138         if (!(RegisterBit & GpeRegisterInfo->EnableForRun))
 139         {
 140             return (AE_BAD_PARAMETER);
 141         }
 142 
 143         /*lint -fallthrough */
 144 
 145     case ACPI_GPE_ENABLE:

 146         ACPI_SET_BIT (EnableMask, RegisterBit);
 147         break;
 148 
 149     case ACPI_GPE_DISABLE:

 150         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
 151         break;
 152 
 153     default:
 154         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action));

 155         return (AE_BAD_PARAMETER);
 156     }
 157 
 158     /* Write the updated enable mask */
 159 
 160     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
 161     return (Status);
 162 }
 163 
 164 
 165 /******************************************************************************
 166  *
 167  * FUNCTION:    AcpiHwClearGpe
 168  *
 169  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
 170  *
 171  * RETURN:      Status
 172  *
 173  * DESCRIPTION: Clear the status bit for a single GPE.
 174  *


 180 {
 181     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
 182     ACPI_STATUS             Status;
 183     UINT32                  RegisterBit;
 184 
 185 
 186     ACPI_FUNCTION_ENTRY ();
 187 
 188     /* Get the info block for the entire GPE register */
 189 
 190     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 191     if (!GpeRegisterInfo)
 192     {
 193         return (AE_NOT_EXIST);
 194     }
 195 
 196     /*
 197      * Write a one to the appropriate bit in the status register to
 198      * clear this GPE.
 199      */
 200     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
 201 
 202     Status = AcpiHwWrite (RegisterBit,
 203                     &GpeRegisterInfo->StatusAddress);
 204 
 205     return (Status);
 206 }
 207 
 208 
 209 /******************************************************************************
 210  *
 211  * FUNCTION:    AcpiHwGetGpeStatus
 212  *
 213  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
 214  *              EventStatus         - Where the GPE status is returned
 215  *
 216  * RETURN:      Status
 217  *
 218  * DESCRIPTION: Return the status of a single GPE.
 219  *
 220  ******************************************************************************/


 228     UINT32                  RegisterBit;
 229     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
 230     ACPI_EVENT_STATUS       LocalEventStatus = 0;
 231     ACPI_STATUS             Status;
 232 
 233 
 234     ACPI_FUNCTION_ENTRY ();
 235 
 236 
 237     if (!EventStatus)
 238     {
 239         return (AE_BAD_PARAMETER);
 240     }
 241 
 242     /* Get the info block for the entire GPE register */
 243 
 244     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 245 
 246     /* Get the register bitmask for this GPE */
 247 
 248     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
 249 
 250     /* GPE currently enabled? (enabled for runtime?) */
 251 
 252     if (RegisterBit & GpeRegisterInfo->EnableForRun)
 253     {
 254         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
 255     }
 256 
 257     /* GPE enabled for wake? */
 258 
 259     if (RegisterBit & GpeRegisterInfo->EnableForWake)
 260     {
 261         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
 262     }
 263 
 264     /* GPE currently active (status bit == 1)? */
 265 
 266     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
 267     if (ACPI_FAILURE (Status))
 268     {


 521  * RETURN:      Status
 522  *
 523  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
 524  *
 525  ******************************************************************************/
 526 
 527 ACPI_STATUS
 528 AcpiHwEnableAllWakeupGpes (
 529     void)
 530 {
 531     ACPI_STATUS             Status;
 532 
 533 
 534     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
 535 
 536 
 537     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
 538     return_ACPI_STATUS (Status);
 539 }
 540 


   1 /******************************************************************************
   2  *
   3  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41  * POSSIBILITY OF SUCH DAMAGES.
  42  */
  43 
  44 #include "acpi.h"
  45 #include "accommon.h"
  46 #include "acevents.h"
  47 
  48 #define _COMPONENT          ACPI_HARDWARE
  49         ACPI_MODULE_NAME    ("hwgpe")
  50 
  51 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
  52 
  53 /* Local prototypes */
  54 
  55 static ACPI_STATUS
  56 AcpiHwEnableWakeupGpeBlock (
  57     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
  58     ACPI_GPE_BLOCK_INFO     *GpeBlock,
  59     void                    *Context);
  60 
  61 
  62 /******************************************************************************
  63  *
  64  * FUNCTION:    AcpiHwGetGpeRegisterBit
  65  *
  66  * PARAMETERS:  GpeEventInfo        - Info block for the GPE

  67  *
  68  * RETURN:      Register mask with a one in the GPE bit position
  69  *
  70  * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
  71  *              correct position for the input GPE.
  72  *
  73  ******************************************************************************/
  74 
  75 UINT32
  76 AcpiHwGetGpeRegisterBit (
  77     ACPI_GPE_EVENT_INFO     *GpeEventInfo)

  78 {
  79 
  80     return ((UINT32) 1 <<
  81         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
  82 }
  83 
  84 
  85 /******************************************************************************
  86  *
  87  * FUNCTION:    AcpiHwLowSetGpe
  88  *
  89  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
  90  *              Action              - Enable or disable
  91  *
  92  * RETURN:      Status
  93  *
  94  * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
  95  *
  96  ******************************************************************************/
  97 
  98 ACPI_STATUS
  99 AcpiHwLowSetGpe (
 100     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
 101     UINT32                  Action)


 110 
 111 
 112     /* Get the info block for the entire GPE register */
 113 
 114     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 115     if (!GpeRegisterInfo)
 116     {
 117         return (AE_NOT_EXIST);
 118     }
 119 
 120     /* Get current value of the enable register that contains this GPE */
 121 
 122     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
 123     if (ACPI_FAILURE (Status))
 124     {
 125         return (Status);
 126     }
 127 
 128     /* Set or clear just the bit that corresponds to this GPE */
 129 
 130     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
 131     switch (Action)
 132     {
 133     case ACPI_GPE_CONDITIONAL_ENABLE:
 134 
 135         /* Only enable if the EnableForRun bit is set */
 136 
 137         if (!(RegisterBit & GpeRegisterInfo->EnableForRun))
 138         {
 139             return (AE_BAD_PARAMETER);
 140         }
 141 
 142         /*lint -fallthrough */
 143 
 144     case ACPI_GPE_ENABLE:
 145 
 146         ACPI_SET_BIT (EnableMask, RegisterBit);
 147         break;
 148 
 149     case ACPI_GPE_DISABLE:
 150 
 151         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
 152         break;
 153 
 154     default:
 155 
 156         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
 157         return (AE_BAD_PARAMETER);
 158     }
 159 
 160     /* Write the updated enable mask */
 161 
 162     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
 163     return (Status);
 164 }
 165 
 166 
 167 /******************************************************************************
 168  *
 169  * FUNCTION:    AcpiHwClearGpe
 170  *
 171  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
 172  *
 173  * RETURN:      Status
 174  *
 175  * DESCRIPTION: Clear the status bit for a single GPE.
 176  *


 182 {
 183     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
 184     ACPI_STATUS             Status;
 185     UINT32                  RegisterBit;
 186 
 187 
 188     ACPI_FUNCTION_ENTRY ();
 189 
 190     /* Get the info block for the entire GPE register */
 191 
 192     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 193     if (!GpeRegisterInfo)
 194     {
 195         return (AE_NOT_EXIST);
 196     }
 197 
 198     /*
 199      * Write a one to the appropriate bit in the status register to
 200      * clear this GPE.
 201      */
 202     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
 203 
 204     Status = AcpiHwWrite (RegisterBit,
 205                     &GpeRegisterInfo->StatusAddress);
 206 
 207     return (Status);
 208 }
 209 
 210 
 211 /******************************************************************************
 212  *
 213  * FUNCTION:    AcpiHwGetGpeStatus
 214  *
 215  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
 216  *              EventStatus         - Where the GPE status is returned
 217  *
 218  * RETURN:      Status
 219  *
 220  * DESCRIPTION: Return the status of a single GPE.
 221  *
 222  ******************************************************************************/


 230     UINT32                  RegisterBit;
 231     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
 232     ACPI_EVENT_STATUS       LocalEventStatus = 0;
 233     ACPI_STATUS             Status;
 234 
 235 
 236     ACPI_FUNCTION_ENTRY ();
 237 
 238 
 239     if (!EventStatus)
 240     {
 241         return (AE_BAD_PARAMETER);
 242     }
 243 
 244     /* Get the info block for the entire GPE register */
 245 
 246     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
 247 
 248     /* Get the register bitmask for this GPE */
 249 
 250     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
 251 
 252     /* GPE currently enabled? (enabled for runtime?) */
 253 
 254     if (RegisterBit & GpeRegisterInfo->EnableForRun)
 255     {
 256         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
 257     }
 258 
 259     /* GPE enabled for wake? */
 260 
 261     if (RegisterBit & GpeRegisterInfo->EnableForWake)
 262     {
 263         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
 264     }
 265 
 266     /* GPE currently active (status bit == 1)? */
 267 
 268     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
 269     if (ACPI_FAILURE (Status))
 270     {


 523  * RETURN:      Status
 524  *
 525  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
 526  *
 527  ******************************************************************************/
 528 
 529 ACPI_STATUS
 530 AcpiHwEnableAllWakeupGpes (
 531     void)
 532 {
 533     ACPI_STATUS             Status;
 534 
 535 
 536     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
 537 
 538 
 539     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
 540     return_ACPI_STATUS (Status);
 541 }
 542 
 543 #endif /* !ACPI_REDUCED_HARDWARE */