summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/it83xx.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 4d65e71a34..2e59be2f07 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -488,25 +488,46 @@ static int it83xx_tcpm_set_polarity(int port, int polarity)
static int it83xx_tcpm_set_vconn(int port, int enable)
{
-#ifdef CONFIG_USBC_VCONN
- /* 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);
+ /*
+ * IT83XX doesn't have integrated circuit to source CC lines for VCONN.
+ * An external device like PPC or Power Switch has to source the VCONN.
+ */
+ if (IS_ENABLED(CONFIG_USBC_VCONN)) {
+ if (enable) {
+ /*
+ * Unused cc will become Vconn SRC, disable cc analog
+ * module (ex.UP/RD/DET/Tx/Rx) and enable 5v tolerant.
+ */
+ it83xx_enable_vconn(port, enable);
+ if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP))
+ /* Enable tcpc receive SOP' packet */
+ IT83XX_USBPD_PDMSR(port) |=
+ USBPD_REG_MASK_SOPP_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) {
+ /* Disable tcpc receive SOP' packet */
+ if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP))
+ IT83XX_USBPD_PDMSR(port) &=
+ ~USBPD_REG_MASK_SOPP_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);
+ /*
+ * Since our cc are not Vconn SRC, enable cc analog
+ * module (ex.UP/RD/DET/Tx/Rx) and disable 5v tolerant.
+ */
+ it83xx_enable_vconn(port, enable);
+ }
}
-#endif
return EC_SUCCESS;
}