From 91a43998df92320610d7399433e221f493169410 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 10 Jan 2022 15:12:46 -0700 Subject: zephyr test: Check EC_CMD_TYPEC_STATUS results After attaching emulated PD charger, using EC_CMD_TYPEC_STATUS to verify USB default charging state. BUG=b:209907297 TEST=zmake configure --test zephyr/test/drivers BRANCH=none Cq-Depend: chromium:3368262 Change-Id: Iaa414a8b459b453ffde64f303f584eeaba7e6871 Signed-off-by: Abe Levkoy Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3379467 Reviewed-by: Yuval Peress --- zephyr/test/drivers/src/integration_usb.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zephyr/test/drivers/src/integration_usb.c b/zephyr/test/drivers/src/integration_usb.c index 2b512525f9..48d8c87726 100644 --- a/zephyr/test/drivers/src/integration_usb.c +++ b/zephyr/test/drivers/src/integration_usb.c @@ -113,6 +113,10 @@ static void test_attach_pd_charger(void) struct ec_response_charge_state charge_response; struct host_cmd_handler_args args = BUILD_HOST_COMMAND( EC_CMD_CHARGE_STATE, 0, charge_response, charge_params); + struct ec_params_typec_status typec_params; + struct ec_response_typec_status typec_response; + struct host_cmd_handler_args typec_args = BUILD_HOST_COMMAND( + EC_CMD_TYPEC_STATUS, 0, typec_response, typec_params); /* * TODO(b/209907297): Implement the steps of the test beyond USB default @@ -167,6 +171,22 @@ static void test_attach_pd_charger(void) "USB default current %dmA", charge_response.get_state.chg_current); + typec_params.port = 0; + zassert_ok(host_command_process(&typec_args), + "Failed to get Type-C state"); + zassert_true(typec_response.pd_enabled, + "Charger attached but PD disabled"); + zassert_true(typec_response.dev_connected, + "Charger attached but device disconnected"); + zassert_true(typec_response.sop_connected, + "Charger attached but not SOP capable"); + zassert_equal(typec_response.source_cap_count, 1, + "Charger has %d source PDOs", + typec_response.source_cap_count); + zassert_equal(typec_response.power_role, PD_ROLE_SINK, + "Charger attached, but TCPM power role is %d", + typec_response.power_role); + /* * 3. Wait for SenderResponseTimeout. Expect TCPM to send Request. * We could verify that the Request references the expected PDO, but -- cgit v1.2.1