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 <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86227
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2025-02-06 12:58:05 +00:00
commit 80801e7f69

View file

@ -8,6 +8,7 @@
#include <device/device.h>
#include <drivers/wifi/generic/wifi.h>
#include <elog.h>
#include <fsp/api.h>
#include <fsp/fsp_debug_event.h>
#include <fsp/util.h>
#include <gpio.h>
@ -16,6 +17,7 @@
#include <intelblocks/cse.h>
#include <intelblocks/pcie_rp.h>
#include <option.h>
#include <soc/intel/common/reset.h>
#include <soc/iomap.h>
#include <soc/msr.h>
#include <soc/pci_devs.h>
@ -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);