summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorRuibin Chang <Ruibin.Chang@ite.com.tw>2019-08-20 13:07:20 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-21 06:44:12 +0000
commit7e6b31e8823f26ebd90e61c528d973a2095cbf55 (patch)
tree57685b66374c0e676ecc3d4744c6dda9d7d64625 /driver
parente1debcba165515eae87ea36034c43a8b58bff58f (diff)
downloadchrome-ec-7e6b31e8823f26ebd90e61c528d973a2095cbf55.tar.gz
driver/tcpm/it83xx: Enable TCPC receive SOP'
Enable TCPC receive SOP' for communication with cable, when we are Vconn source role. BUG=None BRANCH=None TEST=test on board: ampton and reef_it8320 1.SRC connects to SNK via E-mark cable, sources Vconn successfully, and receives cable's ack of discover id request. 2.SRC connects to SNK via E-mark cable, but not source Vconn to cable, and receives nothing of discover id request (this isn't effect on request SNK flow). 3.console cmd pdcable 0 2019-07-30 11:43:40 > pdcable 0 2019-07-30 11:43:45 Cable Type: Passive 2019-07-30 11:43:45 Connector Type: Type C 2019-07-30 11:43:45 Cable Current: 5A 2019-07-30 11:43:45 USB Superspeed Signaling support: Gen 1 Change-Id: Icd2e6f8481bb7a4e0b922460d46b831f36112738 Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1728669 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
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;
}