scb_wr_rd_fence moved to before reading from fifo and writing to
fifo to make sure the the first read/write is done after the required
number of cycles.

Fixes: 27bce457d588 (i2c: img-scb: Add Imagination Technologies I2C SCB driver)
Signed-off-by: Sifan Naeem <[email protected]>
Cc: <[email protected]>
---
 drivers/i2c/busses/i2c-img-scb.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 3c1dcd2..42114a8 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -536,6 +536,7 @@ static void img_i2c_read_fifo(struct img_i2c *i2c)
                u32 fifo_status;
                u8 data;
 
+               img_i2c_wr_rd_fence(i2c);
                fifo_status = img_i2c_readl(i2c, SCB_FIFO_STATUS_REG);
                if (fifo_status & FIFO_READ_EMPTY)
                        break;
@@ -544,7 +545,6 @@ static void img_i2c_read_fifo(struct img_i2c *i2c)
                *i2c->msg.buf = data;
 
                img_i2c_writel(i2c, SCB_READ_FIFO_REG, 0xff);
-               img_i2c_wr_rd_fence(i2c);
                i2c->msg.len--;
                i2c->msg.buf++;
        }
@@ -556,12 +556,12 @@ static void img_i2c_write_fifo(struct img_i2c *i2c)
        while (i2c->msg.len) {
                u32 fifo_status;
 
+               img_i2c_wr_rd_fence(i2c);
                fifo_status = img_i2c_readl(i2c, SCB_FIFO_STATUS_REG);
                if (fifo_status & FIFO_WRITE_FULL)
                        break;
 
                img_i2c_writel(i2c, SCB_WRITE_DATA_REG, *i2c->msg.buf);
-               img_i2c_wr_rd_fence(i2c);
                i2c->msg.len--;
                i2c->msg.buf++;
        }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to