diff options
author | Randall Spangler <rspangler@chromium.org> | 2014-07-14 11:28:44 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-14 23:06:43 +0000 |
commit | 32e4f212b13ad38a6e72d6149b6714c48606afd7 (patch) | |
tree | 0a545eb9b9479dc1294c3e73872ea630982a6758 | |
parent | 423c40c5a0c2b97df287e751a8ebfd326f2e6723 (diff) | |
download | chrome-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>
-rw-r--r-- | common/host_command.c | 34 | ||||
-rw-r--r-- | include/ec_commands.h | 29 |
2 files changed, 55 insertions, 8 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); diff --git a/include/ec_commands.h b/include/ec_commands.h index d867c31dc1..7233d43bd3 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -500,7 +500,7 @@ struct ec_host_response { /* * Notes on commands: * - * Each command is an 8-byte command value. Commands which take params or + * Each command is an 16-bit command value. Commands which take params or * return response data specify structs for that data. If no struct is * specified, the command does not input or output data, respectively. * Parameter/response length is implicit in the structs. Some underlying @@ -2502,6 +2502,33 @@ struct ec_response_pd_status { /*****************************************************************************/ /* + * Passthru commands + * + * Some platforms have sub-processors chained to each other. For example. + * + * AP <--> EC <--> PD MCU + * + * The top 2 bits of the command number are used to indicate which device the + * command is intended for. Device 0 is always the device receiving the + * command; other device mapping is board-specific. + * + * When a device receives a command to be passed to a sub-processor, it passes + * it on with the device number set back to 0. This allows the sub-processor + * to remain blissfully unaware of whether the command originated on the next + * device up the chain, or was passed through from the AP. + * + * In the above example, if the AP wants to send command 0x0002 to the PD MCU, + * AP sends command 0x4002 to the EC + * EC sends command 0x0002 to the PD MCU + * EC forwards PD MCU response back to the AP + */ + +/* Offset and max command number for sub-device n */ +#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n)) +#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff) + +/*****************************************************************************/ +/* * Deprecated constants. These constants have been renamed for clarity. The * meaning and size has not changed. Programs that use the old names should * switch to the new names soon, as the old names may not be carried forward |