diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2014-09-09 12:00:49 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-09-14 09:52:11 +0000 |
commit | fab7ac3b9a5cc26927b8a40bbbba8049d64b323b (patch) | |
tree | 446e8aa1034f2f89a7c6fc248f918b308e6b5f46 | |
parent | 9452186389651b83cee6731567f8f50776e0f19b (diff) | |
download | chrome-ec-fab7ac3b9a5cc26927b8a40bbbba8049d64b323b.tar.gz |
ectool: add new parameter to identify proper EC.
Add parameter name to identify which EC to talk to.
Superseed --dev parameter, removed soon.
--name cros_ec (the default): send commands to /dev/cros_ec.
--name cros_pd: send commands to /dev/cros_pd.
...
BUG=chrome-os-partner:31513
TEST=Tested on samus:
check ectool --name cros_pd version returns proper data:
ectool --name=cros_pd version
RO version: samus_pd_v1.1.2079-8e4f9fc-dirt
....
CQ-DEPEND=CL:217297
BRANCH=ToT
Change-Id: Ie8b5c6c184d73a89b4445e88d6f104169176b9f3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/217311
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | util/burn_my_ec.c | 2 | ||||
-rw-r--r-- | util/comm-dev.c | 6 | ||||
-rw-r--r-- | util/comm-host.c | 7 | ||||
-rw-r--r-- | util/comm-host.h | 3 | ||||
-rw-r--r-- | util/ec_sb_firmware_update.c | 2 | ||||
-rw-r--r-- | util/ectool.c | 13 |
6 files changed, 21 insertions, 12 deletions
diff --git a/util/burn_my_ec.c b/util/burn_my_ec.c index 720d89ed93..4e2e1de866 100644 --- a/util/burn_my_ec.c +++ b/util/burn_my_ec.c @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) { extern uint8_t data[] asm("_payload_start"); - if (comm_init(COMM_ALL) < 0) + if (comm_init(COMM_ALL, NULL) < 0) return -3; flash_partition(EC_IMAGE_RW, data + CONFIG_FW_RW_OFF, diff --git a/util/comm-dev.c b/util/comm-dev.c index ab4f9bca9e..daa2402c20 100644 --- a/util/comm-dev.c +++ b/util/comm-dev.c @@ -78,13 +78,15 @@ static int ec_readmem_dev(int offset, int bytes, void *dest) dest, bytes); } -int comm_init_dev(void) +int comm_init_dev(const char *device_name) { char version[80]; + char device[80] = "/dev/"; int r; char *s; - fd = open("/dev/" CROS_EC_DEV_NAME, O_RDWR); + strncat(device, (device_name ? device_name : CROS_EC_DEV_NAME), 40); + fd = open(device, O_RDWR); if (fd < 0) return 1; diff --git a/util/comm-host.c b/util/comm-host.c index a79a34a385..7da86316fb 100644 --- a/util/comm-host.c +++ b/util/comm-host.c @@ -23,7 +23,7 @@ void *ec_outbuf; void *ec_inbuf; static int command_offset; -int comm_init_dev(void) __attribute__((weak)); +int comm_init_dev(const char *device_name) __attribute__((weak)); int comm_init_lpc(void) __attribute__((weak)); int comm_init_i2c(void) __attribute__((weak)); @@ -75,7 +75,7 @@ int ec_command(int command, int version, indata, insize); } -int comm_init(int interfaces) +int comm_init(int interfaces, const char *device_name) { struct ec_response_get_protocol_info info; @@ -83,7 +83,8 @@ int comm_init(int interfaces) ec_readmem = fake_readmem; /* Prefer new /dev method */ - if ((interfaces & COMM_DEV) && comm_init_dev && !comm_init_dev()) + if ((interfaces & COMM_DEV) && comm_init_dev && + !comm_init_dev(device_name)) goto init_ok; /* Fallback to direct LPC on x86 */ diff --git a/util/comm-host.h b/util/comm-host.h index 30c6acee67..3477661c19 100644 --- a/util/comm-host.h +++ b/util/comm-host.h @@ -37,9 +37,10 @@ enum comm_interface { * Perform initializations needed for subsequent requests * * @param interfaces Interfaces to try; use COMM_ALL to try all of them. + * @param device_name For DEV option, the device file to use. * @return 0 in case of success, or error code. */ -int comm_init(int interfaces); +int comm_init(int interfaces, const char *device_name); /** * Send a command to the EC. Returns the length of output data returned (0 if diff --git a/util/ec_sb_firmware_update.c b/util/ec_sb_firmware_update.c index ee538cbc8a..982a2e66b6 100644 --- a/util/ec_sb_firmware_update.c +++ b/util/ec_sb_firmware_update.c @@ -635,7 +635,7 @@ int main(int argc, char *argv[]) exit(1); } - if (comm_init(interfaces)) { + if (comm_init(interfaces, NULL)) { fprintf(stderr, "Couldn't find EC\n"); goto out; } diff --git a/util/ectool.c b/util/ectool.c index e816a7828b..8cf5408a0f 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -29,11 +29,13 @@ enum { OPT_DEV = 1000, OPT_INTERFACE, + OPT_NAME, }; static struct option long_opts[] = { {"dev", 1, 0, OPT_DEV}, {"interface", 1, 0, OPT_INTERFACE}, + {"name", 1, 0, OPT_NAME}, {NULL, 0, 0, 0} }; @@ -228,9 +230,8 @@ int parse_bool(const char *s, int *dest) void print_help(const char *prog, int print_cmds) { - printf("Usage: %s [--dev=n] [--interface=dev|lpc|i2c] <command> " - "[params]\n\n", - prog); + printf("Usage: %s [--dev=n] [--interface=dev|lpc|i2c] ", prog); + printf("[--name=cros_ec|cros_sh|cros_pd] <command> [params]\n\n"); if (print_cmds) puts(help_str); else @@ -4839,6 +4840,7 @@ int main(int argc, char *argv[]) const struct command *cmd; int dev = 0; int interfaces = COMM_ALL; + char device_name[40] = "cros_ec"; int rv = 1; int parse_error = 0; char *e; @@ -4873,6 +4875,9 @@ int main(int argc, char *argv[]) parse_error = 1; } break; + case OPT_NAME: + strncpy(device_name, optarg, 40); + break; } } @@ -4904,7 +4909,7 @@ int main(int argc, char *argv[]) exit(1); } - if (comm_init(interfaces)) { + if (comm_init(interfaces, device_name)) { fprintf(stderr, "Couldn't find EC\n"); goto out; } |