diff options
author | Tomasz Michalec <tm@semihalf.com> | 2021-12-17 10:20:35 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-14 23:06:41 +0000 |
commit | d51254bcfeedeae83dd59170af31436e9f0c5126 (patch) | |
tree | b50bc9b15012a8d2c2e6cc88d48b847da97bb7a2 /zephyr | |
parent | e5e5f8843baeac7e5aec82d3fba7d2739f669f11 (diff) | |
download | chrome-ec-d51254bcfeedeae83dd59170af31436e9f0c5126.tar.gz |
zephyr: drivers: Add sink plug test
Add simple test of plugging sink device to USB-C port. It is tested if
TCPM reach SNK ready state.
BUG=b:209907609
BRANCH=none
TEST=make configure --test zephyr/test/drivers
Signed-off-by: Tomasz Michalec <tm@semihalf.com>
Change-Id: I6686e3adf704437d9fcce6e372d6f637f9ecb266
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3347663
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Tomasz Michalec <tmichalec@google.com>
Commit-Queue: Tomasz Michalec <tmichalec@google.com>
Diffstat (limited to 'zephyr')
-rw-r--r-- | zephyr/test/drivers/src/integration_usb.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/integration_usb.c b/zephyr/test/drivers/src/integration_usb.c index affd9fe011..72dddbb686 100644 --- a/zephyr/test/drivers/src/integration_usb.c +++ b/zephyr/test/drivers/src/integration_usb.c @@ -12,9 +12,13 @@ #include "ec_tasks.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" +#include "stubs.h" #include "tcpm/tcpci.h" +#include "test/usb_pe.h" +#include "utils.h" #define TCPCI_EMUL_LABEL DT_NODELABEL(tcpci_emul) #define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery)) @@ -174,6 +178,33 @@ static void test_attach_pd_charger(void) */ } +static void test_attach_sink(void) +{ + const struct emul *tcpci_emul = + emul_get_binding(DT_LABEL(TCPCI_EMUL_LABEL)); + struct tcpci_snk_emul_data my_sink; + + /* Set chipset to ON, this will set TCPM to DRP */ + test_set_chipset_to_s0(); + + /* TODO(b/214401892): Check why need to give time TCPM to spin */ + k_sleep(K_SECONDS(1)); + + /* Attach emulated sink */ + tcpci_snk_emul_init(&my_sink); + zassert_ok(tcpci_snk_emul_connect_to_tcpci(&my_sink, tcpci_emul), + NULL); + + /* Wait for PD negotiation */ + k_sleep(K_SECONDS(10)); + + /* + * Test that SRC ready is achieved + * TODO: Change it to examining EC_CMD_TYPEC_STATUS + */ + zassert_equal(PE_SRC_READY, get_state_pe(USBC_PORT_C0), NULL); +} + void test_suite_integration_usb(void) { ztest_test_suite(integration_usb, @@ -182,6 +213,9 @@ void test_suite_integration_usb(void) remove_emulated_devices), ztest_user_unit_test_setup_teardown( test_attach_pd_charger, init_tcpm, + remove_emulated_devices), + ztest_user_unit_test_setup_teardown( + test_attach_sink, init_tcpm, remove_emulated_devices)); ztest_run_test_suite(integration_usb); } |