Marshall Dawson has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40338 )
Change subject: cpu/x86/acpi: Add function to get sleep number from Pm1 ......................................................................
cpu/x86/acpi: Add function to get sleep number from Pm1
Add an inline function to convert the value in Pm1Cnt[SlpTyp] to an integer guaranteed to equal the sleep number. That is, for example, a return value 3 always means S3. This can be used instead of relying on the enuerated values remaining consistent over time.
BUG=b:153854742 TEST=Verify S3 works using other WIP changes
Signed-off-by: Marshall Dawson marshalldawson3rd@gmail.com Change-Id: I1de2e7f65a2dc3f8a9a1c5fd83d164871a4a2b96 --- M src/arch/x86/include/arch/acpi.h 1 file changed, 14 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/38/40338/1
diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h index 644f52f..9f445d8 100644 --- a/src/arch/x86/include/arch/acpi.h +++ b/src/arch/x86/include/arch/acpi.h @@ -963,7 +963,7 @@
#if CONFIG(ACPI_INTEL_HARDWARE_SLEEP_VALUES) \ || CONFIG(ACPI_AMD_HARDWARE_SLEEP_VALUES) -/* Given the provided PM1 control register return the ACPI sleep type. */ +/* Given the provided PM1 control register return the ACPI sleep type enum. */ static inline int acpi_sleep_from_pm1(uint32_t pm1_cnt) { switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) { @@ -975,6 +975,19 @@ } return -1; } + +/* Given the provided PM1 control register return the ACPI sleep number. */ +static inline int acpi_snum_from_pm1(uint32_t pm1_cnt) +{ + switch (((pm1_cnt) & SLP_TYP) >> SLP_TYP_SHIFT) { + case SLP_TYP_S0: return 0; + case SLP_TYP_S1: return 1; + case SLP_TYP_S3: return 3; + case SLP_TYP_S4: return 4; + case SLP_TYP_S5: return 5; + } + return -1; +} #endif
/* Returns ACPI_Sx values. */