diff options
-rw-r--r-- | baseboard/octopus/baseboard.h | 4 | ||||
-rw-r--r-- | board/dragonegg/board.h | 2 | ||||
-rw-r--r-- | board/it83xx_evb/board.h | 1 | ||||
-rw-r--r-- | board/reef_it8320/board.h | 2 | ||||
-rw-r--r-- | driver/tcpm/it83xx.c | 57 | ||||
-rw-r--r-- | include/usb_pd_tcpm.h | 10 |
6 files changed, 49 insertions, 27 deletions
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 56b08b0b72..32210a0ed1 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -296,10 +296,6 @@ /* Forward declare common (within octopus) board-specific functions */ void board_reset_pd_mcu(void); -#ifdef VARIANT_OCTOPUS_USBC_ITE_EC_TCPCS -void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); -#endif - #ifdef VARIANT_OCTOPUS_USBC_STANDALONE_TCPCS void tcpc_alert_event(enum gpio_signal signal); #endif diff --git a/board/dragonegg/board.h b/board/dragonegg/board.h index c03d98b6b3..59feb9dc4f 100644 --- a/board/dragonegg/board.h +++ b/board/dragonegg/board.h @@ -79,8 +79,6 @@ enum battery_type { BATTERY_TYPE_COUNT, }; -void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); - #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/it83xx_evb/board.h b/board/it83xx_evb/board.h index 6ac5e9f8ae..34cae4c144 100644 --- a/board/it83xx_evb/board.h +++ b/board/it83xx_evb/board.h @@ -107,7 +107,6 @@ enum adc_channel { /* delay to turn on/off vconn */ #define PD_VCONN_SWAP_DELAY 5000 /* us */ -void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); void board_pd_vbus_ctrl(int port, int enabled); #endif diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h index ef1a3361e1..a34392173c 100644 --- a/board/reef_it8320/board.h +++ b/board/reef_it8320/board.h @@ -201,8 +201,6 @@ enum reef_it8320_board_version { /* Reset PD MCU */ void board_reset_pd_mcu(void); int board_get_version(void); -/* Turn on/off vconn power switch. */ -void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); #endif /* !__ASSEMBLER__ */ 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; } diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index 71b49a14ff..78bbf9ed24 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -403,4 +403,14 @@ int tcpc_run(int port, int evt); */ int board_tcpc_post_init(int port) __attribute__((weak)); +/** + * Turn on/off VCONN power switch in board specific code. + * + * @param port Type-C port number + * @param cc_pin 0:CC pin 0, 1: CC pin 1 + * @param enabled 1: Enable VCONN, 0: Disable VCONN + * + */ +void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); + #endif /* __CROS_EC_USB_PD_TCPM_H */ |