From 772270c2c1039d902892eef1fe7537d5165c6a9d Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 21 Jan 2026 16:30:58 +0530 Subject: [PATCH] mb/google/bluey: Differentiate low battery boot modes Currently, the system does not explicitly distinguish between a low battery boot with a charger and one without. This is critical for deciding whether to allow the boot to proceed or to protect the battery. This patch: 1. Re-introduces LB_BOOT_MODE_LOW_BATTERY to represent a critical battery state without a charger present. 2. Refactors set_boot_mode() to accommodate off-mode charging and evaluating battery health (low-batter w/ or w/o charger present).. TEST=Verified on Bluey: - Boot with charger + low battery enters LOW_BATTERY_CHARGING. - Boot without charger + low battery enters LOW_BATTERY.. - Boot with normal battery enters NORMAL mode. Change-Id: I2c9fa7eb61d1bbd6f9379c81577aee53ab6a0761 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/90849 Reviewed-by: Kapil Porwal Reviewed-by: Jayvik Desai Tested-by: build bot (Jenkins) --- payloads/libpayload/include/coreboot_tables.h | 2 ++ .../include/commonlib/coreboot_tables.h | 2 ++ src/mainboard/google/bluey/romstage.c | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 6cb2558f3a..9864c2b5d4 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -458,6 +458,8 @@ struct cb_panel_poweroff { enum boot_mode_t { /* Regular boot scenarios */ CB_BOOT_MODE_NORMAL, + /* Device is booting in low-batter w/o charger attached */ + CB_BOOT_MODE_LOW_BATTERY, /* Device is booting in low-batter w/ charger attached */ CB_BOOT_MODE_LOW_BATTERY_CHARGING, /* Device is booting in due to charger insertion */ diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index d4582559df..cb16e65c5c 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -641,6 +641,8 @@ struct lb_panel_poweroff { enum boot_mode_t { /* Regular boot scenarios */ LB_BOOT_MODE_NORMAL, + /* Device is booting in low-batter w/o charger attached */ + LB_BOOT_MODE_LOW_BATTERY, /* Device is booting in low-batter w/ charger attached */ LB_BOOT_MODE_LOW_BATTERY_CHARGING, /* Device is booting in due to charger insertion */ diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index c25704f077..12b1479801 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -36,12 +36,19 @@ static enum boot_mode_t set_boot_mode(void) if (!CONFIG(EC_GOOGLE_CHROMEEC)) return boot_mode; - enum boot_mode_t boot_mode_new = LB_BOOT_MODE_NORMAL; - if (is_off_mode()) + enum boot_mode_t boot_mode_new; + + if (is_off_mode()) { boot_mode_new = LB_BOOT_MODE_OFFMODE_CHARGING; - else if (google_chromeec_is_below_critical_threshold() && - google_chromeec_is_charger_present()) - boot_mode_new = LB_BOOT_MODE_LOW_BATTERY_CHARGING; + } else if (google_chromeec_is_below_critical_threshold()) { + if (google_chromeec_is_charger_present()) + boot_mode_new = LB_BOOT_MODE_LOW_BATTERY_CHARGING; + else + boot_mode_new = LB_BOOT_MODE_LOW_BATTERY; + } else { + boot_mode_new = LB_BOOT_MODE_NORMAL; + } + boot_mode = boot_mode_new; return boot_mode_new; }