From 45f7ddadd176f470c6cc8eb02b9dfaa08a573673 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 3 Jun 2015 15:57:30 -0700 Subject: [PATCH] i2c: fix read-only I2C transfers on STM32F0/F3 Ensure that we put a proper start bit if the transfer only contains a read but has the start flag set. Signed-off-by: Vincent Palatin BRANCH=smaug BUG=chrome-os-partner:40919 TEST=On Smaug (P6), at the Linux prompt, do "cat /sys/class/power_supply/bq27742-0/current_now" and see a proper value rather than an error. Change-Id: I10cc9907476b3cfb006f2c1540688139366c9195 Reviewed-on: https://chromium-review.googlesource.com/275079 Trybot-Ready: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Alec Berg Commit-Queue: Vincent Palatin Tested-by: Puthikorn Voravootivat --- chip/stm32/i2c-stm32f0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 1dfe7d9b36..dc9d295ae0 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -421,7 +421,7 @@ int chip_i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes, | STM32_I2C_CR2_RD_WRN | slave_addr | (xfer_stop ? STM32_I2C_CR2_AUTOEND : 0) | (!xfer_stop ? STM32_I2C_CR2_RELOAD : 0) - | (out_bytes ? STM32_I2C_CR2_START : 0); + | (out_bytes || xfer_start ? STM32_I2C_CR2_START : 0); for (i = 0; i < in_bytes; i++) { /* Wait for receive buffer not empty */