From 511500d64d7f781c7363b2262bc2783883d26d99 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Mon, 16 Nov 2020 14:06:35 -0700 Subject: TCPC: Change SOP' disable interface Add the ability to enable or disable SOP' traffic through a new parameter. Name the function for "enable" to match other EC conventions. BRANCH=None BUG=b:168560801 TEST=make -j buildall Signed-off-by: Diana Z Change-Id: Ife52e7d7d098825ab2163c70a4c59510da958876 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2542864 Reviewed-by: Keith Short --- driver/tcpm/anx7447.c | 2 +- driver/tcpm/anx7688.c | 2 +- driver/tcpm/it83xx.c | 16 +++++++++++----- driver/tcpm/it8xxx2.c | 16 +++++++++++----- driver/tcpm/mt6370.c | 2 +- driver/tcpm/nct38xx.c | 2 +- driver/tcpm/ps8xxx.c | 2 +- driver/tcpm/raa489000.c | 2 +- driver/tcpm/rt1715.c | 2 +- driver/tcpm/stm32gx.c | 4 ++-- driver/tcpm/tcpci.c | 13 ++++--------- driver/tcpm/tcpci.h | 2 +- driver/tcpm/tcpm.h | 4 ++-- driver/tcpm/tusb422.c | 2 +- 14 files changed, 39 insertions(+), 32 deletions(-) (limited to 'driver/tcpm') diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 385cafb081..b009ba32ae 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -810,7 +810,7 @@ const struct tcpm_drv anx7447_tcpm_drv = { .set_cc = &anx7447_set_cc, .set_polarity = &anx7447_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c index 1c6785f406..6b709dd626 100644 --- a/driver/tcpm/anx7688.c +++ b/driver/tcpm/anx7688.c @@ -201,7 +201,7 @@ const struct tcpm_drv anx7688_tcpm_drv = { .set_cc = &tcpci_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index adeda27b3f..5a46742be9 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -556,10 +556,15 @@ static int it83xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) return EC_SUCCESS; } -__maybe_unused static int it83xx_tcpm_decode_sop_prime_disable(int port) +__maybe_unused static int it83xx_tcpm_decode_sop_prime_enable(int port, + bool enable) { - IT83XX_USBPD_PDMSR(port) &= ~(USBPD_REG_MASK_SOPP_ENABLE | - USBPD_REG_MASK_SOPPP_ENABLE); + if (enable) + IT83XX_USBPD_PDMSR(port) |= (USBPD_REG_MASK_SOPP_ENABLE | + USBPD_REG_MASK_SOPPP_ENABLE); + else + IT83XX_USBPD_PDMSR(port) &= ~(USBPD_REG_MASK_SOPP_ENABLE | + USBPD_REG_MASK_SOPPP_ENABLE); return EC_SUCCESS; } @@ -592,7 +597,8 @@ static int it83xx_tcpm_set_vconn(int port, int enable) if (!enable) { /* Disable tcpc receive SOP' and SOP'' packet */ if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) - it83xx_tcpm_decode_sop_prime_disable(port); + it83xx_tcpm_decode_sop_prime_enable(port, + false); /* * We need to make sure cc voltage detector is enabled * after vconn is turned off to avoid the potential risk @@ -831,7 +837,7 @@ const struct tcpm_drv it83xx_tcpm_drv = { .set_cc = &it83xx_tcpm_set_cc, .set_polarity = &it83xx_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &it83xx_tcpm_decode_sop_prime_disable, + .sop_prime_enable = &it83xx_tcpm_decode_sop_prime_enable, #endif .set_vconn = &it83xx_tcpm_set_vconn, .set_msg_header = &it83xx_tcpm_set_msg_header, diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c index 66cfad4940..08cf33e985 100644 --- a/driver/tcpm/it8xxx2.c +++ b/driver/tcpm/it8xxx2.c @@ -489,10 +489,15 @@ static int it83xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) return EC_SUCCESS; } -__maybe_unused static int it83xx_tcpm_decode_sop_prime_disable(int port) +__maybe_unused static int it83xx_tcpm_decode_sop_prime_enable(int port, + bool enable) { - IT83XX_USBPD_PDCSR1(port) &= ~(USBPD_REG_MASK_SOPP_RX_ENABLE | - USBPD_REG_MASK_SOPPP_RX_ENABLE); + if (enable) + IT83XX_USBPD_PDCSR1(port) |= (USBPD_REG_MASK_SOPP_RX_ENABLE | + USBPD_REG_MASK_SOPPP_RX_ENABLE); + else + IT83XX_USBPD_PDCSR1(port) &= ~(USBPD_REG_MASK_SOPP_RX_ENABLE | + USBPD_REG_MASK_SOPPP_RX_ENABLE); return EC_SUCCESS; } @@ -523,7 +528,8 @@ static int it83xx_tcpm_set_vconn(int port, int enable) if (!enable) { if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) /* Disable tcpc receive SOP' and SOP'' packet */ - it83xx_tcpm_decode_sop_prime_disable(port); + it83xx_tcpm_decode_sop_prime_enable(port, + false); /* * We need to make sure cc voltage detector is enabled * after vconn is turned off to avoid the potential risk @@ -861,7 +867,7 @@ const struct tcpm_drv it83xx_tcpm_drv = { .set_cc = &it83xx_tcpm_set_cc, .set_polarity = &it83xx_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &it83xx_tcpm_decode_sop_prime_disable, + .sop_prime_enable = &it83xx_tcpm_decode_sop_prime_enable, #endif .set_vconn = &it83xx_tcpm_set_vconn, .set_msg_header = &it83xx_tcpm_set_msg_header, diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index 07ebeac7f9..cd66dec149 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -196,7 +196,7 @@ const struct tcpm_drv mt6370_tcpm_drv = { .set_cc = &mt6370_set_cc, .set_polarity = &mt6370_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index 79e46fa12a..517c1f23db 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -240,7 +240,7 @@ const struct tcpm_drv nct38xx_tcpm_drv = { .set_cc = &nct38xx_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index b24141c4f0..ea1961dcc1 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -649,7 +649,7 @@ const struct tcpm_drv ps8xxx_tcpm_drv = { .set_cc = &ps8xxx_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c index e9c91bcb83..92a161bf41 100644 --- a/driver/tcpm/raa489000.c +++ b/driver/tcpm/raa489000.c @@ -228,7 +228,7 @@ const struct tcpm_drv raa489000_tcpm_drv = { .set_cc = &raa489000_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/rt1715.c b/driver/tcpm/rt1715.c index cf98666058..0455153a1b 100644 --- a/driver/tcpm/rt1715.c +++ b/driver/tcpm/rt1715.c @@ -56,7 +56,7 @@ const struct tcpm_drv rt1715_tcpm_drv = { .set_cc = &tcpci_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/stm32gx.c b/driver/tcpm/stm32gx.c index 88109329dc..5b20d1f24f 100644 --- a/driver/tcpm/stm32gx.c +++ b/driver/tcpm/stm32gx.c @@ -106,7 +106,7 @@ static int stm32gx_tcpm_transmit(int port, return EC_SUCCESS; } -static int stm32gx_tcpm_sop_prime_disable(int port) +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; @@ -138,7 +138,7 @@ const struct tcpm_drv stm32gx_tcpm_drv = { .set_cc = &stm32gx_tcpm_set_cc, .set_polarity = &stm32gx_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &stm32gx_tcpm_sop_prime_disable, + .sop_prime_enable = &stm32gx_tcpm_sop_prime_enable, #endif .set_vconn = &stm32gx_tcpm_set_vconn, diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index f3c887b365..5fb54b1beb 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -26,7 +26,7 @@ #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) STATIC_IF(CONFIG_USB_PD_DECODE_SOP) - int sop_prime_en[CONFIG_USB_PD_PORT_MAX_COUNT]; + bool sop_prime_en[CONFIG_USB_PD_PORT_MAX_COUNT]; STATIC_IF(CONFIG_USB_PD_DECODE_SOP) int rx_en[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -616,7 +616,7 @@ int tcpci_tcpm_set_src_ctrl(int port, int enable) } #endif -__maybe_unused static int tpcm_set_sop_prime_enable(int port, int enable) +__maybe_unused int tcpci_tcpm_sop_prime_enable(int port, bool enable) { /* save SOP'/SOP'' enable state */ sop_prime_en[port] = enable; @@ -635,11 +635,6 @@ __maybe_unused static int tpcm_set_sop_prime_enable(int port, int enable) return EC_SUCCESS; } -__maybe_unused int tcpci_tcpm_sop_prime_disable(int port) -{ - return tpcm_set_sop_prime_enable(port, 0); -} - int tcpci_tcpm_set_vconn(int port, int enable) { int reg, rv; @@ -649,7 +644,7 @@ int tcpci_tcpm_set_vconn(int port, int enable) return rv; if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) { - rv = tpcm_set_sop_prime_enable(port, enable); + rv = tcpci_tcpm_sop_prime_enable(port, enable); if (rv) return rv; } @@ -1760,7 +1755,7 @@ const struct tcpm_drv tcpci_tcpm_drv = { .set_cc = &tcpci_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h index a8aa7774c4..594e3adc3c 100644 --- a/driver/tcpm/tcpci.h +++ b/driver/tcpm/tcpci.h @@ -224,7 +224,7 @@ bool tcpci_tcpm_check_vbus_level(int port, enum vbus_level level); int tcpci_tcpm_select_rp_value(int port, int rp); int tcpci_tcpm_set_cc(int port, int pull); int tcpci_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity); -int tcpci_tcpm_sop_prime_disable(int port); +int tcpci_tcpm_sop_prime_enable(int port, bool enable); int tcpci_tcpm_set_vconn(int port, int enable); int tcpci_tcpm_set_msg_header(int port, int power_role, int data_role); int tcpci_tcpm_set_rx_enable(int port, int enable); diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h index f457196d65..9a00a4f402 100644 --- a/driver/tcpm/tcpm.h +++ b/driver/tcpm/tcpm.h @@ -193,10 +193,10 @@ static inline int tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) return tcpc_config[port].drv->set_polarity(port, polarity); } -static inline int tcpm_sop_prime_disable(int port) +static inline int tcpm_sop_prime_enable(int port, bool enable) { #ifdef CONFIG_USB_PD_DECODE_SOP - return tcpc_config[port].drv->sop_prime_disable(port); + return tcpc_config[port].drv->sop_prime_enable(port, enable); #else return EC_SUCCESS; #endif diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c index 75ffcd1d43..18fd053e7c 100644 --- a/driver/tcpm/tusb422.c +++ b/driver/tcpm/tusb422.c @@ -159,7 +159,7 @@ const struct tcpm_drv tusb422_tcpm_drv = { .set_cc = &tusb422_tcpm_set_cc, .set_polarity = &tcpci_tcpm_set_polarity, #ifdef CONFIG_USB_PD_DECODE_SOP - .sop_prime_disable = &tcpci_tcpm_sop_prime_disable, + .sop_prime_enable = &tcpci_tcpm_sop_prime_enable, #endif .set_vconn = &tcpci_tcpm_set_vconn, .set_msg_header = &tcpci_tcpm_set_msg_header, -- cgit v1.2.1