diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-07-14 15:02:53 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-21 01:34:39 +0000 |
commit | 305e45d19e8aad0531ff22577fd24d5fb26b8865 (patch) | |
tree | 41da5a2f478d6463149174e37aa24cf191fb8c91 /driver | |
parent | 5ab2a3eec255d05789a85c6925b6e604010ef0f4 (diff) | |
download | chrome-ec-305e45d19e8aad0531ff22577fd24d5fb26b8865.tar.gz |
sm5803: Use VBUS ADCs for VBUS presence
For some reason, using the CHG_DET bit in the status register does not
always leave us with the right result for VBUS presence. However, the
VBUS threshold interrupts seem very reliable. There could be some
timing issue at play.
This commit changes the init to use the VBUS ADC measurements to
determine whether VBUS is present or not to be consistent with the
run-time notification triggered from the VBUS threshold interrupts.
BUG=b:161269327
BRANCH=None
TEST=Build and flash waddledee, with other CL to change extpower to
consult the VBUS ADCs, verify that AC presence is notified in the
system correctly during run-time and at init.
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: I6e694611cf58a59f20fa6843cf145421d33d0784
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2297982
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/sm5803.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index 0e0f84ff80..132e2e5a9c 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -206,26 +206,27 @@ static void sm5803_init(int chgnum) { enum ec_error_list rv; int reg; + int vbus_mv; /* * If a charger is not currently present, disable switching per OCPC * requirements */ - rv = main_read8(chgnum, SM5803_REG_STATUS1, ®); + rv = charger_get_vbus_voltage(chgnum, &vbus_mv); if (rv == EC_SUCCESS) { - if (!(reg & SM5803_STATUS1_CHG_DET)) { + if (vbus_mv < 4000) { /* * No charger connected, disable CHG_EN * (note other bits default to 0) */ rv = chg_write8(chgnum, SM5803_FLOW1_CHG_EN, 0); - } else { + } else if (!sm5803_is_sourcing_otg_power(chgnum, chgnum)) { charger_vbus[chgnum] = 1; } } else { - CPRINTS("%s %d: Failed to read status during init", - CHARGER_NAME, chgnum); + CPRINTS("%s %d: Failed to read VBUS voltage during init", + CHARGER_NAME, chgnum); return; } |