diff options
author | Diana Z <dzigterman@chromium.org> | 2022-07-17 21:32:01 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-20 18:37:55 +0000 |
commit | 02697b8e382f34b2b5a1560c67cb5eff4ce86519 (patch) | |
tree | 03435764419e007a211fa637bf92c4fb60a0d2b0 | |
parent | d5c7c721d59e18853a366685462d3a17f68464ce (diff) | |
download | chrome-ec-02697b8e382f34b2b5a1560c67cb5eff4ce86519.tar.gz |
Zephyr: Sub-divide TYPEC_CONTROL Utility
Sub-divide out the TYPEC_CONTROL utility on a per-subcommand basis.
This will ensure we can still type check arguments, while not creating a
massive argument list for a one-size-fits-all utility.
BRANCH=None
BUG=b:234839764
TEST=zmake testall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I85b39da986a88fe30c1928a3d17855858db81ec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3768918
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | zephyr/test/drivers/include/test/drivers/utils.h | 20 | ||||
-rw-r--r-- | zephyr/test/drivers/src/utils.c | 23 | ||||
-rw-r--r-- | zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c | 17 |
3 files changed, 36 insertions, 24 deletions
diff --git a/zephyr/test/drivers/include/test/drivers/utils.h b/zephyr/test/drivers/include/test/drivers/utils.h index 24927e2bf0..3754979a14 100644 --- a/zephyr/test/drivers/include/test/drivers/utils.h +++ b/zephyr/test/drivers/include/test/drivers/utils.h @@ -369,17 +369,21 @@ void host_cmd_usb_pd_get_amode( int *response_size); /** - * Run the host command to control PD port behavior. For now, this function only - * supports entering and exiting modes. + * Run the host command to control PD port behavior, with the sub-command of + * TYPEC_CONTROL_COMMAND_ENTER_MODE + * + * @param port The USB-C port number + * @param mode Mode to enter + */ +void host_cmd_typec_control_enter_mode(int port, enum typec_mode mode); + +/** + * Run the host command to control PD port behavior, with the sub-command of + * TYPEC_CONTROL_COMMAND_EXIT_MODES * * @param port The USB-C port number - * @param command Sub-command to perform on the port - * @param mode The mode to enter if command is - * TYPEC_CONTROL_COMMAND_ENTER_MODE. - * @param response_size Number of bytes in response */ -void host_cmd_typec_control(int port, enum typec_control_command command, - enum typec_mode mode); +void host_cmd_typec_control_exit_modes(int port); #define GPIO_ACOK_OD_NODE DT_NODELABEL(gpio_acok_od) #define GPIO_ACOK_OD_PIN DT_GPIO_PIN(GPIO_ACOK_OD_NODE, gpios) diff --git a/zephyr/test/drivers/src/utils.c b/zephyr/test/drivers/src/utils.c index 8375bf1d77..c88a4cde56 100644 --- a/zephyr/test/drivers/src/utils.c +++ b/zephyr/test/drivers/src/utils.c @@ -372,12 +372,25 @@ void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type, "Failed to get Type-C state for port %d", port); } -void host_cmd_typec_control(int port, enum typec_control_command command, - enum typec_mode mode) +void host_cmd_typec_control_enter_mode(int port, enum typec_mode mode) { - struct ec_params_typec_control params = { .port = port, - .command = command, - .mode_to_enter = mode }; + struct ec_params_typec_control params = { + .port = port, + .command = TYPEC_CONTROL_COMMAND_ENTER_MODE, + .mode_to_enter = mode + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassume_ok(host_command_process(&args), + "Failed to send Type-C control for port %d", port); +} + +void host_cmd_typec_control_exit_modes(int port) +{ + struct ec_params_typec_control params = { + .port = port, .command = TYPEC_CONTROL_COMMAND_EXIT_MODES + }; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c index 4e9911ea5b..ff2a372a7f 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c @@ -243,8 +243,7 @@ ZTEST_F(usbc_alt_mode, verify_displayport_mode_entry) /* TODO(b/237553647): Test EC-driven mode entry (requires a separate * config). */ - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_ENTER_MODE, - TYPEC_MODE_DP); + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); k_sleep(K_SECONDS(1)); /* Verify host command when VDOs are present. */ @@ -266,20 +265,18 @@ ZTEST_F(usbc_alt_mode, verify_displayport_mode_entry) ZTEST_F(usbc_alt_mode, verify_displayport_mode_reentry) { - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_ENTER_MODE, - TYPEC_MODE_DP); + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); k_sleep(K_SECONDS(1)); /* DPM configures the partner on DP mode entry */ /* Verify port partner thinks its configured for DisplayPort */ zassert_true(fixture->partner.displayport_configured, NULL); - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_EXIT_MODES, 0); + host_cmd_typec_control_exit_modes(TEST_PORT); k_sleep(K_SECONDS(1)); zassert_false(fixture->partner.displayport_configured, NULL); - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_ENTER_MODE, - TYPEC_MODE_DP); + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); k_sleep(K_SECONDS(1)); zassert_true(fixture->partner.displayport_configured, NULL); @@ -305,8 +302,7 @@ ZTEST_SUITE(usbc_alt_mode, drivers_predicate_post_main, usbc_alt_mode_setup, */ ZTEST_F(usbc_alt_mode_dp_unsupported, verify_discovery) { - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_ENTER_MODE, - TYPEC_MODE_DP); + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); k_sleep(K_SECONDS(1)); uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE]; @@ -344,8 +340,7 @@ ZTEST_F(usbc_alt_mode_dp_unsupported, verify_discovery) */ ZTEST_F(usbc_alt_mode_dp_unsupported, verify_displayport_mode_nonentry) { - host_cmd_typec_control(TEST_PORT, TYPEC_CONTROL_COMMAND_ENTER_MODE, - TYPEC_MODE_DP); + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); k_sleep(K_SECONDS(1)); zassert_false(fixture->partner.displayport_configured, NULL); |