From 32e4f212b13ad38a6e72d6149b6714c48606afd7 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Mon, 14 Jul 2014 11:28:44 -0700 Subject: samus: Add passthru for host commands Host commands in the range 0x4000-0x7fff will be passed thru the EC to the PD MCU as 0x0000-0x3fff. BUG=chrome-os-partner:30079 BRANCH=samus TEST=manual. On PD console: hcdebug params On EC console: hostcmd 2 0 -> hex string of EC version hostcmd 0x4002 0 -> hex string of PD version, and PD console shows host command 2 was received. The hex response shown on the PD console matches the one printed by the EC Change-Id: Icc2d97c5977145a0c3ad2630d2b5a19e876a36d0 Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/207821 Reviewed-by: Bill Richardson --- common/host_command.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'common/host_command.c') diff --git a/common/host_command.c b/common/host_command.c index 9f72fe7f43..22374059c6 100644 --- a/common/host_command.c +++ b/common/host_command.c @@ -530,18 +530,38 @@ static void host_command_debug_request(struct host_cmd_handler_args *args) enum ec_status host_command_process(struct host_cmd_handler_args *args) { - const struct host_command *cmd = find_host_command(args->command); + const struct host_command *cmd; enum ec_status rv; if (hcdebug) host_command_debug_request(args); - if (!cmd) - rv = EC_RES_INVALID_COMMAND; - else if (!(EC_VER_MASK(args->version) & cmd->version_mask)) - rv = EC_RES_INVALID_VERSION; - else - rv = cmd->handler(args); +#ifdef HAS_TASK_PDCMD + if (args->command >= EC_CMD_PASSTHRU_OFFSET(1) && + args->command <= EC_CMD_PASSTHRU_MAX(1)) { + rv = pd_host_command(args->command - EC_CMD_PASSTHRU_OFFSET(1), + args->version, + args->params, args->params_size, + args->response, args->response_max); + if (rv >= 0) { + /* Success; store actual response size */ + args->response_size = rv; + rv = EC_SUCCESS; + } else { + /* Failure, returned as negative error code */ + rv = -rv; + } + } else +#endif + { + cmd = find_host_command(args->command); + if (!cmd) + rv = EC_RES_INVALID_COMMAND; + else if (!(EC_VER_MASK(args->version) & cmd->version_mask)) + rv = EC_RES_INVALID_VERSION; + else + rv = cmd->handler(args); + } if (rv != EC_RES_SUCCESS) CPRINTS("HC err %d", rv); -- cgit v1.2.1