From 0e1742a7e227a97b6f3370686792f2c4f2e3080d Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 11 Nov 2025 06:18:09 +0000 Subject: [PATCH] mb/google/bluey: Control slow battery charging via boot mode The slow battery charging control was split across two locations: 1. Unconditionally enabled in `romstage.c`. 2. Conditionally disabled later in `mainboard.c` for normal boot mode. This split logic is unnecessary and can be simplified. Battery charging should only be enabled when the system determines it needs to enter a low-battery boot mode (`LB_BOOT_MODE_LOW_BATTERY`). This commit refactors the control flow by: 1. Removing the unconditional `enable_slow_battery_charging()` call from `romstage.c`. 2. Enabling `slow_battery_charging()` only within `lb_add_boot_mode()` when the determined boot mode is low-battery. This ensures charging is managed solely based on the determined boot mode, confining the control logic to a single location. BUG=b:457566143 TEST=Able to build and boot google/quenbi. Ensure charging is only enabled in AP firmware if booted in low-battery mode. Change-Id: I906d555b9fa4ad2581f598621ea96bda891ff47e Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/89990 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- src/mainboard/google/bluey/mainboard.c | 6 +++--- src/mainboard/google/bluey/romstage.c | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mainboard/google/bluey/mainboard.c b/src/mainboard/google/bluey/mainboard.c index 123e39854d..df2d3d33a7 100644 --- a/src/mainboard/google/bluey/mainboard.c +++ b/src/mainboard/google/bluey/mainboard.c @@ -32,9 +32,9 @@ void lb_add_boot_mode(struct lb_header *header) if (google_chromeec_is_below_critical_threshold()) mode->boot_mode = LB_BOOT_MODE_LOW_BATTERY; - /* Booting into normal mode hence disable charging */ - if (mode->boot_mode == LB_BOOT_MODE_NORMAL) - disable_slow_battery_charging(); + /* Enable charging only during low-battery mode */ + if (mode->boot_mode == LB_BOOT_MODE_LOW_BATTERY) + enable_slow_battery_charging(); } bool mainboard_needs_pcie_init(void) diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index da87261fef..b76dfba1f2 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -18,8 +18,6 @@ void platform_romstage_main(void) /* QCLib: DDR init & train */ qclib_load_and_run(); - enable_slow_battery_charging(); - aop_fw_load_reset(); qclib_rerun();