summaryrefslogtreecommitdiff
path: root/util/comm-i2c.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-12 10:40:51 -0700
committerGerrit <chrome-bot@google.com>2012-07-12 18:10:30 -0700
commit02d820786c2fda890411494ddbc9e6d2ddf90f32 (patch)
tree264cbf06f8a0bc14c52be1dae895abe6efd88b39 /util/comm-i2c.c
parentc304ff7d81a2a3072e5388584b232413a76f3343 (diff)
downloadchrome-ec-02d820786c2fda890411494ddbc9e6d2ddf90f32.tar.gz
Support new-style LPC command interface in EC, ectool
Both EC and ectool are still backwards-compatible to the old interface. BUG=chrome-os-partner:11275 TEST=manual From U-boot prompt: mkbp hash // test old host talking to new EC From root shell: ectool echash // test new host talking to new EC You can also update just the OS and use an old EC, and verify that 'ectool echash' still works, which tests a new host talking to an old EC. Change-Id: I2afbb208cb16836f842ba119b74b1ab6a38ce5d5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27313
Diffstat (limited to 'util/comm-i2c.c')
-rw-r--r--util/comm-i2c.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/util/comm-i2c.c b/util/comm-i2c.c
index 5020db3ecf..5ff71700fd 100644
--- a/util/comm-i2c.c
+++ b/util/comm-i2c.c
@@ -75,7 +75,7 @@ int comm_init(void)
/* Sends a command to the EC. Returns the command status code, or
* -1 if other error. */
-int ec_command(int command, const void *indata, int insize,
+int ec_command(int command, int version, const void *indata, int insize,
void *outdata, int outsize)
{
struct i2c_rdwr_ioctl_data data;
@@ -89,6 +89,11 @@ int ec_command(int command, const void *indata, int insize,
uint8_t sum;
struct i2c_msg i2c_msg[2];
+ if (version > 0) {
+ fprintf(stderr, "Command versions >0 unsupported.\n");
+ return -EC_RES_ERROR;
+ }
+
if (i2c_fd < 0)
return -EC_RES_ERROR;
@@ -194,7 +199,7 @@ uint8_t read_mapped_mem8(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xff;
@@ -209,7 +214,7 @@ uint16_t read_mapped_mem16(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xffff;
@@ -224,7 +229,7 @@ uint32_t read_mapped_mem32(uint8_t offset)
p.offset = offset;
p.size = sizeof(val);
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
&val, sizeof(val)) < 0)
return 0xffffffff;
@@ -239,7 +244,7 @@ int read_mapped_string(uint8_t offset, char *buf)
p.offset = offset;
p.size = EC_MEMMAP_TEXT_MAX;
- if (ec_command(EC_CMD_READ_MEMMAP, &p, sizeof(p),
+ if (ec_command(EC_CMD_READ_MEMMAP, 0, &p, sizeof(p),
buf, EC_MEMMAP_TEXT_MAX) < 0) {
*buf = 0;
return -1;