summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbc/usb_pe_drp_sm.c4
-rw-r--r--driver/tcpm/anx7447.c2
-rw-r--r--driver/tcpm/anx7688.c2
-rw-r--r--driver/tcpm/it83xx.c16
-rw-r--r--driver/tcpm/it8xxx2.c16
-rw-r--r--driver/tcpm/mt6370.c2
-rw-r--r--driver/tcpm/nct38xx.c2
-rw-r--r--driver/tcpm/ps8xxx.c2
-rw-r--r--driver/tcpm/raa489000.c2
-rw-r--r--driver/tcpm/rt1715.c2
-rw-r--r--driver/tcpm/stm32gx.c4
-rw-r--r--driver/tcpm/tcpci.c13
-rw-r--r--driver/tcpm/tcpci.h2
-rw-r--r--driver/tcpm/tcpm.h4
-rw-r--r--driver/tcpm/tusb422.c2
-rw-r--r--include/usb_pd_tcpm.h8
16 files changed, 46 insertions, 37 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index bffba90088..81c9a8d79c 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -5684,7 +5684,7 @@ static void pe_vcs_evaluate_swap_entry(int port)
* We continue to source VCONN while we wait as required by the
* spec.
*/
- tcpm_sop_prime_disable(port);
+ tcpm_sop_prime_enable(port, false);
}
}
@@ -5762,7 +5762,7 @@ static void pe_vcs_send_swap_run(int port)
* Prevent receiving any SOP' and SOP''
* messages while a swap is in progress.
*/
- tcpm_sop_prime_disable(port);
+ tcpm_sop_prime_enable(port, false);
set_state_pe(port,
PE_VCS_WAIT_FOR_VCONN_SWAP);
} else {
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,
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index bd4b29ddba..8cc5543c53 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -233,15 +233,17 @@ struct tcpm_drv {
#ifdef CONFIG_USB_PD_DECODE_SOP
/**
- * Disable receive of SOP' and SOP'' messages. This is provided
+ * Control receive of SOP' and SOP'' messages. This is provided
* separately from set_vconn so that we can preemptively disable
- * receipt of SOP' messages during a VCONN swap.
+ * receipt of SOP' messages during a VCONN swap, or disable during spans
+ * when port partners may erroneously be sending cable messages.
*
* @param port Type-C port number
+ * @param enable Enable SOP' and SOP'' messages
*
* @return EC_SUCCESS or error
*/
- int (*sop_prime_disable)(int port);
+ int (*sop_prime_enable)(int port, bool enable);
#endif
/**