summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/test/drivers/include/test/drivers/utils.h14
-rw-r--r--zephyr/test/drivers/src/utils.c13
2 files changed, 27 insertions, 0 deletions
diff --git a/zephyr/test/drivers/include/test/drivers/utils.h b/zephyr/test/drivers/include/test/drivers/utils.h
index c3fe4db868..d934144a67 100644
--- a/zephyr/test/drivers/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/include/test/drivers/utils.h
@@ -8,6 +8,7 @@
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <stddef.h>
#include <string.h>
#include "charger.h"
@@ -451,6 +452,19 @@ int host_cmd_motion_sense_spoof(uint8_t sensor_num, uint8_t enable,
void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type,
void *response, size_t response_size);
+/**
+ * Run the host command to control PD port behavior. For now, this function only
+ * supports entering and exiting 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);
+
#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 b46f87f83c..e7c4e2d145 100644
--- a/zephyr/test/drivers/src/utils.c
+++ b/zephyr/test/drivers/src/utils.c
@@ -367,6 +367,19 @@ 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)
+{
+ struct ec_params_typec_control params = { .port = port,
+ .command = command,
+ .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);
+}
+
K_HEAP_DEFINE(test_heap, 2048);
void *test_malloc(size_t bytes)