From 12f5bd4c29d5da7d00fdcf82a29b4fc319c62758 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Wed, 10 Jan 2018 02:42:39 -0600 Subject: MLK-17357-2 lpi2c: Add bus busy error handling When doing "i2c dev 4; i2c probe" with ENET daughter card connected on iMX8QXP MEK board, we met a i2c bus busy issue, that the BBF of lpi2c always show busy, but the master is idle, and stop is detected (SDF set). This patch addes a handling to re-init the lpi2c master for this case. Then the issue can be worked around. Signed-off-by: Ye Li Acked-by: Peng Fan (cherry picked from commit 6b4021d04c7f637fd60cf73f9cc46fdebc853790) --- drivers/i2c/imx_lpi2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index e159e3307d..018b2b6eba 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -20,6 +20,8 @@ DECLARE_GLOBAL_DATA_PTR; #define LPI2C_NACK_TOUT_MS 1 #define LPI2C_TIMEOUT_MS 100 +static int bus_i2c_init(struct udevice *bus, int speed); + /* Weak linked function for overridden by some SoC power function */ int __weak init_i2c_power(unsigned i2c_num) { @@ -168,7 +170,14 @@ static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir) result = imx_lpci2c_check_busy_bus(bus); if (result) { debug("i2c: start check busy bus: 0x%x\n", result); - return result; + + /* Try to init the lpi2c then check the bus busy again */ + bus_i2c_init(bus, 100000); + result = imx_lpci2c_check_busy_bus(bus); + if (result) { + printf("i2c: Error check busy bus: 0x%x\n", result); + return result; + } } /* clear all status flags */ writel(0x7f00, ®s->msr); -- cgit v1.2.3