summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-01-10 02:42:39 -0600
committerYe Li <ye.li@nxp.com>2018-01-10 03:12:08 -0600
commit12f5bd4c29d5da7d00fdcf82a29b4fc319c62758 (patch)
treef3eb0f1b3e448b62f420ff06e4f01b60494a577e
parent8b6b4eb9086292143d0451f0e50eeb75a2e9ca81 (diff)
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 <ye.li@nxp.com> Acked-by: Peng Fan <peng.fan@nxp.com> (cherry picked from commit 6b4021d04c7f637fd60cf73f9cc46fdebc853790)
-rw-r--r--drivers/i2c/imx_lpi2c.c11
1 files changed, 10 insertions, 1 deletions
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, &regs->msr);