diff options
Diffstat (limited to 'sys/contrib/dev/acpica/hwsleep.c')
-rw-r--r-- | sys/contrib/dev/acpica/hwsleep.c | 116 |
1 files changed, 62 insertions, 54 deletions
diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index 40c78b6..fc07c05 100644 --- a/sys/contrib/dev/acpica/hwsleep.c +++ b/sys/contrib/dev/acpica/hwsleep.c @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,20 +121,7 @@ ACPI_MODULE_NAME ("hwsleep") -#define METHOD_NAME__BFS "\\_BFS" -#define METHOD_NAME__GTS "\\_GTS" -#define METHOD_NAME__PTS "\\_PTS" -#define METHOD_NAME__SST "\\_SI._SST" -#define METHOD_NAME__WAK "\\_WAK" - -#define ACPI_SST_INDICATOR_OFF 0 -#define ACPI_SST_WORKING 1 -#define ACPI_SST_WAKING 2 -#define ACPI_SST_SLEEPING 3 -#define ACPI_SST_SLEEP_CONTEXT 4 - - -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiSetFirmwareWakingVector * @@ -143,7 +130,7 @@ * * RETURN: Status * - * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -172,17 +159,17 @@ AcpiSetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetFirmwareWakingVector * - * PARAMETERS: *PhysicalAddress - Output buffer where contents of + * PARAMETERS: *PhysicalAddress - Where the contents of * the FirmwareWakingVector field of - * the FACS will be stored. + * the FACS will be returned. * - * RETURN: Status + * RETURN: Status, vector * - * DESCRIPTION: Access function for FirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -216,7 +203,7 @@ AcpiGetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStatePrep * @@ -294,7 +281,7 @@ AcpiEnterSleepStatePrep ( break; default: - Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is indicator off */ + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ break; } @@ -303,14 +290,15 @@ AcpiEnterSleepStatePrep ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (AE_OK); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepState * @@ -370,7 +358,8 @@ AcpiEnterSleepState ( { /* Disable BM arbitration */ - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, + 1, ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -381,14 +370,14 @@ AcpiEnterSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -396,16 +385,19 @@ AcpiEnterSleepState ( /* Get current value of PM1A control */ - Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl); + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState)); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); /* Clear SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask); + PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); PM1BControl = PM1AControl; /* Insert SLP_TYP bits */ @@ -420,13 +412,15 @@ AcpiEnterSleepState ( /* Write #1: fill in SLP_TYP data */ - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -441,13 +435,15 @@ AcpiEnterSleepState ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -456,10 +452,11 @@ AcpiEnterSleepState ( 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!) + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) * - * Wait ten seconds, then try again. This is to get S4/S5 to work on all machines. + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * 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 @@ -467,7 +464,8 @@ AcpiEnterSleepState ( */ AcpiOsStall (10000000); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, SleepEnableRegInfo->AccessBitMask); if (ACPI_FAILURE (Status)) { @@ -480,7 +478,8 @@ AcpiEnterSleepState ( Retry = 1000; do { - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -503,7 +502,7 @@ AcpiEnterSleepState ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStateS4bios * @@ -543,14 +542,14 @@ AcpiEnterSleepStateS4bios ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -558,11 +557,13 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (UINT32) AcpiGbl_FADT->S4BiosReq, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, + (UINT32) AcpiGbl_FADT->S4BiosReq, 8); do { AcpiOsStall(1000); - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -573,7 +574,7 @@ AcpiEnterSleepStateS4bios ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiLeaveSleepState * @@ -656,20 +657,23 @@ AcpiLeaveSleepState ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } Arg.Integer.Value = SleepState; Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", + AcpiFormatException (Status))); } Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", + AcpiFormatException (Status))); } /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ @@ -678,14 +682,14 @@ AcpiLeaveSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_NOT_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = TRUE; - Status = AcpiHwEnableAllRuntimeGpes (ACPI_NOT_ISR); + Status = AcpiHwEnableAllRuntimeGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -693,9 +697,12 @@ AcpiLeaveSleepState ( /* Enable power button */ - (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); - (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); /* Enable BM arbitration */ @@ -710,7 +717,8 @@ AcpiLeaveSleepState ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (Status); |