From 5c44e689ee763608c5db9fe51a8c075483383f9d Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 24 Feb 2026 12:35:30 +0530 Subject: [PATCH] vc/google/chromeos: Add platform hook for emergency battery shutdown Introduce platform_handle_emergency_low_battery() to handle the pre-shutdown sequence when battery levels are critical. This hook ensures: 1. Visual feedback is provided (Lightbar set to red). 2. The event is logged to ELOG for post-mortem analysis. 3. A delay is enforced to ensure logs are committed and the user notices the alert before the AP powers off. BUG=none BRANCH=none TEST=Verified lightbar turns red and ELOG is recorded on low battery boot. Change-Id: I3f1b2757002d7a2a76dfb51d24a04e2d81b061bb Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/91409 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/include/bootsplash.h | 7 +++++++ src/vendorcode/google/chromeos/battery.c | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/include/bootsplash.h b/src/include/bootsplash.h index cd02f7382e..67b3a405a1 100644 --- a/src/include/bootsplash.h +++ b/src/include/bootsplash.h @@ -191,8 +191,15 @@ void bmp_release_logo(void); */ #if CONFIG(PLATFORM_HAS_LOW_BATTERY_INDICATOR) bool platform_is_low_battery_shutdown_needed(void); +/* + * Platform hooks for system shutdown due to critical battery levels. + * Provides visual feedback via the Lightbar/LEDs and logs the event + * to non-volatile storage before signaling to cut power. + */ +void platform_handle_emergency_low_battery(void); #else static inline bool platform_is_low_battery_shutdown_needed(void) { return false; } +static inline void platform_handle_emergency_low_battery(void) { /* nop */ } #endif /* diff --git a/src/vendorcode/google/chromeos/battery.c b/src/vendorcode/google/chromeos/battery.c index 438098256b..0e676b3f2a 100644 --- a/src/vendorcode/google/chromeos/battery.c +++ b/src/vendorcode/google/chromeos/battery.c @@ -2,6 +2,8 @@ #include #include +#include +#include /* * Check if low battery shutdown is needed @@ -32,3 +34,25 @@ bool platform_is_low_battery_shutdown_needed(void) return result; } + +/* + * Platform hooks for system shutdown due to critical battery levels. + * Provides visual feedback via the Lightbar/LEDs and logs the event + * to non-volatile storage before signaling to cut power. + */ +void platform_handle_emergency_low_battery(void) +{ + if (!CONFIG(EC_GOOGLE_CHROMEEC)) + return; + + /* Visual alert: Set Lightbar to solid Red */ + google_chromeec_set_lightbar_rgb(0xff, 0xff, 0x00, 0x00); + + /* Record the event for post-mortem diagnostics (stored in CMOS/Flash) */ + elog_add_event_byte(ELOG_TYPE_LOW_BATTERY_INDICATOR, ELOG_FW_ISSUE_SHUTDOWN); + + /* * Pause briefly to ensure the user perceives the LED change and + * the event log is safely committed to storage. + */ + delay(CONFIG_PLATFORM_POST_RENDER_DELAY_SEC); +}