[v2] i2c: imx: add workaround for erratum ERR010027

Message ID 20181103015132.37498-1-ying.zhang22455@nxp.com
State New
Headers show
Series
  • [v2] i2c: imx: add workaround for erratum ERR010027
Related show

Commit Message

Zhang Ying-22455 Nov. 3, 2018, 1:51 a.m.
From: Zhang Ying-22455 <ying.zhang22455@nxp.com>

ERR010027: Attempting a start cycle while the bus is busy may
generate a short clock pulse.

Software must ensure that the I2C BUS is idle by checking the
bus busy before switching to master mode and attempting a Start
cycle.

Signed-off-by: Zhang Ying-22455 <ying.zhang22455@nxp.com>
---
 drivers/i2c/busses/i2c-imx.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index c406700..2ab24bd 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -890,6 +890,14 @@  static int i2c_imx_xfer(struct i2c_adapter *adapter,
 
 	dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
 
+	/*
+	 * workround for ERR010027: ensure that the I2C BUS is idle
+	 * before switching to master mode and attempting a Start cycle
+	 */
+	result =  i2c_imx_bus_busy(i2c_imx, 0);
+	if (result)
+		goto out;
+
 	result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent);
 	if (result < 0)
 		goto out;