summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Herrmann <eherrmann@chromium.org>2021-03-03 12:32:59 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-04 00:35:27 +0000
commit8fffb7f40b72742551a343209a97a7a9add6a827 (patch)
tree7c98297003a29e66a730c10f109ad06a534b40be
parent8be85441500e7b44daaeafeb138383e7ac656062 (diff)
downloadchrome-ec-8fffb7f40b72742551a343209a97a7a9add6a827.tar.gz
TCPMv1/v2: Move SOP' enabling to tcpm_set_vconn
Currently SOP' enabling is done as part of the TCPCI driver when vconn is set - however if we aren't using VCONN from the TCPC, we need to enable SOP' separately. So, instead of enabling it in the TCPCI driver, enable it in the general TCPM set VCONN function. BUG=b:181692098,b:181691263,b:173459141 TEST=Make sure cable discovery works TEST=make buildall BRANCH=None Signed-off-by: Eric Herrmann <eherrmann@chromium.org> Change-Id: Iecc06760f2b8af588c427b9565c6aa31ee719edf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2733574 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usb_pd_protocol.c3
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c3
-rw-r--r--driver/tcpm/tcpci.c6
-rw-r--r--fuzz/usb_pd_fuzz.c8
-rw-r--r--include/driver/tcpm/tcpm.h20
5 files changed, 29 insertions, 11 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 9004246296..5d883760dd 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -438,8 +438,7 @@ static void set_vconn(int port, int enable)
*
* See b/72961003 and b/180973460
*/
- if (IS_ENABLED(CONFIG_USB_PD_TCPC_VCONN))
- tcpm_set_vconn(port, enable);
+ tcpm_set_vconn(port, enable);
if (IS_ENABLED(CONFIG_USBC_PPC_VCONN) && enable)
ppc_set_vconn(port, 1);
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 82f8f001b5..6d9e2a7e60 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1778,8 +1778,7 @@ static void set_vconn(int port, int enable)
*
* See b/72961003 and b/180973460
*/
- if (IS_ENABLED(CONFIG_USB_PD_TCPC_VCONN))
- tcpm_set_vconn(port, enable);
+ tcpm_set_vconn(port, enable);
if (IS_ENABLED(CONFIG_USBC_PPC_VCONN) && enable)
ppc_set_vconn(port, 1);
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 36f4cf4085..24a24d45df 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -645,12 +645,6 @@ int tcpci_tcpm_set_vconn(int port, int enable)
if (rv)
return rv;
- if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) {
- rv = tcpci_tcpm_sop_prime_enable(port, enable);
- if (rv)
- return rv;
- }
-
reg &= ~TCPC_REG_POWER_CTRL_VCONN(1);
reg |= TCPC_REG_POWER_CTRL_VCONN(enable);
return tcpc_write(port, TCPC_REG_POWER_CTRL, reg);
diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c
index 89babff09b..205360015a 100644
--- a/fuzz/usb_pd_fuzz.c
+++ b/fuzz/usb_pd_fuzz.c
@@ -36,6 +36,11 @@ static int mock_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity)
return EC_SUCCESS;
}
+static __maybe_unused int mock_tcpm_sop_prime_enable(int port, bool enable)
+{
+ return EC_SUCCESS;
+}
+
static int mock_tcpm_set_vconn(int port, int enable) { return EC_SUCCESS; }
static int mock_tcpm_set_msg_header(int port,
int power_role, int data_role) { return EC_SUCCESS; }
@@ -131,6 +136,9 @@ static const struct tcpm_drv mock_tcpm_drv = {
.select_rp_value = &mock_tcpm_select_rp_value,
.set_cc = &mock_tcpm_set_cc,
.set_polarity = &mock_tcpm_set_polarity,
+#ifdef CONFIG_USB_PD_DECODE_SOP
+ .sop_prime_enable = &mock_tcpm_sop_prime_enable,
+#endif
.set_vconn = &mock_tcpm_set_vconn,
.set_msg_header = &mock_tcpm_set_msg_header,
.set_rx_enable = &mock_tcpm_set_rx_enable,
diff --git a/include/driver/tcpm/tcpm.h b/include/driver/tcpm/tcpm.h
index 092b266784..3464ce04e1 100644
--- a/include/driver/tcpm/tcpm.h
+++ b/include/driver/tcpm/tcpm.h
@@ -204,7 +204,15 @@ static inline int tcpm_sop_prime_enable(int port, bool enable)
static inline int tcpm_set_vconn(int port, int enable)
{
- return tcpc_config[port].drv->set_vconn(port, enable);
+#ifdef CONFIG_USB_PD_TCPC_VCONN
+ int rv;
+
+ rv = tcpc_config[port].drv->set_vconn(port, enable);
+ if (rv)
+ return rv;
+#endif
+
+ return tcpm_sop_prime_enable(port, enable);
}
static inline int tcpm_set_msg_header(int port, int power_role, int data_role)
@@ -445,6 +453,16 @@ int tcpm_set_cc(int port, int pull);
int tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity);
/**
+ * Enable SOP' message transmit/receive.
+ *
+ * @param port Type-C port number
+ * @param enable Enable/Disable SOP' and SOP'' messages
+ *
+ * @return EC_SUCCESS or error
+ */
+int tcpm_sop_prime_enable(int port, int enable);
+
+/**
* Set Vconn.
*
* @param port Type-C port number