In case of collision on i2c bus the controller which lost bus mastership stays as a slave<div>for all subsequent transfers. This results in the i2c controller never writing to the bus </div><div>for future transactions, resulting in i2c transfer timeouts.</div>

<div>  This fix checks for a collision on last I2C transaction and sets the I2COM_MASTER </div><div>bit for the new transaction.</div><div><div><div><br></div><div>Signed-off-by: Sachin Surendran <<a href="mailto:sachin.surendran@alliedtelesis.co.nz">sachin.surendran@alliedtelesis.co.nz</a>><br>

</div><div>---</div><div><div><div><div> drivers/i2c/busses/i2c-cpm.c |    8 ++++++++</div><div> 1 file changed, 8 insertions(+)</div><div><br></div><div>diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c</div>

<div>index c1e1096..bb94c6d 100644</div><div>--- a/drivers/i2c/busses/i2c-cpm.c</div><div>+++ b/drivers/i2c/busses/i2c-cpm.c</div><div>@@ -338,6 +338,14 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)</div>

<div>        tptr = 0;</div><div>        rptr = 0;</div><div> </div><div>+       /*</div><div>+        * If there was a collision in the last i2c transaction,</div><div>+        * Set I2COM_MASTER as it was cleared during collision.</div>

<div>+        */</div><div>+       if (in_be16(&tbdf->cbd_sc) & BD_SC_CL) {</div><div>+               out_8(&cpm->i2c_reg->i2com, I2COM_MASTER);</div><div>+       }</div><div>+</div><div>        while (tptr < num) {</div>

<div>                pmsg = &msgs[tptr];</div><div>                dev_dbg(&adap->dev, "R: %d T: %d\n", rptr, tptr);</div></div></div></div><div><br></div>
</div></div>