From 6e61ea65a8933048f288593f50786ddabb76d57a Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 3 Sep 2025 11:06:38 +0530 Subject: [PATCH] mb/google/bluey: Add disable slow charging support This commit adds a new function, disable_slow_battery_charging, to disable charging on the Bluey mainboard. This function writes a disable command to the SMBUS chargers, turning off the charging process. Additionally, this patch makes the following changes to support this new functionality: - The charging.c file is now compiled in both the romstage and ramstage phases. - The new disable_slow_battery_charging function is declared in board.h. - A new charging_status enum is introduced to clearly define the charging states. These changes ensure that the system can now properly control charging, allowing it to be disabled when necessary. BUG=b:439819922 TEST=Able to build and boot google/quenbi. Change-Id: Ic0c59e0509889e6d166becf76279718b853021cc Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/89022 Reviewed-by: Kapil Porwal Tested-by: build bot (Jenkins) --- src/mainboard/google/bluey/Makefile.mk | 2 ++ src/mainboard/google/bluey/board.h | 1 + src/mainboard/google/bluey/charging.c | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/mainboard/google/bluey/Makefile.mk b/src/mainboard/google/bluey/Makefile.mk index 556509b3cb..87d58149af 100644 --- a/src/mainboard/google/bluey/Makefile.mk +++ b/src/mainboard/google/bluey/Makefile.mk @@ -12,4 +12,6 @@ romstage-y += romstage.c romstage-y += charging.c +ramstage-y += charging.c + ramstage-y += mainboard.c diff --git a/src/mainboard/google/bluey/board.h b/src/mainboard/google/bluey/board.h index 2a7120a719..31b6212256 100644 --- a/src/mainboard/google/bluey/board.h +++ b/src/mainboard/google/bluey/board.h @@ -39,5 +39,6 @@ void setup_chromeos_gpios(void); void enable_slow_battery_charging(void); +void disable_slow_battery_charging(void); #endif /* MAINBOARD_GOOGLE_BLUEY_BOARD_H */ diff --git a/src/mainboard/google/bluey/charging.c b/src/mainboard/google/bluey/charging.c index 3b9e4492b9..2c1e447585 100644 --- a/src/mainboard/google/bluey/charging.c +++ b/src/mainboard/google/bluey/charging.c @@ -13,7 +13,11 @@ #define SMB2_CHGR_CHRG_EN_CMD ((SMB2_SLAVE_ID << 16) | SCHG_CHGR_CHARGING_ENABLE_CMD) #define FCC_1A_STEP_50MA 0x14 -#define CHRG_ENABLE 0x01 + +enum charging_status { + CHRG_DISABLE, + CHRG_ENABLE, +}; /* * Enable charging w/ 1A Icurrent supply at max. @@ -27,3 +31,13 @@ void enable_slow_battery_charging(void) spmi_write8(SMB1_CHGR_CHRG_EN_CMD, CHRG_ENABLE); spmi_write8(SMB2_CHGR_CHRG_EN_CMD, CHRG_ENABLE); } + +/* + * Disable charging. + */ +void disable_slow_battery_charging(void) +{ + printk(BIOS_INFO, "Disable slow charge support\n"); + spmi_write8(SMB1_CHGR_CHRG_EN_CMD, CHRG_DISABLE); + spmi_write8(SMB2_CHGR_CHRG_EN_CMD, CHRG_DISABLE); +}