summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-03-25 14:55:19 -0600
committerCommit Bot <commit-bot@chromium.org>2020-03-26 22:48:05 +0000
commit4b0e42bf7402c899f3690ea0cbf4d157c41fab93 (patch)
treea4429a0ed3646a52f636105e6316b44061d11a8d
parent3da80621017eed8462f1825fe073de5db729d428 (diff)
downloadchrome-ec-4b0e42bf7402c899f3690ea0cbf4d157c41fab93.tar.gz
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 <dzigterman@chromium.org> Change-Id: I8713c50f7f6706882ecb9917bb329be22e0e1384 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2121199 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/charger/sm5803.c16
1 files changed, 6 insertions, 10 deletions
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;
}