diff options
author | Yilun Lin <yllin@google.com> | 2019-01-29 15:20:04 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-02-12 04:26:53 -0800 |
commit | cc736a3e98b8069897d3256b7f75ba88922eefd1 (patch) | |
tree | 6a73ac8f800a858b44922984c1735e430c96f3d2 /driver/tcpm/mt6370.c | |
parent | 52569e08985bb8406343835bb7134490f5b86b5c (diff) | |
download | chrome-ec-cc736a3e98b8069897d3256b7f75ba88922eefd1.tar.gz |
tcpc/mt6370: Fix keeps entering/leaving LPM when sink device attached.
When usb-c port is attached, TCPM will make TCPC leave LPM by calling
tcpm_init->mt6370_init. However, mt6370_init will do soft reset
in the function, and mt6370 is not able to report the correct CC status
via auto-toggle when soft reset is done while usb-c port being plugged
with a sink device (source device is fine in this case).
This CL only allows doing soft reset when it is woken up from the
shipping mode. This can solve the issue since that it won't woken
up by a source device.
BRANCH=None
BUG=b:122017882
TEST=1. cutoff; plugged pd charger, and see EC running normal.
2. Plug a sink device, and see the TCPC move its states to non-LPM;
unplug hub, and see it in LPM.
3. Plug a nothing connected hub, and see mt6370 move its states
to non-LPM; unplug the hub, and see mt6370 in LPM.
3. Plug a nothing connected hub, and see mt6370 move its states
to non-LPM; plug a charger to the hub, and see mt6370 sinking
power from the hub.
4. Plug pd charger, and see the TCPC move its state to LPM.
Change-Id: Iba95e9eb43cac4c01b8f66fcf82fc3deb947fecb
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1442391
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/tcpm/mt6370.c')
-rw-r--r-- | driver/tcpm/mt6370.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index dba3a045a0..e478d560a0 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -28,15 +28,21 @@ static int mt6370_i2c_write8(int port, int reg, int val) static int mt6370_init(int port) { - int rv; + int rv, val; - /* Software reset. */ - rv = tcpc_write(port, MT6370_REG_SWRESET, 1); - if (rv) - return rv; + rv = tcpc_read(port, MT6370_REG_IDLE_CTRL, &val); - /* Need 1 ms for software reset. */ - msleep(1); + /* Only do soft-reset in shipping mode. (b:122017882) */ + if (!(val & MT6370_REG_SHIPPING_OFF)) { + + /* Software reset. */ + rv = tcpc_write(port, MT6370_REG_SWRESET, 1); + if (rv) + return rv; + + /* Need 1 ms for software reset. */ + msleep(1); + } /* The earliest point that we can do generic init. */ rv = tcpci_tcpm_init(port); |