From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Ott Date: Tue, 28 Nov 2017 22:25:23 -0500 Subject: [U-Boot] [PATCH 1/2] i2c: at91_i2c: Wait for TXRDY after sending the first byte In-Reply-To: <20171129032524.14431-1-alan@softiron.com> References: <20171129032524.14431-1-alan@softiron.com> Message-ID: <20171129032524.14431-2-alan@softiron.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de The driver must wait for TXRDY after each byte is pushed into the i2c FIFO before pushing the next byte. Previously this was not done for the first byte, causing a race condition with zeros sometimes being sent for the next byte (which is typically the first actual data byte). Signed-off-by: Alan Ott --- drivers/i2c/at91_i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c index d394044..20d0929 100644 --- a/drivers/i2c/at91_i2c.c +++ b/drivers/i2c/at91_i2c.c @@ -72,6 +72,8 @@ static int at91_i2c_xfer_msg(struct at91_i2c_bus *bus, struct i2c_msg *msg) } else { writel(msg->buf[0], ®->thr); + ret = at91_wait_for_xfer(bus, TWI_SR_TXRDY); + for (i = 1; !ret && (i < msg->len); i++) { writel(msg->buf[i], ®->thr); ret = at91_wait_for_xfer(bus, TWI_SR_TXRDY); -- 2.9.3