summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2016-07-29 11:25:09 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-08-21 22:03:34 -0700
commite3297d725517de90a657e157f3ceafe53b2b13f2 (patch)
treef642d92bf18b7f3407327b1e4bfc21cb256def47
parentb387bdf40ec8e1929cd5a8b96464bec8e9ee5d94 (diff)
downloadchrome-ec-e3297d725517de90a657e157f3ceafe53b2b13f2.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 Reviewed-on: https://chromium-review.googlesource.com/364351 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--driver/tcpm/anx7688.c17
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, &reg);
+ 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,