Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74421 )
Change subject: WIP mb/prodrive/atlas: Enable/disable sleep states based on EC ......................................................................
WIP mb/prodrive/atlas: Enable/disable sleep states based on EC
With the profile ATLAS_PROF_REALTIME_PERFORMANCE it is desired to not have the option to be able to sleep, the reason being that windows goes to sleep after 30min of inactivity.
Change-Id: I424db7e712a705c628aa3a10a486d3313404987a Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/acpi/Kconfig M src/mainboard/prodrive/atlas/Kconfig M src/mainboard/prodrive/atlas/mainboard.c M src/southbridge/intel/common/acpi/sleepstates.asl 4 files changed, 68 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/21/74421/1
diff --git a/src/acpi/Kconfig b/src/acpi/Kconfig index ec7fcc4..1b40386 100644 --- a/src/acpi/Kconfig +++ b/src/acpi/Kconfig @@ -58,3 +58,11 @@ depends on HAVE_ACPI_TABLES help Selected by platforms that support and fill Intel Low Power Idle Table. + +config OVERRIDE_ENABLED_SLEEP_STATES + bool + depends on HAVE_ACPI_TABLES + help + Select this on platforms that want a way to override the enabled + _Sx states during runtime. Do this by adding a namespace '\OSFG'. + bit 0 enabled S1, bit 1 S2 etc. S0 and S5 are assumed. diff --git a/src/mainboard/prodrive/atlas/Kconfig b/src/mainboard/prodrive/atlas/Kconfig index 914ce9f..2a70901 100644 --- a/src/mainboard/prodrive/atlas/Kconfig +++ b/src/mainboard/prodrive/atlas/Kconfig @@ -12,6 +12,7 @@ select PCIEXP_SUPPORT_RESIZABLE_BARS select SOC_INTEL_ALDERLAKE_PCH_P select SOC_INTEL_ALDERLAKE_S3 + select OVERRIDE_ENABLED_SLEEP_STATES
if BOARD_PRODRIVE_ATLAS_BASEBOARD
diff --git a/src/mainboard/prodrive/atlas/mainboard.c b/src/mainboard/prodrive/atlas/mainboard.c index db808ce..54fddc4 100644 --- a/src/mainboard/prodrive/atlas/mainboard.c +++ b/src/mainboard/prodrive/atlas/mainboard.c @@ -1,10 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <acpi/acpigen.h> #include <console/console.h> #include <device/device.h> #include <gpio.h> #include <smbios.h> #include <string.h> +#include <sys/types.h> #include <types.h>
#include "gpio.h" @@ -66,9 +68,25 @@ t->count = smbios_add_string(t->eos, get_formatted_pn()); }
+#define S1_ENABLE (1 << 0) +#define S2_ENABLE (1 << 1) +#define S3_ENABLE (1 << 2) +#define S4_ENABLE (1 << 3) + +static void mainboard_fill_ssdt(const struct device *dev) +{ + acpigen_write_scope("\"); + const struct emi_eeprom_vpd *eeprom = get_emi_eeprom_vpd(); + uint32_t sleep_enable = eeprom->profile == ATLAS_PROF_REALTIME_PERFORMANCE ? + S4_ENABLE : (CONFIG(HAVE_ACPI_RESUME) ? S3_ENABLE : S1_RESUME) | S4_ENABLE; + acpigen_write_name_dword("OSFG", sleep_enable); + acpigen_pop_len(); +} + static void mainboard_enable(struct device *dev) { dev->ops->get_smbios_strings = mainboard_smbios_strings; + dev->ops->acpi_fill_ssdt = mainboard_fill_ssdt; }
struct chip_operations mainboard_ops = { diff --git a/src/southbridge/intel/common/acpi/sleepstates.asl b/src/southbridge/intel/common/acpi/sleepstates.asl index eae7642..1649334 100644 --- a/src/southbridge/intel/common/acpi/sleepstates.asl +++ b/src/southbridge/intel/common/acpi/sleepstates.asl @@ -1,12 +1,31 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-Name(_S0, Package(){0x0,0x0,0x0,0x0}) -#if !CONFIG(HAVE_ACPI_RESUME) -Name(_S1, Package(){0x1,0x0,0x0,0x0}) +/* S1 support: bit 0, S2 Support: bit 1, etc. S0 & S5 assumed */ +#if CONFIG(HAVE_ACPI_RESUME) +Name (SSFG, 0x0D) #else -Name(_S3, Package(){0x5,0x0,0x0,0x0}) +Name (SSFG, 0x09) #endif -#if !CONFIG(DISABLE_ACPI_HIBERNATE) -Name(_S4, Package(){0x6,0x0,0x0,0x0}) -#endif -Name(_S5, Package(){0x7,0x0,0x0,0x0}) +If (CONFIG(DISABLE_ACPI_HIBERNATE)) { + SSFG &= 0xf7 +} + +if (CONFIG(OVERRIDE_ENABLED_ACPI_SLEEP_STATES)) { + External (\OSFG, IntObj) + SSFG = \OSFG +} + +/* Supported sleep states: */ +Name(_S0, Package () {0x00, 0x00, 0x00, 0x00} ) /* (S0) - working state */ + +If (SSFG & 0x01) { + Name(_S1, Package () {0x01, 0x00, 0x00, 0x00} ) /* (S1) - sleeping w/CPU context */ +} +If (SSFG & 0x04) { + Name(_S3, Package () {0x06, 0x00, 0x00, 0x00} ) /* (S3) - Suspend to RAM */ +} +If (SSFG & 0x08) { + Name(_S4, Package () {0x04, 0x04, 0x00, 0x00} ) /* (S4) - Suspend to Disk */ +} + +Name(_S5, Package () {0x07, 0x00, 0x00, 0x00} ) /* (S5) - Soft Off */