summaryrefslogtreecommitdiff
path: root/common/i2c_master.c
diff options
context:
space:
mode:
authorKarthikeyan Ramasubramanian <kramasub@chromium.org>2018-12-19 14:01:42 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-01-11 23:14:42 +0000
commit4e469ad515b4f4da96671c9bdbe8a59380cc6ab5 (patch)
tree2295484c51627ece3972808d7eee34d79539d959 /common/i2c_master.c
parent8416a685cfd8a2da2def210ffd33ee437b7bc847 (diff)
downloadchrome-ec-4e469ad515b4f4da96671c9bdbe8a59380cc6ab5.tar.gz
i2c_master: Protect TCPC I2C tunnels as part of EC_REBOOT_DISABLE_JUMP
Currently EC keeps the I2C tunnels open enabling depthcharge to perform firmware update on those ports. Once the firmware update is done, depthcharge triggers a command to protect the I2C tunnels. But not all TCPC ports are registered for firmware update in depthcharge. This causes some I2C tunnels to be left unprotected. Update EC to protect all the TCPC I2C tunnels when depthcharge invokes EC_REBOOT_DISABLE_JUMP command. This usually happens when the EC software sync is complete and the control jumps to OS. Also protect the TCPC I2C tunnels only when the WP is enabled. BUG=b:119130829 BRANCH=octopus TEST=make -j buildall && Boot to ChromeOS and ensure that the TCPC I2C tunnels are protected. Change-Id: Ice681038bbf725b3aa44b13ff71724937c6045e9 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Previous-Reviewed-on: https://chromium-review.googlesource.com/1390944 (cherry picked from commit b2e60f2fa4cd606fa1399a4051a22904b23ba956) Reviewed-on: https://chromium-review.googlesource.com/c/1405406 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/i2c_master.c')
-rw-r--r--common/i2c_master.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c
index ec2cad96df..c2cc22f06c 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -37,7 +37,7 @@ static struct mutex port_mutex[I2C_CONTROLLER_COUNT];
/* A bitmap of the controllers which are currently servicing a request. */
static uint32_t i2c_port_active_list;
BUILD_ASSERT(I2C_CONTROLLER_COUNT < 32);
-static uint8_t port_protected[I2C_CONTROLLER_COUNT];
+static uint8_t port_protected[I2C_PORT_COUNT];
/**
* Non-deterministically test the lock status of the port. If another task
@@ -761,6 +761,14 @@ 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));
+void i2c_passthru_protect_port(uint32_t port)
+{
+ if (port < I2C_PORT_COUNT)
+ port_protected[port] = 1;
+ else
+ PTHRUPRINTF("Invalid I2C port %d to be protected\n", port);
+}
+
static int i2c_command_passthru_protect(struct host_cmd_handler_args *args)
{
const struct ec_params_i2c_passthru_protect *params = args->params;
@@ -790,7 +798,7 @@ static int i2c_command_passthru_protect(struct host_cmd_handler_args *args)
resp->status = port_protected[params->port];
args->response_size = sizeof(*resp);
} else if (params->subcmd == EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE) {
- port_protected[params->port] = 1;
+ i2c_passthru_protect_port(params->port);
} else {
return EC_RES_INVALID_COMMAND;
}