summaryrefslogtreecommitdiff
path: root/common/host_command_master.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-07-25 15:43:49 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-30 00:23:25 +0000
commit4692a1387a492d5697ae12a7195eac6e1249fc6b (patch)
treeb2a88ded7123eee5d4f1b1fa4f8d9af697eae249 /common/host_command_master.c
parente449a42f08a6b9e70b50c7f67dfd00d2f4e30fb4 (diff)
downloadchrome-ec-4692a1387a492d5697ae12a7195eac6e1249fc6b.tar.gz
i2c: add support for timeout configuration at runtime
When the EC sends longer commands to the PD chip (such as flash erase/write over the passthru from AP), allow it to take a second instead of the default 100ms timeout. BUG=chrome-os-partner:30935 BRANCH=none TEST=samus boots battery command works from EC console ectool passthru of flash erase to PD works (requires hacked ectool) Change-Id: I08ff94f7ac6aee351aa73c9d28b5fd715d463b3a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209936 Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/host_command_master.c')
-rw-r--r--common/host_command_master.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/host_command_master.c b/common/host_command_master.c
index 55e3befbee..23441d0a3a 100644
--- a/common/host_command_master.c
+++ b/common/host_command_master.c
@@ -9,12 +9,16 @@
#include "console.h"
#include "host_command.h"
#include "i2c.h"
+#include "timer.h"
#include "util.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_HOSTCMD, outstr)
#define CPRINTF(format, args...) cprintf(CC_HOSTCMD, format, ## args)
+/* Host command timeout */
+#define HOST_COMMAND_TIMEOUT_US SECOND
+
/*
* Sends a command to the PD (protocol v3).
*
@@ -71,9 +75,11 @@ int pd_host_command(int command, int version,
* length.
*/
i2c_lock(I2C_PORT_PD_MCU, 1);
+ i2c_set_timeout(I2C_PORT_PD_MCU, HOST_COMMAND_TIMEOUT_US);
ret = i2c_xfer(I2C_PORT_PD_MCU, CONFIG_USB_PD_I2C_SLAVE_ADDR,
&req_buf[0], outsize + sizeof(rq) + 1, &resp_buf[0],
2, I2C_XFER_START);
+ i2c_set_timeout(I2C_PORT_PD_MCU, 0);
i2c_lock(I2C_PORT_PD_MCU, 0);
if (ret) {
CPRINTF("[%T i2c transaction 1 failed: %d]\n", ret);