summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-07-02 11:25:22 -0700
committerChromeBot <chrome-bot@google.com>2013-07-03 18:23:09 -0700
commit5f30f40cb5a83bc900ce3400d6a5f3327bc96fdc (patch)
treee16e8104d83f9f3cc61e9212bd544aa85d5308a3 /util
parent1b9a0ade1604b5ed9c6677eaef835014e2b55e3e (diff)
downloadchrome-ec-5f30f40cb5a83bc900ce3400d6a5f3327bc96fdc.tar.gz
Move protocol v2 constants to ec_commands.h
These constants are scattered around the various interface implementations and should be in one place. This will also clean up the u-boot side when ec_commands.h is copied there. BUG=chrome-os-partner:20257 BRANCH=none TEST=build link, spring, pit; test 'ectool hello' Change-Id: Ib1425db00ec8220538d8c5c65107ac9548009516 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60810 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/comm-dev.c2
-rw-r--r--util/comm-i2c.c13
-rw-r--r--util/comm-lpc.c8
3 files changed, 9 insertions, 14 deletions
diff --git a/util/comm-dev.c b/util/comm-dev.c
index c6bd6b4176..fb5fb31ae6 100644
--- a/util/comm-dev.c
+++ b/util/comm-dev.c
@@ -110,7 +110,7 @@ int comm_init_dev(void)
* TODO: need a way to get this from the driver and EC. For now,
* pick a magic lowest common denominator value.
*/
- ec_max_outsize = EC_HOST_PARAM_SIZE - 8;
+ ec_max_outsize = EC_PROTO2_MAX_PARAM_SIZE - 8;
return 0;
}
diff --git a/util/comm-i2c.c b/util/comm-i2c.c
index eab48d2a99..91ceb555e2 100644
--- a/util/comm-i2c.c
+++ b/util/comm-i2c.c
@@ -32,15 +32,8 @@
#define debug(...)
#endif
-/* v2 protocol bytes
- * OUT: (version, command, size, ... request ..., checksum) */
-#define PROTO_V2_IN 4
-/* IN: (command, size, ... response ..., checkcum) */
-#define PROTO_V2_OUT 3
-
static int i2c_fd = -1;
-
/*
* Sends a command to the EC (protocol v2). Returns the command status code, or
* -1 if other error.
@@ -90,7 +83,7 @@ static int ec_command_i2c(int command, int version,
* allocate larger packet
* (version, command, size, ..., checksum)
*/
- req_len = outsize + PROTO_V2_IN;
+ req_len = outsize + EC_PROTO2_REQUEST_OVERHEAD;
req_buf = calloc(1, req_len);
if (!req_buf)
goto done;
@@ -115,7 +108,7 @@ static int ec_command_i2c(int command, int version,
* allocate larger packet
* (result, size, ..., checksum)
*/
- resp_len = insize + PROTO_V2_OUT;
+ resp_len = insize + EC_PROTO2_RESPONSE_OVERHEAD;
resp_buf = calloc(1, resp_len);
if (!resp_buf)
goto done;
@@ -213,7 +206,7 @@ int comm_init_i2c(void)
free(file_path);
ec_command = ec_command_i2c;
- ec_max_outsize = ec_max_insize = EC_HOST_PARAM_SIZE;
+ ec_max_outsize = ec_max_insize = EC_PROTO2_MAX_PARAM_SIZE;
return 0;
}
diff --git a/util/comm-lpc.c b/util/comm-lpc.c
index f2c635770e..adbbb89f10 100644
--- a/util/comm-lpc.c
+++ b/util/comm-lpc.c
@@ -266,13 +266,13 @@ int comm_init_lpc(void)
*/
byte &= inb(EC_LPC_ADDR_HOST_CMD);
byte &= inb(EC_LPC_ADDR_HOST_DATA);
- for (i = 0; i < EC_HOST_PARAM_SIZE && byte == 0xff; ++i)
+ for (i = 0; i < EC_PROTO2_MAX_PARAM_SIZE && byte == 0xff; ++i)
byte &= inb(EC_LPC_ADDR_HOST_PARAM + i);
if (byte == 0xff) {
fprintf(stderr, "Port 0x%x,0x%x,0x%x-0x%x are all 0xFF.\n",
EC_LPC_ADDR_HOST_CMD, EC_LPC_ADDR_HOST_DATA,
EC_LPC_ADDR_HOST_PARAM,
- EC_LPC_ADDR_HOST_PARAM + EC_HOST_PARAM_SIZE - 1);
+ EC_LPC_ADDR_HOST_PARAM + EC_PROTO2_MAX_PARAM_SIZE - 1);
fprintf(stderr,
"Very likely this board doesn't have a Chromium EC.\n");
return -4;
@@ -296,6 +296,7 @@ int comm_init_lpc(void)
i = inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_HOST_CMD_FLAGS);
if (i & EC_HOST_CMD_FLAG_VERSION_3) {
+ /* Protocol version 3 */
ec_command = ec_command_lpc_3;
ec_max_outsize = EC_LPC_HOST_PACKET_SIZE -
sizeof(struct ec_host_request);
@@ -303,8 +304,9 @@ int comm_init_lpc(void)
sizeof(struct ec_host_response);
} else if (i & EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED) {
+ /* Protocol version 2*/
ec_command = ec_command_lpc;
- ec_max_outsize = ec_max_insize = EC_HOST_PARAM_SIZE;
+ ec_max_outsize = ec_max_insize = EC_PROTO2_MAX_PARAM_SIZE;
} else {
fprintf(stderr, "EC doesn't support protocols we need.\n");