aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2018-07-17 11:00:05 +0200
committerSimon Horman <horms+renesas@verge.net.au>2018-08-09 17:21:46 +0200
commit83d60b9c20b5192c77168ec0389ca6d7f2a53f40 (patch)
tree08375fe0532e411fe31081a0864cd60fe8910b66
parent67e73a8de8a2828661ba8c4e048e92bc183624ad (diff)
downloadrenesas-backport-83d60b9c20b5192c77168ec0389ca6d7f2a53f40.tar.gz
i2c: recovery: make pin init look like STOP
When we initialize the pins, make sure it looks like STOP by dividing the delay into halves. It shouldn't matter because SDA is expected to be held low by a device, but for super-safety, let's do it. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com> Reviewed-by: Peter Rosin <peda@axentia.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> (cherry picked from commit c4ae05b976b2a67fb24f35d21731b4da2c235bbf) Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
-rw-r--r--drivers/i2c/i2c-core-base.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index ba113c44aab008..eefa1faf3d26e9 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -224,10 +224,17 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
if (bri->prepare_recovery)
bri->prepare_recovery(adap);
+ /*
+ * If we can set SDA, we will always create a STOP to ensure additional
+ * pulses will do no harm. This is achieved by letting SDA follow SCL
+ * half a cycle later. Check the 'incomplete_write_byte' fault injector
+ * for details.
+ */
bri->set_scl(adap, scl);
+ ndelay(RECOVERY_NDELAY / 2);
if (bri->set_sda)
- bri->set_sda(adap, 1);
- ndelay(RECOVERY_NDELAY);
+ bri->set_sda(adap, scl);
+ ndelay(RECOVERY_NDELAY / 2);
/*
* By this time SCL is high, as we need to give 9 falling-rising edges
@@ -245,13 +252,7 @@ static int i2c_generic_recovery(struct i2c_adapter *adap)
scl = !scl;
bri->set_scl(adap, scl);
-
- /*
- * If we can set SDA, we will always create STOP here to ensure
- * the additional pulses will do no harm. This is achieved by
- * letting SDA follow SCL half a cycle later. Check the
- * 'incomplete_write_byte' fault injector for details.
- */
+ /* Creating STOP again, see above */
ndelay(RECOVERY_NDELAY / 2);
if (bri->set_sda)
bri->set_sda(adap, scl);