From 37d5a8382752364aca3349e03e7aa9e5e5dec32c Mon Sep 17 00:00:00 2001 From: Leifu Zhao Date: Thu, 11 Jul 2019 11:03:36 +0800 Subject: arcada: ensure i2c transmit fifo is empty Make sure transmit fifo is empty before disable i2c controller during transfer, otherwise the i2c write may fail for speed 100k, it also helps 400K and 1M. BUG=b:137218876 BRANCH=none TEST=tested on arcada Signed-off-by: Leifu Zhao Change-Id: I6f9fb9a71c28f2d3f9696340cc87fe3b72c25a02 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1697061 Reviewed-by: Leifu Zhao Reviewed-by: Jett Rink Reviewed-by: Jack Rosenthal Tested-by: Leifu Zhao Auto-Submit: Leifu Zhao Commit-Queue: Leifu Zhao --- chip/ish/i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'chip/ish') diff --git a/chip/ish/i2c.c b/chip/ish/i2c.c index f6c0cf3d0b..07da8638d2 100644 --- a/chip/ish/i2c.c +++ b/chip/ish/i2c.c @@ -404,8 +404,9 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, /* do not disable device before master is idle */ expire_ts = __hw_clock_source_read() + I2C_TSC_TIMEOUT; - while (i2c_mmio_read(ctx->base, IC_STATUS) & - BIT(IC_STATUS_MASTER_ACTIVITY)) { + while ((i2c_mmio_read(ctx->base, IC_STATUS) & + (BIT(IC_STATUS_MASTER_ACTIVITY) | BIT(IC_STATUS_TFE))) != + BIT(IC_STATUS_TFE)) { if (__hw_clock_source_read() >= expire_ts) { ctx->error_flag = 1; -- cgit v1.2.1