]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2c: cadance: fix ctrl/addr reg write order
authorMatt Weber <matthew.weber@rockwellcollins.com>
Thu, 22 Jun 2017 20:00:33 +0000 (15:00 -0500)
committerWolfram Sang <wsa@the-dreams.de>
Fri, 23 Jun 2017 18:56:21 +0000 (20:56 +0200)
The driver was clearing the hold bit in the control register before
writing to the address register which resulted in a stop condition
being generated rather than a repeated start.

This issue was only observed when a system was running much
slower than a normal processor would execute.  The IP data sheet
mentions a ordering of writing to the address register before
clearing the hold.

Fixes: df8eb5691c4 ("i2c: Add driver for Cadence I2C controller")
Signed-off-by: John Linn <john.linn@xilinx.com>
Signed-off-by: Paresh Chaudhary <paresh.chaudhary@rockwellcollins.com>
Signed-off-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-cadence.c

index 45d6771fac8ce1efcd093a710c6c3fad64ca33b8..75d80161931f20554fbaa9e9fed9a912d2835ae8 100644 (file)
@@ -405,14 +405,14 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
                cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET);
        }
 
+       /* Set the slave address in address register - triggers operation */
+       cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
+                                               CDNS_I2C_ADDR_OFFSET);
        /* Clear the bus hold flag if bytes to receive is less than FIFO size */
        if (!id->bus_hold_flag &&
                ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) &&
                (id->recv_count <= CDNS_I2C_FIFO_DEPTH))
                        cdns_i2c_clear_bus_hold(id);
-       /* Set the slave address in address register - triggers operation */
-       cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK,
-                                               CDNS_I2C_ADDR_OFFSET);
        cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET);
 }