summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbc/usb_mode.c4
-rw-r--r--zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c38
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