summaryrefslogtreecommitdiff
path: root/driver/tcpm/tusb422.c
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-02-25 16:53:54 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-13 21:51:19 +0000
commit10f3b2a248dc20473ba1bf9377fa51f59e2d4f7f (patch)
treecf57d419b26b5f7be3bddfe3369c927aa6163741 /driver/tcpm/tusb422.c
parent23b93b7b24fec66d3b3d0e75d2383081a81008cf (diff)
downloadchrome-ec-10f3b2a248dc20473ba1bf9377fa51f59e2d4f7f.tar.gz
tusb422: Fix DRP auto toggle
Fix DRP auto toggle on the TUSB422 TCPC. The CC lines get stuck in a persistent SRC.Open state after a device connection (SRC or SNK) if AUTO_DISCHARGE_DISCONNECT is clear. BUG=b:145250123, b:149974946 BRANCH=none TEST=make buildall TEST=Verify connection of SRC and SNK devices to USB C0 on Volteer. Change-Id: I048e75e906714c542a0aefe5e47731686a13a5ca Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073279 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'driver/tcpm/tusb422.c')
-rw-r--r--driver/tcpm/tusb422.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c
index 0e6a6c51d5..db8a9f7c0b 100644
--- a/driver/tcpm/tusb422.c
+++ b/driver/tcpm/tusb422.c
@@ -18,13 +18,30 @@
#endif
-int tusb422_tcpci_tcpn_init(int port)
+#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) && \
+ !defined(CONFIG_USB_PD_TCPC_LOW_POWER)
+#error "TUSB422 driver requires CONFIG_USB_PD_TCPC_LOW_POWER if"
+#error "CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE is enabled"
+#endif
+
+static int tusb422_tcpci_tcpm_init(int port)
{
int rv = tcpci_tcpm_init(port);
if (rv)
return rv;
+ if (IS_ENABLED(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE)) {
+ /*
+ * When dual role auto toggle is enabled, the TUSB422 needs
+ * auto discharge disconnect enabled so that the CC state
+ * is detected correctly.
+ * Without this, the CC lines get stuck in the SRC.Open state
+ * after updating the ROLE Control register on a device connect.
+ */
+ tusb422_tcpm_drv.tcpc_enable_auto_discharge_disconnect(port, 1);
+ }
+
/*
* VBUS detection is supposed to be enabled by default, however the
* TUSB422 has this disabled following reset.
@@ -34,7 +51,7 @@ int tusb422_tcpci_tcpn_init(int port)
}
const struct tcpm_drv tusb422_tcpm_drv = {
- .init = &tusb422_tcpci_tcpn_init,
+ .init = &tusb422_tcpci_tcpm_init,
.release = &tcpci_tcpm_release,
.get_cc = &tcpci_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
@@ -52,6 +69,8 @@ const struct tcpm_drv tusb422_tcpm_drv = {
#ifdef CONFIG_USB_PD_DISCHARGE_TCPC
.tcpc_discharge_vbus = &tcpci_tcpc_discharge_vbus,
#endif
+ .tcpc_enable_auto_discharge_disconnect =
+ &tcpci_tcpc_enable_auto_discharge_disconnect,
#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
.drp_toggle = &tcpci_tcpc_drp_toggle,
#endif