summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2020-04-27 15:40:39 -0600
committerCommit Bot <commit-bot@chromium.org>2020-04-28 22:35:36 +0000
commit0ec4d5f9a9c200c64ce8f1e5a4a43af006e5f73e (patch)
tree1655e851a3a7df67b7b2d3d8b7b6da3294bae593
parentbff373fdcdcfb67e52e8d9ef9223f2474adcb9f3 (diff)
downloadchrome-ec-0ec4d5f9a9c200c64ce8f1e5a4a43af006e5f73e.tar.gz
TCPMv1: skip cable probing when not VCONN source
USB PD specification only permits the port that is currently sourcing VCONN to send SOP' and SOP'' messages to the cable. Ensure USB4 and TBT modes are not probed or entered if the EC is not sourcing VCONN. BUG=b:155073708 BRANCH=none TEST=make buildall TEST=connect Gatkex board to Volteer, with PD analyzer observe that when Gatkex claims VCONN source, EC code skips all SOP' messages but otherwise completes PD discovery. TEST=connect TBT dock, verify SOP' messages sent and TBT mode is entered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ie7cf2910c0d9d78ba809ca25943585cfc96031a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2169476 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Ayushee Shah <ayushee.shah@intel.com>
-rw-r--r--common/usb_pd_policy.c37
-rw-r--r--common/usb_pd_protocol.c3
-rw-r--r--include/usb_pd.h5
3 files changed, 15 insertions, 30 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index af8e9ebf50..ec5b9aba7c 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -147,20 +147,19 @@ bool consume_sop_prime_prime_repeat_msg(int port, uint8_t msg_id)
return true;
}
-static void disable_transmit_sop_prime(int port)
+__maybe_unused static void disable_transmit_sop_prime(int port)
{
if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP))
cable[port].flags &= ~CABLE_FLAGS_SOP_PRIME_ENABLE;
}
-static void disable_transmit_sop_prime_prime(int port)
+__maybe_unused static void disable_transmit_sop_prime_prime(int port)
{
if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP))
cable[port].flags &= ~CABLE_FLAGS_SOP_PRIME_PRIME_ENABLE;
}
-enum pd_msg_type pd_msg_tx_type(int port, enum pd_data_role data_role,
- uint32_t pd_flags)
+__maybe_unused static uint8_t is_sop_prime_ready(int port)
{
/*
* Ref: USB PD 3.0 sec 2.5.4: When an Explicit Contract is in place the
@@ -173,27 +172,16 @@ enum pd_msg_type pd_msg_tx_type(int port, enum pd_data_role data_role,
* Sec 3.6.11 : Before communicating with a Cable Plug a Port Should
* ensure that it is the Vconn Source
*/
- if (pd_flags & PD_FLAGS_VCONN_ON && (IS_ENABLED(CONFIG_USB_PD_REV30) ||
- data_role == PD_ROLE_DFP)) {
- if (is_transmit_msg_sop_prime(port))
- return PD_MSG_SOP_PRIME;
- if (is_transmit_msg_sop_prime_prime(port))
- return PD_MSG_SOP_PRIME_PRIME;
- }
+ return (pd_get_vconn_state(port) && (IS_ENABLED(CONFIG_USB_PD_REV30)
+ || (pd_get_data_role(port) == PD_ROLE_DFP)));
+}
- if (is_transmit_msg_sop_prime(port)) {
- /*
- * Clear the CABLE_FLAGS_SOP_PRIME_ENABLE flag if the port is
- * unable to communicate with the cable plug.
- */
- disable_transmit_sop_prime(port);
- } else if (is_transmit_msg_sop_prime_prime(port)) {
- /*
- * Clear the CABLE_FLAGS_SOP_PRIME_PRIME_ENABLE flag if the port
- * is unable to communicate with the cable plug.
- */
- disable_transmit_sop_prime_prime(port);
- }
+enum pd_msg_type pd_msg_tx_type(int port)
+{
+ if (is_transmit_msg_sop_prime(port))
+ return PD_MSG_SOP_PRIME;
+ if (is_transmit_msg_sop_prime_prime(port))
+ return PD_MSG_SOP_PRIME_PRIME;
return PD_MSG_SOP;
}
@@ -949,6 +937,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload,
disable_transmit_sop_prime(port);
/* Received a SOP Discover Ident Message */
} else if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP) &&
+ is_sop_prime_ready(port) &&
board_is_tbt_usb4_port(port)) {
pd_dfp_discovery_init(port);
dfp_consume_identity(port, cnt, payload);
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index e3d5503ea6..50a5b33750 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -2147,8 +2147,7 @@ static void pd_vdm_send_state_machine(int port)
{
int res;
uint16_t header;
- enum pd_msg_type msg_type =
- pd_msg_tx_type(port, pd[port].data_role, pd[port].flags);
+ enum pd_msg_type msg_type = pd_msg_tx_type(port);
switch (pd[port].vdm_state) {
case VDM_STATE_READY:
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 2ab0fef72f..96d468839b 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1815,12 +1815,9 @@ bool is_transmit_msg_sop_prime_prime(int port);
* Returns the type of communication (SOP/SOP'/SOP'')
*
* @param port USB-C port number
- * @param data_role current data role
- * @param pd_flags current pd flags
* @return Type of message to be transmitted
*/
-enum pd_msg_type pd_msg_tx_type(int port, enum pd_data_role data_role,
- uint32_t pd_flags);
+enum pd_msg_type pd_msg_tx_type(int port);
/**
* Reset Cable type, Cable attributes and cable flags