Support for GAS GPEs/FixedEvents/Timer

date	2002.03.27.22.14.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 16:53:22 +00:00
parent e5bd2eb216
commit 16bb6612f4
3 changed files with 386 additions and 592 deletions

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Module Name: hwgpe - Low level GPE enable/disable/clear functions
* $Revision: 1.35 $
* $Revision: 1.40 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -121,7 +121,27 @@
#include "acevents.h"
#define _COMPONENT ACPI_HARDWARE
MODULE_NAME ("hwgpe")
ACPI_MODULE_NAME ("hwgpe")
/******************************************************************************
*
* FUNCTION: AcpiHwGetGpeBitMask
*
* PARAMETERS: GpeNumber - The GPE
*
* RETURN: Gpe register bitmask for this gpe level
*
* DESCRIPTION: Get the bitmask for this GPE
*
******************************************************************************/
UINT32
AcpiHwGetGpeBitMask (
UINT32 GpeNumber)
{
return (AcpiGbl_GpeNumberInfo [AcpiEvGetGpeNumberIndex (GpeNumber)].BitMask);
}
/******************************************************************************
@ -145,29 +165,28 @@ AcpiHwEnableGpe (
UINT32 BitMask;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/*
* Read the current value of the register, set the appropriate bit
* to enable the GPE, and write out the new register.
*/
InByte = 0;
AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, &InByte, 8);
AcpiOsWritePort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr,
(InByte | BitMask), 8);
InByte = AcpiHwLowLevelRead (8,
&AcpiGbl_GpeRegisterInfo[RegisterIndex].EnableAddress, 0);
AcpiHwLowLevelWrite (8, (InByte | BitMask),
&AcpiGbl_GpeRegisterInfo[RegisterIndex].EnableAddress, 0);
}
/******************************************************************************
*
* FUNCTION: AcpiHwEnableGpeForWakeup
@ -189,25 +208,24 @@ AcpiHwEnableGpeForWakeup (
UINT32 BitMask;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/*
* Set the bit so we will not disable this when sleeping
*/
AcpiGbl_GpeRegisters[RegisterIndex].WakeEnable |= BitMask;
AcpiGbl_GpeRegisterInfo[RegisterIndex].WakeEnable |= BitMask;
}
/******************************************************************************
*
* FUNCTION: AcpiHwDisableGpe
@ -229,31 +247,30 @@ AcpiHwDisableGpe (
UINT32 BitMask;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/*
* Read the current value of the register, clear the appropriate bit,
* and write out the new register value to disable the GPE.
*/
InByte = 0;
AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, &InByte, 8);
AcpiOsWritePort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr,
(InByte & ~BitMask), 8);
InByte = AcpiHwLowLevelRead (8,
&AcpiGbl_GpeRegisterInfo[RegisterIndex].EnableAddress, 0);
AcpiHwLowLevelWrite (8, (InByte & ~BitMask),
&AcpiGbl_GpeRegisterInfo[RegisterIndex].EnableAddress, 0);
AcpiHwDisableGpeForWakeup(GpeNumber);
}
/******************************************************************************
*
* FUNCTION: AcpiHwDisableGpeForWakeup
@ -275,25 +292,24 @@ AcpiHwDisableGpeForWakeup (
UINT32 BitMask;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/*
* Clear the bit so we will disable this when sleeping
*/
AcpiGbl_GpeRegisters[RegisterIndex].WakeEnable &= ~BitMask;
AcpiGbl_GpeRegisterInfo[RegisterIndex].WakeEnable &= ~BitMask;
}
/******************************************************************************
*
* FUNCTION: AcpiHwClearGpe
@ -314,24 +330,23 @@ AcpiHwClearGpe (
UINT32 BitMask;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/*
* Write a one to the appropriate bit in the status register to
* clear this GPE.
*/
AcpiOsWritePort (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, BitMask, 8);
AcpiHwLowLevelWrite (8, BitMask,
&AcpiGbl_GpeRegisterInfo[RegisterIndex].StatusAddress, 0);
}
@ -355,9 +370,10 @@ AcpiHwGetGpeStatus (
UINT32 InByte = 0;
UINT32 RegisterIndex = 0;
UINT32 BitMask = 0;
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
if (!EventStatus)
@ -367,45 +383,40 @@ AcpiHwGetGpeStatus (
(*EventStatus) = 0;
/*
* Translate GPE number to index into global registers array.
*/
RegisterIndex = AcpiGbl_GpeValid[GpeNumber];
/* Translate GPE number to index into global registers array. */
/*
* Figure out the bit offset for this GPE within the target register.
*/
BitMask = AcpiGbl_DecodeTo8bit [MOD_8 (GpeNumber)];
RegisterIndex = AcpiEvGetGpeRegisterIndex (GpeNumber);
GpeRegisterInfo = &AcpiGbl_GpeRegisterInfo[RegisterIndex];
/*
* Enabled?:
*/
InByte = 0;
AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr, &InByte, 8);
/* Get the register bitmask for this GPE */
BitMask = AcpiHwGetGpeBitMask (GpeNumber);
/* GPE Enabled? */
InByte = AcpiHwLowLevelRead (8, &GpeRegisterInfo->EnableAddress, 0);
if (BitMask & InByte)
{
(*EventStatus) |= ACPI_EVENT_FLAG_ENABLED;
}
/*
* Enabled for wake?:
*/
if (BitMask & AcpiGbl_GpeRegisters[RegisterIndex].WakeEnable)
/* GPE Enabled for wake? */
if (BitMask & GpeRegisterInfo->WakeEnable)
{
(*EventStatus) |= ACPI_EVENT_FLAG_WAKE_ENABLED;
}
/*
* Set?
*/
InByte = 0;
AcpiOsReadPort (AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr, &InByte, 8);
/* GPE active (set)? */
InByte = AcpiHwLowLevelRead (8, &GpeRegisterInfo->StatusAddress, 0);
if (BitMask & InByte)
{
(*EventStatus) |= ACPI_EVENT_FLAG_SET;
}
}
/******************************************************************************
*
* FUNCTION: AcpiHwDisableNonWakeupGpes
@ -416,7 +427,7 @@ AcpiHwGetGpeStatus (
*
* DESCRIPTION: Disable all non-wakeup GPEs
* Call with interrupts disabled. The interrupt handler also
* modifies AcpiGbl_GpeRegisters[i].Enable, so it should not be
* modifies AcpiGbl_GpeRegisterInfo[i].Enable, so it should not be
* given the chance to run until after non-wake GPEs are
* re-enabled.
*
@ -427,26 +438,32 @@ AcpiHwDisableNonWakeupGpes (
void)
{
UINT32 i;
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
ACPI_FUNCTION_ENTRY ();
FUNCTION_ENTRY ();
for (i = 0; i < AcpiGbl_GpeRegisterCount; i++)
{
GpeRegisterInfo = &AcpiGbl_GpeRegisterInfo[i];
/*
* Read the enabled status of all GPEs. We
* will be using it to restore all the GPEs later.
*/
AcpiOsReadPort (AcpiGbl_GpeRegisters[i].EnableAddr,
&AcpiGbl_GpeRegisters[i].Enable, 8);
GpeRegisterInfo->Enable = (UINT8) AcpiHwLowLevelRead (8,
&GpeRegisterInfo->EnableAddress, 0);
/*
* Disable all GPEs but wakeup GPEs.
* Disable all GPEs except wakeup GPEs.
*/
AcpiOsWritePort(AcpiGbl_GpeRegisters[i].EnableAddr,
AcpiGbl_GpeRegisters[i].WakeEnable, 8);
AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable,
&GpeRegisterInfo->EnableAddress, 0);
}
}
/******************************************************************************
*
* FUNCTION: AcpiHwEnableNonWakeupGpes
@ -464,16 +481,21 @@ AcpiHwEnableNonWakeupGpes (
void)
{
UINT32 i;
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
ACPI_FUNCTION_ENTRY ();
FUNCTION_ENTRY ();
for (i = 0; i < AcpiGbl_GpeRegisterCount; i++)
{
GpeRegisterInfo = &AcpiGbl_GpeRegisterInfo[i];
/*
* We previously stored the enabled status of all GPEs.
* Blast them back in.
*/
AcpiOsWritePort(AcpiGbl_GpeRegisters[i].EnableAddr,
AcpiGbl_GpeRegisters[i].Enable, 8);
AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable, &
GpeRegisterInfo->EnableAddress, 0);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
/******************************************************************************
*
* Name: hwtimer.c - ACPI Power Management Timer Interface
* $Revision: 1.30 $
* $Revision: 1.20 $
*
*****************************************************************************/
@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@ -116,6 +116,7 @@
*****************************************************************************/
#include "acpi.h"
#include "achware.h"
#define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME ("hwtimer")
@ -125,11 +126,11 @@
*
* FUNCTION: AcpiGetTimerResolution
*
* PARAMETERS: Resolution - Where the resolution is returned
* PARAMETERS: none
*
* RETURN: Status and timer resolution
* RETURN: Number of bits of resolution in the PM Timer (24 or 32).
*
* DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits).
* DESCRIPTION: Obtains resolution of the ACPI PM Timer.
*
******************************************************************************/
@ -162,11 +163,11 @@ AcpiGetTimerResolution (
*
* FUNCTION: AcpiGetTimer
*
* PARAMETERS: Ticks - Where the timer value is returned
* PARAMETERS: none
*
* RETURN: Status and current timer value (ticks)
* RETURN: Current value of the ACPI PM Timer (in ticks).
*
* DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
* DESCRIPTION: Obtains current value of ACPI PM Timer.
*
******************************************************************************/
@ -174,9 +175,6 @@ ACPI_STATUS
AcpiGetTimer (
UINT32 *Ticks)
{
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE ("AcpiGetTimer");
@ -185,9 +183,9 @@ AcpiGetTimer (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
Status = AcpiHwLowLevelRead (32, Ticks, &AcpiGbl_FADT->XPmTmrBlk);
*Ticks = AcpiHwLowLevelRead (32, &AcpiGbl_FADT->XPmTmrBlk, 0);
return_ACPI_STATUS (Status);
return_ACPI_STATUS (AE_OK);
}
@ -195,11 +193,11 @@ AcpiGetTimer (
*
* FUNCTION: AcpiGetTimerDuration
*
* PARAMETERS: StartTicks - Starting timestamp
* EndTicks - End timestamp
* TimeElapsed - Where the elapsed time is returned
* PARAMETERS: StartTicks
* EndTicks
* TimeElapsed
*
* RETURN: Status and TimeElapsed
* RETURN: TimeElapsed
*
* DESCRIPTION: Computes the time elapsed (in microseconds) between two
* PM Timer time stamps, taking into account the possibility of
@ -210,13 +208,10 @@ AcpiGetTimer (
* transitions (unlike many CPU timestamp counters) -- making it
* a versatile and accurate timer.
*
* Note that this function accommodates only a single timer
* Note that this function accomodates only a single timer
* rollover. Thus for 24-bit timers, this function should only
* be used for calculating durations less than ~4.6 seconds
* (~20 minutes for 32-bit timers) -- calculations below:
*
* 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
* 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
* (~20 hours for 32-bit timers).
*
******************************************************************************/
@ -226,9 +221,10 @@ AcpiGetTimerDuration (
UINT32 EndTicks,
UINT32 *TimeElapsed)
{
UINT32 DeltaTicks = 0;
UINT64_OVERLAY NormalizedTicks;
ACPI_STATUS Status;
UINT32 DeltaTicks;
ACPI_INTEGER Quotient;
ACPI_INTEGER OutQuotient;
ACPI_FUNCTION_TRACE ("AcpiGetTimerDuration");
@ -241,7 +237,8 @@ AcpiGetTimerDuration (
/*
* Compute Tick Delta:
* Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
* -------------------
* Handle (max one) timer rollovers on 24- versus 32-bit timers.
*/
if (StartTicks < EndTicks)
{
@ -262,21 +259,26 @@ AcpiGetTimerDuration (
DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks;
}
}
else /* StartTicks == EndTicks */
else
{
*TimeElapsed = 0;
return_ACPI_STATUS (AE_OK);
}
/*
* Compute Duration (Requires a 64-bit multiply and divide):
* Compute Duration:
* -----------------
*
* Requires a 64-bit divide:
*
* TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY;
*/
Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000,
PM_TIMER_FREQUENCY, &Quotient, NULL);
NormalizedTicks.Full = ((UINT64) DeltaTicks) * 1000000;
*TimeElapsed = (UINT32) Quotient;
Status = AcpiUtShortDivide (&NormalizedTicks.Full, PM_TIMER_FREQUENCY,
&OutQuotient, NULL);
*TimeElapsed = (UINT32) OutQuotient;
return_ACPI_STATUS (Status);
}