summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2023-04-25 16:23:37 +0200
committerLean Sheng Tan <sheng.tan@9elements.com>2023-05-01 06:38:36 +0000
commit0eb5974def63a2fc0dce6dfdad62b0b4c6f4b865 (patch)
tree07c39c0c877c94778a483b69883642ebac786575
parentcd48c7ece3d38acaf67d25e35b1a66a47728aec8 (diff)
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 <arthur@aheymans.xyz> Change-Id: Ic21830c1ef9c183b1e3005cc1f8b7daf7e9ea998 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74762 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-by: Jan Samek <jan.samek@siemens.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
-rw-r--r--src/acpi/acpigen.c14
-rw-r--r--src/include/acpi/acpigen.h4
-rw-r--r--src/southbridge/intel/common/acpi/sleepstates.asl5
3 files changed, 23 insertions, 0 deletions
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();
+}
diff --git a/src/include/acpi/acpigen.h b/src/include/acpi/acpigen.h
index 180e93779d..fc1d01b4e3 100644
--- a/src/include/acpi/acpigen.h
+++ b/src/include/acpi/acpigen.h
@@ -695,4 +695,8 @@ void acpigen_resource_qword(u16 res_type, u16 gen_flags, u16 type_flags,
/* Emits Notify(namestr, value) */
void acpigen_notify(const char *namestr, int value);
+/* Create a namespace \OSFG to override the enabled sleep states */
+void acpigen_ssdt_override_sleep_states(bool enable_s1, bool enable_s2, bool enable_s3,
+ bool enable_s4);
+
#endif /* __ACPI_ACPIGEN_H__ */
diff --git a/src/southbridge/intel/common/acpi/sleepstates.asl b/src/southbridge/intel/common/acpi/sleepstates.asl
index 079ab1ab84..14ed86e91e 100644
--- a/src/southbridge/intel/common/acpi/sleepstates.asl
+++ b/src/southbridge/intel/common/acpi/sleepstates.asl
@@ -15,6 +15,11 @@ If (CONFIG(DISABLE_ACPI_HIBERNATE)) {
SSFG &= 0xf7
}
+External (\OSFG, IntObj)
+If (CondRefOf(\OSFG)) {
+ SSFG = \OSFG
+}
+
/* Supported sleep states: */
Name(\_S0, Package () {0x00, 0x00, 0x00, 0x00} ) /* (S0) - working state */