summaryrefslogtreecommitdiff
path: root/common/usb_pd_protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r--common/usb_pd_protocol.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 67592e3249..e1b1b8e27b 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -2902,7 +2902,21 @@ void pd_task(void *u)
*/
pd_power_supply_reset(port);
#ifdef CONFIG_USBC_VCONN
- set_vconn(port, 0);
+#ifdef CONFIG_USB_PD_DUAL_ROLE
+ /*
+ * If we were previously a sink but also the VCONN source, we should
+ * still continue to source VCONN. Otherwise, we should turn off VCONN
+ * since we are also going to turn off VBUS.
+ */
+ if (pd_comm_is_enabled(port) &&
+ (pd_get_saved_port_flags(port, &saved_flgs) == EC_SUCCESS) &&
+ ((saved_flgs & PD_BBRMFLG_POWER_ROLE) == PD_ROLE_SINK) &&
+ (saved_flgs & PD_BBRMFLG_EXPLICIT_CONTRACT) &&
+ (saved_flgs & PD_BBRMFLG_VCONN_ROLE))
+ set_vconn(port, 1);
+ else
+#endif
+ set_vconn(port, 0);
#endif
/* Initialize TCPM driver and wait for TCPC to be ready */