summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-06-24 13:44:19 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-29 19:43:38 +0000
commit1641c8a4ae88e5fb5e9213f20f16f8a71dca82e0 (patch)
tree3994960e896023ce7723133be28bfe90b6914f10 /zephyr
parentee550514d7d113191d0f3848772fd94d0d2ec0c0 (diff)
downloadchrome-ec-1641c8a4ae88e5fb5e9213f20f16f8a71dca82e0.tar.gz
zephyr: test: Wrap TYPEC_CONTROL in util function
Define host_cmd_typec_control to make it easier to use HOST_CMD_TYPEC_CONTROL in tests. For the time being, only support sub-commands that don't require extra arguments or that require a mode SVID (enter mode). BUG=b:235984702 TEST=zmake testall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I7eb91f0b7fa8ba6414263efe1d578b52420b2185 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3724159 Reviewed-by: Aaron Massey <aaronmassey@google.com>
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)