diff options
author | Rong Chang <rongchang@chromium.org> | 2015-10-20 14:27:17 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-10-23 05:12:09 -0700 |
commit | c5f9f00dfbd00642e5bb948bee977ca1be58c13b (patch) | |
tree | 816de85663e65769f1d91e8e97b383ce8e085df4 /chip/stm32 | |
parent | d8b81cdc0f0e98af3625c082d0b3ee3f22944ee7 (diff) | |
download | chrome-ec-c5f9f00dfbd00642e5bb948bee977ca1be58c13b.tar.gz |
oak: stm32f0: implement i2c_set_timeout
EC communicates with PD through I2C host command. This CL adds
i2c_set_timeout implementation.
BRANCH=none
BUG=chrome-os-partner:41608
TEST=manual
build and load on oak, check PD host command.
Change-Id: I05259b40223b435eaf2a0c38954573e97ea4b32b
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/306909
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r-- | chip/stm32/i2c-stm32f0.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 1c9ba7113b..c06f0d2619 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -40,6 +40,18 @@ #endif #endif + +/* I2C port state data */ +struct i2c_port_data { + uint32_t timeout_us; /* Transaction timeout, or 0 to use default */ +}; +static struct i2c_port_data pdata[I2C_PORT_COUNT]; + +void i2c_set_timeout(int port, uint32_t timeout) +{ + pdata[port].timeout_us = timeout ? timeout : I2C_TX_TIMEOUT_MASTER; +} + /** * Wait for ISR register to contain the specified mask. * @@ -48,7 +60,7 @@ */ static int wait_isr(int port, int mask) { - uint64_t timeout = get_time().val + I2C_TX_TIMEOUT_MASTER; + uint64_t timeout = get_time().val + pdata[port].timeout_us; while (get_time().val < timeout) { int isr = STM32_I2C_ISR(port); @@ -143,6 +155,9 @@ defined(CONFIG_LOW_POWER_IDLE) && \ /* Set up initial bus frequencies */ i2c_set_freq_port(p); + + /* Set up default timeout */ + i2c_set_timeout(port, 0); } /*****************************************************************************/ |