From ffa5765555b6d684cd465db15081545cf41e2265 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Wed, 12 Oct 2022 11:39:11 -0600 Subject: zephyr test: VCONN Swap off via host command With the TCPM as VCONN Source, use EC_CMD_USB_PD_CONTROL to initiate a VCONN Swap. Verify that the TCPM is not VCONN Source afterward. BUG=b:251485312 TEST=twister -s zephyr/test/drivers/drivers.usbc_vconn_swap BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ifa5bc067270f0744d74b0f7004b8820ba4f8b778 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949613 Reviewed-by: Jack Rosenthal Code-Coverage: Zoss Commit-Queue: Jack Rosenthal --- .../test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 70d13bdada..c7f20e5387 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 @@ -134,5 +134,21 @@ ZTEST_F(usbc_vconn_swap, vconn_swap_before_discovery) "TCPM did not initiate VCONN Swap after attach"); } +ZTEST_F(usbc_vconn_swap, vconn_swap_via_host_command) +{ + struct ec_response_typec_status status = + host_cmd_typec_status(TEST_PORT); + + zassume_equal(status.vconn_role, PD_ROLE_VCONN_SRC, + "TCPM did not initiate VCONN Swap after attach"); + + host_cmd_usb_pd_control(TEST_PORT, USB_PD_CTRL_SWAP_VCONN); + k_sleep(K_SECONDS(1)); + + status = host_cmd_typec_status(TEST_PORT); + zassert_equal(status.vconn_role, PD_ROLE_VCONN_OFF, + "TCPM did not initiate VCONN Swap after host command"); +} + ZTEST_SUITE(usbc_vconn_swap, drivers_predicate_post_main, usbc_vconn_swap_setup, usbc_vconn_swap_before, usbc_vconn_swap_after, NULL); -- cgit v1.2.1