diff options
author | Ruibin Chang <ruibin.chang@ite.com.tw> | 2020-07-28 10:57:55 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-31 05:24:29 +0000 |
commit | d986075dc3c41748556170dd3ef3b67adb64578b (patch) | |
tree | 02c45d67a7c72297436619ec1861d6b8eaf8bb6b /chip | |
parent | 7e36bc92e96b9bf7a64f1b0abb51c67cf967ad54 (diff) | |
download | chrome-ec-d986075dc3c41748556170dd3ef3b67adb64578b.tar.gz |
chip/it83xx, it8xxx2: implement detect cc disconnection interrupt for SRC role
Implement detect cc disconnection interrupt for source. When TCPC
detect SNK/audio/debug device plug out (cc lines open), TCPC can
interrupt pd task to update cc state.
BUG=b:160548079
BRANCH=none
TEST=test on board reef_it8320, it81202_pdevb with TCPMv1, TCPMv2.
Connect to dongle, adapter and DRP, check
1.Plug in/out interrupt fire correctly.
2.Power role swap can state to SRC_READY and SNK_READY.
3.When partner disconnect, we discharge Vconn within
tVconnOFF(35ms).
Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
Change-Id: I58bc8a5a9289df4ea4e8b3efec000d3a9ab1cb5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2294626
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/it83xx/config_chip_it8320.h | 4 | ||||
-rw-r--r-- | chip/it83xx/config_chip_it8xxx2.h | 8 | ||||
-rw-r--r-- | chip/it83xx/intc.c | 36 |
3 files changed, 26 insertions, 22 deletions
diff --git a/chip/it83xx/config_chip_it8320.h b/chip/it83xx/config_chip_it8320.h index a95faccddc..7fc191f11c 100644 --- a/chip/it83xx/config_chip_it8320.h +++ b/chip/it83xx/config_chip_it8320.h @@ -87,8 +87,8 @@ #define IT83XX_INTC_FAST_SWAP_SUPPORT /* Enable interrupts of group 21 and 22. */ #define IT83XX_INTC_GROUP_21_22_SUPPORT -/* Enable detect type-c plug in interrupt. */ -#define IT83XX_INTC_PLUG_IN_SUPPORT +/* Enable detect type-c plug in and out interrupt. */ +#define IT83XX_INTC_PLUG_IN_OUT_SUPPORT /* Chip Dx transmit status bit of PD register is different from Bx. */ #define IT83XX_PD_TX_ERROR_STATUS_BIT5 /* Chip IT8320DX actually has TCPC physical port count */ diff --git a/chip/it83xx/config_chip_it8xxx2.h b/chip/it83xx/config_chip_it8xxx2.h index 9336a407fb..e7c4e880de 100644 --- a/chip/it83xx/config_chip_it8xxx2.h +++ b/chip/it83xx/config_chip_it8xxx2.h @@ -71,8 +71,8 @@ #define IT83XX_H2RAM_REMAPPING /* Enable FRS detection interrupt. */ #define IT83XX_INTC_FAST_SWAP_SUPPORT -/* Enable detect type-c plug in interrupt. */ -#define IT83XX_INTC_PLUG_IN_SUPPORT +/* Enable detect type-c plug in and out interrupt. */ +#define IT83XX_INTC_PLUG_IN_OUT_SUPPORT /* Chip IT83202BX actually has TCPC physical port count. */ #define IT83XX_USBPD_PHY_PORT_COUNT 3 #elif defined(CHIP_VARIANT_IT81302AX_1024) \ @@ -118,8 +118,8 @@ #define IT83XX_H2RAM_REMAPPING /* Enable FRS detection interrupt. */ #define IT83XX_INTC_FAST_SWAP_SUPPORT -/* Enable detect type-c plug in interrupt. */ -#define IT83XX_INTC_PLUG_IN_SUPPORT +/* Enable detect type-c plug in and out interrupt. */ +#define IT83XX_INTC_PLUG_IN_OUT_SUPPORT /* Wake up CPU from low power mode even if interrupts are disabled */ #define IT83XX_RISCV_WAKEUP_CPU_WITHOUT_INT_ENABLED /* Auto reset rx fifo while CS# deasserted. */ diff --git a/chip/it83xx/intc.c b/chip/it83xx/intc.c index ce5aca43b7..2a6e3688d9 100644 --- a/chip/it83xx/intc.c +++ b/chip/it83xx/intc.c @@ -62,24 +62,28 @@ static void chip_pd_irq(enum usbpd_port port) TASK_EVENT_PHY_TX_DONE, 0); } - if (IS_ENABLED(IT83XX_INTC_PLUG_IN_SUPPORT)) { + if (IS_ENABLED(IT83XX_INTC_PLUG_IN_OUT_SUPPORT)) { if (USBPD_IS_PLUG_IN_OUT_DETECT(port)) { - /* - * When tcpc detect type-c plug in, then disable - * this interrupt. Because any cc volt changes - * (include pd negotiation) would trigger plug in - * interrupt, frequently plug in interrupt and wakeup - * pd task may cause task starvation or device dead - * (ex.transmit lots SRC_Cap). - * - * When polling disconnect will enable detect type-c - * plug in again. - * - * Clear detect type-c plug in interrupt status. - */ + if (USBPD_IS_PLUG_IN(port)) + /* + * When tcpc detect type-c plug in: + * 1)If we are sink, disable detect interrupt, + * messages on cc line won't trigger interrupt. + * 2)If we are source, then set plug out + * detection. + */ + switch_plug_out_type(port); + else + /* + * When tcpc detect type-c plug out: + * switch to detect plug in. + */ + IT83XX_USBPD_TCDCR(port) &= + ~USBPD_REG_PLUG_OUT_SELECT; + + /* clear type-c device plug in/out detect interrupt */ IT83XX_USBPD_TCDCR(port) |= - (USBPD_REG_PLUG_IN_OUT_DETECT_DISABLE | - USBPD_REG_PLUG_IN_OUT_DETECT_STAT); + USBPD_REG_PLUG_IN_OUT_DETECT_STAT; task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); } |