summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2017-09-07 10:47:44 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-09-08 22:08:54 -0700
commit103108ec216e67a4937d9a51f7134d4923dd31f5 (patch)
treea79f8681cb94bfca5d35404b8764c6affa9d2510
parentb39f6780a15920e4c2c5d1b25c4d99d57c8544ff (diff)
downloadchrome-ec-103108ec216e67a4937d9a51f7134d4923dd31f5.tar.gz
tcpm: it83xx: enable cc voltage detector after vconn is offed
We found a potential risk that voltage might fed back into EC Vcore. If the CC pin voltage detector is enabled and there is an unexpected voltage source over 3.3v fed back into EC, this might cause an exception or unknown reset. BRANCH=none BUG=none TEST=The voltage detector is enabled after vconn is offed. Change-Id: I78975fa195eef0b96056a39ee3c6d92c3bb6f8c0 Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/647673 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--driver/tcpm/it83xx.c20
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;