diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-11-24 16:41:51 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-30 18:54:04 -0800 |
commit | 4421d75c24738a524ed840935d4495cf1a75a3c3 (patch) | |
tree | c697ed1ce685f914d25537631680ea0b3c7fec1d | |
parent | 07bf28b77c7890f134e147baac0823a5c7a322f2 (diff) | |
download | chrome-ec-4421d75c24738a524ed840935d4495cf1a75a3c3.tar.gz |
mec1322: i2c: Assume read-no-write transactions are repeated start
If we're doing a read transaction without a write and asked to send a
start condition, assume that the slave has already been addressed and
make a repeated start.
BUG=chromium:561143
TEST=Verify "ectool i2cxfer 1 0x25 1 2" succeeds on glados
BRANCH=None
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic60a5c0f0fa32d5541b3cc6dce48cac28f26cd06
Reviewed-on: https://chromium-review.googlesource.com/314313
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r-- | chip/mec1322/i2c.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c index cc8649cd10..a800e9e780 100644 --- a/chip/mec1322/i2c.c +++ b/chip/mec1322/i2c.c @@ -234,11 +234,11 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, select_port(port); controller = i2c_port_to_controller(port); - if (send_start) + if (send_start && out_size) wait_idle(controller); reg = MEC1322_I2C_STATUS(controller); - if (send_start && + if (send_start && out_size && (((reg & (STS_BER | STS_LAB)) || !(reg & STS_NBB)) || (get_line_level(controller) != I2C_LINE_IDLE))) { @@ -293,24 +293,15 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, if (in_size) { /* Resend start bit when changing direction */ if (out_size || send_start) { - /* Repeated start case */ - if (out_size) - MEC1322_I2C_CTRL(controller) = CTRL_ESO | - CTRL_STA | - CTRL_ACK | - CTRL_ENI; + /* Repeated start */ + MEC1322_I2C_CTRL(controller) = CTRL_ESO | + CTRL_STA | + CTRL_ACK | + CTRL_ENI; MEC1322_I2C_DATA(controller) = (uint8_t)slave_addr | 0x01; - /* New transaction case, clock out slave address. */ - if (!out_size) - MEC1322_I2C_CTRL(controller) = CTRL_ESO | - CTRL_STA | - CTRL_ACK | - CTRL_ENI | - CTRL_PIN; - /* Skip over the dummy byte */ skip = 1; in_size++; |