From 0fe338c88b06d70c5f7e64efcabf1991068daf98 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Fri, 14 Feb 2025 09:42:22 +0000 Subject: [PATCH] soc/intel/cmn/pmc: Add support for early power off This commit adds support for early power off on Intel platforms along with existing PMC based implementation to support power off at later stage (like ramstage). A new function, `platform_do_early_poweroff`, is added to the pmclib to handle platform-specific early power off procedures. This function is called before memory initialization (in romstage or earlier). Note: While Intel chipsets do not support power off before silicon initialization, this change leverages Chrome EC APIs to enable power off in romstage for low-battery boot on ChromeOS devices. Power off failures in ramstage prior to FSP-S are outside the scope of this change. BUG=b:339673254 TEST=Able to build and boot google/brox. Change-Id: I39f516640b3f75ab4c6a09826922289c0533f79b Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/86336 Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian Reviewed-by: Julius Werner --- src/soc/intel/common/block/pmc/pmclib.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c index 8c48e8873f..64b9bb997c 100644 --- a/src/soc/intel/common/block/pmc/pmclib.c +++ b/src/soc/intel/common/block/pmc/pmclib.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -615,7 +616,8 @@ void vboot_platform_prepare_reboot(void) pmc_write_pm1_control(pm1_cnt); } -void poweroff(void) +/* Helper function to perform poweroff operation using PMC chipset register. */ +static void pmc_control_poweroff(void) { pmc_enable_pm1_control(SLP_EN | (SLP_TYP_S5 << SLP_TYP_SHIFT)); @@ -628,6 +630,19 @@ void poweroff(void) halt(); } +void poweroff(void) +{ + if (!ENV_ROMSTAGE_OR_BEFORE) { + pmc_control_poweroff(); + } else if (CONFIG(HAVE_EARLY_POWEROFF_SUPPORT)) { + platform_do_early_poweroff(); + } else { + printk(BIOS_EMERG, "This platform cannot be powered off until the silicon" + " initialization is complete, hanging!\n"); + halt(); + } +} + void pmc_gpe_init(void) { uint32_t gpio_cfg = 0;