Skip to content

Commit c407ea0

Browse files
Abe LevkoyCommit Bot
authored andcommitted
zephyr test: Support EC_CMD_TYPEC_DISCOVERY
Add a utility function to wrap the Type-C Discovery host command. BUG=b:219556831 TEST=zmake testall BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I1737eadd58febfc7a4bd0a15098840ace510df08 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3502649 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
1 parent cc910bb commit c407ea0

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

zephyr/test/drivers/include/utils.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <drivers/emul.h>
1010
#include <drivers/gpio/gpio_emul.h>
11+
#include <string.h>
1112

1213
#include "charger.h"
1314
#include "emul/tcpc/emul_tcpci_partner_src.h"
@@ -208,6 +209,7 @@ host_cmd_get_charge_control(void)
208209

209210
zassume_ok(host_command_process(&args),
210211
"Failed to get charge control values");
212+
211213
return response;
212214
}
213215

@@ -224,6 +226,19 @@ host_cmd_get_charge_control(void)
224226
void host_cmd_motion_sense_dump(int max_sensor_count,
225227
struct ec_response_motion_sense *response);
226228

229+
/**
230+
* Run the host command to get the PD discovery responses.
231+
*
232+
* @param port The USB-C port number
233+
* @param partner_type SOP, SOP', or SOP''
234+
* @param response Destination buffer for command response;
235+
* should hold struct ec_response_typec_discovery and
236+
* enough struct svid_mode_info for expected response.
237+
* @param response_size Number of bytes in response
238+
*/
239+
void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type,
240+
void *response, size_t response_size);
241+
227242
#define GPIO_ACOK_OD_NODE DT_NODELABEL(gpio_acok_od)
228243
#define GPIO_ACOK_OD_PIN DT_GPIO_PIN(GPIO_ACOK_OD_NODE, gpios)
229244

zephyr/test/drivers/src/utils.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,21 @@ void host_cmd_motion_sense_dump(int max_sensor_count,
111111
zassume_ok(host_command_process(&args),
112112
"Failed to get motion_sense dump");
113113
}
114+
115+
void host_cmd_typec_discovery(int port, enum typec_partner_type partner_type,
116+
void *response, size_t response_size)
117+
{
118+
struct ec_params_typec_discovery params = {
119+
.port = port, .partner_type = partner_type
120+
};
121+
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
122+
EC_CMD_TYPEC_DISCOVERY, 0, params);
123+
/* The expected response to EC_CMD_TYPEC_DISCOVERY extends beyond the
124+
* bounds of struct ec_response_typec_discovery.
125+
*/
126+
args.response = response;
127+
args.response_max = response_size;
128+
129+
zassume_ok(host_command_process(&args),
130+
"Failed to get Type-C state for port %d", port);
131+
}

0 commit comments

Comments
 (0)