summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-12-25 17:18:23 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-06 02:33:04 +0000
commitc3adc315b3ba724bccafe7c97e2c1b8ab6120cf9 (patch)
tree1a7735730e1cc248fea742daef48c061e78c8652
parent6fec4e4a69729cc715ceddaf9e8c6fad4ddacc80 (diff)
downloadchrome-ec-c3adc315b3ba724bccafe7c97e2c1b8ab6120cf9.tar.gz
Support command versioning of new host command range
We've extended host command range from 8-bit to 16-bit. Extend EC_CMD_GET_CMD_VERSIONS so that the host may query supported command versions of the new host commands. BRANCH=All BUG=chrome-os-partner:26577 TEST=Extend 'usbpd' to version 1. Test that we can check its version. TEST=Run 'ectool gpioget' with new ectool and old EC. TEST=Run 'ectool gpioget' with old ectool and new EC. Change-Id: I1651aaf21ac2604aea101244b5e53713ead8c1af Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/237622 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/host_command.c7
-rw-r--r--include/ec_commands.h4
-rw-r--r--util/misc_util.c11
3 files changed, 18 insertions, 4 deletions
diff --git a/common/host_command.c b/common/host_command.c
index a036c184e6..51d1a9cf97 100644
--- a/common/host_command.c
+++ b/common/host_command.c
@@ -505,9 +505,12 @@ DECLARE_HOST_COMMAND(EC_CMD_READ_MEMMAP,
static int host_command_get_cmd_versions(struct host_cmd_handler_args *args)
{
const struct ec_params_get_cmd_versions *p = args->params;
+ const struct ec_params_get_cmd_versions_v1 *p_v1 = args->params;
struct ec_response_get_cmd_versions *r = args->response;
- const struct host_command *cmd = find_host_command(p->cmd);
+ const struct host_command *cmd =
+ (args->version == 1) ? find_host_command(p_v1->cmd) :
+ find_host_command(p->cmd);
if (!cmd)
return EC_RES_INVALID_PARAM;
@@ -520,7 +523,7 @@ static int host_command_get_cmd_versions(struct host_cmd_handler_args *args)
}
DECLARE_HOST_COMMAND(EC_CMD_GET_CMD_VERSIONS,
host_command_get_cmd_versions,
- EC_VER_MASK(0));
+ EC_VER_MASK(0) | EC_VER_MASK(1));
/**
* Print debug output for the host command request, before it's processed.
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 0a6858e2f2..c06e3464a0 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -617,6 +617,10 @@ struct ec_params_get_cmd_versions {
uint8_t cmd; /* Command to check */
} __packed;
+struct ec_params_get_cmd_versions_v1 {
+ uint16_t cmd; /* Command to check */
+} __packed;
+
struct ec_response_get_cmd_versions {
/*
* Mask of supported versions; use EC_VER_MASK() to compare with a
diff --git a/util/misc_util.c b/util/misc_util.c
index 005c84e50c..9699ac4a61 100644
--- a/util/misc_util.c
+++ b/util/misc_util.c
@@ -93,16 +93,23 @@ int is_string_printable(const char *buf)
*/
int ec_get_cmd_versions(int cmd, uint32_t *pmask)
{
+ struct ec_params_get_cmd_versions_v1 pver_v1;
struct ec_params_get_cmd_versions pver;
struct ec_response_get_cmd_versions rver;
int rv;
*pmask = 0;
- pver.cmd = cmd;
- rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &pver, sizeof(pver),
+ pver_v1.cmd = cmd;
+ rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 1, &pver_v1, sizeof(pver_v1),
&rver, sizeof(rver));
+ if (rv == -EECRESULT - EC_RES_INVALID_VERSION) {
+ pver.cmd = cmd;
+ rv = ec_command(EC_CMD_GET_CMD_VERSIONS, 0, &pver, sizeof(pver),
+ &rver, sizeof(rver));
+ }
+
if (rv < 0)
return rv;