From b67d88aecbd3396ef35c952a1c5af0734f7663aa Mon Sep 17 00:00:00 2001 From: Kapil Porwal Date: Mon, 25 Aug 2025 09:44:44 +0530 Subject: [PATCH] mb/google/bluey: Enable PMIC based slow charging in romstage Enable PMIC based slow charging in romstage until we have fast charging solution enabled. BUG=b:438004604 TEST=Verify battery charging during romstage. Change-Id: Idb8ea7151a2a467194aee2b357d8a5f24e691717 Signed-off-by: Kapil Porwal Reviewed-on: https://review.coreboot.org/c/coreboot/+/88928 Reviewed-by: Subrata Banik Tested-by: build bot (Jenkins) --- src/mainboard/google/bluey/romstage.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index b76dfba1f2..67d19aa1e6 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -5,9 +5,32 @@ #include #include #include +#include #include #include +#define SMB1_SLAVE_ID 0x07 +#define SMB2_SLAVE_ID 0x0A +#define SCHG_CHGR_MAX_FAST_CHARGE_CURRENT_CFG 0x2666 +#define SMB1_CHGR_MAX_FCC_CFG ((SMB1_SLAVE_ID << 16) | SCHG_CHGR_MAX_FAST_CHARGE_CURRENT_CFG) +#define SMB2_CHGR_MAX_FCC_CFG ((SMB2_SLAVE_ID << 16) | SCHG_CHGR_MAX_FAST_CHARGE_CURRENT_CFG) +#define SCHG_CHGR_CHARGING_ENABLE_CMD 0x2642 +#define SMB1_CHGR_CHRG_EN_CMD ((SMB1_SLAVE_ID << 16) | SCHG_CHGR_CHARGING_ENABLE_CMD) +#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 + +static void enable_battery_charging(void) +{ + /* Configure FCC and enable charging */ + printk(BIOS_INFO, "Use slow charging without fast charge support\n"); + spmi_write8(SMB1_CHGR_MAX_FCC_CFG, FCC_1A_STEP_50MA); + spmi_write8(SMB2_CHGR_MAX_FCC_CFG, FCC_1A_STEP_50MA); + spmi_write8(SMB1_CHGR_CHRG_EN_CMD, CHRG_ENABLE); + spmi_write8(SMB2_CHGR_CHRG_EN_CMD, CHRG_ENABLE); +} + void platform_romstage_main(void) { /* Watchdog must be checked first to avoid erasing watchdog info later. */ @@ -22,6 +45,8 @@ void platform_romstage_main(void) qclib_rerun(); + enable_battery_charging(); + /* * Enable this power rail now for FPMCU stability prior to * its reset being deasserted in ramstage. This applies