From 0449fb45a690adc303abb899059441cabae88dcf Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Sun, 8 Mar 2026 09:06:57 +0000 Subject: [PATCH] mb/google/bluey: Refactor and secure low-power charging boot path Refactor the low-power/off-mode charging logic into a dedicated helper function `handle_low_power_charging_boot`. Additionally, replace the `return` statement with `halt()` after the charging applet logic. This ensures that if the system is in a low-power charging state, it cannot accidentally proceed with the rest of the mainboard initialization, which could lead to unstable behavior or power-sequencing issues. Included to provide the necessary definition. BUG=none BRANCH=none TEST=Build and boot on google/quartz. Verify that low-battery boot correctly enters the charging applet and does not proceed to full init. Change-Id: I4bf9bb0f89d117fea9b81a5f8369fa23043a1e82 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/91599 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/mainboard/google/bluey/mainboard.c | 38 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/mainboard/google/bluey/mainboard.c b/src/mainboard/google/bluey/mainboard.c index 3bc7557519..12e180af54 100644 --- a/src/mainboard/google/bluey/mainboard.c +++ b/src/mainboard/google/bluey/mainboard.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,28 @@ static void trigger_critical_battery_shutdown(void) google_chromeec_ap_poweroff(); } +/* + * Handle charging and UI states for low-power or off-mode boot scenarios. + * This function handles the transitions needed when the device is powered + * solely to show a charging status rather than a full OS boot. + */ +static void handle_low_power_charging_boot(void) +{ + /* TODO: enable fast charging */ + enable_slow_battery_charging(); + + /* + * Disable the lightbar for Low-Battery or Off-Mode charging sequences. + * This maintains visual consistency between the built-in display + * indicators and the external lightbar. + */ + if (CONFIG(EC_GOOGLE_CHROMEEC_LED_CONTROL)) + google_chromeec_lightbar_off(); + + /* Boot to charging applet; if this fails, the applet should trigger a reset */ + launch_charger_applet(); +} + static void mainboard_init(struct device *dev) { configure_parallel_charging(); @@ -198,19 +221,8 @@ static void mainboard_init(struct device *dev) /* Skip mainboard initialization if boot mode is "low-battery" or "off-mode charging" */ if (is_low_power_boot_with_charger()) { - /* TODO: enable fast charging */ - enable_slow_battery_charging(); - - /* Disable the lightbar for Low-Battery or Off-Mode charging sequences. - * This maintains visual consistency between the built-in display - * indicators and the external lightbar. - */ - if (CONFIG(EC_GOOGLE_CHROMEEC_LED_CONTROL)) - google_chromeec_lightbar_off(); - - /* Boot to charging applet */ - launch_charger_applet(); - return; + handle_low_power_charging_boot(); + halt(); } gpi_firmware_load(QUP_0_GSI_BASE);