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 <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89990
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
Subrata Banik 2025-11-11 06:18:09 +00:00
commit 0e1742a7e2
2 changed files with 3 additions and 5 deletions

View file

@ -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)

View file

@ -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();