From 0eb5974def63a2fc0dce6dfdad62b0b4c6f4b865 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Tue, 25 Apr 2023 16:23:37 +0200 Subject: acpigen: Add a runtime method to override exposed _Sx sleep states This allows mainboards to override available sleep states at runtime. This is done by adding a IntObj in SSDT that DSDT consumes to override the available _Sx states. Signed-off-by: Arthur Heymans Change-Id: Ic21830c1ef9c183b1e3005cc1f8b7daf7e9ea998 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74762 Reviewed-by: Nico Huber Reviewed-by: Jakub Czapiga Reviewed-by: Jan Samek Tested-by: build bot (Jenkins) Reviewed-by: Lean Sheng Tan --- src/acpi/acpigen.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/acpi') diff --git a/src/acpi/acpigen.c b/src/acpi/acpigen.c index d613becbc3..94a6f908a9 100644 --- a/src/acpi/acpigen.c +++ b/src/acpi/acpigen.c @@ -2364,3 +2364,17 @@ void acpigen_write_delay_until_namestr_int(uint32_t wait_ms, const char *name, u acpigen_emit_byte(LOCAL7_OP); acpigen_pop_len(); /* While */ } + +void acpigen_ssdt_override_sleep_states(bool enable_s1, bool enable_s2, bool enable_s3, + bool enable_s4) +{ + assert(!(enable_s1 && CONFIG(ACPI_S1_NOT_SUPPORTED))); + assert(!(enable_s3 && !CONFIG(HAVE_ACPI_RESUME))); + assert(!(enable_s4 && CONFIG(DISABLE_ACPI_HIBERNATE))); + + acpigen_write_scope("\\"); + uint32_t sleep_enable = (enable_s1 << 0) | (enable_s2 << 1) + | (enable_s3 << 2) | (enable_s4 << 3); + acpigen_write_name_dword("OSFG", sleep_enable); + acpigen_pop_len(); +} -- cgit v1.2.3