summaryrefslogtreecommitdiff
path: root/common/host_command.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-07-14 11:28:44 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-14 23:06:43 +0000
commit32e4f212b13ad38a6e72d6149b6714c48606afd7 (patch)
tree0a545eb9b9479dc1294c3e73872ea630982a6758 /common/host_command.c
parent423c40c5a0c2b97df287e751a8ebfd326f2e6723 (diff)
downloadchrome-ec-32e4f212b13ad38a6e72d6149b6714c48606afd7.tar.gz
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 <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207821 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/host_command.c')
-rw-r--r--common/host_command.c34
1 files changed, 27 insertions, 7 deletions
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);