diff options
author | Randall Spangler <rspangler@chromium.org> | 2014-07-14 16:12:32 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-16 07:16:47 +0000 |
commit | 241cc626850175acac7a2e95cddbeb269f75c1ba (patch) | |
tree | 96f9ae3d712371c976286d574302aa8f78aa59e7 /util/comm-host.c | |
parent | 9ef82030e6a005df990f8f2924cf54076cd2e8da (diff) | |
download | chrome-ec-241cc626850175acac7a2e95cddbeb269f75c1ba.tar.gz |
samus: add options for device passthru and interface
This allows sending host commands to the PD chip through the EC.
The --interface option allows forcing a particular host interface.
This is necessary at present because the crosec device driver doesn't
support host protocol v3 so only has 8-bit command numbers.
BUG=chrome-os-partner:30079
BRANCH=none
TEST=from EC console,
ectool version -> prints EC version
ectool --interface=lpc --dev=0 version -> prints EC version
ectool --interface=lpc --dev=1 version -> prints PD version
ectool --interface=lpc --dev=2 version -> prints error
ectool --interface=i2c version -> can't find EC
ectool --interface=dev version -> prints EC version
Change-Id: I9dd10578dac77e3e104d19e2f37759814eec6ca2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207948
Diffstat (limited to 'util/comm-host.c')
-rw-r--r-- | util/comm-host.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/util/comm-host.c b/util/comm-host.c index d0ab376aa9..3f8c70a4e7 100644 --- a/util/comm-host.c +++ b/util/comm-host.c @@ -11,15 +11,16 @@ #include "comm-host.h" #include "ec_commands.h" -int (*ec_command)(int command, int version, - const void *outdata, int outsize, - void *indata, int insize); +int (*ec_command_proto)(int command, int version, + const void *outdata, int outsize, + void *indata, int insize); int (*ec_readmem)(int offset, int bytes, void *dest); int ec_max_outsize, ec_max_insize; void *ec_outbuf; void *ec_inbuf; +static int command_offset; int comm_init_dev(void) __attribute__((weak)); int comm_init_lpc(void) __attribute__((weak)); @@ -58,21 +59,36 @@ static int fake_readmem(int offset, int bytes, void *dest) return EC_MEMMAP_TEXT_MAX - 1; } -int comm_init(void) +void set_command_offset(int offset) +{ + command_offset = offset; +} + +int ec_command(int command, int version, + const void *outdata, int outsize, + void *indata, int insize) +{ + /* Offset command code to support sub-devices */ + return ec_command_proto(command_offset + command, version, + outdata, outsize, + indata, insize); +} + +int comm_init(int interfaces) { /* Default memmap access */ ec_readmem = fake_readmem; /* Prefer new /dev method */ - if (comm_init_dev && !comm_init_dev()) + if ((interfaces & COMM_DEV) && comm_init_dev && !comm_init_dev()) goto init_ok; /* Fallback to direct LPC on x86 */ - if (comm_init_lpc && !comm_init_lpc()) + if ((interfaces & COMM_LPC) && comm_init_lpc && !comm_init_lpc()) goto init_ok; /* Fallback to direct i2c on ARM */ - if (comm_init_i2c && !comm_init_i2c()) + if ((interfaces & COMM_I2C) && comm_init_i2c && !comm_init_i2c()) goto init_ok; /* Give up */ |