From 2e8545c44106fe7bae4552da5a5635878b1f362f Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 10 Feb 2026 15:52:11 +0530 Subject: [PATCH] soc/intel/common: Refactor poweroff() logic for early poweroff support The existing logic prioritized the check for ENV_ROMSTAGE_OR_BEFORE over the HAVE_EARLY_POWEROFF_SUPPORT configuration. This meant that platforms with early poweroff support might still fall through to the incorrect path depending on the boot phase. Refactor the logic to: 1. Prioritize CONFIG(HAVE_EARLY_POWEROFF_SUPPORT) as the primary mechanism for poweroff. 2. If early support is not available, check the environment stage: - Perform standard pmc_control_poweroff() if after romstage. - Halt with an emergency message if attempted too early in the boot process without platform support. This structure ensures that platform-specific early poweroff routines are always preferred when configured. TEST=Able to verify the AC host event is not getting cleared after power-off. Change-Id: Ieec8bcae5e1002d264db59cafe9236aaef6576e0 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/91149 Tested-by: build bot (Jenkins) Reviewed-by: Pranava Y N Reviewed-by: Avi Uday --- src/soc/intel/common/block/pmc/pmclib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/soc/intel/common/block/pmc/pmclib.c b/src/soc/intel/common/block/pmc/pmclib.c index 64b9bb997c..dc36d30bdb 100644 --- a/src/soc/intel/common/block/pmc/pmclib.c +++ b/src/soc/intel/common/block/pmc/pmclib.c @@ -632,14 +632,16 @@ static void pmc_control_poweroff(void) void poweroff(void) { - if (!ENV_ROMSTAGE_OR_BEFORE) { - pmc_control_poweroff(); - } else if (CONFIG(HAVE_EARLY_POWEROFF_SUPPORT)) { + 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(); + if (!ENV_ROMSTAGE_OR_BEFORE) { + pmc_control_poweroff(); + } else { + printk(BIOS_EMERG, "This platform cannot be powered off until the silicon" + " initialization is complete, hanging!\n"); + halt(); + } } }