Skip to content

Commit d358def

Browse files
Shubhrajyoti DattaWolfram Sang
authored andcommitted
i2c: cadence: Fix the hold bit setting
In case the hold bit is not needed we are carrying the old values. Fix the same by resetting the bit when not needed. Fixes the sporadic i2c bus lockups on National Instruments Zynq-based devices. Fixes: df8eb56 ("i2c: Add driver for Cadence I2C controller") Reported-by: Kyle Roeschley <kyle.roeschley@ni.com> Acked-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Tested-by: Kyle Roeschley <kyle.roeschley@ni.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent d139371 commit d358def

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/i2c/busses/i2c-cadence.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
382382
* Check for the message size against FIFO depth and set the
383383
* 'hold bus' bit if it is greater than FIFO depth.
384384
*/
385-
if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
385+
if ((id->recv_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
386386
ctrl_reg |= CDNS_I2C_CR_HOLD;
387+
else
388+
ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
387389

388390
cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
389391

@@ -440,8 +442,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)
440442
* Check for the message size against FIFO depth and set the
441443
* 'hold bus' bit if it is greater than FIFO depth.
442444
*/
443-
if (id->send_count > CDNS_I2C_FIFO_DEPTH)
445+
if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
444446
ctrl_reg |= CDNS_I2C_CR_HOLD;
447+
else
448+
ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;
449+
445450
cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);
446451

447452
/* Clear the interrupts in interrupt status register. */

0 commit comments

Comments
 (0)