diff options
author | Ruibin Chang <Ruibin.Chang@ite.com.tw> | 2019-08-20 13:07:20 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-21 06:44:12 +0000 |
commit | 7e6b31e8823f26ebd90e61c528d973a2095cbf55 (patch) | |
tree | 57685b66374c0e676ecc3d4744c6dda9d7d64625 | |
parent | e1debcba165515eae87ea36034c43a8b58bff58f (diff) | |
download | chrome-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>
-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 */ |