diff options
-rw-r--r-- | driver/tcpm/it83xx.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index e1593b0d89..c8c2edbc38 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -17,6 +17,11 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" +/* Wait time for vconn power switch to turn off. */ +#ifndef PD_IT83XX_VCONN_TURN_OFF_DELAY_US +#define PD_IT83XX_VCONN_TURN_OFF_DELAY_US 500 +#endif + const struct usbpd_ctrl_t usbpd_ctrl_regs[] = { {&IT83XX_GPIO_GPCRF4, &IT83XX_GPIO_GPCRF5, IT83XX_IRQ_USBPD0}, {&IT83XX_GPIO_GPCRH1, &IT83XX_GPIO_GPCRH2, IT83XX_IRQ_USBPD1}, @@ -404,12 +409,23 @@ static int it83xx_tcpm_set_polarity(int port, int polarity) static int it83xx_tcpm_set_vconn(int port, int enable) { #ifdef CONFIG_USBC_VCONN - it83xx_enable_vconn(port, enable); - /* vconn switch */ + /* Disable cc voltage detector and enable 5v tolerant. */ + if (enable) + it83xx_enable_vconn(port, enable); + /* Turn on/off vconn power switch. */ board_pd_vconn_ctrl(port, USBPD_GET_PULL_CC_SELECTION(port) ? USBPD_CC_PIN_2 : USBPD_CC_PIN_1, enable); + if (!enable) { + /* + * We need to make sure cc voltage detector is enabled after + * vconn is turned off to avoid the potential risk of voltage + * fed back into Vcore. + */ + usleep(PD_IT83XX_VCONN_TURN_OFF_DELAY_US); + it83xx_enable_vconn(port, enable); + } #endif return EC_SUCCESS; |