Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/hwgpe.c need to be fixed.

0001 
0002 /******************************************************************************
0003  *
0004  * Module Name: hwgpe - Low level GPE enable/disable/clear functions
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights.  You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code.  No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision.  In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change.  Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee.  Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution.  In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government.  In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************/
0116 
0117 #include "acpi.h"
0118 #include "accommon.h"
0119 #include "acevents.h"
0120 
0121 #define _COMPONENT          ACPI_HARDWARE
0122         ACPI_MODULE_NAME    ("hwgpe")
0123 
0124 /* Local prototypes */
0125 
0126 static ACPI_STATUS
0127 AcpiHwEnableWakeupGpeBlock (
0128     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0129     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0130     void                    *Context);
0131 
0132 
0133 /******************************************************************************
0134  *
0135  * FUNCTION:    AcpiHwLowDisableGpe
0136  *
0137  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be disabled
0138  *
0139  * RETURN:      Status
0140  *
0141  * DESCRIPTION: Disable a single GPE in the enable register.
0142  *
0143  ******************************************************************************/
0144 
0145 ACPI_STATUS
0146 AcpiHwLowDisableGpe (
0147     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
0148 {
0149     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0150     ACPI_STATUS             Status;
0151     UINT32                  EnableMask;
0152 
0153 
0154     /* Get the info block for the entire GPE register */
0155 
0156     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0157     if (!GpeRegisterInfo)
0158     {
0159         return (AE_NOT_EXIST);
0160     }
0161 
0162     /* Get current value of the enable register that contains this GPE */
0163 
0164     Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress);
0165     if (ACPI_FAILURE (Status))
0166     {
0167         return (Status);
0168     }
0169 
0170     /* Clear just the bit that corresponds to this GPE */
0171 
0172     ACPI_CLEAR_BIT (EnableMask, ((UINT32) 1 <<
0173         (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)));
0174 
0175 
0176     /* Write the updated enable mask */
0177 
0178     Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress);
0179     return (Status);
0180 }
0181 
0182 
0183 /******************************************************************************
0184  *
0185  * FUNCTION:    AcpiHwWriteGpeEnableReg
0186  *
0187  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be enabled
0188  *
0189  * RETURN:      Status
0190  *
0191  * DESCRIPTION: Write a GPE enable register.  Note: The bit for this GPE must
0192  *              already be cleared or set in the parent register
0193  *              EnableForRun mask.
0194  *
0195  ******************************************************************************/
0196 
0197 ACPI_STATUS
0198 AcpiHwWriteGpeEnableReg (
0199     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
0200 {
0201     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0202     ACPI_STATUS             Status;
0203 
0204 
0205     ACPI_FUNCTION_ENTRY ();
0206 
0207 
0208     /* Get the info block for the entire GPE register */
0209 
0210     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0211     if (!GpeRegisterInfo)
0212     {
0213         return (AE_NOT_EXIST);
0214     }
0215 
0216     /* Write the entire GPE (runtime) enable register */
0217 
0218     Status = AcpiHwWrite (GpeRegisterInfo->EnableForRun,
0219                     &GpeRegisterInfo->EnableAddress);
0220 
0221     return (Status);
0222 }
0223 
0224 
0225 /******************************************************************************
0226  *
0227  * FUNCTION:    AcpiHwClearGpe
0228  *
0229  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to be cleared
0230  *
0231  * RETURN:      Status
0232  *
0233  * DESCRIPTION: Clear the status bit for a single GPE.
0234  *
0235  ******************************************************************************/
0236 
0237 ACPI_STATUS
0238 AcpiHwClearGpe (
0239     ACPI_GPE_EVENT_INFO     *GpeEventInfo)
0240 {
0241     ACPI_STATUS             Status;
0242     UINT8                   RegisterBit;
0243 
0244 
0245     ACPI_FUNCTION_ENTRY ();
0246 
0247 
0248     RegisterBit = (UINT8) (1 <<
0249         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
0250 
0251     /*
0252      * Write a one to the appropriate bit in the status register to
0253      * clear this GPE.
0254      */
0255     Status = AcpiHwWrite (RegisterBit,
0256                     &GpeEventInfo->RegisterInfo->StatusAddress);
0257 
0258     return (Status);
0259 }
0260 
0261 
0262 /******************************************************************************
0263  *
0264  * FUNCTION:    AcpiHwGetGpeStatus
0265  *
0266  * PARAMETERS:  GpeEventInfo        - Info block for the GPE to queried
0267  *              EventStatus         - Where the GPE status is returned
0268  *
0269  * RETURN:      Status
0270  *
0271  * DESCRIPTION: Return the status of a single GPE.
0272  *
0273  ******************************************************************************/
0274 
0275 ACPI_STATUS
0276 AcpiHwGetGpeStatus (
0277     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
0278     ACPI_EVENT_STATUS       *EventStatus)
0279 {
0280     UINT32                  InByte;
0281     UINT8                   RegisterBit;
0282     ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
0283     ACPI_STATUS             Status;
0284     ACPI_EVENT_STATUS       LocalEventStatus = 0;
0285 
0286 
0287     ACPI_FUNCTION_ENTRY ();
0288 
0289 
0290     if (!EventStatus)
0291     {
0292         return (AE_BAD_PARAMETER);
0293     }
0294 
0295     /* Get the info block for the entire GPE register */
0296 
0297     GpeRegisterInfo = GpeEventInfo->RegisterInfo;
0298 
0299     /* Get the register bitmask for this GPE */
0300 
0301     RegisterBit = (UINT8) (1 <<
0302         (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber));
0303 
0304     /* GPE currently enabled? (enabled for runtime?) */
0305 
0306     if (RegisterBit & GpeRegisterInfo->EnableForRun)
0307     {
0308         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
0309     }
0310 
0311     /* GPE enabled for wake? */
0312 
0313     if (RegisterBit & GpeRegisterInfo->EnableForWake)
0314     {
0315         LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
0316     }
0317 
0318     /* GPE currently active (status bit == 1)? */
0319 
0320     Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress);
0321     if (ACPI_FAILURE (Status))
0322     {
0323         goto UnlockAndExit;
0324     }
0325 
0326     if (RegisterBit & InByte)
0327     {
0328         LocalEventStatus |= ACPI_EVENT_FLAG_SET;
0329     }
0330 
0331     /* Set return value */
0332 
0333     (*EventStatus) = LocalEventStatus;
0334 
0335 
0336 UnlockAndExit:
0337     return (Status);
0338 }
0339 
0340 
0341 /******************************************************************************
0342  *
0343  * FUNCTION:    AcpiHwDisableGpeBlock
0344  *
0345  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0346  *              GpeBlock            - Gpe Block info
0347  *
0348  * RETURN:      Status
0349  *
0350  * DESCRIPTION: Disable all GPEs within a single GPE block
0351  *
0352  ******************************************************************************/
0353 
0354 ACPI_STATUS
0355 AcpiHwDisableGpeBlock (
0356     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0357     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0358     void                    *Context)
0359 {
0360     UINT32                  i;
0361     ACPI_STATUS             Status;
0362 
0363 
0364     /* Examine each GPE Register within the block */
0365 
0366     for (i = 0; i < GpeBlock->RegisterCount; i++)
0367     {
0368         /* Disable all GPEs in this register */
0369 
0370         Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress);
0371         if (ACPI_FAILURE (Status))
0372         {
0373             return (Status);
0374         }
0375     }
0376 
0377     return (AE_OK);
0378 }
0379 
0380 
0381 /******************************************************************************
0382  *
0383  * FUNCTION:    AcpiHwClearGpeBlock
0384  *
0385  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0386  *              GpeBlock            - Gpe Block info
0387  *
0388  * RETURN:      Status
0389  *
0390  * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
0391  *
0392  ******************************************************************************/
0393 
0394 ACPI_STATUS
0395 AcpiHwClearGpeBlock (
0396     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0397     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0398     void                    *Context)
0399 {
0400     UINT32                  i;
0401     ACPI_STATUS             Status;
0402 
0403 
0404     /* Examine each GPE Register within the block */
0405 
0406     for (i = 0; i < GpeBlock->RegisterCount; i++)
0407     {
0408         /* Clear status on all GPEs in this register */
0409 
0410         Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress);
0411         if (ACPI_FAILURE (Status))
0412         {
0413             return (Status);
0414         }
0415     }
0416 
0417     return (AE_OK);
0418 }
0419 
0420 
0421 /******************************************************************************
0422  *
0423  * FUNCTION:    AcpiHwEnableRuntimeGpeBlock
0424  *
0425  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0426  *              GpeBlock            - Gpe Block info
0427  *
0428  * RETURN:      Status
0429  *
0430  * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
0431  *              combination wake/run GPEs.
0432  *
0433  ******************************************************************************/
0434 
0435 ACPI_STATUS
0436 AcpiHwEnableRuntimeGpeBlock (
0437     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0438     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0439     void                    *Context)
0440 {
0441     UINT32                  i;
0442     ACPI_STATUS             Status;
0443 
0444 
0445     /* NOTE: assumes that all GPEs are currently disabled */
0446 
0447     /* Examine each GPE Register within the block */
0448 
0449     for (i = 0; i < GpeBlock->RegisterCount; i++)
0450     {
0451         if (!GpeBlock->RegisterInfo[i].EnableForRun)
0452         {
0453             continue;
0454         }
0455 
0456         /* Enable all "runtime" GPEs in this register */
0457 
0458         Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun,
0459                     &GpeBlock->RegisterInfo[i].EnableAddress);
0460         if (ACPI_FAILURE (Status))
0461         {
0462             return (Status);
0463         }
0464     }
0465 
0466     return (AE_OK);
0467 }
0468 
0469 
0470 /******************************************************************************
0471  *
0472  * FUNCTION:    AcpiHwEnableWakeupGpeBlock
0473  *
0474  * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
0475  *              GpeBlock            - Gpe Block info
0476  *
0477  * RETURN:      Status
0478  *
0479  * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
0480  *              combination wake/run GPEs.
0481  *
0482  ******************************************************************************/
0483 
0484 static ACPI_STATUS
0485 AcpiHwEnableWakeupGpeBlock (
0486     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0487     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0488     void                    *Context)
0489 {
0490     UINT32                  i;
0491     ACPI_STATUS             Status;
0492 
0493 
0494     /* Examine each GPE Register within the block */
0495 
0496     for (i = 0; i < GpeBlock->RegisterCount; i++)
0497     {
0498         if (!GpeBlock->RegisterInfo[i].EnableForWake)
0499         {
0500             continue;
0501         }
0502 
0503         /* Enable all "wake" GPEs in this register */
0504 
0505         Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake,
0506                     &GpeBlock->RegisterInfo[i].EnableAddress);
0507         if (ACPI_FAILURE (Status))
0508         {
0509             return (Status);
0510         }
0511     }
0512 
0513     return (AE_OK);
0514 }
0515 
0516 
0517 /******************************************************************************
0518  *
0519  * FUNCTION:    AcpiHwDisableAllGpes
0520  *
0521  * PARAMETERS:  None
0522  *
0523  * RETURN:      Status
0524  *
0525  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
0526  *
0527  ******************************************************************************/
0528 
0529 ACPI_STATUS
0530 AcpiHwDisableAllGpes (
0531     void)
0532 {
0533     ACPI_STATUS             Status;
0534 
0535 
0536     ACPI_FUNCTION_TRACE (HwDisableAllGpes);
0537 
0538 
0539     Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
0540     Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL);
0541     return_ACPI_STATUS (Status);
0542 }
0543 
0544 
0545 /******************************************************************************
0546  *
0547  * FUNCTION:    AcpiHwEnableAllRuntimeGpes
0548  *
0549  * PARAMETERS:  None
0550  *
0551  * RETURN:      Status
0552  *
0553  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
0554  *
0555  ******************************************************************************/
0556 
0557 ACPI_STATUS
0558 AcpiHwEnableAllRuntimeGpes (
0559     void)
0560 {
0561     ACPI_STATUS             Status;
0562 
0563 
0564     ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes);
0565 
0566 
0567     Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL);
0568     return_ACPI_STATUS (Status);
0569 }
0570 
0571 
0572 /******************************************************************************
0573  *
0574  * FUNCTION:    AcpiHwEnableAllWakeupGpes
0575  *
0576  * PARAMETERS:  None
0577  *
0578  * RETURN:      Status
0579  *
0580  * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
0581  *
0582  ******************************************************************************/
0583 
0584 ACPI_STATUS
0585 AcpiHwEnableAllWakeupGpes (
0586     void)
0587 {
0588     ACPI_STATUS             Status;
0589 
0590 
0591     ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes);
0592 
0593 
0594     Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL);
0595     return_ACPI_STATUS (Status);
0596 }
0597