]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: i2c-cdns: Prevent early termination of write
authorSai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Tue, 1 Mar 2022 08:16:52 +0000 (09:16 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 9 Mar 2022 11:36:37 +0000 (12:36 +0100)
During sequential loading of data, hold the bus to prevent controller
from sending stop signal in case no data is available in fifo.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Reviewed-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/2407b39d305999cb42438c5423aebc3b514acabb.1646122610.git.michal.simek@xilinx.com
drivers/i2c/i2c-cdns.c

index 07d53be11f128a764c9db377d82f2113681d973c..0da9f6f35a9f9ea536aa683e9a5224eaf545b4ed 100644 (file)
@@ -257,16 +257,18 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,
        setbits_le32(&regs->control, CDNS_I2C_CONTROL_CLR_FIFO);
        clrbits_le32(&regs->control, CDNS_I2C_CONTROL_RW);
 
-       /* Check message size against FIFO depth, and set hold bus bit
-        * if it is greater than FIFO depth
+       /*
+        * For sequential data load hold the bus.
         */
-       if (len > CDNS_I2C_FIFO_DEPTH)
+       if (len > 1)
                setbits_le32(&regs->control, CDNS_I2C_CONTROL_HOLD);
 
        /* Clear the interrupts in status register */
        writel(CDNS_I2C_INTERRUPTS_MASK, &regs->interrupt_status);
 
-       writel(addr, &regs->address);
+       /* In case of Probe (i.e no data), start the transfer */
+       if (!len)
+               writel(addr, &regs->address);
 
        while (len-- && !is_arbitration_lost(regs)) {
                writel(*(cur_data++), &regs->data);