From 219b6c84387948efb283e28e1ff9ae36a47bfba7 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 21 Jan 2026 15:36:50 +0530 Subject: [PATCH] mb/google/bluey: Rename LB_BOOT_MODE_LOW_BATTERY for clarity The current LB_BOOT_MODE_LOW_BATTERY actually implies a state where the battery is below the critical threshold but a charger is attached, allowing the system to boot into a charging-only or limited state. Update the enum name to LB_BOOT_MODE_LOW_BATTERY_CHARGING across coreboot tables and libpayload to better reflect this hardware state. Changes: - Rename boot mode enums in commonlib and libpayload. - Update bluey mainboard logic to use the more descriptive name. - Refactor is_low_power_boot() to is_low_power_boot_with_charger() to improve code readability. - Ensure the charger-present condition is explicitly checked in romstage when setting the boot mode. TEST=Verify bluey boots into off-mode charging and low-battery charging modes correctly. Change-Id: I2478c7519c781a8b5af78445899b7f9bf412cf42 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/90845 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal Reviewed-by: Jayvik Desai --- payloads/libpayload/include/coreboot_tables.h | 5 ++++- .../include/commonlib/coreboot_tables.h | 5 ++++- src/mainboard/google/bluey/mainboard.c | 20 ++++++++++--------- src/mainboard/google/bluey/romstage.c | 5 +++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 36ec6e9125..6cb2558f3a 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -456,8 +456,11 @@ struct cb_panel_poweroff { }; enum boot_mode_t { + /* Regular boot scenarios */ CB_BOOT_MODE_NORMAL, - 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 */ CB_BOOT_MODE_OFFMODE_CHARGING, }; diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index ed5d52f0b5..d4582559df 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -639,8 +639,11 @@ struct lb_panel_poweroff { }; enum boot_mode_t { + /* Regular boot scenarios */ LB_BOOT_MODE_NORMAL, - 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 */ LB_BOOT_MODE_OFFMODE_CHARGING, }; diff --git a/src/mainboard/google/bluey/mainboard.c b/src/mainboard/google/bluey/mainboard.c index ad02b2ea3c..6d3538dcde 100644 --- a/src/mainboard/google/bluey/mainboard.c +++ b/src/mainboard/google/bluey/mainboard.c @@ -63,13 +63,15 @@ static enum boot_mode_t get_boot_mode(void) return boot_mode; } -static bool is_low_power_boot(void) +static bool is_low_power_boot_with_charger(void) { + bool ret = false; enum boot_mode_t boot_mode = get_boot_mode(); - if ((boot_mode == LB_BOOT_MODE_LOW_BATTERY) || + if ((boot_mode == LB_BOOT_MODE_LOW_BATTERY_CHARGING) || (boot_mode == LB_BOOT_MODE_OFFMODE_CHARGING)) - return true; - return false; + ret = true; + + return ret; } static void enable_usb_camera(void) @@ -99,7 +101,7 @@ static void setup_usb(void) static void setup_usb_late(void *unused) { /* Skip USB initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return; setup_usb_host0(); @@ -119,15 +121,15 @@ void lb_add_boot_mode(struct lb_header *header) mode->size = sizeof(*mode); mode->boot_mode = get_boot_mode(); - /* Enable charging only during off-mode or low-battery mode and charger present */ - if (is_low_power_boot() && google_chromeec_is_charger_present()) + /* Enable charging only during off-mode or low-battery mode with charger present */ + if (is_low_power_boot_with_charger()) enable_slow_battery_charging(); } bool mainboard_needs_pcie_init(void) { /* Skip PCIe initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return false; return true; @@ -152,7 +154,7 @@ static void mainboard_init(struct device *dev) configure_parallel_charging(); /* Skip mainboard initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return; gpi_firmware_load(QUP_0_GSI_BASE); diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index aeb1eeda6b..c25704f077 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -39,8 +39,9 @@ static enum boot_mode_t set_boot_mode(void) enum boot_mode_t boot_mode_new = LB_BOOT_MODE_NORMAL; if (is_off_mode()) boot_mode_new = LB_BOOT_MODE_OFFMODE_CHARGING; - else if (google_chromeec_is_below_critical_threshold()) - boot_mode_new = LB_BOOT_MODE_LOW_BATTERY; + else if (google_chromeec_is_below_critical_threshold() && + google_chromeec_is_charger_present()) + boot_mode_new = LB_BOOT_MODE_LOW_BATTERY_CHARGING; boot_mode = boot_mode_new; return boot_mode_new; }