diff options
author | Scott Collyer <scollyer@google.com> | 2020-11-05 10:20:32 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-20 09:11:55 +0000 |
commit | 28e7a812d26ab801dfc260164c3195a9eed12950 (patch) | |
tree | 7619b206c886a1569352d021a549022db90ce0b0 /driver/tcpm | |
parent | e82929c183162dbea16de4c37d017587318ff9bb (diff) | |
download | chrome-ec-28e7a812d26ab801dfc260164c3195a9eed12950.tar.gz |
tcpm: Add USB-PD messaging support for stm32gx driver
This CL implements the tcpci driver wrapper functions for usb-pd
messaging which then call into the underlying ucpd driver.
BUG=b:167601672
BRANCH=None
TEST=verfied type-c attaches properly on quiche
Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: I6d0a585f6988ef8a45823381038fe04dbbc72ef6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522650
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver/tcpm')
-rw-r--r-- | driver/tcpm/stm32gx.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/driver/tcpm/stm32gx.c b/driver/tcpm/stm32gx.c index 790b373925..0606668abe 100644 --- a/driver/tcpm/stm32gx.c +++ b/driver/tcpm/stm32gx.c @@ -25,6 +25,9 @@ #error "Unsupported config options of Stm32gx PD driver" #endif +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) + /* Wait time for vconn power switch to turn off. */ #ifndef PD_STM32GX_VCONN_TURN_OFF_DELAY_US #define PD_STM32GX_VCONN_TURN_OFF_DELAY_US 500 @@ -35,8 +38,7 @@ static int cached_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; static int stm32gx_tcpm_get_message_raw(int port, uint32_t *buf, int *head) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_get_message_raw(port, buf, head); } static int stm32gx_tcpm_init(int port) @@ -77,24 +79,22 @@ static int stm32gx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) static int stm32gx_tcpm_set_vconn(int port, int enable) { - /* - * TODO(b/167601672): VCONN is not provided by ucpd peripheral, so the - * only action required here will be to remove Rp from the CC line that - * is supplying VCONN. - */ + stm32gx_ucpd_vconn_disc_rp(port, enable); + + if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) + stm32gx_ucpd_sop_prime_enable(port, enable); + return EC_SUCCESS; } static int stm32gx_tcpm_set_msg_header(int port, int power_role, int data_role) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_set_msg_header(port, power_role, data_role); } static int stm32gx_tcpm_set_rx_enable(int port, int enable) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_set_rx_enable(port, enable); } static int stm32gx_tcpm_transmit(int port, @@ -102,22 +102,19 @@ static int stm32gx_tcpm_transmit(int port, uint16_t header, const uint32_t *data) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_transmit(port, type, header, data); } static int stm32gx_tcpm_sop_prime_enable(int port, bool enable) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_sop_prime_enable(port, enable); } static int stm32gx_tcpm_get_chip_info(int port, int live, struct ec_response_pd_chip_info_v1 *chip_info) { - /* TODO(b/167601672): Need to implement this for USB-PD support */ - return EC_SUCCESS; + return stm32gx_ucpd_get_chip_info(port, live, chip_info); } static void stm32gx_tcpm_sw_reset(void) @@ -140,7 +137,6 @@ const struct tcpm_drv stm32gx_tcpm_drv = { #ifdef CONFIG_USB_PD_DECODE_SOP .sop_prime_enable = &stm32gx_tcpm_sop_prime_enable, #endif - .set_vconn = &stm32gx_tcpm_set_vconn, .set_msg_header = &stm32gx_tcpm_set_msg_header, .set_rx_enable = &stm32gx_tcpm_set_rx_enable, |