Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:02

0001 /******************************************************************************
0002  *
0003  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "acevents.h"
0155 
0156 #define _COMPONENT          ACPI_HARDWARE
0157         ACPI_MODULE_NAME    ("hwgpe")
0158 
0159 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
0160 
0161 /* Local prototypes */
0162 
0163 static ACPI_STATUS
0164 AcpiHwEnableWakeupGpeBlock (
0165     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0166     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0167     void                    *Context);
0168 
0169 static ACPI_STATUS
0170 AcpiHwGpeEnableWrite (
0171     UINT8                   EnableMask,
0172     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo);
0173 
0174 
0175 /******************************************************************************
0176  *
0177  * FUNCTION:    AcpiHwGetGpeRegisterBit
0178  *
0179  * PARAMETERS:  GpeEventInfo        - Info block for the GPE
0180  *
0181  * RETURN:      Register mask with a one in the GPE bit position
0182  *
0183  * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the
0184  *              correct position for the input GPE.
0185  *
0186  ******************************************************************************/
0187 
0188 UINT32
0189 AcpiHwGetGpeRegisterBit (
0190     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
0191 {
0192 
0193     return ((UINT32) 1 <<
0194         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
0195 }
0196 
0197 
0198 /******************************************************************************
0199  *
0200  * FUNCTION:    AcpiHwLowSetGpe
0201  *
0202  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
0203  *              Action              - Enable or disable
0204  *
0205  * RETURN:      Status
0206  *
0207  * DESCRIPTION: Enable or disable a single GPE in the parent enable register.
0208  *              The EnableMask field of the involved GPE register must be
0209  *              updated by the caller if necessary.
0210  *
0211  ******************************************************************************/
0212 
0213 ACPI_STATUS
0214 AcpiHwLowSetGpe (
0215     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
0216     UINT32                  Action)
0217 {
0218     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0219     ACPI_STATUS             Status = AE_OK;
0220     UINT64                  EnableMask;
0221     UINT32                  RegisterBit;
0222 
0223 
0224     ACPI_FUNCTION_ENTRY ();
0225 
0226 
0227     /* Get the info block for the entire GPE register */
0228 
0229     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0230     if (!GpeRegisterInfo)
0231     {
0232         return (AE_NOT_EXIST);
0233     }
0234 
0235     /* Get current value of the enable register that contains this GPE */
0236 
0237     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
0238     if (ACPI_FAILURE (Status))
0239     {
0240         return (Status);
0241     }
0242 
0243     /* Set or clear just the bit that corresponds to this GPE */
0244 
0245     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
0246     switch (Action)
0247     {
0248     case ACPI_GPE_CONDITIONAL_ENABLE:
0249 
0250         /* Only enable if the corresponding EnableMask bit is set */
0251 
0252         if (!(RegisterBit & GpeRegisterInfo->EnableMask))
0253         {
0254             return (AE_BAD_PARAMETER);
0255         }
0256 
0257         ACPI_FALLTHROUGH;
0258 
0259     case ACPI_GPE_ENABLE:
0260 
0261         ACPI_SET_BIT (EnableMask, RegisterBit);
0262         break;
0263 
0264     case ACPI_GPE_DISABLE:
0265 
0266         ACPI_CLEAR_BIT (EnableMask, RegisterBit);
0267         break;
0268 
0269     default:
0270 
0271         ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u", Action));
0272         return (AE_BAD_PARAMETER);
0273     }
0274 
0275     if (!(RegisterBit & GpeRegisterInfo->MaskForRun))
0276     {
0277         /* Write the updated enable mask */
0278 
0279         Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
0280     }
0281     return (Status);
0282 }
0283 
0284 
0285 /******************************************************************************
0286  *
0287  * FUNCTION:    AcpiHwClearGpe
0288  *
0289  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
0290  *
0291  * RETURN:      Status
0292  *
0293  * DESCRIPTION: Clear the status bit for a single GPE.
0294  *
0295  ******************************************************************************/
0296 
0297 ACPI_STATUS
0298 AcpiHwClearGpe (
0299     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
0300 {
0301     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0302     ACPI_STATUS             Status;
0303     UINT32                  RegisterBit;
0304 
0305 
0306     ACPI_FUNCTION_ENTRY ();
0307 
0308     /* Get the info block for the entire GPE register */
0309 
0310     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0311     if (!GpeRegisterInfo)
0312     {
0313         return (AE_NOT_EXIST);
0314     }
0315 
0316     /*
0317      * Write a one to the appropriate bit in the status register to
0318      * clear this GPE.
0319      */
0320     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
0321 
0322     Status = AcpiHwWrite (RegisterBit, &GpeRegisterInfo->StatusAddress);
0323     return (Status);
0324 }
0325 
0326 
0327 /******************************************************************************
0328  *
0329  * FUNCTION:    AcpiHwGetGpeStatus
0330  *
0331  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
0332  *              EventStatus         - Where the GPE status is returned
0333  *
0334  * RETURN:      Status
0335  *
0336  * DESCRIPTION: Return the status of a single GPE.
0337  *
0338  ******************************************************************************/
0339 
0340 ACPI_STATUS
0341 AcpiHwGetGpeStatus (
0342     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
0343     ACPI_EVENT_STATUS       *EventStatus)
0344 {
0345     UINT64                  InByte;
0346     UINT32                  RegisterBit;
0347     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0348     ACPI_EVENT_STATUS       LocalEventStatus = 0;
0349     ACPI_STATUS             Status;
0350 
0351 
0352     ACPI_FUNCTION_ENTRY ();
0353 
0354 
0355     if (!EventStatus)
0356     {
0357         return (AE_BAD_PARAMETER);
0358     }
0359 
0360     /* GPE currently handled? */
0361 
0362     if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) !=
0363         ACPI_GPE_DISPATCH_NONE)
0364     {
0365         LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
0366     }
0367 
0368     /* Get the info block for the entire GPE register */
0369 
0370     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0371 
0372     /* Get the register bitmask for this GPE */
0373 
0374     RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
0375 
0376     /* GPE currently enabled? (enabled for runtime?) */
0377 
0378     if (RegisterBit & GpeRegisterInfo->EnableForRun)
0379     {
0380         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
0381     }
0382 
0383     /* GPE currently masked? (masked for runtime?) */
0384 
0385     if (RegisterBit & GpeRegisterInfo->MaskForRun)
0386     {
0387         LocalEventStatus |= ACPI_EVENT_FLAG_MASKED;
0388     }
0389 
0390     /* GPE enabled for wake? */
0391 
0392     if (RegisterBit & GpeRegisterInfo->EnableForWake)
0393     {
0394         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
0395     }
0396 
0397     /* GPE currently enabled (enable bit == 1)? */
0398 
0399     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->EnableAddress);
0400     if (ACPI_FAILURE (Status))
0401     {
0402         return (Status);
0403     }
0404 
0405     if (RegisterBit & InByte)
0406     {
0407         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLE_SET;
0408     }
0409 
0410     /* GPE currently active (status bit == 1)? */
0411 
0412     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
0413     if (ACPI_FAILURE (Status))
0414     {
0415         return (Status);
0416     }
0417 
0418     if (RegisterBit & InByte)
0419     {
0420         LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
0421     }
0422 
0423     /* Set return value */
0424 
0425     (*EventStatus) = LocalEventStatus;
0426     return (AE_OK);
0427 }
0428 
0429 
0430 /******************************************************************************
0431  *
0432  * FUNCTION:    AcpiHwGpeEnableWrite
0433  *
0434  * PARAMETERS:  EnableMask          - Bit mask to write to the GPE register
0435  *              GpeRegisterInfo     - Gpe Register info
0436  *
0437  * RETURN:      Status
0438  *
0439  * DESCRIPTION: Write the enable mask byte to the given GPE register.
0440  *
0441  ******************************************************************************/
0442 
0443 static ACPI_STATUS
0444 AcpiHwGpeEnableWrite (
0445     UINT8                   EnableMask,
0446     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo)
0447 {
0448     ACPI_STATUS             Status;
0449 
0450 
0451     GpeRegisterInfo->EnableMask = EnableMask;
0452 
0453     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
0454     return (Status);
0455 }
0456 
0457 
0458 /******************************************************************************
0459  *
0460  * FUNCTION:    AcpiHwDisableGpeBlock
0461  *
0462  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0463  *              GpeBlock            - Gpe Block info
0464  *
0465  * RETURN:      Status
0466  *
0467  * DESCRIPTION: Disable all GPEs within a single GPE block
0468  *
0469  ******************************************************************************/
0470 
0471 ACPI_STATUS
0472 AcpiHwDisableGpeBlock (
0473     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0474     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0475     void                    *Context)
0476 {
0477     UINT32                  i;
0478     ACPI_STATUS             Status;
0479 
0480 
0481     /* Examine each GPE Register within the block */
0482 
0483     for (i = 0; i < GpeBlock->RegisterCount; i++)
0484     {
0485         /* Disable all GPEs in this register */
0486 
0487         Status = AcpiHwGpeEnableWrite (0x00, &GpeBlock->RegisterInfo[i]);
0488         if (ACPI_FAILURE (Status))
0489         {
0490             return (Status);
0491         }
0492     }
0493 
0494     return (AE_OK);
0495 }
0496 
0497 
0498 /******************************************************************************
0499  *
0500  * FUNCTION:    AcpiHwClearGpeBlock
0501  *
0502  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0503  *              GpeBlock            - Gpe Block info
0504  *
0505  * RETURN:      Status
0506  *
0507  * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
0508  *
0509  ******************************************************************************/
0510 
0511 ACPI_STATUS
0512 AcpiHwClearGpeBlock (
0513     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0514     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0515     void                    *Context)
0516 {
0517     UINT32                  i;
0518     ACPI_STATUS             Status;
0519 
0520 
0521     /* Examine each GPE Register within the block */
0522 
0523     for (i = 0; i < GpeBlock->RegisterCount; i++)
0524     {
0525         /* Clear status on all GPEs in this register */
0526 
0527         Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
0528         if (ACPI_FAILURE (Status))
0529         {
0530             return (Status);
0531         }
0532     }
0533 
0534     return (AE_OK);
0535 }
0536 
0537 
0538 /******************************************************************************
0539  *
0540  * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
0541  *
0542  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0543  *              GpeBlock            - Gpe Block info
0544  *
0545  * RETURN:      Status
0546  *
0547  * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
0548  *              combination wake/run GPEs.
0549  *
0550  ******************************************************************************/
0551 
0552 ACPI_STATUS
0553 AcpiHwEnableRuntimeGpeBlock (
0554     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0555     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0556     void                    *Context)
0557 {
0558     UINT32                  i;
0559     ACPI_STATUS             Status;
0560     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0561     UINT8                   EnableMask;
0562 
0563 
0564     /* NOTE: assumes that all GPEs are currently disabled */
0565 
0566     /* Examine each GPE Register within the block */
0567 
0568     for (i = 0; i < GpeBlock->RegisterCount; i++)
0569     {
0570         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
0571         if (!GpeRegisterInfo->EnableForRun)
0572         {
0573             continue;
0574         }
0575 
0576         /* Enable all "runtime" GPEs in this register */
0577 
0578         EnableMask = GpeRegisterInfo->EnableForRun &
0579             ~GpeRegisterInfo->MaskForRun;
0580         Status = AcpiHwGpeEnableWrite (EnableMask, GpeRegisterInfo);
0581         if (ACPI_FAILURE (Status))
0582         {
0583             return (Status);
0584         }
0585     }
0586 
0587     return (AE_OK);
0588 }
0589 
0590 
0591 /******************************************************************************
0592  *
0593  * FUNCTION:    AcpiHwEnableWakeupGpeBlock
0594  *
0595  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0596  *              GpeBlock            - Gpe Block info
0597  *
0598  * RETURN:      Status
0599  *
0600  * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
0601  *              combination wake/run GPEs.
0602  *
0603  ******************************************************************************/
0604 
0605 static ACPI_STATUS
0606 AcpiHwEnableWakeupGpeBlock (
0607     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0608     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0609     void                    *Context)
0610 {
0611     UINT32                  i;
0612     ACPI_STATUS             Status;
0613     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0614 
0615 
0616     /* Examine each GPE Register within the block */
0617 
0618     for (i = 0; i < GpeBlock->RegisterCount; i++)
0619     {
0620         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
0621 
0622         /*
0623          * Enable all "wake" GPEs in this register and disable the
0624          * remaining ones.
0625          */
0626         Status = AcpiHwGpeEnableWrite (GpeRegisterInfo->EnableForWake,
0627             GpeRegisterInfo);
0628         if (ACPI_FAILURE (Status))
0629         {
0630             return (Status);
0631         }
0632     }
0633 
0634     return (AE_OK);
0635 }
0636 
0637 
0638 /******************************************************************************
0639  *
0640  * FUNCTION:    AcpiHwGetGpeBlockStatus
0641  *
0642  * PARAMETERS:  GpeXruptInfo    - GPE Interrupt info
0643  *              GpeBlock        - Gpe Block info
0644  *
0645  * RETURN:      Success
0646  *
0647  * DESCRIPTION: Produce a combined GPE status bits mask for the given block.
0648  *
0649  ******************************************************************************/
0650 
0651 static ACPI_STATUS
0652 AcpiHwGetGpeBlockStatus(
0653     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0654     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0655     void *RetPtr)
0656 {
0657     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0658     UINT64                  InEnable;
0659     UINT64                  InStatus;
0660     ACPI_STATUS             Status;
0661     UINT8                   *Ret = RetPtr;
0662     UINT32                  i;
0663 
0664 
0665     /* Examine each GPE Register within the block */
0666 
0667     for (i = 0; i < GpeBlock->RegisterCount; i++)
0668     {
0669         GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
0670 
0671         Status = AcpiHwRead (&InEnable, &GpeRegisterInfo->EnableAddress);
0672         if (ACPI_FAILURE (Status))
0673         {
0674             continue;
0675         }
0676 
0677         Status = AcpiHwRead (&InStatus, &GpeRegisterInfo->StatusAddress);
0678         if (ACPI_FAILURE (Status))
0679         {
0680             continue;
0681         }
0682 
0683         *Ret |= InEnable & InStatus;
0684     }
0685 
0686     return (AE_OK);
0687 }
0688 
0689 
0690 /******************************************************************************
0691  *
0692  * FUNCTION:    AcpiHwDisableAllGpes
0693  *
0694  * PARAMETERS:  None
0695  *
0696  * RETURN:      Status
0697  *
0698  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
0699  *
0700  ******************************************************************************/
0701 
0702 ACPI_STATUS
0703 AcpiHwDisableAllGpes (
0704     void)
0705 {
0706     ACPI_STATUS             Status;
0707 
0708 
0709     ACPI_FUNCTION_TRACE (HwDisableAllGpes);
0710 
0711 
0712     Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
0713     return_ACPI_STATUS (Status);
0714 }
0715 
0716 
0717 /******************************************************************************
0718  *
0719  * FUNCTION:    AcpiHwEnableAllRuntimeGpes
0720  *
0721  * PARAMETERS:  None
0722  *
0723  * RETURN:      Status
0724  *
0725  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
0726  *
0727  ******************************************************************************/
0728 
0729 ACPI_STATUS
0730 AcpiHwEnableAllRuntimeGpes (
0731     void)
0732 {
0733     ACPI_STATUS             Status;
0734 
0735 
0736     ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
0737 
0738 
0739     Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
0740     return_ACPI_STATUS (Status);
0741 }
0742 
0743 
0744 /******************************************************************************
0745  *
0746  * FUNCTION:    AcpiHwEnableAllWakeupGpes
0747  *
0748  * PARAMETERS:  None
0749  *
0750  * RETURN:      Status
0751  *
0752  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
0753  *
0754  ******************************************************************************/
0755 
0756 ACPI_STATUS
0757 AcpiHwEnableAllWakeupGpes (
0758     void)
0759 {
0760     ACPI_STATUS             Status;
0761 
0762 
0763     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
0764 
0765 
0766     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
0767     return_ACPI_STATUS (Status);
0768 }
0769 
0770 
0771 /******************************************************************************
0772  *
0773  * FUNCTION:    AcpiHwCheckAllGpes
0774  *
0775  * PARAMETERS:  None
0776  *
0777  * RETURN:      Combined status of all GPEs
0778  *
0779  * DESCRIPTION: Check all enabled GPEs in all GPE blocks and return TRUE if the
0780  *              status bit is set for at least one of them of FALSE otherwise.
0781  *
0782  ******************************************************************************/
0783 
0784 UINT8
0785 AcpiHwCheckAllGpes (
0786     void)
0787 {
0788     UINT8                      Ret = 0;
0789 
0790 
0791     ACPI_FUNCTION_TRACE (AcpiHwCheckAllGpes);
0792 
0793     (void) AcpiEvWalkGpeList (AcpiHwGetGpeBlockStatus, &Ret);
0794     return (Ret != 0);
0795 }
0796 
0797 #endif /* !ACPI_REDUCED_HARDWARE */