From 615b9e45f5c93b27ff6487bb4100da529d72d0cd Mon Sep 17 00:00:00 2001 From: hgt463 Date: Wed, 6 Dec 2017 14:52:14 +0800 Subject: [PATCH] Driver updates: - In the case of I2C bus dead lock occurred during driver probing, it is better try to recovery it. so added bus recovery step in octeon_i2c_probe(); Signed-off-by: hgt463 --- drivers/i2c/busses/i2c-octeon-platdrv.c | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-octeon-platdrv.c b/drivers/i2c/busses/i2c-octeon-platdrv.c index 64bda83..f364ea2 100644 --- a/drivers/i2c/busses/i2c-octeon-platdrv.c +++ b/drivers/i2c/busses/i2c-octeon-platdrv.c @@ -228,12 +228,6 @@ static int octeon_i2c_probe(struct platform_device *pdev) if (OCTEON_IS_MODEL(OCTEON_CN38XX)) i2c->broken_irq_check = true; - result = octeon_i2c_init_lowlevel(i2c); - if (result) { - dev_err(i2c->dev, "init low level failed\n"); - goto out; - } - octeon_i2c_set_clock(i2c); i2c->adap = octeon_i2c_ops; @@ -245,6 +239,20 @@ static int octeon_i2c_probe(struct platform_device *pdev) i2c_set_adapdata(&i2c->adap, i2c); platform_set_drvdata(pdev, i2c); + /* + * Try to recover bus in three conditions: TWSI core status + * not IDLE, SDA stucked low or TWSI_CTL_IFLG not cleared + */ + if ((octeon_i2c_stat_read(i2c) != STAT_IDLE) || + !(octeon_i2c_read_int(i2c) & TWSI_INT_SDA_OVR) || + (octeon_i2c_ctl_read(i2c) & TWSI_CTL_IFLG)) { + result = octeon_i2c_recovery(i2c); + if (result) { + dev_err(i2c->dev, "octeon i2c recovery failed\n"); + goto out; + } + } + result = i2c_add_adapter(&i2c->adap); if (result < 0) goto out; -- 1.7.1