summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-07-19 14:05:00 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-20 20:01:13 +0000
commitb210e6e41577b491cedfe108e215b8361a108f0b (patch)
tree02924bc7470eef519c37a198eac4ac3541871bf5
parent1a14800b0f4375eec81aaf72c1812248e02e40cc (diff)
downloadchrome-ec-b210e6e41577b491cedfe108e215b8361a108f0b.tar.gz
Zephyr: Add utilities for mux set and event clear
Add utilities to allow tests to clear port events and set muxes using the TYPEC_CONTROL host command. BRANCH=None BUG=b:234839764 TEST=zmake testall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I28af3cbff7b045f41b7af4b282cdae1f03811524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3774147 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--zephyr/test/drivers/include/test/drivers/utils.h20
-rw-r--r--zephyr/test/drivers/src/utils.c29
2 files changed, 49 insertions, 0 deletions
diff --git a/zephyr/test/drivers/include/test/drivers/utils.h b/zephyr/test/drivers/include/test/drivers/utils.h
index 3754979a14..b7fd6ebb86 100644
--- a/zephyr/test/drivers/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/include/test/drivers/utils.h
@@ -385,6 +385,26 @@ void host_cmd_typec_control_enter_mode(int port, enum typec_mode mode);
*/
void host_cmd_typec_control_exit_modes(int port);
+/**
+ * Run the host command to control PD port behavior, with the sub-command of
+ * TYPEC_CONTROL_COMMAND_USB_MUX_SET
+ *
+ * @param port The USB-C port number
+ * @param mux_set Mode and mux index to set
+ */
+void host_cmd_typec_control_usb_mux_set(int port,
+ struct typec_usb_mux_set mux_set);
+
+/**
+ * Run the host command to control PD port behavior, with the sub-command of
+ * TYPEC_CONTROL_COMMAND_CLEAR_EVENTS
+ *
+ * @param port The USB-C port number
+ * @param events Events to clear for the port (see PD_STATUS_EVENT_*
+ * definitions for options)
+ */
+void host_cmd_typec_control_clear_events(int port, uint32_t events);
+
#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 c88a4cde56..ba27eb7095 100644
--- a/zephyr/test/drivers/src/utils.c
+++ b/zephyr/test/drivers/src/utils.c
@@ -398,6 +398,35 @@ void host_cmd_typec_control_exit_modes(int port)
"Failed to send Type-C control for port %d", port);
}
+void host_cmd_typec_control_usb_mux_set(int port,
+ struct typec_usb_mux_set mux_set)
+{
+ struct ec_params_typec_control params = {
+ .port = port,
+ .command = TYPEC_CONTROL_COMMAND_USB_MUX_SET,
+ .mux_params = mux_set,
+ };
+ 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_clear_events(int port, uint32_t events)
+{
+ struct ec_params_typec_control params = {
+ .port = port,
+ .command = TYPEC_CONTROL_COMMAND_CLEAR_EVENTS,
+ .clear_events_mask = events,
+ };
+ 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_usb_pd_get_amode(
uint8_t port, uint16_t svid_idx,
struct ec_params_usb_pd_get_mode_response *response, int *response_size)