From 242cd4e3ad9b8dfa793769523fc5be6e5dd0fed7 Mon Sep 17 00:00:00 2001 From: Jett Rink Date: Fri, 9 Feb 2018 08:59:13 -0700 Subject: [PATCH] usb-pd: Apply Vconn before Vbus as per USB TypeC spec (v 1.3) According to table 4-25 in USB TypeC spec version 1.3, Vconn should be sourced before Vbus or within 2ms. On Grunt I am see tVconnON around 2.3 ms, which is out of spec. We can simply source Vconn first to comply with spec. BRANCH=none BUG=b:72811851 TEST=Grunt's tVonnOn is now <2ms Change-Id: I52ca6a52bf576487061b2c33f348edf58eb06ca0 Signed-off-by: Jett Rink Reviewed-on: https://chromium-review.googlesource.com/911928 Reviewed-by: Aseda Aboagye Reviewed-by: Edward Hill Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index af623fbcbe..dda616d4b7 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2353,26 +2353,35 @@ void pd_task(void *u) pd[port].flags |= PD_FLAGS_TS_DTS_PARTNER; +#ifdef CONFIG_USBC_VCONN + /* + * Start sourcing Vconn before Vbus to ensure + * we are within USB Type-C Spec 1.3 tVconnON + */ + set_vconn(port, 1); + pd[port].flags |= PD_FLAGS_VCONN_ON; +#endif + #ifndef CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP /* Enable VBUS */ if (pd_set_power_supply_ready(port)) { +#ifdef CONFIG_USBC_VCONN + /* Stop sourcing Vconn if Vbus failed */ + set_vconn(port, 0); + pd[port].flags &= ~PD_FLAGS_VCONN_ON; +#endif /* CONFIG_USBC_VCONN */ #ifdef CONFIG_USBC_SS_MUX usb_mux_set(port, TYPEC_MUX_NONE, USB_SWITCH_DISCONNECT, pd[port].polarity); -#endif +#endif /* CONFIG_USBC_SS_MUX */ break; } -#endif +#endif /* CONFIG_USBC_BACKWARDS_COMPATIBLE_DFP */ /* If PD comm is enabled, enable TCPC RX */ if (pd_comm_is_enabled(port)) tcpm_set_rx_enable(port, 1); -#ifdef CONFIG_USBC_VCONN - set_vconn(port, 1); - pd[port].flags |= PD_FLAGS_VCONN_ON; -#endif - pd[port].flags |= PD_FLAGS_CHECK_PR_ROLE | PD_FLAGS_CHECK_DR_ROLE; hard_reset_count = 0;