MLK-17357-2 lpi2c: Add bus busy error handling
authorYe Li <ye.li@nxp.com>
Wed, 10 Jan 2018 08:42:39 +0000 (02:42 -0600)
committerYe Li <ye.li@nxp.com>
Wed, 10 Jan 2018 09:08:15 +0000 (03:08 -0600)
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 <ye.li@nxp.com>
Acked-by: Peng Fan <peng.fan@nxp.com>
drivers/i2c/imx_lpi2c.c

index e159e33..018b2b6 100644 (file)
@@ -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, &regs->msr);