diff options
author | Jett Rink <jettrink@chromium.org> | 2019-05-08 07:34:00 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-23 00:12:21 +0000 |
commit | 0237cc790983b9fa4159963ec6ee2feab5a7f512 (patch) | |
tree | 56c0dfc524d54ebdc96d4dd226d87ed07b2a5835 /common | |
parent | 4a538f82eb1225afc44e612b1fec46506c0e1efb (diff) | |
download | chrome-ec-0237cc790983b9fa4159963ec6ee2feab5a7f512.tar.gz |
i2c: add i2clookup host command
Add a new host command that will allow you to lookup a well known device
on the EC. This is useful for FAFT tests that want to talk directly
with i2c devices but don't know the physical address for each platform.
BRANCH=octopus
BUG=b:119065537
TEST=Used this with new faft test in CL:1601300
Change-Id: I82c2d5462fcb4edbc92ea60765971190fed7ae81
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1601060
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1767514
Reviewed-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Tested-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/i2c_master.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c index bda3561d34..afa40254d5 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -852,6 +852,34 @@ static int i2c_command_passthru(struct host_cmd_handler_args *args) } DECLARE_HOST_COMMAND(EC_CMD_I2C_PASSTHRU, i2c_command_passthru, EC_VER_MASK(0)); +static int i2c_command_lookup(struct host_cmd_handler_args *args) +{ + const struct ec_params_i2c_lookup *params = args->params; + struct ec_response_i2c_lookup *resp = args->response; + + switch (params->type) { + case I2C_LOOKUP_TYPE_CBI_EEPROM: +#ifdef CONFIG_CROS_BOARD_INFO + resp->i2c_port = I2C_PORT_EEPROM; + /* Convert from 8-bit address to 7-bit address */ + resp->i2c_addr = I2C_ADDR_EEPROM >> 1; +#else + /* Lookup type is supported, but not present on system. */ + return EC_RES_UNAVAILABLE; +#endif /* CONFIG_CROS_BOARD_INFO */ + break; + default: + /* The type was unrecognized */ + return EC_RES_INVALID_PARAM; + } + + args->response_size = sizeof(*resp); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_I2C_LOOKUP, i2c_command_lookup, EC_VER_MASK(0)); +/* If the params union expands in the future, need to bump EC_VER_MASK */ +BUILD_ASSERT(sizeof(struct ec_params_i2c_lookup) == 4); + void i2c_passthru_protect_port(uint32_t port) { if (port < I2C_PORT_COUNT) |