Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c18daf1b authored by Shubhrajyoti Datta's avatar Shubhrajyoti Datta Committed by Greg Kroah-Hartman
Browse files

i2c: cadence: Fix the hold bit setting



[ Upstream commit d358def706880defa4c9e87381c5bf086a97d5f9 ]

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: df8eb569 ("i2c: Add driver for Cadence I2C controller")
Reported-by: default avatarKyle Roeschley <kyle.roeschley@ni.com>
Acked-by: default avatarMichal Simek <michal.simek@xilinx.com>
Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Tested-by: default avatarKyle Roeschley <kyle.roeschley@ni.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 65513463
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -378,8 +378,10 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
	 * Check for the message size against FIFO depth and set the
	 * 'hold bus' bit if it is greater than FIFO depth.
	 */
	if (id->recv_count > CDNS_I2C_FIFO_DEPTH)
	if ((id->recv_count > CDNS_I2C_FIFO_DEPTH)  || id->bus_hold_flag)
		ctrl_reg |= CDNS_I2C_CR_HOLD;
	else
		ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;

	cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);

@@ -436,8 +438,11 @@ static void cdns_i2c_msend(struct cdns_i2c *id)
	 * Check for the message size against FIFO depth and set the
	 * 'hold bus' bit if it is greater than FIFO depth.
	 */
	if (id->send_count > CDNS_I2C_FIFO_DEPTH)
	if ((id->send_count > CDNS_I2C_FIFO_DEPTH) || id->bus_hold_flag)
		ctrl_reg |= CDNS_I2C_CR_HOLD;
	else
		ctrl_reg = ctrl_reg & ~CDNS_I2C_CR_HOLD;

	cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET);

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