| From 582a4447399c7e6f653df70f35b80777a906ce88 Mon Sep 17 00:00:00 2001 |
| From: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| Date: Tue, 9 Jan 2018 14:58:58 +0100 |
| Subject: [PATCH 0775/1795] i2c: send STOP after successful bus recovery |
| |
| If we managed to get a client release SDA again, send a STOP afterwards |
| to make sure we have a consistent state on the bus again. |
| |
| Tested-by: Phil Reid <preid@electromag.com.au> |
| Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| Signed-off-by: Wolfram Sang <wsa@the-dreams.de> |
| (cherry picked from commit 2806e6ad77c71dd2538cb698aad476e8cf3af004) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> |
| --- |
| drivers/i2c/i2c-core-base.c | 12 ++++++++++++ |
| 1 file changed, 12 insertions(+) |
| |
| diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c |
| index 1b67768f01b2..b9f39122a059 100644 |
| --- a/drivers/i2c/i2c-core-base.c |
| +++ b/drivers/i2c/i2c-core-base.c |
| @@ -238,6 +238,18 @@ static int i2c_generic_recovery(struct i2c_adapter *adap) |
| if (bri->get_sda && !bri->get_sda(adap)) |
| ret = -EBUSY; |
| |
| + /* If all went well, send STOP for a sane bus state. */ |
| + if (ret == 0 && bri->set_sda) { |
| + bri->set_scl(adap, 0); |
| + ndelay(RECOVERY_NDELAY / 2); |
| + bri->set_sda(adap, 0); |
| + ndelay(RECOVERY_NDELAY / 2); |
| + bri->set_scl(adap, 1); |
| + ndelay(RECOVERY_NDELAY / 2); |
| + bri->set_sda(adap, 1); |
| + ndelay(RECOVERY_NDELAY / 2); |
| + } |
| + |
| if (bri->unprepare_recovery) |
| bri->unprepare_recovery(adap); |
| |
| -- |
| 2.19.0 |
| |