From 80801e7f694b263fc8faca207e3af1aad3523bc4 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Thu, 6 Feb 2025 12:58:05 +0000 Subject: [PATCH] soc/intel/alderlake: Handle critical low battery early in romstage This commit implements early handling of critical low battery conditions in the romstage for Alder Lake platforms. A message is displayed to the user via ux_inform_user_of_poweroff_operation. A short delay is introduced to allow the user to see the message. A low battery event is logged. The system is shut down via the Chrome EC. This early handling prevents the system from proceeding with boot (while performing firmware update) if the battery is critically low and ensures a clean shutdown. This is particularly important for ChromeOS devices. BUG=b:339673254 TEST=Verified low battery boot event logging and controlled shutdown. Change-Id: Ib4be86ed17818ee05b7bec0337a90f80017183c2 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/86227 Reviewed-by: Julius Werner Reviewed-by: Karthik Ramasubramanian Tested-by: build bot (Jenkins) --- src/soc/intel/alderlake/romstage/fsp_params.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/soc/intel/alderlake/romstage/fsp_params.c b/src/soc/intel/alderlake/romstage/fsp_params.c index 4a03b7438f..71791ae90b 100644 --- a/src/soc/intel/alderlake/romstage/fsp_params.c +++ b/src/soc/intel/alderlake/romstage/fsp_params.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -427,6 +429,28 @@ static void fill_fspm_sign_of_life(FSP_M_CONFIG *m_cfg, * user with an on-screen text message. */ if (!arch_upd->NvsBufferPtr) { + /* + * Low Battery Check During Firmware Update (Chrome OS specific): + * - If `PLATFORM_HAS_EARLY_LOW_BATTERY_INDICATOR` is enabled AND the + * system is in firmware update mode (If valid MRC cache data is not found, + * it means that the system needs to perform), it checks if the battery level is + * critically low. + * - This is because memory training, which can take a significant amount of + * time, might cause an abrupt shutdown due to low battery, interrupting the + * firmware update process and potentially leaving the system in an unstable + * state. + * - To prevent this, if the battery is critically low, the system is powered + * off to allow it to charge. This ensures that the firmware update process + * can complete without interruption. + * - Since a functional GFX mode display may not be ready at this stage, VGA + * mode is used to display a text message informing the user about the + * shutdown. + */ + if (CONFIG(PLATFORM_HAS_EARLY_LOW_BATTERY_INDICATOR) && + platform_is_low_battery_shutdown_needed()) { + ux_inform_user_of_poweroff_operation("low-battery shutdown"); + do_low_battery_poweroff(); + } esol_required = true; name = "memory training"; elog_add_event_byte(ELOG_TYPE_FW_EARLY_SOL, ELOG_FW_EARLY_SOL_MRC);