From 1a1b1e9704db2a2639a5c6857327c95a01f5f079 Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Fri, 6 Mar 2020 13:49:16 -0800 Subject: bq25710: Do not soft reset when running out of RW image The bq25710 does not have a reset pin and therefore it's only following a power on reset that its registers are reset. The driver's init function executes a soft reset of the bq25710 to ensure that register settings following either an EC reboot or power on reset are the same. However, this is happening when the EC is in RO or RW, and there is no need to do this in RW. This CL adds a check around the soft reset so that it's only done in R0. BUG=b:148189096 BRANCH=firmware-hatch-12672.B TEST=Verified that low power mode no longer gets reenabled following the jump to RW. Signed-off-by: Scott Collyer Change-Id: I78a7484d3e44147cf350b785889f0f913b03bd06 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2092213 Tested-by: Scott Collyer Reviewed-by: Tim Wawrzynczak Commit-Queue: Tim Wawrzynczak Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094836 Tested-by: Tim Wawrzynczak --- driver/charger/bq25710.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 9df085d78f..68fb757a72 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -15,6 +15,7 @@ #include "hooks.h" #include "i2c.h" #include "task.h" +#include "system.h" #include "timer.h" #ifndef CONFIG_CHARGER_NARROW_VDC @@ -194,22 +195,25 @@ static void bq25710_init(void) * MIN_SYSTEM_VOLTAGE register prior to setting the reset so that the * correct value is preserved. In order to have the correct value read, * the bq25710 must not be in low power mode, otherwise the VDDA rail - * may not be powered if AC is not connected. + * may not be powered if AC is not connected. Note, this reset is only + * required when running out of RO and not following sysjump to RW. */ - rv = bq25710_set_low_power_mode(0); - /* Allow enough time for VDDA to be powered */ - msleep(BQ25710_VDDA_STARTUP_DELAY_MSEC); - rv |= raw_read16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, &vsys); - rv |= raw_read16(BQ25710_REG_CHARGE_OPTION_3, ®); - if (!rv) { - reg |= BQ25710_CHARGE_OPTION_3_RESET_REG; - /* Set all registers to default values */ - raw_write16(BQ25710_REG_CHARGE_OPTION_3, reg); - /* Restore VSYS_MIN voltage to POR reset value */ - raw_write16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, vsys); + if (!system_is_in_rw()) { + rv = bq25710_set_low_power_mode(0); + /* Allow enough time for VDDA to be powered */ + msleep(BQ25710_VDDA_STARTUP_DELAY_MSEC); + rv |= raw_read16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, &vsys); + rv |= raw_read16(BQ25710_REG_CHARGE_OPTION_3, ®); + if (!rv) { + reg |= BQ25710_CHARGE_OPTION_3_RESET_REG; + /* Set all registers to default values */ + raw_write16(BQ25710_REG_CHARGE_OPTION_3, reg); + /* Restore VSYS_MIN voltage to POR reset value */ + raw_write16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, vsys); + } + /* Reenable low power mode */ + bq25710_set_low_power_mode(1); } - /* Reenable low power mode */ - bq25710_set_low_power_mode(1); if (!raw_read16(BQ25710_REG_PROCHOT_OPTION_1, ®)) { /* Disbale VDPM prochot profile at initialization */ -- cgit v1.2.1