summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2020-02-24 11:54:11 +0800
committerCommit Bot <commit-bot@chromium.org>2020-02-28 07:14:56 +0000
commit84ed9da8d116d7385c9b22aaadee2b409ef961d8 (patch)
tree1cb3ce2f69c11fdb883a61114f493a671d59b53b /common
parent65a9ccd061dd23cd6e39c3f3987b398a8ca43997 (diff)
downloadchrome-ec-84ed9da8d116d7385c9b22aaadee2b409ef961d8.tar.gz
i2c: fix the tcpc i2c protection in the i2c_command_passthru_protect
In the depthcharge, we call the EC host command with the subcmd EC_CMD_I2C_PASSTHRU_PROTECT to block all of the TCPC i2c pass through commands from the AP. However, the params->port isn't set because we need to block all of the TCPC. In order to support the tcpc i2c ports protection correctly, we need to skip the get_i2c_port checking BUG=b:150099159 TEST=ran on Palkia Change-Id: I4ab13a8f737f0e7b9ae88e51012d1737fc34e1a1 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2069959 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/i2c_master.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/common/i2c_master.c b/common/i2c_master.c
index 29a906aeda..ccb5a34492 100644
--- a/common/i2c_master.c
+++ b/common/i2c_master.c
@@ -1228,6 +1228,18 @@ i2c_command_passthru_protect(struct host_cmd_handler_args *args)
return EC_RES_INVALID_PARAM;
}
+ /*
+ * When calling the subcmd to protect all tcpcs, the i2c port isn't
+ * expected to be set in the args. So, putting a check here to avoid
+ * the get_i2c_port return error.
+ */
+ if (params->subcmd == EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS) {
+ if (IS_ENABLED(CONFIG_USB_POWER_DELIVERY) &&
+ !IS_ENABLED(CONFIG_USB_PD_TCPM_STUB))
+ i2c_passthru_protect_tcpc_ports();
+ return EC_RES_SUCCESS;
+ }
+
if (!get_i2c_port(params->port)) {
PTHRUPRINTS("protect invalid port %d", params->port);
return EC_RES_INVALID_PARAM;
@@ -1245,10 +1257,6 @@ i2c_command_passthru_protect(struct host_cmd_handler_args *args)
args->response_size = sizeof(*resp);
} else if (params->subcmd == EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE) {
i2c_passthru_protect_port(params->port);
- } else if (params->subcmd == EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS) {
- if (IS_ENABLED(CONFIG_USB_POWER_DELIVERY) &&
- !IS_ENABLED(CONFIG_USB_PD_TCPM_STUB))
- i2c_passthru_protect_tcpc_ports();
} else {
return EC_RES_INVALID_COMMAND;
}