diff options
author | Nicolas Boichat <drinkcat@google.com> | 2016-05-19 08:58:47 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-24 19:23:27 -0700 |
commit | f5bba241fdcefcc0c1d2f82b097caa2923b3ccc5 (patch) | |
tree | 7844194da213c658c2558c54a966e4340e5f4246 /include | |
parent | d2bbc229f378b741bfc2ff0d2092d501531626a9 (diff) | |
download | chrome-ec-f5bba241fdcefcc0c1d2f82b097caa2923b3ccc5.tar.gz |
common/i2c: Add I2C passthru_protect command
This allows the AP to protect a I2C passthru bus. A board-specific
function then defines what I2C commands are allowed, so that we
can white/black list some addresses (e.g. I2C address allowing
PD chip FW updating).
BRANCH=none
BUG=chrome-os-partner:52431
TEST=Book elm-rev1
Change-Id: Ib106924418b16388ea8ea53c7b6bda6ef92e1d09
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Reviewed-on: https://chromium-review.googlesource.com/345761
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | include/ec_commands.h | 19 | ||||
-rw-r--r-- | include/i2c.h | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/include/config.h b/include/config.h index effc6d9cc7..591af79c5f 100644 --- a/include/config.h +++ b/include/config.h @@ -538,6 +538,7 @@ #define CONFIG_CMD_HASH #define CONFIG_CMD_HCDEBUG #undef CONFIG_CMD_HOSTCMD +#undef CONFIG_CMD_I2C_PROTECT #define CONFIG_CMD_I2C_SCAN #define CONFIG_CMD_I2C_XFER #undef CONFIG_CMD_I2CWEDGE diff --git a/include/ec_commands.h b/include/ec_commands.h index bc5b342817..27049eac5a 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3195,6 +3195,25 @@ struct ec_params_entering_mode { #define VBOOT_MODE_RECOVERY 2 /*****************************************************************************/ +/* I2C passthru protection command: Protects I2C tunnels against access on + * certain addresses (board-specific). */ +#define EC_CMD_I2C_PASSTHRU_PROTECT 0xb7 + +enum ec_i2c_passthru_protect_subcmd { + EC_CMD_I2C_PASSTHRU_PROTECT_STATUS = 0x0, + EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE = 0x1, +}; + +struct ec_params_i2c_passthru_protect { + uint8_t subcmd; + uint8_t port; /* I2C port number */ +} __packed; + +struct ec_response_i2c_passthru_protect { + uint8_t status; /* Status flags (0: unlocked, 1: locked) */ +} __packed; + +/*****************************************************************************/ /* System commands */ /* diff --git a/include/i2c.h b/include/i2c.h index fdda5a0187..d3329df64a 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -31,6 +31,10 @@ struct i2c_port_t { int kbps; /* Speed in kbps */ enum gpio_signal scl; /* Port SCL GPIO line */ enum gpio_signal sda; /* Port SDA GPIO line */ + /* When bus is protected, returns true if passthru allowed for address. + * If the function is not defined, the default value is true. */ + int (*passthru_allowed)(const struct i2c_port_t *port, + uint16_t address); }; extern const struct i2c_port_t i2c_ports[]; |