Skip to content

Commit 61e6fe5

Browse files
ceggers-arriwsakernel
authored andcommitted
i2c: imx: Don't generate STOP condition if arbitration has been lost
If arbitration is lost, the master automatically changes to slave mode. I2SR_IBB may or may not be reset by hardware. Raising a STOP condition by resetting I2CR_MSTA has no effect and will not clear I2SR_IBB. So calling i2c_imx_bus_busy() is not required and would busy-wait until timeout. Signed-off-by: Christian Eggers <ceggers@arri.de> Tested (not extensively) on Vybrid VF500 (Toradex VF50): Tested-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de> Cc: stable@vger.kernel.org # Requires trivial backporting, simple remove # the 3rd argument from the calls to # i2c_imx_bus_busy(). Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 1de67a3 commit 61e6fe5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/i2c/busses/i2c-imx.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx, bool atomic)
615615
/* Stop I2C transaction */
616616
dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
617617
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
618+
if (!(temp & I2CR_MSTA))
619+
i2c_imx->stopped = 1;
618620
temp &= ~(I2CR_MSTA | I2CR_MTX);
619621
if (i2c_imx->dma)
620622
temp &= ~I2CR_DMAEN;
@@ -778,9 +780,12 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
778780
*/
779781
dev_dbg(dev, "<%s> clear MSTA\n", __func__);
780782
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
783+
if (!(temp & I2CR_MSTA))
784+
i2c_imx->stopped = 1;
781785
temp &= ~(I2CR_MSTA | I2CR_MTX);
782786
imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
783-
i2c_imx_bus_busy(i2c_imx, 0, false);
787+
if (!i2c_imx->stopped)
788+
i2c_imx_bus_busy(i2c_imx, 0, false);
784789
} else {
785790
/*
786791
* For i2c master receiver repeat restart operation like:
@@ -905,9 +910,12 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs,
905910
dev_dbg(&i2c_imx->adapter.dev,
906911
"<%s> clear MSTA\n", __func__);
907912
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
913+
if (!(temp & I2CR_MSTA))
914+
i2c_imx->stopped = 1;
908915
temp &= ~(I2CR_MSTA | I2CR_MTX);
909916
imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);
910-
i2c_imx_bus_busy(i2c_imx, 0, atomic);
917+
if (!i2c_imx->stopped)
918+
i2c_imx_bus_busy(i2c_imx, 0, atomic);
911919
} else {
912920
/*
913921
* For i2c master receiver repeat restart operation like:

0 commit comments

Comments
 (0)