diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2023-05-15 12:46:52 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-05-16 21:19:52 +0000 |
commit | cfc740514c3de776534d22673ebf05fe8c906c5b (patch) | |
tree | 24c8b87eb98d51c9621899d5695de600b9941bff | |
parent | 32a3d94e879efebef135062342fdbd9dae8ec463 (diff) | |
download | chrome-ec-cfc740514c3de776534d22673ebf05fe8c906c5b.tar.gz |
TCPMv2: Do not attempt Enter_USB under PD 2.0
If the port partner is not PD 3.0 or higher, do not consider it to
support USB4/Enter_USB. If the AP requests USB4 entry, disregard the
request and consider mode entry complete. Avoid repeatedly sending
Enter_USB to a PD 2.0 partner.
BUG=b:279421317
TEST=twister -s drivers/drivers.usbc_usb4_mode
Change-Id: I3e82738f816e6dd5af24d627b6cd971a34d74586
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4533369
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Tested-by: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Jameson Thies <jthies@google.com>
-rw-r--r-- | common/usbc/usb_mode.c | 4 | ||||
-rw-r--r-- | zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c | 38 |
2 files changed, 42 insertions, 0 deletions
diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c index 017f89fc74..157c1b1f04 100644 --- a/common/usbc/usb_mode.c +++ b/common/usbc/usb_mode.c @@ -20,6 +20,7 @@ #include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" #include "usb_pe_sm.h" +#include "usb_prl_sm.h" #include "usb_tbt_alt_mode.h" #include "usbc_ppc.h" @@ -169,6 +170,9 @@ bool enter_usb_port_partner_is_capable(int port) if (usb4_state[port] == USB4_INACTIVE) return false; + if (prl_get_rev(port, TCPCI_MSG_SOP) < PD_REV30) + return false; + if (!PD_PRODUCT_IS_USB4(disc->identity.product_t1.raw_value)) return false; diff --git a/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c index 4c21aaeac4..25fcff61e1 100644 --- a/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c +++ b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c @@ -259,6 +259,44 @@ ZTEST_F(usbc_usb4_mode, test_verify_usb4_passive_entry_exit) USB_PD_MUX_USB_ENABLED, "Failed to see USB set"); } +/* If the partner claims to support USB4, but communication is only PD 2.0, the + * EC should disregard a request to enter USB4 from the host. + */ +ZTEST_F(usbc_usb4_mode, test_verify_usb4_pd2_no_entry) +{ + struct ec_response_typec_status status; + + tcpci_partner_init(&fixture->partner, PD_REV20); + fixture->partner.cable = &passive_usb4; + connect_sink_to_port(&fixture->partner, fixture->tcpci_emul, + fixture->charger_emul); + + /* Instruct partner port to accept Enter_USB message */ + fixture->partner.enter_usb_accept = true; + + /* Verify that we properly identify a USB4 capable passive cable */ + verify_cable_found(fixture->partner.cable); + + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x", + status.mux_state); + + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_USB4); + k_sleep(K_SECONDS(1)); + + /* PD 2.0 doesn't include Enter_USB, so it's not possible to enter USB4 + * mode. A Discover Identity ACK indicating support for USB4 isn't even + * valid under PD 2.0. If the host nevertheless commands the EC to enter + * USB4, the EC should not attempt to do so. + */ + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Failed to see USB still set"); + zassert_not_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB4_ENABLED, "Unexpected USB4 mode set"); +} + /* * TODO(b/260095516): This test suite is only testing the default good case, and * one error case where the cable doesn't support USB4. This suite needs to be |