diff options
author | Tomasz Michalec <tm@semihalf.com> | 2022-01-05 19:08:55 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-14 23:07:39 +0000 |
commit | ade78132bcaac0c6b1e6eaf3689231e9f5b99ae9 (patch) | |
tree | 94b8b96f1e45a12cea85e5a9d4258141e69ec474 | |
parent | 0c279f0c9e64b4d90c8eb3079d2d6ab8e18dfa94 (diff) | |
download | chrome-ec-ade78132bcaac0c6b1e6eaf3689231e9f5b99ae9.tar.gz |
zephyr: drivers: Add DRP plug test
Add test of plugging dual role device. It is plugged as sink, but TCPM
should try power swap and switch DRP device to power source.
BUG=none
BRANCH=none
TEST=make configure --test zephyr/test/drivers
Signed-off-by: Tomasz Michalec <tm@semihalf.com>
Change-Id: I17880f266d8359fb223559327e40237ed5cb6ce0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3368265
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Tomasz Michalec <tmichalec@google.com>
Commit-Queue: Tomasz Michalec <tmichalec@google.com>
-rw-r--r-- | zephyr/test/drivers/prj.conf | 3 | ||||
-rw-r--r-- | zephyr/test/drivers/src/integration_usb.c | 35 |
2 files changed, 36 insertions, 2 deletions
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index a4cc8beead..ad6b72f554 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -41,8 +41,7 @@ CONFIG_EMUL_BMI=y CONFIG_EMUL_TCS3400=y CONFIG_EMUL_BB_RETIMER=y CONFIG_EMUL_PS8XXX=y -CONFIG_EMUL_TCPCI_PARTNER_SRC=y -CONFIG_EMUL_TCPCI_PARTNER_SNK=y +CONFIG_EMUL_TCPCI_PARTNER_DRP=y CONFIG_PLATFORM_EC_CHARGE_MANAGER=y CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y diff --git a/zephyr/test/drivers/src/integration_usb.c b/zephyr/test/drivers/src/integration_usb.c index cbf084a2ab..92dd6b82d6 100644 --- a/zephyr/test/drivers/src/integration_usb.c +++ b/zephyr/test/drivers/src/integration_usb.c @@ -12,6 +12,7 @@ #include "ec_tasks.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_drp.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" @@ -213,6 +214,37 @@ static void test_attach_sink(void) zassert_equal(PE_SRC_READY, get_state_pe(USBC_PORT_C0), NULL); } +static void test_attach_drp(void) +{ + const struct emul *tcpci_emul = + emul_get_binding(DT_LABEL(TCPCI_EMUL_LABEL)); + struct tcpci_drp_emul my_drp; + + /* 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_drp_emul_init(&my_drp); + zassert_ok(tcpci_drp_emul_connect_to_tcpci(&my_drp.data, + &my_drp.src_data, + &my_drp.snk_data, + &my_drp.common_data, + &my_drp.ops, 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_SNK_READY, get_state_pe(USBC_PORT_C0), NULL); +} + void test_suite_integration_usb(void) { ztest_test_suite(integration_usb, @@ -224,6 +256,9 @@ void test_suite_integration_usb(void) remove_emulated_devices), ztest_user_unit_test_setup_teardown( test_attach_sink, init_tcpm, + remove_emulated_devices), + ztest_user_unit_test_setup_teardown( + test_attach_drp, init_tcpm, remove_emulated_devices)); ztest_run_test_suite(integration_usb); } |