summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2018-01-09 14:58:56 +0100
committerWolfram Sang <wsa@the-dreams.de>2018-01-16 00:04:19 +0100
commit8092178ffe67dbd1f987e2e308e871c774774a16 (patch)
treece87bba0677a51c8727e8a6d712e1b7125733796 /drivers/i2c
parent6c92204e446694306198c7c394f3692bde46b696 (diff)
downloadlinux-8092178ffe67dbd1f987e2e308e871c774774a16.tar.gz
linux-8092178ffe67dbd1f987e2e308e871c774774a16.tar.bz2
linux-8092178ffe67dbd1f987e2e308e871c774774a16.zip
i2c: add 'set_sda' to bus_recovery_info
This will be needed when we want to create STOP conditions, too, later. Create the needed fields and populate them for the GPIO case if the GPIO is set to output. Tested-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core-base.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index bb34a5d41133..a8b3fbe16fa0 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -147,6 +147,11 @@ static int get_sda_gpio_value(struct i2c_adapter *adap)
return gpiod_get_value_cansleep(adap->bus_recovery_info->sda_gpiod);
}
+static void set_sda_gpio_value(struct i2c_adapter *adap, int val)
+{
+ gpiod_set_value_cansleep(adap->bus_recovery_info->sda_gpiod, val);
+}
+
/*
* We are generating clock pulses. ndelay() determines durating of clk pulses.
* We will generate clock with rate 100 KHz and so duration of both clock levels
@@ -225,8 +230,12 @@ static void i2c_init_recovery(struct i2c_adapter *adap)
if (bri->scl_gpiod && bri->recover_bus == i2c_generic_scl_recovery) {
bri->get_scl = get_scl_gpio_value;
bri->set_scl = set_scl_gpio_value;
- if (bri->sda_gpiod)
+ if (bri->sda_gpiod) {
bri->get_sda = get_sda_gpio_value;
+ /* FIXME: add proper flag instead of '0' once available */
+ if (gpiod_get_direction(bri->sda_gpiod) == 0)
+ bri->set_sda = set_sda_gpio_value;
+ }
return;
}