hwsleep.c revision 26f3cdf03f1adcc98f6d3d99843ee71e9229a8c0
/******************************************************************************
*
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2011, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "acpi.h"
#include "accommon.h"
#define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME ("hwsleep")
/*******************************************************************************
*
* FUNCTION: AcpiSetFirmwareWakingVector
*
* PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode
* entry point.
*
* RETURN: Status
*
* DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS
*
******************************************************************************/
{
/* Set the 32-bit vector */
/* Clear the 64-bit vector if it exists */
{
}
}
#if ACPI_MACHINE_WIDTH == 64
/*******************************************************************************
*
* FUNCTION: AcpiSetFirmwareWakingVector64
*
* PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected
* mode entry point.
*
* RETURN: Status
*
* DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if
* it exists in the table. This function is intended for use with
* 64-bit host operating systems.
*
******************************************************************************/
{
/* Determine if the 64-bit vector actually exists */
{
}
/* Clear 32-bit vector, set the 64-bit X_ vector */
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiEnterSleepStatePrep
*
* PARAMETERS: SleepState - Which sleep state to enter
*
* RETURN: Status
*
* DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
* This function must execute with interrupts enabled.
* We break sleeping into 2 stages so that OSPM can handle
* various OS-specific tasks between the two steps.
*
******************************************************************************/
{
/* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
if (ACPI_FAILURE (Status))
{
}
/* Execute the _PTS method (Prepare To Sleep) */
{
}
/* Setup the argument to the _SST method (System STatus) */
switch (SleepState)
{
case ACPI_STATE_S0:
break;
case ACPI_STATE_S1:
case ACPI_STATE_S2:
case ACPI_STATE_S3:
break;
case ACPI_STATE_S4:
break;
default:
break;
}
/*
* Set the system indicators to show the desired sleep state.
* _SST is an optional method (return no error if not found)
*/
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiEnterSleepState
*
* PARAMETERS: SleepState - Which sleep state to enter
*
* RETURN: Status
*
* DESCRIPTION: Enter a system sleep state
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
*
******************************************************************************/
{
if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
{
}
/* Clear wake status */
if (ACPI_FAILURE (Status))
{
}
/* Clear all fixed and general purpose status bits */
Status = AcpiHwClearAcpiStatus ();
if (ACPI_FAILURE (Status))
{
}
if (SleepState != ACPI_STATE_S5)
{
/*
* Disable BM arbitration. This feature is contained within an
* optional register (PM2 Control), so ignore a BAD_ADDRESS
* exception.
*/
{
}
}
/*
* 2) Enable all wakeup GPEs
*/
Status = AcpiHwDisableAllGpes ();
if (ACPI_FAILURE (Status))
{
}
if (ACPI_FAILURE (Status))
{
}
/* Execute the _GTS method (Going To Sleep) */
{
}
/* Get current value of PM1A control */
&Pm1aControl);
if (ACPI_FAILURE (Status))
{
}
"Entering sleep state [S%u]\n", SleepState));
/* Clear the SLP_EN and SLP_TYP fields */
/* Insert the SLP_TYP bits */
/*
* We split the writes of SLP_TYP and SLP_EN to workaround
* poorly implemented hardware.
*/
/* Write #1: write the SLP_TYP data to the PM1 Control registers */
if (ACPI_FAILURE (Status))
{
}
/* Insert the sleep enable (SLP_EN) bit */
/* Flush caches, as per ACPI specification */
/* Write #2: Write both SLP_TYP + SLP_EN */
if (ACPI_FAILURE (Status))
{
}
if (SleepState > ACPI_STATE_S3)
{
/*
* We wanted to sleep > S3, but it didn't happen (by virtue of the
* fact that we are still executing!)
*
* all machines.
*
* We wait so long to allow chipsets that poll this reg very slowly
* to still read the right value. Ideally, this block would go
* away entirely.
*/
AcpiOsStall (10000000);
if (ACPI_FAILURE (Status))
{
}
}
/* Wait until we enter sleep state */
do
{
if (ACPI_FAILURE (Status))
{
}
/* Spin until we wake */
} while (!InValue);
}
/*******************************************************************************
*
* FUNCTION: AcpiEnterSleepStateS4bios
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Perform a S4 bios request.
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
*
******************************************************************************/
void)
{
/* Clear the wake status bit (PM1) */
if (ACPI_FAILURE (Status))
{
}
Status = AcpiHwClearAcpiStatus ();
if (ACPI_FAILURE (Status))
{
}
/*
* 2) Enable all wakeup GPEs
*/
Status = AcpiHwDisableAllGpes ();
if (ACPI_FAILURE (Status))
{
}
if (ACPI_FAILURE (Status))
{
}
do {
AcpiOsStall(1000);
if (ACPI_FAILURE (Status))
{
}
} while (!InValue);
}
/*******************************************************************************
*
* FUNCTION: AcpiLeaveSleepState
*
* PARAMETERS: SleepState - Which sleep state we just exited
*
* RETURN: Status
*
* DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
* Called with interrupts ENABLED.
*
******************************************************************************/
{
/*
* Set SLP_TYPE and SLP_EN to state S0.
* This is unclear from the ACPI Spec, but it is required
* by some machines.
*/
if (ACPI_SUCCESS (Status))
{
/* Get current value of PM1A control */
&Pm1aControl);
if (ACPI_SUCCESS (Status))
{
/* Clear the SLP_EN and SLP_TYP fields */
/* Insert the SLP_TYP bits */
Pm1aControl |= (AcpiGbl_SleepTypeA <<
Pm1bControl |= (AcpiGbl_SleepTypeB <<
/* Write the control registers and ignore any errors */
}
}
/* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
/* Setup parameter object */
/* Ignore any errors from these methods */
{
}
{
}
{
}
/* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
/*
* Restore the GPEs:
* 2) Enable all runtime GPEs
*/
Status = AcpiHwDisableAllGpes ();
if (ACPI_FAILURE (Status))
{
}
if (ACPI_FAILURE (Status))
{
}
/* Enable power button */
(void) AcpiWriteBitRegister(
(void) AcpiWriteBitRegister(
/*
* Enable BM arbitration. This feature is contained within an
* optional register (PM2 Control), so ignore a BAD_ADDRESS
* exception.
*/
{
}
{
}
}