hwgpe.c revision 126372
171867Smsmith 267754Smsmith/****************************************************************************** 367754Smsmith * 467754Smsmith * Module Name: hwgpe - Low level GPE enable/disable/clear functions 5126372Snjl * $Revision: 56 $ 667754Smsmith * 767754Smsmith *****************************************************************************/ 867754Smsmith 967754Smsmith/****************************************************************************** 1067754Smsmith * 1167754Smsmith * 1. Copyright Notice 1267754Smsmith * 13126372Snjl * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. 1470243Smsmith * All rights reserved. 1567754Smsmith * 1667754Smsmith * 2. License 1767754Smsmith * 1867754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1967754Smsmith * rights. You may have additional license terms from the party that provided 2067754Smsmith * you this software, covering your right to use that party's intellectual 2167754Smsmith * property rights. 2267754Smsmith * 2367754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2467754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2567754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2667754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2867754Smsmith * Code in any form, with the right to sublicense such rights; and 2967754Smsmith * 3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3167754Smsmith * license (with the right to sublicense), under only those claims of Intel 3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3567754Smsmith * license, and in no event shall the patent license extend to any additions 3667754Smsmith * to or modifications of the Original Intel Code. No other license or right 3767754Smsmith * is granted directly or by implication, estoppel or otherwise; 3867754Smsmith * 3967754Smsmith * The above copyright and patent license is granted only if the following 4067754Smsmith * conditions are met: 4167754Smsmith * 4267754Smsmith * 3. Conditions 4367754Smsmith * 4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4567754Smsmith * Redistribution of source code of any substantial portion of the Covered 4667754Smsmith * Code or modification with rights to further distribute source must include 4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4867754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5167754Smsmith * Code and the date of any change. Licensee must include in that file the 5267754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5367754Smsmith * must include a prominent statement that the modification is derived, 5467754Smsmith * directly or indirectly, from Original Intel Code. 5567754Smsmith * 5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5767754Smsmith * Redistribution of source code of any substantial portion of the Covered 5867754Smsmith * Code or modification without rights to further distribute source must 5967754Smsmith * include the following Disclaimer and Export Compliance provision in the 6067754Smsmith * documentation and/or other materials provided with distribution. In 6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6367754Smsmith * license from Licensee to its licensee is limited to the intellectual 6467754Smsmith * property embodied in the software Licensee provides to its licensee, and 6567754Smsmith * not to intellectual property embodied in modifications its licensee may 6667754Smsmith * make. 6767754Smsmith * 6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7167754Smsmith * provision in the documentation and/or other materials provided with the 7267754Smsmith * distribution. 7367754Smsmith * 7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7567754Smsmith * Intel Code. 7667754Smsmith * 7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7967754Smsmith * other dealings in products derived from or relating to the Covered Code 8067754Smsmith * without prior written authorization from Intel. 8167754Smsmith * 8267754Smsmith * 4. Disclaimer and Export Compliance 8367754Smsmith * 8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8567754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9067754Smsmith * PARTICULAR PURPOSE. 9167754Smsmith * 9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9967754Smsmith * LIMITED REMEDY. 10067754Smsmith * 10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10267754Smsmith * software or system incorporating such software without first obtaining any 10367754Smsmith * required license or other approval from the U. S. Department of Commerce or 10467754Smsmith * any other agency or department of the United States Government. In the 10567754Smsmith * event Licensee exports any such software from the United States or 10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10767754Smsmith * ensure that the distribution and export/re-export of the software is in 10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11167754Smsmith * software, or service, directly or indirectly, to any country for which the 11267754Smsmith * United States government or any agency thereof requires an export license, 11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11467754Smsmith * such license, approval or letter. 11567754Smsmith * 11667754Smsmith *****************************************************************************/ 11767754Smsmith 11867754Smsmith#include "acpi.h" 11967754Smsmith#include "acevents.h" 12067754Smsmith 12177424Smsmith#define _COMPONENT ACPI_HARDWARE 12291116Smsmith ACPI_MODULE_NAME ("hwgpe") 12367754Smsmith 12467754Smsmith 12567754Smsmith/****************************************************************************** 12667754Smsmith * 12767754Smsmith * FUNCTION: AcpiHwEnableGpe 12867754Smsmith * 12967754Smsmith * PARAMETERS: GpeNumber - The GPE 13067754Smsmith * 13167754Smsmith * RETURN: None 13267754Smsmith * 13367754Smsmith * DESCRIPTION: Enable a single GPE. 13467754Smsmith * 13567754Smsmith ******************************************************************************/ 13667754Smsmith 13799679SiwasakiACPI_STATUS 13867754SmsmithAcpiHwEnableGpe ( 139114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo) 14067754Smsmith{ 14180062Smsmith UINT32 InByte; 14299679Siwasaki ACPI_STATUS Status; 14367754Smsmith 14483174Smsmith 14591116Smsmith ACPI_FUNCTION_ENTRY (); 14683174Smsmith 14783174Smsmith 14867754Smsmith /* 14967754Smsmith * Read the current value of the register, set the appropriate bit 15067754Smsmith * to enable the GPE, and write out the new register. 15167754Smsmith */ 152102550Siwasaki Status = AcpiHwLowLevelRead (8, &InByte, 153117521Snjl &GpeEventInfo->RegisterInfo->EnableAddress); 15499679Siwasaki if (ACPI_FAILURE (Status)) 15599679Siwasaki { 15699679Siwasaki return (Status); 15799679Siwasaki } 15899679Siwasaki 159114237Snjl /* Write with the new GPE bit enabled */ 16099679Siwasaki 161114237Snjl Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask), 162117521Snjl &GpeEventInfo->RegisterInfo->EnableAddress); 163114237Snjl 16499679Siwasaki return (Status); 16567754Smsmith} 16667754Smsmith 16791116Smsmith 16884491Smsmith/****************************************************************************** 16984491Smsmith * 17084491Smsmith * FUNCTION: AcpiHwEnableGpeForWakeup 17184491Smsmith * 17284491Smsmith * PARAMETERS: GpeNumber - The GPE 17384491Smsmith * 17484491Smsmith * RETURN: None 17584491Smsmith * 17684491Smsmith * DESCRIPTION: Keep track of which GPEs the OS has requested not be 17784491Smsmith * disabled when going to sleep. 17884491Smsmith * 17984491Smsmith ******************************************************************************/ 18067754Smsmith 18184491Smsmithvoid 18284491SmsmithAcpiHwEnableGpeForWakeup ( 183114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo) 18484491Smsmith{ 185114237Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 18684491Smsmith 18784491Smsmith 18891116Smsmith ACPI_FUNCTION_ENTRY (); 18984491Smsmith 19084491Smsmith 191114237Snjl /* Get the info block for the entire GPE register */ 19284491Smsmith 193114237Snjl GpeRegisterInfo = GpeEventInfo->RegisterInfo; 194114237Snjl if (!GpeRegisterInfo) 195114237Snjl { 196114237Snjl return; 197114237Snjl } 19884491Smsmith 19984491Smsmith /* 20084491Smsmith * Set the bit so we will not disable this when sleeping 20184491Smsmith */ 202114237Snjl GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask; 20384491Smsmith} 20484491Smsmith 20591116Smsmith 20667754Smsmith/****************************************************************************** 20767754Smsmith * 20867754Smsmith * FUNCTION: AcpiHwDisableGpe 20967754Smsmith * 21067754Smsmith * PARAMETERS: GpeNumber - The GPE 21167754Smsmith * 21267754Smsmith * RETURN: None 21367754Smsmith * 21467754Smsmith * DESCRIPTION: Disable a single GPE. 21567754Smsmith * 21667754Smsmith ******************************************************************************/ 21767754Smsmith 21899679SiwasakiACPI_STATUS 21967754SmsmithAcpiHwDisableGpe ( 220114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo) 22167754Smsmith{ 22280062Smsmith UINT32 InByte; 22399679Siwasaki ACPI_STATUS Status; 224114237Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 22567754Smsmith 22683174Smsmith 22791116Smsmith ACPI_FUNCTION_ENTRY (); 22883174Smsmith 22983174Smsmith 230114237Snjl /* Get the info block for the entire GPE register */ 23167754Smsmith 232114237Snjl GpeRegisterInfo = GpeEventInfo->RegisterInfo; 233114237Snjl if (!GpeRegisterInfo) 234114237Snjl { 235114237Snjl return (AE_BAD_PARAMETER); 236114237Snjl } 23767754Smsmith 23867754Smsmith /* 23967754Smsmith * Read the current value of the register, clear the appropriate bit, 24067754Smsmith * and write out the new register value to disable the GPE. 24167754Smsmith */ 24299679Siwasaki Status = AcpiHwLowLevelRead (8, &InByte, 243117521Snjl &GpeRegisterInfo->EnableAddress); 24499679Siwasaki if (ACPI_FAILURE (Status)) 24599679Siwasaki { 24699679Siwasaki return (Status); 24799679Siwasaki } 24884491Smsmith 249114237Snjl /* Write the byte with this GPE bit cleared */ 250114237Snjl 251114237Snjl Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)), 252117521Snjl &GpeRegisterInfo->EnableAddress); 25399679Siwasaki if (ACPI_FAILURE (Status)) 25499679Siwasaki { 25599679Siwasaki return (Status); 25699679Siwasaki } 25799679Siwasaki 258114237Snjl AcpiHwDisableGpeForWakeup (GpeEventInfo); 25999679Siwasaki return (AE_OK); 26067754Smsmith} 26167754Smsmith 26291116Smsmith 26384491Smsmith/****************************************************************************** 26484491Smsmith * 26584491Smsmith * FUNCTION: AcpiHwDisableGpeForWakeup 26684491Smsmith * 26784491Smsmith * PARAMETERS: GpeNumber - The GPE 26884491Smsmith * 26984491Smsmith * RETURN: None 27084491Smsmith * 27184491Smsmith * DESCRIPTION: Keep track of which GPEs the OS has requested not be 27284491Smsmith * disabled when going to sleep. 27384491Smsmith * 27484491Smsmith ******************************************************************************/ 27567754Smsmith 27684491Smsmithvoid 27784491SmsmithAcpiHwDisableGpeForWakeup ( 278114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo) 27984491Smsmith{ 280114237Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 28184491Smsmith 28284491Smsmith 28391116Smsmith ACPI_FUNCTION_ENTRY (); 28484491Smsmith 28584491Smsmith 286114237Snjl /* Get the info block for the entire GPE register */ 28784491Smsmith 288114237Snjl GpeRegisterInfo = GpeEventInfo->RegisterInfo; 289114237Snjl if (!GpeRegisterInfo) 290114237Snjl { 291114237Snjl return; 292114237Snjl } 29384491Smsmith 29484491Smsmith /* 29584491Smsmith * Clear the bit so we will disable this when sleeping 29684491Smsmith */ 297114237Snjl GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask); 29884491Smsmith} 29984491Smsmith 30091116Smsmith 30167754Smsmith/****************************************************************************** 30267754Smsmith * 30367754Smsmith * FUNCTION: AcpiHwClearGpe 30467754Smsmith * 30567754Smsmith * PARAMETERS: GpeNumber - The GPE 30667754Smsmith * 30767754Smsmith * RETURN: None 30867754Smsmith * 30967754Smsmith * DESCRIPTION: Clear a single GPE. 31067754Smsmith * 31167754Smsmith ******************************************************************************/ 31267754Smsmith 31399679SiwasakiACPI_STATUS 31467754SmsmithAcpiHwClearGpe ( 315114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo) 31667754Smsmith{ 31799679Siwasaki ACPI_STATUS Status; 31867754Smsmith 31980062Smsmith 32091116Smsmith ACPI_FUNCTION_ENTRY (); 32183174Smsmith 32283174Smsmith 32367754Smsmith /* 32467754Smsmith * Write a one to the appropriate bit in the status register to 32567754Smsmith * clear this GPE. 32667754Smsmith */ 327114237Snjl Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask, 328117521Snjl &GpeEventInfo->RegisterInfo->StatusAddress); 32999679Siwasaki 33099679Siwasaki return (Status); 33167754Smsmith} 33267754Smsmith 33367754Smsmith 33467754Smsmith/****************************************************************************** 33567754Smsmith * 33667754Smsmith * FUNCTION: AcpiHwGetGpeStatus 33767754Smsmith * 33867754Smsmith * PARAMETERS: GpeNumber - The GPE 33967754Smsmith * 34067754Smsmith * RETURN: None 34167754Smsmith * 34267754Smsmith * DESCRIPTION: Return the status of a single GPE. 34367754Smsmith * 34467754Smsmith ******************************************************************************/ 34567754Smsmith 34699679SiwasakiACPI_STATUS 34767754SmsmithAcpiHwGetGpeStatus ( 348117521Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo, 34967754Smsmith ACPI_EVENT_STATUS *EventStatus) 35067754Smsmith{ 351114237Snjl UINT32 InByte; 352114237Snjl UINT8 BitMask; 35391116Smsmith ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 35499679Siwasaki ACPI_STATUS Status; 355114237Snjl ACPI_EVENT_STATUS LocalEventStatus = 0; 35667754Smsmith 35780062Smsmith 35891116Smsmith ACPI_FUNCTION_ENTRY (); 35983174Smsmith 36083174Smsmith 36167754Smsmith if (!EventStatus) 36267754Smsmith { 36399679Siwasaki return (AE_BAD_PARAMETER); 36467754Smsmith } 36567754Smsmith 366114237Snjl /* Get the info block for the entire GPE register */ 36767754Smsmith 368114237Snjl GpeRegisterInfo = GpeEventInfo->RegisterInfo; 36967754Smsmith 37091116Smsmith /* Get the register bitmask for this GPE */ 37191116Smsmith 372114237Snjl BitMask = GpeEventInfo->BitMask; 37391116Smsmith 37491116Smsmith /* GPE Enabled? */ 37591116Smsmith 376117521Snjl Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress); 37799679Siwasaki if (ACPI_FAILURE (Status)) 37899679Siwasaki { 379117521Snjl goto UnlockAndExit; 38099679Siwasaki } 38199679Siwasaki 38267754Smsmith if (BitMask & InByte) 38367754Smsmith { 384114237Snjl LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; 38567754Smsmith } 38667754Smsmith 38791116Smsmith /* GPE Enabled for wake? */ 38891116Smsmith 38991116Smsmith if (BitMask & GpeRegisterInfo->WakeEnable) 39084491Smsmith { 391114237Snjl LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; 39284491Smsmith } 39384491Smsmith 39491116Smsmith /* GPE active (set)? */ 39591116Smsmith 396117521Snjl Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress); 39799679Siwasaki if (ACPI_FAILURE (Status)) 39899679Siwasaki { 399117521Snjl goto UnlockAndExit; 40099679Siwasaki } 40199679Siwasaki 40267754Smsmith if (BitMask & InByte) 40367754Smsmith { 404114237Snjl LocalEventStatus |= ACPI_EVENT_FLAG_SET; 40567754Smsmith } 406114237Snjl 407114237Snjl /* Set return value */ 408114237Snjl 409114237Snjl (*EventStatus) = LocalEventStatus; 410117521Snjl 411117521Snjl 412117521SnjlUnlockAndExit: 413117521Snjl return (Status); 414117521Snjl} 415117521Snjl 416117521Snjl 417117521Snjl/****************************************************************************** 418117521Snjl * 419117521Snjl * FUNCTION: AcpiHwDisableGpeBlock 420117521Snjl * 421117521Snjl * PARAMETERS: GpeXruptInfo - GPE Interrupt info 422117521Snjl * GpeBlock - Gpe Block info 423117521Snjl * 424117521Snjl * RETURN: Status 425117521Snjl * 426117521Snjl * DESCRIPTION: Disable all GPEs within a GPE block 427117521Snjl * 428117521Snjl ******************************************************************************/ 429117521Snjl 430117521SnjlACPI_STATUS 431117521SnjlAcpiHwDisableGpeBlock ( 432117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 433117521Snjl ACPI_GPE_BLOCK_INFO *GpeBlock) 434117521Snjl{ 435117521Snjl UINT32 i; 436117521Snjl ACPI_STATUS Status; 437117521Snjl 438117521Snjl 439117521Snjl /* Examine each GPE Register within the block */ 440117521Snjl 441117521Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 442117521Snjl { 443126372Snjl /* Disable all GPEs in this register */ 444126372Snjl 445117521Snjl Status = AcpiHwLowLevelWrite (8, 0x00, 446117521Snjl &GpeBlock->RegisterInfo[i].EnableAddress); 447117521Snjl if (ACPI_FAILURE (Status)) 448117521Snjl { 449117521Snjl return (Status); 450117521Snjl } 451117521Snjl } 452117521Snjl 45399679Siwasaki return (AE_OK); 45467754Smsmith} 45584491Smsmith 45691116Smsmith 45784491Smsmith/****************************************************************************** 45884491Smsmith * 459117521Snjl * FUNCTION: AcpiHwClearGpeBlock 460117521Snjl * 461117521Snjl * PARAMETERS: GpeXruptInfo - GPE Interrupt info 462117521Snjl * GpeBlock - Gpe Block info 463117521Snjl * 464117521Snjl * RETURN: Status 465117521Snjl * 466117521Snjl * DESCRIPTION: Clear all GPEs within a GPE block 467117521Snjl * 468117521Snjl ******************************************************************************/ 469117521Snjl 470117521SnjlACPI_STATUS 471117521SnjlAcpiHwClearGpeBlock ( 472117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 473117521Snjl ACPI_GPE_BLOCK_INFO *GpeBlock) 474117521Snjl{ 475117521Snjl UINT32 i; 476117521Snjl ACPI_STATUS Status; 477117521Snjl 478117521Snjl 479117521Snjl /* Examine each GPE Register within the block */ 480117521Snjl 481117521Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 482117521Snjl { 483126372Snjl /* Clear all GPEs in this register */ 484126372Snjl 485117521Snjl Status = AcpiHwLowLevelWrite (8, 0xFF, 486117521Snjl &GpeBlock->RegisterInfo[i].StatusAddress); 487117521Snjl if (ACPI_FAILURE (Status)) 488117521Snjl { 489117521Snjl return (Status); 490117521Snjl } 491117521Snjl } 492117521Snjl 493117521Snjl return (AE_OK); 494117521Snjl} 495117521Snjl 496117521Snjl 497117521Snjl/****************************************************************************** 498117521Snjl * 499117521Snjl * FUNCTION: AcpiHwDisableNonWakeupGpeBlock 500117521Snjl * 501117521Snjl * PARAMETERS: GpeXruptInfo - GPE Interrupt info 502117521Snjl * GpeBlock - Gpe Block info 503117521Snjl * 504117521Snjl * RETURN: Status 505117521Snjl * 506117521Snjl * DESCRIPTION: Disable all GPEs except wakeup GPEs in a GPE block 507117521Snjl * 508117521Snjl ******************************************************************************/ 509117521Snjl 510117521Snjlstatic ACPI_STATUS 511117521SnjlAcpiHwDisableNonWakeupGpeBlock ( 512117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 513117521Snjl ACPI_GPE_BLOCK_INFO *GpeBlock) 514117521Snjl{ 515117521Snjl UINT32 i; 516117521Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 517117521Snjl UINT32 InValue; 518117521Snjl ACPI_STATUS Status; 519117521Snjl 520117521Snjl 521117521Snjl /* Get the register info for the entire GPE block */ 522117521Snjl 523117521Snjl GpeRegisterInfo = GpeBlock->RegisterInfo; 524117521Snjl 525117521Snjl /* Examine each GPE Register within the block */ 526117521Snjl 527117521Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 528117521Snjl { 529117521Snjl /* 530117521Snjl * Read the enabled status of all GPEs. We 531117521Snjl * will be using it to restore all the GPEs later. 532117521Snjl */ 533117521Snjl Status = AcpiHwLowLevelRead (8, &InValue, 534117521Snjl &GpeRegisterInfo->EnableAddress); 535117521Snjl if (ACPI_FAILURE (Status)) 536117521Snjl { 537117521Snjl return (Status); 538117521Snjl } 539117521Snjl 540117521Snjl GpeRegisterInfo->Enable = (UINT8) InValue; 541117521Snjl 542117521Snjl /* 543117521Snjl * Disable all GPEs except wakeup GPEs. 544117521Snjl */ 545117521Snjl Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable, 546117521Snjl &GpeRegisterInfo->EnableAddress); 547117521Snjl if (ACPI_FAILURE (Status)) 548117521Snjl { 549117521Snjl return (Status); 550117521Snjl } 551117521Snjl 552117521Snjl GpeRegisterInfo++; 553117521Snjl } 554117521Snjl 555117521Snjl return (AE_OK); 556117521Snjl} 557117521Snjl 558117521Snjl 559117521Snjl/****************************************************************************** 560117521Snjl * 56184491Smsmith * FUNCTION: AcpiHwDisableNonWakeupGpes 56284491Smsmith * 56384491Smsmith * PARAMETERS: None 56484491Smsmith * 56584491Smsmith * RETURN: None 56684491Smsmith * 56784491Smsmith * DESCRIPTION: Disable all non-wakeup GPEs 568117521Snjl * Called with interrupts disabled. The interrupt handler also 569114237Snjl * modifies GpeRegisterInfo->Enable, so it should not be 57084491Smsmith * given the chance to run until after non-wake GPEs are 57184491Smsmith * re-enabled. 57284491Smsmith * 57384491Smsmith ******************************************************************************/ 57484491Smsmith 57599679SiwasakiACPI_STATUS 57684491SmsmithAcpiHwDisableNonWakeupGpes ( 57784491Smsmith void) 57884491Smsmith{ 57999679Siwasaki ACPI_STATUS Status; 58084491Smsmith 58184491Smsmith 58291116Smsmith ACPI_FUNCTION_ENTRY (); 58391116Smsmith 58491116Smsmith 585117521Snjl Status = AcpiEvWalkGpeList (AcpiHwDisableNonWakeupGpeBlock); 58691116Smsmith 587117521Snjl return (Status); 588117521Snjl} 58984491Smsmith 59099679Siwasaki 591117521Snjl/****************************************************************************** 592117521Snjl * 593117521Snjl * FUNCTION: AcpiHwEnableNonWakeupGpeBlock 594117521Snjl * 595117521Snjl * PARAMETERS: GpeXruptInfo - GPE Interrupt info 596117521Snjl * GpeBlock - Gpe Block info 597117521Snjl * 598117521Snjl * RETURN: Status 599117521Snjl * 600117521Snjl * DESCRIPTION: Enable a single GPE. 601117521Snjl * 602117521Snjl ******************************************************************************/ 603114237Snjl 604117521Snjlstatic ACPI_STATUS 605117521SnjlAcpiHwEnableNonWakeupGpeBlock ( 606117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 607117521Snjl ACPI_GPE_BLOCK_INFO *GpeBlock) 608117521Snjl{ 609117521Snjl UINT32 i; 610117521Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 611117521Snjl ACPI_STATUS Status; 612114237Snjl 613117521Snjl 614117521Snjl /* This callback processes one entire GPE block */ 615117521Snjl 616117521Snjl /* Get the register info for the entire GPE block */ 617117521Snjl 618117521Snjl GpeRegisterInfo = GpeBlock->RegisterInfo; 619117521Snjl 620117521Snjl /* Examine each GPE register within the block */ 621117521Snjl 622117521Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 623117521Snjl { 624126372Snjl /* Clear the entire status register */ 625126372Snjl 626126372Snjl Status = AcpiHwLowLevelWrite (8, 0xFF, 627126372Snjl &GpeBlock->RegisterInfo[i].StatusAddress); 628126372Snjl if (ACPI_FAILURE (Status)) 629126372Snjl { 630126372Snjl return (Status); 631126372Snjl } 632126372Snjl 633117521Snjl /* 634117521Snjl * We previously stored the enabled status of all GPEs. 635117521Snjl * Blast them back in. 636117521Snjl */ 637117521Snjl Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable, 638117521Snjl &GpeRegisterInfo->EnableAddress); 639117521Snjl if (ACPI_FAILURE (Status)) 640117521Snjl { 641117521Snjl return (Status); 64299679Siwasaki } 643114237Snjl 644117521Snjl GpeRegisterInfo++; 64584491Smsmith } 646114237Snjl 647117521Snjl 64899679Siwasaki return (AE_OK); 64984491Smsmith} 65084491Smsmith 65191116Smsmith 65284491Smsmith/****************************************************************************** 65384491Smsmith * 65484491Smsmith * FUNCTION: AcpiHwEnableNonWakeupGpes 65584491Smsmith * 65684491Smsmith * PARAMETERS: None 65784491Smsmith * 65884491Smsmith * RETURN: None 65984491Smsmith * 66084491Smsmith * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled. 66184491Smsmith * 66284491Smsmith ******************************************************************************/ 66384491Smsmith 66499679SiwasakiACPI_STATUS 66584491SmsmithAcpiHwEnableNonWakeupGpes ( 66684491Smsmith void) 66784491Smsmith{ 66899679Siwasaki ACPI_STATUS Status; 66984491Smsmith 67084491Smsmith 67191116Smsmith ACPI_FUNCTION_ENTRY (); 67291116Smsmith 67391116Smsmith 674117521Snjl Status = AcpiEvWalkGpeList (AcpiHwEnableNonWakeupGpeBlock); 67591116Smsmith 676117521Snjl return (Status); 67784491Smsmith} 678