From 4b0e42bf7402c899f3690ea0cbf4d157c41fab93 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Wed, 25 Mar 2020 14:55:19 -0600 Subject: SM5803: Clear Vbus source bits when setting charge mode When either inhibiting charging from happening or enabling charging, the bits in FLOW_REG1 which cause Vbus to be sourced should be cleared. BUG=None BRANCH=None TEST=make -j buildall Signed-off-by: Diana Z Change-Id: I8713c50f7f6706882ecb9917bb329be22e0e1384 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2121199 Reviewed-by: Aseda Aboagye --- driver/charger/sm5803.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'driver') diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index 75bc48fff5..559237e4ec 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -290,23 +290,19 @@ static enum ec_error_list sm5803_set_mode(int chgnum, int mode) enum ec_error_list rv; int flow1_reg, flow2_reg; - rv = chg_read8(chgnum, SM5803_REG_FLOW1, &flow1_reg); - if (rv) - return rv; - rv = chg_read8(chgnum, SM5803_REG_FLOW2, &flow2_reg); if (rv) return rv; + /* + * Note: when charging or inhibiting charge, ensure bits to source Vbus + * in flow1 are zeroed. + */ if (mode & CHARGE_FLAG_INHIBIT_CHARGE) { - /* If already inhibited, don't bother re-inhibiting */ - if (!(flow1_reg & SM5803_FLOW1_CHG_EN)) - return EC_SUCCESS; - - flow1_reg &= ~SM5803_FLOW1_CHG_EN; + flow1_reg = 0; flow2_reg &= ~SM5803_FLOW2_AUTO_ENABLED; } else { - flow1_reg |= SM5803_FLOW1_CHG_EN; + flow1_reg = SM5803_FLOW1_CHG_EN; flow2_reg |= SM5803_FLOW2_AUTO_ENABLED; } -- cgit v1.2.1