summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-10-12 17:02:22 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-14 01:07:07 +0000
commit87b811257a46409020535545ab7913f9c4189298 (patch)
tree4ca1b67afdff87be43d08681cd596d193d533aa7
parent7b218cd2968de6158e7a5dc0fd2bf85228631ba5 (diff)
downloadchrome-ec-87b811257a46409020535545ab7913f9c4189298.tar.gz
zephyr test: Exercise force-VCONN flow
Set up the partner emulator (and create the associated suite boilerplate) to not support VCONN. Verify that the TCPM will unilaterally enable VCONN in this scenario. BUG=b:251485312 TEST=twister -s zephyr/test/drivers/drivers.usbc_vconn_swap BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Id6b6aa76a1f8e171cd74e6e6c36a44c60c531687 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949579 Reviewed-by: Aaron Massey <aaronmassey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
index c7f20e5387..324df08826 100644
--- a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
+++ b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
@@ -37,6 +37,10 @@ struct usbc_vconn_swap_fixture {
struct common_fixture common;
};
+struct usbc_vconn_swap_not_supported_fixture {
+ struct common_fixture common;
+};
+
static void connect_partner_to_port(const struct emul *tcpc_emul,
const struct emul *charger_emul,
struct tcpci_partner_data *partner_emul,
@@ -92,6 +96,15 @@ static void *usbc_vconn_swap_setup(void)
return common_setup();
}
+static void *usbc_vconn_swap_not_supported_setup(void)
+{
+ struct usbc_vconn_swap_fixture *fixture = common_setup();
+
+ /* The partner will respond to VCONN_Swap with Not_Supported. */
+ tcpci_partner_set_vconn_support(&fixture->common.partner, false);
+ return fixture;
+}
+
static void common_before(struct common_fixture *fixture)
{
/* Set chipset to ON, this will set TCPM to DRP */
@@ -112,6 +125,13 @@ static void usbc_vconn_swap_before(void *data)
common_before(&outer->common);
}
+static void usbc_vconn_swap_not_supported_before(void *data)
+{
+ struct usbc_vconn_swap_not_supported_fixture *outer = data;
+
+ common_before(&outer->common);
+}
+
static void common_after(struct common_fixture *fixture)
{
disconnect_partner_from_port(fixture->tcpci_emul,
@@ -125,6 +145,13 @@ static void usbc_vconn_swap_after(void *data)
common_after(&outer->common);
}
+static void usbc_vconn_swap_not_supported_after(void *data)
+{
+ struct usbc_vconn_swap_not_supported_fixture *outer = data;
+
+ common_after(&outer->common);
+}
+
ZTEST_F(usbc_vconn_swap, vconn_swap_before_discovery)
{
struct ec_response_typec_status status =
@@ -152,3 +179,17 @@ ZTEST_F(usbc_vconn_swap, vconn_swap_via_host_command)
ZTEST_SUITE(usbc_vconn_swap, drivers_predicate_post_main, usbc_vconn_swap_setup,
usbc_vconn_swap_before, usbc_vconn_swap_after, NULL);
+
+ZTEST_F(usbc_vconn_swap_not_supported, vconn_swap_force_vconn)
+{
+ struct ec_response_typec_status status =
+ host_cmd_typec_status(TEST_PORT);
+
+ zassert_equal(status.vconn_role, PD_ROLE_VCONN_SRC,
+ "TCPM did not initiate VCONN Swap after attach");
+}
+
+ZTEST_SUITE(usbc_vconn_swap_not_supported, drivers_predicate_post_main,
+ usbc_vconn_swap_not_supported_setup,
+ usbc_vconn_swap_not_supported_before,
+ usbc_vconn_swap_not_supported_after, NULL);