diff options
author | Nicolas Boichat <drinkcat@google.com> | 2016-07-29 11:25:09 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-08-17 15:37:13 +0000 |
commit | 330e6b4cece754100efe74c4adc854d3826a9df9 (patch) | |
tree | 1d8e337bf40a697735e5f97f0e8172279b390bcb | |
parent | 946330afbf53d602b13a5ff99088e26824bf15e1 (diff) | |
download | chrome-ec-330e6b4cece754100efe74c4adc854d3826a9df9.tar.gz |
anx7688: Add custom vbus function
On ANX7688, POWER_STATUS.VBusPresent is averaged 16 times, so its
value may not be set to 1 quickly enough during power role swap.
Therefore, we use a proprietary register to read the unfiltered VBus
value.
BRANCH=oak
BUG=chrome-os-partner:55221
TEST=LG monitor works over type-C, power role swap looks good
Change-Id: I68572c34440be65882f431bb892ed032da05bd0a
Previous-Reviewed-on: https://chromium-review.googlesource.com/364351
(cherry picked from commit aa42553fde803a39e7e4ae66b9c58a0347b5b934)
Reviewed-on: https://chromium-review.googlesource.com/371778
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Trybot-Ready: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r-- | driver/tcpm/anx7688.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c index 7e499629a8..ae1dd32124 100644 --- a/driver/tcpm/anx7688.c +++ b/driver/tcpm/anx7688.c @@ -160,12 +160,27 @@ static int anx7688_mux_set(int i2c_addr, mux_state_t mux_state) return tcpc_write(port, TCPC_REG_CONFIG_STD_OUTPUT, reg); } +#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC +static int anx7688_tcpm_get_vbus_level(int port) +{ + int reg = 0; + + /* On ANX7688, POWER_STATUS.VBusPresent (bit 2) is averaged 16 times, so + * its value may not be set to 1 quickly enough during power role swap. + * Therefore, we use a proprietary register to read the unfiltered VBus + * value. See crosbug.com/p/55221 . + */ + i2c_read8(I2C_PORT_TCPC, 0x50, 0x40, ®); + return ((reg & 0x10) ? 1 : 0); +} +#endif + /* ANX7688 is a TCPCI compatible port controller */ const struct tcpm_drv anx7688_tcpm_drv = { .init = &anx7688_init, .get_cc = &tcpci_tcpm_get_cc, #ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC - .get_vbus_level = &tcpci_tcpm_get_vbus_level, + .get_vbus_level = &anx7688_tcpm_get_vbus_level, #endif .set_cc = &tcpci_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, |