hwgpe.c revision 128212
1130803Smarcel 2130803Smarcel/****************************************************************************** 3130803Smarcel * 4130803Smarcel * Module Name: hwgpe - Low level GPE enable/disable/clear functions 5130803Smarcel * $Revision: 57 $ 6130803Smarcel * 7130803Smarcel *****************************************************************************/ 8130803Smarcel 9130803Smarcel/****************************************************************************** 10130803Smarcel * 11130803Smarcel * 1. Copyright Notice 12130803Smarcel * 13130803Smarcel * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. 14130803Smarcel * All rights reserved. 15130803Smarcel * 16130803Smarcel * 2. License 17130803Smarcel * 18130803Smarcel * 2.1. This is your license from Intel Corp. under its intellectual property 19130803Smarcel * rights. You may have additional license terms from the party that provided 20130803Smarcel * you this software, covering your right to use that party's intellectual 21130803Smarcel * property rights. 22130803Smarcel * 23130803Smarcel * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24130803Smarcel * copy of the source code appearing in this file ("Covered Code") an 25130803Smarcel * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26130803Smarcel * base code distributed originally by Intel ("Original Intel Code") to copy, 27130803Smarcel * make derivatives, distribute, use and display any portion of the Covered 28130803Smarcel * Code in any form, with the right to sublicense such rights; and 29130803Smarcel * 30130803Smarcel * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31130803Smarcel * license (with the right to sublicense), under only those claims of Intel 32130803Smarcel * patents that are infringed by the Original Intel Code, to make, use, sell, 33130803Smarcel * offer to sell, and import the Covered Code and derivative works thereof 34130803Smarcel * solely to the minimum extent necessary to exercise the above copyright 35130803Smarcel * license, and in no event shall the patent license extend to any additions 36130803Smarcel * to or modifications of the Original Intel Code. No other license or right 37130803Smarcel * is granted directly or by implication, estoppel or otherwise; 38130803Smarcel * 39130803Smarcel * The above copyright and patent license is granted only if the following 40130803Smarcel * conditions are met: 41130803Smarcel * 42130803Smarcel * 3. Conditions 43130803Smarcel * 44130803Smarcel * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45130803Smarcel * Redistribution of source code of any substantial portion of the Covered 46130803Smarcel * Code or modification with rights to further distribute source must include 47130803Smarcel * the above Copyright Notice, the above License, this list of Conditions, 48130803Smarcel * and the following Disclaimer and Export Compliance provision. In addition, 49130803Smarcel * Licensee must cause all Covered Code to which Licensee contributes to 50130803Smarcel * contain a file documenting the changes Licensee made to create that Covered 51130803Smarcel * Code and the date of any change. Licensee must include in that file the 52130803Smarcel * documentation of any changes made by any predecessor Licensee. Licensee 53130803Smarcel * must include a prominent statement that the modification is derived, 54130803Smarcel * directly or indirectly, from Original Intel Code. 55130803Smarcel * 56130803Smarcel * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57130803Smarcel * Redistribution of source code of any substantial portion of the Covered 58130803Smarcel * Code or modification without rights to further distribute source must 59130803Smarcel * include the following Disclaimer and Export Compliance provision in the 60130803Smarcel * documentation and/or other materials provided with distribution. In 61130803Smarcel * addition, Licensee may not authorize further sublicense of source of any 62130803Smarcel * portion of the Covered Code, and must include terms to the effect that the 63130803Smarcel * license from Licensee to its licensee is limited to the intellectual 64130803Smarcel * property embodied in the software Licensee provides to its licensee, and 65130803Smarcel * not to intellectual property embodied in modifications its licensee may 66130803Smarcel * make. 67130803Smarcel * 68130803Smarcel * 3.3. Redistribution of Executable. Redistribution in executable form of any 69130803Smarcel * substantial portion of the Covered Code or modification must reproduce the 70130803Smarcel * above Copyright Notice, and the following Disclaimer and Export Compliance 71130803Smarcel * provision in the documentation and/or other materials provided with the 72130803Smarcel * distribution. 73130803Smarcel * 74130803Smarcel * 3.4. Intel retains all right, title, and interest in and to the Original 75130803Smarcel * Intel Code. 76130803Smarcel * 77130803Smarcel * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78130803Smarcel * Intel shall be used in advertising or otherwise to promote the sale, use or 79130803Smarcel * other dealings in products derived from or relating to the Covered Code 80130803Smarcel * without prior written authorization from Intel. 81130803Smarcel * 82130803Smarcel * 4. Disclaimer and Export Compliance 83130803Smarcel * 84130803Smarcel * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85130803Smarcel * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86130803Smarcel * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87130803Smarcel * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88130803Smarcel * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89130803Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90130803Smarcel * PARTICULAR PURPOSE. 91130803Smarcel * 92130803Smarcel * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93130803Smarcel * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94130803Smarcel * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95130803Smarcel * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96130803Smarcel * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97130803Smarcel * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98130803Smarcel * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99130803Smarcel * LIMITED REMEDY. 100130803Smarcel * 101130803Smarcel * 4.3. Licensee shall not export, either directly or indirectly, any of this 102130803Smarcel * software or system incorporating such software without first obtaining any 103130803Smarcel * required license or other approval from the U. S. Department of Commerce or 104130803Smarcel * any other agency or department of the United States Government. In the 105130803Smarcel * event Licensee exports any such software from the United States or 106130803Smarcel * re-exports any such software from a foreign destination, Licensee shall 107130803Smarcel * ensure that the distribution and export/re-export of the software is in 108130803Smarcel * compliance with all laws, regulations, orders, or other restrictions of the 109130803Smarcel * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110130803Smarcel * any of its subsidiaries will export/re-export any technical data, process, 111130803Smarcel * software, or service, directly or indirectly, to any country for which the 112130803Smarcel * United States government or any agency thereof requires an export license, 113130803Smarcel * other governmental approval, or letter of assurance, without first obtaining 114130803Smarcel * such license, approval or letter. 115130803Smarcel * 116130803Smarcel *****************************************************************************/ 117130803Smarcel 118130803Smarcel#include "acpi.h" 119130803Smarcel#include "acevents.h" 120130803Smarcel 121130803Smarcel#define _COMPONENT ACPI_HARDWARE 122130803Smarcel ACPI_MODULE_NAME ("hwgpe") 123130803Smarcel 124130803Smarcel 125130803Smarcel/****************************************************************************** 126130803Smarcel * 127130803Smarcel * FUNCTION: AcpiHwEnableGpe 128130803Smarcel * 129130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled 130130803Smarcel * 131130803Smarcel * RETURN: Status 132130803Smarcel * 133130803Smarcel * DESCRIPTION: Enable a single GPE. 134130803Smarcel * 135130803Smarcel ******************************************************************************/ 136130803Smarcel 137130803SmarcelACPI_STATUS 138130803SmarcelAcpiHwEnableGpe ( 139130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo) 140130803Smarcel{ 141130803Smarcel UINT32 InByte; 142130803Smarcel ACPI_STATUS Status; 143130803Smarcel 144130803Smarcel 145130803Smarcel ACPI_FUNCTION_ENTRY (); 146130803Smarcel 147130803Smarcel 148130803Smarcel /* 149130803Smarcel * Read the current value of the register, set the appropriate bit 150130803Smarcel * to enable the GPE, and write out the new register. 151130803Smarcel */ 152130803Smarcel Status = AcpiHwLowLevelRead (8, &InByte, 153130803Smarcel &GpeEventInfo->RegisterInfo->EnableAddress); 154130803Smarcel if (ACPI_FAILURE (Status)) 155130803Smarcel { 156130803Smarcel return (Status); 157130803Smarcel } 158130803Smarcel 159130803Smarcel /* Write with the new GPE bit enabled */ 160130803Smarcel 161130803Smarcel Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask), 162130803Smarcel &GpeEventInfo->RegisterInfo->EnableAddress); 163130803Smarcel 164130803Smarcel return (Status); 165130803Smarcel} 166130803Smarcel 167130803Smarcel 168130803Smarcel/****************************************************************************** 169130803Smarcel * 170130803Smarcel * FUNCTION: AcpiHwEnableGpeForWakeup 171130803Smarcel * 172130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled 173130803Smarcel * 174130803Smarcel * RETURN: None 175130803Smarcel * 176130803Smarcel * DESCRIPTION: Keep track of which GPEs the OS has requested not be 177130803Smarcel * disabled when going to sleep. 178130803Smarcel * 179130803Smarcel ******************************************************************************/ 180130803Smarcel 181130803Smarcelvoid 182130803SmarcelAcpiHwEnableGpeForWakeup ( 183130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo) 184130803Smarcel{ 185130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 186130803Smarcel 187130803Smarcel 188130803Smarcel ACPI_FUNCTION_ENTRY (); 189130803Smarcel 190130803Smarcel 191130803Smarcel /* Get the info block for the entire GPE register */ 192130803Smarcel 193130803Smarcel GpeRegisterInfo = GpeEventInfo->RegisterInfo; 194130803Smarcel if (!GpeRegisterInfo) 195130803Smarcel { 196130803Smarcel return; 197130803Smarcel } 198130803Smarcel 199130803Smarcel /* 200130803Smarcel * Set the bit so we will not enable this GPE when sleeping (and disable 201130803Smarcel * it upon wake) 202130803Smarcel */ 203130803Smarcel GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask; 204130803Smarcel GpeEventInfo->Flags |= (ACPI_GPE_TYPE_WAKE | ACPI_GPE_ENABLED); 205130803Smarcel} 206130803Smarcel 207130803Smarcel 208130803Smarcel/****************************************************************************** 209130803Smarcel * 210130803Smarcel * FUNCTION: AcpiHwDisableGpe 211130803Smarcel * 212130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled 213130803Smarcel * 214130803Smarcel * RETURN: Status 215130803Smarcel * 216130803Smarcel * DESCRIPTION: Disable a single GPE. 217130803Smarcel * 218130803Smarcel ******************************************************************************/ 219130803Smarcel 220130803SmarcelACPI_STATUS 221130803SmarcelAcpiHwDisableGpe ( 222130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo) 223130803Smarcel{ 224130803Smarcel UINT32 InByte; 225130803Smarcel ACPI_STATUS Status; 226130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 227130803Smarcel 228130803Smarcel 229130803Smarcel ACPI_FUNCTION_ENTRY (); 230130803Smarcel 231130803Smarcel 232130803Smarcel /* Get the info block for the entire GPE register */ 233130803Smarcel 234130803Smarcel GpeRegisterInfo = GpeEventInfo->RegisterInfo; 235130803Smarcel if (!GpeRegisterInfo) 236130803Smarcel { 237130803Smarcel return (AE_BAD_PARAMETER); 238130803Smarcel } 239130803Smarcel 240130803Smarcel /* 241130803Smarcel * Read the current value of the register, clear the appropriate bit, 242130803Smarcel * and write out the new register value to disable the GPE. 243130803Smarcel */ 244130803Smarcel Status = AcpiHwLowLevelRead (8, &InByte, 245130803Smarcel &GpeRegisterInfo->EnableAddress); 246130803Smarcel if (ACPI_FAILURE (Status)) 247130803Smarcel { 248130803Smarcel return (Status); 249130803Smarcel } 250130803Smarcel 251130803Smarcel /* Write the byte with this GPE bit cleared */ 252130803Smarcel 253130803Smarcel Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)), 254130803Smarcel &GpeRegisterInfo->EnableAddress); 255130803Smarcel if (ACPI_FAILURE (Status)) 256130803Smarcel { 257130803Smarcel return (Status); 258130803Smarcel } 259130803Smarcel 260130803Smarcel /* Make sure this GPE is disabled for wake, also */ 261130803Smarcel 262130803Smarcel AcpiHwDisableGpeForWakeup (GpeEventInfo); 263130803Smarcel return (AE_OK); 264130803Smarcel} 265130803Smarcel 266130803Smarcel 267130803Smarcel/****************************************************************************** 268130803Smarcel * 269130803Smarcel * FUNCTION: AcpiHwDisableGpeForWakeup 270130803Smarcel * 271130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled 272130803Smarcel * 273130803Smarcel * RETURN: None 274130803Smarcel * 275130803Smarcel * DESCRIPTION: Keep track of which GPEs the OS has requested not be 276130803Smarcel * disabled when going to sleep. 277130803Smarcel * 278130803Smarcel ******************************************************************************/ 279130803Smarcel 280130803Smarcelvoid 281130803SmarcelAcpiHwDisableGpeForWakeup ( 282130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo) 283130803Smarcel{ 284130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 285130803Smarcel 286130803Smarcel 287130803Smarcel ACPI_FUNCTION_ENTRY (); 288130803Smarcel 289130803Smarcel 290130803Smarcel /* Get the info block for the entire GPE register */ 291130803Smarcel 292130803Smarcel GpeRegisterInfo = GpeEventInfo->RegisterInfo; 293130803Smarcel if (!GpeRegisterInfo) 294130803Smarcel { 295130803Smarcel return; 296130803Smarcel } 297130803Smarcel 298130803Smarcel /* Clear the bit so we will disable this when sleeping */ 299130803Smarcel 300130803Smarcel GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask); 301130803Smarcel} 302130803Smarcel 303130803Smarcel 304130803Smarcel/****************************************************************************** 305130803Smarcel * 306130803Smarcel * FUNCTION: AcpiHwClearGpe 307130803Smarcel * 308130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared 309130803Smarcel * 310130803Smarcel * RETURN: StatusStatus 311130803Smarcel * 312130803Smarcel * DESCRIPTION: Clear the status bit for a single GPE. 313130803Smarcel * 314130803Smarcel ******************************************************************************/ 315130803Smarcel 316130803SmarcelACPI_STATUS 317130803SmarcelAcpiHwClearGpe ( 318130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo) 319130803Smarcel{ 320130803Smarcel ACPI_STATUS Status; 321130803Smarcel 322130803Smarcel 323130803Smarcel ACPI_FUNCTION_ENTRY (); 324130803Smarcel 325130803Smarcel 326130803Smarcel /* 327130803Smarcel * Write a one to the appropriate bit in the status register to 328130803Smarcel * clear this GPE. 329130803Smarcel */ 330130803Smarcel Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask, 331130803Smarcel &GpeEventInfo->RegisterInfo->StatusAddress); 332130803Smarcel 333130803Smarcel return (Status); 334130803Smarcel} 335130803Smarcel 336130803Smarcel 337130803Smarcel/****************************************************************************** 338130803Smarcel * 339130803Smarcel * FUNCTION: AcpiHwGetGpeStatus 340130803Smarcel * 341130803Smarcel * PARAMETERS: GpeEventInfo - Info block for the GPE to queried 342130803Smarcel * EventStatus - Where the GPE status is returned 343130803Smarcel * 344130803Smarcel * RETURN: Status 345130803Smarcel * 346130803Smarcel * DESCRIPTION: Return the status of a single GPE. 347130803Smarcel * 348130803Smarcel ******************************************************************************/ 349130803Smarcel 350130803SmarcelACPI_STATUS 351130803SmarcelAcpiHwGetGpeStatus ( 352130803Smarcel ACPI_GPE_EVENT_INFO *GpeEventInfo, 353130803Smarcel ACPI_EVENT_STATUS *EventStatus) 354130803Smarcel{ 355130803Smarcel UINT32 InByte; 356130803Smarcel UINT8 BitMask; 357130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 358130803Smarcel ACPI_STATUS Status; 359130803Smarcel ACPI_EVENT_STATUS LocalEventStatus = 0; 360130803Smarcel 361130803Smarcel 362130803Smarcel ACPI_FUNCTION_ENTRY (); 363130803Smarcel 364130803Smarcel 365130803Smarcel if (!EventStatus) 366130803Smarcel { 367130803Smarcel return (AE_BAD_PARAMETER); 368130803Smarcel } 369130803Smarcel 370130803Smarcel /* Get the info block for the entire GPE register */ 371130803Smarcel 372130803Smarcel GpeRegisterInfo = GpeEventInfo->RegisterInfo; 373130803Smarcel 374130803Smarcel /* Get the register bitmask for this GPE */ 375130803Smarcel 376130803Smarcel BitMask = GpeEventInfo->BitMask; 377130803Smarcel 378130803Smarcel /* GPE Enabled? */ 379130803Smarcel 380130803Smarcel Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress); 381130803Smarcel if (ACPI_FAILURE (Status)) 382130803Smarcel { 383130803Smarcel goto UnlockAndExit; 384130803Smarcel } 385130803Smarcel 386130803Smarcel if (BitMask & InByte) 387130803Smarcel { 388130803Smarcel LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; 389130803Smarcel } 390130803Smarcel 391130803Smarcel /* GPE Enabled for wake? */ 392130803Smarcel 393130803Smarcel if (BitMask & GpeRegisterInfo->WakeEnable) 394130803Smarcel { 395130803Smarcel LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; 396130803Smarcel } 397130803Smarcel 398130803Smarcel /* GPE active (set)? */ 399130803Smarcel 400130803Smarcel Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress); 401130803Smarcel if (ACPI_FAILURE (Status)) 402130803Smarcel { 403130803Smarcel goto UnlockAndExit; 404130803Smarcel } 405130803Smarcel 406130803Smarcel if (BitMask & InByte) 407130803Smarcel { 408130803Smarcel LocalEventStatus |= ACPI_EVENT_FLAG_SET; 409130803Smarcel } 410130803Smarcel 411130803Smarcel /* Set return value */ 412130803Smarcel 413130803Smarcel (*EventStatus) = LocalEventStatus; 414130803Smarcel 415130803Smarcel 416130803SmarcelUnlockAndExit: 417130803Smarcel return (Status); 418130803Smarcel} 419130803Smarcel 420130803Smarcel 421130803Smarcel/****************************************************************************** 422130803Smarcel * 423130803Smarcel * FUNCTION: AcpiHwDisableGpeBlock 424130803Smarcel * 425130803Smarcel * PARAMETERS: GpeXruptInfo - GPE Interrupt info 426130803Smarcel * GpeBlock - Gpe Block info 427130803Smarcel * 428130803Smarcel * RETURN: Status 429130803Smarcel * 430130803Smarcel * DESCRIPTION: Disable all GPEs within a GPE block 431130803Smarcel * 432130803Smarcel ******************************************************************************/ 433130803Smarcel 434130803SmarcelACPI_STATUS 435130803SmarcelAcpiHwDisableGpeBlock ( 436130803Smarcel ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 437130803Smarcel ACPI_GPE_BLOCK_INFO *GpeBlock) 438130803Smarcel{ 439130803Smarcel UINT32 i; 440130803Smarcel ACPI_STATUS Status; 441130803Smarcel 442130803Smarcel 443130803Smarcel /* Examine each GPE Register within the block */ 444130803Smarcel 445130803Smarcel for (i = 0; i < GpeBlock->RegisterCount; i++) 446130803Smarcel { 447130803Smarcel /* Disable all GPEs in this register */ 448130803Smarcel 449130803Smarcel Status = AcpiHwLowLevelWrite (8, 0x00, 450130803Smarcel &GpeBlock->RegisterInfo[i].EnableAddress); 451130803Smarcel if (ACPI_FAILURE (Status)) 452130803Smarcel { 453130803Smarcel return (Status); 454130803Smarcel } 455130803Smarcel } 456130803Smarcel 457130803Smarcel return (AE_OK); 458130803Smarcel} 459130803Smarcel 460130803Smarcel 461130803Smarcel/****************************************************************************** 462130803Smarcel * 463130803Smarcel * FUNCTION: AcpiHwClearGpeBlock 464130803Smarcel * 465130803Smarcel * PARAMETERS: GpeXruptInfo - GPE Interrupt info 466130803Smarcel * GpeBlock - Gpe Block info 467130803Smarcel * 468130803Smarcel * RETURN: Status 469130803Smarcel * 470130803Smarcel * DESCRIPTION: Clear status bits for all GPEs within a GPE block 471130803Smarcel * 472130803Smarcel ******************************************************************************/ 473130803Smarcel 474130803SmarcelACPI_STATUS 475130803SmarcelAcpiHwClearGpeBlock ( 476130803Smarcel ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 477130803Smarcel ACPI_GPE_BLOCK_INFO *GpeBlock) 478130803Smarcel{ 479130803Smarcel UINT32 i; 480130803Smarcel ACPI_STATUS Status; 481130803Smarcel 482130803Smarcel 483130803Smarcel /* Examine each GPE Register within the block */ 484130803Smarcel 485130803Smarcel for (i = 0; i < GpeBlock->RegisterCount; i++) 486130803Smarcel { 487130803Smarcel /* Clear status on all GPEs in this register */ 488130803Smarcel 489130803Smarcel Status = AcpiHwLowLevelWrite (8, 0xFF, 490130803Smarcel &GpeBlock->RegisterInfo[i].StatusAddress); 491130803Smarcel if (ACPI_FAILURE (Status)) 492130803Smarcel { 493130803Smarcel return (Status); 494130803Smarcel } 495130803Smarcel } 496130803Smarcel 497130803Smarcel return (AE_OK); 498130803Smarcel} 499130803Smarcel 500130803Smarcel 501130803Smarcel/****************************************************************************** 502130803Smarcel * 503130803Smarcel * FUNCTION: AcpiHwPrepareGpeBlockForSleep 504130803Smarcel * 505130803Smarcel * PARAMETERS: GpeXruptInfo - GPE Interrupt info 506130803Smarcel * GpeBlock - Gpe Block info 507130803Smarcel * 508130803Smarcel * RETURN: Status 509130803Smarcel * 510130803Smarcel * DESCRIPTION: Disable all runtime GPEs and enable all wakeup GPEs -- within 511130803Smarcel * a single GPE block 512130803Smarcel * 513130803Smarcel ******************************************************************************/ 514130803Smarcel 515130803Smarcelstatic ACPI_STATUS 516130803SmarcelAcpiHwPrepareGpeBlockForSleep ( 517130803Smarcel ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 518130803Smarcel ACPI_GPE_BLOCK_INFO *GpeBlock) 519130803Smarcel{ 520130803Smarcel UINT32 i; 521130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 522130803Smarcel UINT32 InValue; 523130803Smarcel ACPI_STATUS Status; 524130803Smarcel 525130803Smarcel 526130803Smarcel /* Get the register info for the entire GPE block */ 527130803Smarcel 528130803Smarcel GpeRegisterInfo = GpeBlock->RegisterInfo; 529130803Smarcel 530130803Smarcel /* Examine each GPE Register within the block */ 531130803Smarcel 532130803Smarcel for (i = 0; i < GpeBlock->RegisterCount; i++) 533130803Smarcel { 534130803Smarcel /* 535130803Smarcel * Read the enabled/disabled status of all GPEs. We 536130803Smarcel * will be using it to restore all the GPEs later. 537130803Smarcel * 538130803Smarcel * NOTE: Wake GPEs are are ALL disabled at this time, so when we wake 539130803Smarcel * and restore this register, they will be automatically disabled. 540130803Smarcel */ 541130803Smarcel Status = AcpiHwLowLevelRead (8, &InValue, 542130803Smarcel &GpeRegisterInfo->EnableAddress); 543130803Smarcel if (ACPI_FAILURE (Status)) 544130803Smarcel { 545130803Smarcel return (Status); 546130803Smarcel } 547130803Smarcel 548130803Smarcel GpeRegisterInfo->Enable = (UINT8) InValue; 549130803Smarcel 550130803Smarcel /* 551130803Smarcel * 1) Disable all runtime GPEs 552130803Smarcel * 2) Enable all wakeup GPEs 553130803Smarcel */ 554130803Smarcel Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable, 555130803Smarcel &GpeRegisterInfo->EnableAddress); 556130803Smarcel if (ACPI_FAILURE (Status)) 557130803Smarcel { 558130803Smarcel return (Status); 559130803Smarcel } 560130803Smarcel 561130803Smarcel /* Point to next GPE register */ 562130803Smarcel 563130803Smarcel GpeRegisterInfo++; 564130803Smarcel } 565130803Smarcel 566130803Smarcel return (AE_OK); 567130803Smarcel} 568130803Smarcel 569130803Smarcel 570130803Smarcel/****************************************************************************** 571130803Smarcel * 572130803Smarcel * FUNCTION: AcpiHwPrepareGpesForSleep 573130803Smarcel * 574130803Smarcel * PARAMETERS: None 575130803Smarcel * 576130803Smarcel * RETURN: Status 577130803Smarcel * 578130803Smarcel * DESCRIPTION: Disable all runtime GPEs, enable all wake GPEs. 579130803Smarcel * Called with interrupts disabled. The interrupt handler also 580130803Smarcel * modifies GpeRegisterInfo->Enable, so it should not be 581130803Smarcel * given the chance to run until after the runtime GPEs are 582130803Smarcel * re-enabled. 583130803Smarcel * 584130803Smarcel ******************************************************************************/ 585130803Smarcel 586130803SmarcelACPI_STATUS 587130803SmarcelAcpiHwPrepareGpesForSleep ( 588130803Smarcel void) 589130803Smarcel{ 590130803Smarcel ACPI_STATUS Status; 591130803Smarcel 592130803Smarcel 593130803Smarcel ACPI_FUNCTION_ENTRY (); 594130803Smarcel 595130803Smarcel 596130803Smarcel Status = AcpiEvWalkGpeList (AcpiHwPrepareGpeBlockForSleep); 597130803Smarcel return (Status); 598130803Smarcel} 599130803Smarcel 600130803Smarcel 601130803Smarcel/****************************************************************************** 602130803Smarcel * 603130803Smarcel * FUNCTION: AcpiHwRestoreGpeBlockOnWake 604130803Smarcel * 605130803Smarcel * PARAMETERS: GpeXruptInfo - GPE Interrupt info 606130803Smarcel * GpeBlock - Gpe Block info 607130803Smarcel * 608130803Smarcel * RETURN: Status 609130803Smarcel * 610130803Smarcel * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in one 611130803Smarcel * GPE block 612130803Smarcel * 613130803Smarcel ******************************************************************************/ 614130803Smarcel 615130803Smarcelstatic ACPI_STATUS 616130803SmarcelAcpiHwRestoreGpeBlockOnWake ( 617130803Smarcel ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 618130803Smarcel ACPI_GPE_BLOCK_INFO *GpeBlock) 619130803Smarcel{ 620130803Smarcel UINT32 i; 621130803Smarcel ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 622130803Smarcel ACPI_STATUS Status; 623130803Smarcel 624130803Smarcel 625130803Smarcel /* This callback processes one entire GPE block */ 626130803Smarcel 627130803Smarcel /* Get the register info for the entire GPE block */ 628130803Smarcel 629130803Smarcel GpeRegisterInfo = GpeBlock->RegisterInfo; 630130803Smarcel 631130803Smarcel /* Examine each GPE register within the block */ 632130803Smarcel 633130803Smarcel for (i = 0; i < GpeBlock->RegisterCount; i++) 634130803Smarcel { 635130803Smarcel /* Clear the entire status register */ 636130803Smarcel 637130803Smarcel Status = AcpiHwLowLevelWrite (8, 0xFF, 638130803Smarcel &GpeBlock->RegisterInfo[i].StatusAddress); 639130803Smarcel if (ACPI_FAILURE (Status)) 640130803Smarcel { 641130803Smarcel return (Status); 642130803Smarcel } 643130803Smarcel 644130803Smarcel /* 645130803Smarcel * Restore the GPE Enable register, which will do the following: 646130803Smarcel * 647130803Smarcel * 1) Disable all wakeup GPEs 648130803Smarcel * 2) Enable all runtime GPEs 649130803Smarcel * 650130803Smarcel * (On sleep, we saved the enabled status of all GPEs) 651130803Smarcel */ 652130803Smarcel Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable, 653130803Smarcel &GpeRegisterInfo->EnableAddress); 654130803Smarcel if (ACPI_FAILURE (Status)) 655130803Smarcel { 656130803Smarcel return (Status); 657130803Smarcel } 658130803Smarcel 659130803Smarcel /* Point to next GPE register */ 660130803Smarcel 661130803Smarcel GpeRegisterInfo++; 662130803Smarcel } 663130803Smarcel 664130803Smarcel return (AE_OK); 665130803Smarcel} 666130803Smarcel 667130803Smarcel 668130803Smarcel/****************************************************************************** 669130803Smarcel * 670130803Smarcel * FUNCTION: AcpiHwRestoreGpesOnWake 671130803Smarcel * 672130803Smarcel * PARAMETERS: None 673130803Smarcel * 674130803Smarcel * RETURN: Status 675130803Smarcel * 676130803Smarcel * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in all 677130803Smarcel * GPE blocks 678130803Smarcel * 679130803Smarcel ******************************************************************************/ 680130803Smarcel 681130803SmarcelACPI_STATUS 682130803SmarcelAcpiHwRestoreGpesOnWake ( 683130803Smarcel void) 684130803Smarcel{ 685130803Smarcel ACPI_STATUS Status; 686130803Smarcel 687130803Smarcel 688130803Smarcel ACPI_FUNCTION_ENTRY (); 689130803Smarcel 690130803Smarcel 691130803Smarcel Status = AcpiEvWalkGpeList (AcpiHwRestoreGpeBlockOnWake); 692130803Smarcel return (Status); 693130803Smarcel} 694130803Smarcel