Commit ebd10e07 authored by Virupax Sadashivpetimath's avatar Virupax Sadashivpetimath Committed by Ben Dooks

i2c-nomadik: add code to retry on timeout failure

It is seen that i2c-nomadik controller randomly stops generating the
interrupts leading to a i2c timeout. As a workaround to this problem,
add retries to the on going transfer on failure.
Signed-off-by: default avatarVirupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Reviewed-by: default avatarJonas ABERG <jonas.aberg@stericsson.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
parent b0e751a9
...@@ -255,8 +255,6 @@ static int init_hw(struct nmk_i2c_dev *dev) ...@@ -255,8 +255,6 @@ static int init_hw(struct nmk_i2c_dev *dev)
{ {
int stat; int stat;
clk_enable(dev->clk);
stat = flush_i2c_fifo(dev); stat = flush_i2c_fifo(dev);
if (stat) if (stat)
goto exit; goto exit;
...@@ -271,8 +269,6 @@ static int init_hw(struct nmk_i2c_dev *dev) ...@@ -271,8 +269,6 @@ static int init_hw(struct nmk_i2c_dev *dev)
dev->cli.operation = I2C_NO_OPERATION; dev->cli.operation = I2C_NO_OPERATION;
exit: exit:
/* TODO: Why disable clocks after init hw? */
clk_disable(dev->clk);
/* /*
* TODO: What is this delay for? * TODO: What is this delay for?
* Must be pretty pointless since the hw block * Must be pretty pointless since the hw block
...@@ -572,6 +568,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -572,6 +568,7 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
u32 cause; u32 cause;
struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap); struct nmk_i2c_dev *dev = i2c_get_adapdata(i2c_adap);
u32 i2c_sr; u32 i2c_sr;
int j;
dev->busy = true; dev->busy = true;
...@@ -579,12 +576,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -579,12 +576,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
regulator_enable(dev->regulator); regulator_enable(dev->regulator);
pm_runtime_get_sync(&dev->pdev->dev); pm_runtime_get_sync(&dev->pdev->dev);
clk_enable(dev->clk);
status = init_hw(dev); status = init_hw(dev);
if (status) if (status)
goto out2; goto out;
clk_enable(dev->clk);
for (j = 0; j < 3; j++) {
/* setup the i2c controller */ /* setup the i2c controller */
setup_i2c_controller(dev); setup_i2c_controller(dev);
...@@ -614,28 +612,31 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -614,28 +612,31 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
if (status || (dev->result)) { if (status || (dev->result)) {
i2c_sr = readl(dev->virtbase + I2C_SR); i2c_sr = readl(dev->virtbase + I2C_SR);
/* /*
* Check if the controller I2C operation status is set * Check if the controller I2C operation status
* to ABORT(11b). * is set to ABORT(11b).
*/ */
if (((i2c_sr >> 2) & 0x3) == 0x3) { if (((i2c_sr >> 2) & 0x3) == 0x3) {
/* get the abort cause */ /* get the abort cause */
cause = (i2c_sr >> 4) cause = (i2c_sr >> 4)
& 0x7; & 0x7;
dev_err(&dev->pdev->dev, "%s\n", cause >= dev_err(&dev->pdev->dev, "%s\n", cause
ARRAY_SIZE(abort_causes) ? >= ARRAY_SIZE(abort_causes) ?
"unknown reason" : "unknown reason" :
abort_causes[cause]); abort_causes[cause]);
} }
status = status ? status : dev->result; status = status ? status : dev->result;
goto out;
break;
} }
udelay(I2C_DELAY); udelay(I2C_DELAY);
} }
if (status == 0)
break;
}
out: out:
clk_disable(dev->clk); clk_disable(dev->clk);
out2:
pm_runtime_put_sync(&dev->pdev->dev); pm_runtime_put_sync(&dev->pdev->dev);
if (dev->regulator) if (dev->regulator)
regulator_disable(dev->regulator); regulator_disable(dev->regulator);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment