summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorRuibin Chang <Ruibin.Chang@ite.com.tw>2018-12-17 18:16:29 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-18 00:43:03 -0800
commitc7d12adf74c22a1ef538ce9d7faac1a0d7c7ab66 (patch)
tree31504efe882b55984dad7d9429c21e437da8d291 /driver
parentf0998e9a4bbd7f77c9574f9e27e7e8b8bcc65a18 (diff)
downloadchrome-ec-c7d12adf74c22a1ef538ce9d7faac1a0d7c7ab66.tar.gz
it83xx/intc:add type-c plug in interrupt
When tcpc detect type-c plug in (cc lines voltage change), it will interrupt fw to wake pd task, so task can react immediately. BRANCH=None BUG=None TEST=GRL USBPD test Change-Id: I194b2fcad1d0c62dde2d3296753abd47af8feea6 Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1333207 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/it83xx.c17
-rw-r--r--driver/tcpm/it83xx_pd.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 447ba7fd1d..3cf554cf76 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -361,6 +361,16 @@ static void it83xx_init(enum usbpd_port port, int role)
/* enable tx done and reset detect interrupt */
IT83XX_USBPD_IMR(port) &= ~(USBPD_REG_MASK_MSG_TX_DONE |
USBPD_REG_MASK_HARD_RESET_DETECT);
+#ifdef IT83XX_INTC_PLUG_IN_SUPPORT
+ /*
+ * when tcpc detect type-c plug in (cc lines voltage change), it will
+ * interrupt fw to wake pd task, so task can react immediately.
+ *
+ * w/c status and unmask TCDCR (detect type-c plug in interrupt default
+ * is enable).
+ */
+ IT83XX_USBPD_TCDCR(port) = USBPD_REG_PLUG_IN_OUT_DETECT_STAT;
+#endif //IT83XX_INTC_PLUG_IN_SUPPORT
IT83XX_USBPD_CCPSR(port) = 0xff;
/* cc connect */
IT83XX_USBPD_CCCSR(port) = 0;
@@ -581,6 +591,13 @@ static void it83xx_tcpm_sw_reset(void)
int port = TASK_ID_TO_PD_PORT(task_get_current());
/* Invalidate last received message id variable */
invalidate_last_message_id(port);
+#ifdef IT83XX_INTC_PLUG_IN_SUPPORT
+ /*
+ * Enable detect type-c plug in interrupt, since the pd task has
+ * detected a type-c physical disconnected.
+ */
+ IT83XX_USBPD_TCDCR(port) &= ~USBPD_REG_PLUG_IN_OUT_DETECT_DISABLE;
+#endif //IT83XX_INTC_PLUG_IN_SUPPORT
/* exit BIST test data mode */
USBPD_SW_RESET(port);
}
diff --git a/driver/tcpm/it83xx_pd.h b/driver/tcpm/it83xx_pd.h
index c0714dd9b1..0f6be9b24f 100644
--- a/driver/tcpm/it83xx_pd.h
+++ b/driver/tcpm/it83xx_pd.h
@@ -70,6 +70,10 @@
IS_MASK_SET(IT83XX_USBPD_ISR(port), USBPD_REG_MASK_MSG_TX_DONE)
#define USBPD_IS_RX_DONE(port) \
IS_MASK_SET(IT83XX_USBPD_ISR(port), USBPD_REG_MASK_MSG_RX_DONE)
+#ifdef IT83XX_INTC_PLUG_IN_SUPPORT
+#define USBPD_IS_PLUG_IN_OUT_DETECT(port)\
+ IS_MASK_SET(IT83XX_USBPD_TCDCR(port), USBPD_REG_PLUG_IN_OUT_DETECT_STAT)
+#endif //IT83XX_INTC_PLUG_IN_SUPPORT
enum usbpd_cc_pin {
USBPD_CC_PIN_1,