diff options
author | Keith Short <keithshort@chromium.org> | 2020-04-27 15:40:39 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-28 22:35:36 +0000 |
commit | 0ec4d5f9a9c200c64ce8f1e5a4a43af006e5f73e (patch) | |
tree | 1655e851a3a7df67b7b2d3d8b7b6da3294bae593 /common/usb_pd_policy.c | |
parent | bff373fdcdcfb67e52e8d9ef9223f2474adcb9f3 (diff) | |
download | chrome-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>
Diffstat (limited to 'common/usb_pd_policy.c')
-rw-r--r-- | common/usb_pd_policy.c | 37 |
1 files changed, 13 insertions, 24 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); |