diff options
author | Tim Wawrzynczak <twawrzynczak@chromium.org> | 2020-01-14 14:13:59 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-15 16:39:15 +0000 |
commit | bcefa9176290c88b5aab2e5f06fe89ceecba5b01 (patch) | |
tree | 83aaaced347f771c66d9c8cd9af45af108c698b3 | |
parent | c4296cbbea6bcb2c439927b03706375b9b79ec51 (diff) | |
download | chrome-ec-bcefa9176290c88b5aab2e5f06fe89ceecba5b01.tar.gz |
ps8xxx: Add workaround for PS8751 FW ver 0x44.
When the AP is powered on, DRP mode is enabled. Right as the AP is
powered off, and thus DRP mode is disabled, it appears that sometimes
the CC_STATUS register may return incorrect values for CC2 State and/or
CC1 State. At this point in the process, if there is no port partner
for the TCPC, reading CC_STATUS sometimes returns SNK.Power1.5 instead
of SNK.Open (because no port partner is present).
BUG=b:147472779, b:147684491
BRANCH=firmware-hatch-12672.B
TEST=Repeat reproduction procedure 20 times,
ensure it cannot be reproduced. Also added
debug code to ensure that the CC_STATUS is
read correctly on the second time around.
Change-Id: I1844b577b314c1c8c2740e7d29aa296821996b63
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2001135
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
(cherry picked from commit 95a7db7ac0ab2029218a18161315439e853d0fe8)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002952
-rw-r--r-- | driver/tcpm/ps8xxx.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index 81117a5af1..e87372be17 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -246,10 +246,41 @@ static int ps8xxx_tcpm_init(int port) return ps8xxx_dci_disable(port); } +static int ps8xxx_get_cc(int port, enum tcpc_cc_voltage_status *cc1, + enum tcpc_cc_voltage_status *cc2) +{ + int rv; + int status; + + /* + * TODO(twawrzynczak): remove this workaround when no + * longer needed, see b/147684491. + * + * This is a workaround for what appears to be a bug in PS8751 firmware + * version 0x44. + * + * With nothing connected to the port, sometimes after DRP is disabled, + * the CC_STATUS register reads the CC state incorrectly (reading it + * as though a port partner is detected), which ends up confusing + * our TCPM. The workaround for this seems to be a short sleep and + * then re-reading the CC state. In other words, the issue shows up + * as a short glitch or transient, which a dummy read and then a short + * delay will allow the transient to disappear. + */ + rv = tcpc_read(port, TCPC_REG_CC_STATUS, &status); + if (rv) + return rv; + + /* Derived empirically */ + usleep(300); + + return tcpci_tcpm_get_cc(port, cc1, cc2); +} + const struct tcpm_drv ps8xxx_tcpm_drv = { .init = &ps8xxx_tcpm_init, .release = &ps8xxx_tcpm_release, - .get_cc = &tcpci_tcpm_get_cc, + .get_cc = &ps8xxx_get_cc, #ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC .get_vbus_level = &tcpci_tcpm_get_vbus_level, #endif |