From 10f3b2a248dc20473ba1bf9377fa51f59e2d4f7f Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 25 Feb 2020 16:53:54 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2073279 Reviewed-by: Denis Brockus --- driver/tcpm/tusb422.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'driver/tcpm/tusb422.c') 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 -- cgit v1.2.1