All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: i2c-gpio: add support for clock stretching
@ 2020-01-23 22:30 Michael Auchter
  2020-01-27  7:00 ` Heiko Schocher
  2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
  0 siblings, 2 replies; 8+ messages in thread
From: Michael Auchter @ 2020-01-23 22:30 UTC (permalink / raw)
  To: u-boot

This adds support for clock stretching to the i2c-gpio driver. This is
accomplished by switching the GPIO used for the SCL line to an input
when it should be driven high, and polling on the SCL line value until
it goes high (indicating that the I2C slave is no longer pulling it
low).

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Cc: Heiko Schocher <hs@denx.de>
---
 drivers/i2c/i2c-gpio.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 4e8fa21473..80ac26e583 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -49,11 +49,18 @@ static void i2c_gpio_sda_set(struct gpio_desc *sda, int bit)
 
 static void i2c_gpio_scl_set(struct gpio_desc *scl, int bit)
 {
-	ulong flags = GPIOD_IS_OUT;
+	int count = 0;
 
-	if (bit)
-		flags |= GPIOD_IS_OUT_ACTIVE;
-	dm_gpio_set_dir_flags(scl, flags);
+	if (bit) {
+		dm_gpio_set_dir_flags(scl, GPIOD_IS_IN);
+		while (!dm_gpio_get_value(scl) && count++ < 100000)
+			udelay(1);
+
+		if (!dm_gpio_get_value(scl))
+			pr_err("timeout waiting on slave to release scl\n");
+	} else {
+		dm_gpio_set_dir_flags(scl, GPIOD_IS_OUT);
+	}
 }
 
 static void i2c_gpio_write_bit(struct gpio_desc *scl, struct gpio_desc *sda,
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] dm: i2c-gpio: add support for clock stretching
  2020-01-23 22:30 [PATCH] dm: i2c-gpio: add support for clock stretching Michael Auchter
@ 2020-01-27  7:00 ` Heiko Schocher
  2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
  1 sibling, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2020-01-27  7:00 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 23.01.2020 um 23:30 schrieb Michael Auchter:
> This adds support for clock stretching to the i2c-gpio driver. This is
> accomplished by switching the GPIO used for the SCL line to an input
> when it should be driven high, and polling on the SCL line value until
> it goes high (indicating that the I2C slave is no longer pulling it
> low).
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   drivers/i2c/i2c-gpio.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
> index 4e8fa21473..80ac26e583 100644
> --- a/drivers/i2c/i2c-gpio.c
> +++ b/drivers/i2c/i2c-gpio.c
> @@ -49,11 +49,18 @@ static void i2c_gpio_sda_set(struct gpio_desc *sda, int bit)
>   
>   static void i2c_gpio_scl_set(struct gpio_desc *scl, int bit)
>   {
> -	ulong flags = GPIOD_IS_OUT;
> +	int count = 0;
>   
> -	if (bit)
> -		flags |= GPIOD_IS_OUT_ACTIVE;
> -	dm_gpio_set_dir_flags(scl, flags);
> +	if (bit) {
> +		dm_gpio_set_dir_flags(scl, GPIOD_IS_IN);
> +		while (!dm_gpio_get_value(scl) && count++ < 100000)
> +			udelay(1);
> +
> +		if (!dm_gpio_get_value(scl))
> +			pr_err("timeout waiting on slave to release scl\n");
> +	} else {
> +		dm_gpio_set_dir_flags(scl, GPIOD_IS_OUT);
> +	}
>   }
>   
>   static void i2c_gpio_write_bit(struct gpio_desc *scl, struct gpio_desc *sda,
> 

In principle I would say Ok, but your patch changes behaviour for
all boards which use this driver currently ...

May they cannot reread the gpio ... we have no scl_get() yet!

So please, make this change dependend on linux property "i2c-gpio,scl-output-only"
see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/i2c/i2c-gpio.yaml#n36

As an example in linux:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-gpio.c#n317

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/algos/i2c-algo-bit.c#n75

So at least, we have the chance to switch back to old behaviour by adding
this (new for U-Boot) property.

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions
  2020-01-23 22:30 [PATCH] dm: i2c-gpio: add support for clock stretching Michael Auchter
  2020-01-27  7:00 ` Heiko Schocher
@ 2020-02-07 16:55 ` Michael Auchter
  2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Michael Auchter @ 2020-02-07 16:55 UTC (permalink / raw)
  To: u-boot

This patch reworks i2c-gpio to make it easier to switch out the
implementation of the sda/scl get/set functions. This is in preparation
for a patch to conditionally implement clock stretching support.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Cc: Heiko Schocher <hs@denx.de>
---
 drivers/i2c/i2c-gpio.c | 133 ++++++++++++++++++++---------------------
 1 file changed, 64 insertions(+), 69 deletions(-)

diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 4e8fa21473..d989449513 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -32,23 +32,32 @@ struct i2c_gpio_bus {
 	int udelay;
 	 /* sda, scl */
 	struct gpio_desc gpios[PIN_COUNT];
+
+	int (*get_sda)(struct i2c_gpio_bus *bus);
+	void (*set_sda)(struct i2c_gpio_bus *bus, int bit);
+	void (*set_scl)(struct i2c_gpio_bus *bus, int bit);
 };
 
-static int i2c_gpio_sda_get(struct gpio_desc *sda)
+static int i2c_gpio_sda_get(struct i2c_gpio_bus *bus)
 {
+	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
+
 	return dm_gpio_get_value(sda);
 }
 
-static void i2c_gpio_sda_set(struct gpio_desc *sda, int bit)
+static void i2c_gpio_sda_set(struct i2c_gpio_bus *bus, int bit)
 {
+	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
+
 	if (bit)
 		dm_gpio_set_dir_flags(sda, GPIOD_IS_IN);
 	else
 		dm_gpio_set_dir_flags(sda, GPIOD_IS_OUT);
 }
 
-static void i2c_gpio_scl_set(struct gpio_desc *scl, int bit)
+static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit)
 {
+	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
 	ulong flags = GPIOD_IS_OUT;
 
 	if (bit)
@@ -56,65 +65,60 @@ static void i2c_gpio_scl_set(struct gpio_desc *scl, int bit)
 	dm_gpio_set_dir_flags(scl, flags);
 }
 
-static void i2c_gpio_write_bit(struct gpio_desc *scl, struct gpio_desc *sda,
-			       int delay, uchar bit)
+static void i2c_gpio_write_bit(struct i2c_gpio_bus *bus, int delay, uchar bit)
 {
-	i2c_gpio_scl_set(scl, 0);
+	bus->set_scl(bus, 0);
 	udelay(delay);
-	i2c_gpio_sda_set(sda, bit);
+	bus->set_sda(bus, bit);
 	udelay(delay);
-	i2c_gpio_scl_set(scl, 1);
+	bus->set_scl(bus, 1);
 	udelay(2 * delay);
 }
 
-static int i2c_gpio_read_bit(struct gpio_desc *scl, struct gpio_desc *sda,
-			     int delay)
+static int i2c_gpio_read_bit(struct i2c_gpio_bus *bus, int delay)
 {
 	int value;
 
-	i2c_gpio_scl_set(scl, 1);
+	bus->set_scl(bus, 1);
 	udelay(delay);
-	value = i2c_gpio_sda_get(sda);
+	value = bus->get_sda(bus);
 	udelay(delay);
-	i2c_gpio_scl_set(scl, 0);
+	bus->set_scl(bus, 0);
 	udelay(2 * delay);
 
 	return value;
 }
 
 /* START: High -> Low on SDA while SCL is High */
-static void i2c_gpio_send_start(struct gpio_desc *scl, struct gpio_desc *sda,
-				int delay)
+static void i2c_gpio_send_start(struct i2c_gpio_bus *bus, int delay)
 {
 	udelay(delay);
-	i2c_gpio_sda_set(sda, 1);
+	bus->set_sda(bus, 1);
 	udelay(delay);
-	i2c_gpio_scl_set(scl, 1);
+	bus->set_scl(bus, 1);
 	udelay(delay);
-	i2c_gpio_sda_set(sda, 0);
+	bus->set_sda(bus, 0);
 	udelay(delay);
 }
 
 /* STOP: Low -> High on SDA while SCL is High */
-static void i2c_gpio_send_stop(struct gpio_desc *scl, struct gpio_desc *sda,
-			       int delay)
+static void i2c_gpio_send_stop(struct i2c_gpio_bus *bus, int delay)
 {
-	i2c_gpio_scl_set(scl, 0);
+	bus->set_scl(bus, 0);
 	udelay(delay);
-	i2c_gpio_sda_set(sda, 0);
+	bus->set_sda(bus, 0);
 	udelay(delay);
-	i2c_gpio_scl_set(scl, 1);
+	bus->set_scl(bus, 1);
 	udelay(delay);
-	i2c_gpio_sda_set(sda, 1);
+	bus->set_sda(bus, 1);
 	udelay(delay);
 }
 
 /* ack should be I2C_ACK or I2C_NOACK */
-static void i2c_gpio_send_ack(struct gpio_desc *scl, struct gpio_desc *sda,
-			      int delay, int ack)
+static void i2c_gpio_send_ack(struct i2c_gpio_bus *bus, int delay, int ack)
 {
-	i2c_gpio_write_bit(scl, sda, delay, ack);
-	i2c_gpio_scl_set(scl, 0);
+	i2c_gpio_write_bit(bus, delay, ack);
+	bus->set_scl(bus, 0);
 	udelay(delay);
 }
 
@@ -123,44 +127,41 @@ static void i2c_gpio_send_ack(struct gpio_desc *scl, struct gpio_desc *sda,
  * to clock any confused device back into an idle state.  Also send a
  * <stop> at the end of the sequence for belts & suspenders.
  */
-static void i2c_gpio_send_reset(struct gpio_desc *scl, struct gpio_desc *sda,
-				int delay)
+static void i2c_gpio_send_reset(struct i2c_gpio_bus *bus, int delay)
 {
 	int j;
 
 	for (j = 0; j < 9; j++)
-		i2c_gpio_write_bit(scl, sda, delay, 1);
+		i2c_gpio_write_bit(bus, delay, 1);
 
-	i2c_gpio_send_stop(scl, sda, delay);
+	i2c_gpio_send_stop(bus, delay);
 }
 
 /* Set sda high with low clock, before reading slave data */
-static void i2c_gpio_sda_high(struct gpio_desc *scl, struct gpio_desc *sda,
-			      int delay)
+static void i2c_gpio_sda_high(struct i2c_gpio_bus *bus, int delay)
 {
-	i2c_gpio_scl_set(scl, 0);
+	bus->set_scl(bus, 0);
 	udelay(delay);
-	i2c_gpio_sda_set(sda, 1);
+	bus->set_sda(bus, 1);
 	udelay(delay);
 }
 
 /* Send 8 bits and look for an acknowledgement */
-static int i2c_gpio_write_byte(struct gpio_desc *scl, struct gpio_desc *sda,
-			       int delay, uchar data)
+static int i2c_gpio_write_byte(struct i2c_gpio_bus *bus, int delay, uchar data)
 {
 	int j;
 	int nack;
 
 	for (j = 0; j < 8; j++) {
-		i2c_gpio_write_bit(scl, sda, delay, data & 0x80);
+		i2c_gpio_write_bit(bus, delay, data & 0x80);
 		data <<= 1;
 	}
 
 	udelay(delay);
 
 	/* Look for an <ACK>(negative logic) and return it */
-	i2c_gpio_sda_high(scl, sda, delay);
-	nack = i2c_gpio_read_bit(scl, sda, delay);
+	i2c_gpio_sda_high(bus, delay);
+	nack = i2c_gpio_read_bit(bus, delay);
 
 	return nack;	/* not a nack is an ack */
 }
@@ -169,31 +170,29 @@ static int i2c_gpio_write_byte(struct gpio_desc *scl, struct gpio_desc *sda,
  * if ack == I2C_ACK, ACK the byte so can continue reading, else
  * send I2C_NOACK to end the read.
  */
-static uchar i2c_gpio_read_byte(struct gpio_desc *scl, struct gpio_desc *sda,
-				int delay, int ack)
+static uchar i2c_gpio_read_byte(struct i2c_gpio_bus *bus, int delay, int ack)
 {
 	int  data;
 	int  j;
 
-	i2c_gpio_sda_high(scl, sda, delay);
+	i2c_gpio_sda_high(bus, delay);
 	data = 0;
 	for (j = 0; j < 8; j++) {
 		data <<= 1;
-		data |= i2c_gpio_read_bit(scl, sda, delay);
+		data |= i2c_gpio_read_bit(bus, delay);
 	}
-	i2c_gpio_send_ack(scl, sda, delay, ack);
+	i2c_gpio_send_ack(bus, delay, ack);
 
 	return data;
 }
 
 /* send start and the slave chip address */
-int i2c_send_slave_addr(struct gpio_desc *scl, struct gpio_desc *sda, int delay,
-			uchar chip)
+int i2c_send_slave_addr(struct i2c_gpio_bus *bus, int delay, uchar chip)
 {
-	i2c_gpio_send_start(scl, sda, delay);
+	i2c_gpio_send_start(bus, delay);
 
-	if (i2c_gpio_write_byte(scl, sda, delay, chip)) {
-		i2c_gpio_send_stop(scl, sda, delay);
+	if (i2c_gpio_write_byte(bus, delay, chip)) {
+		i2c_gpio_send_stop(bus, delay);
 		return -EIO;
 	}
 
@@ -204,29 +203,27 @@ static int i2c_gpio_write_data(struct i2c_gpio_bus *bus, uchar chip,
 			       uchar *buffer, int len,
 			       bool end_with_repeated_start)
 {
-	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
-	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
 	unsigned int delay = bus->udelay;
 	int failures = 0;
 
 	debug("%s: chip %x buffer %p len %d\n", __func__, chip, buffer, len);
 
-	if (i2c_send_slave_addr(scl, sda, delay, chip << 1)) {
+	if (i2c_send_slave_addr(bus, delay, chip << 1)) {
 		debug("i2c_write, no chip responded %02X\n", chip);
 		return -EIO;
 	}
 
 	while (len-- > 0) {
-		if (i2c_gpio_write_byte(scl, sda, delay, *buffer++))
+		if (i2c_gpio_write_byte(bus, delay, *buffer++))
 			failures++;
 	}
 
 	if (!end_with_repeated_start) {
-		i2c_gpio_send_stop(scl, sda, delay);
+		i2c_gpio_send_stop(bus, delay);
 		return failures;
 	}
 
-	if (i2c_send_slave_addr(scl, sda, delay, (chip << 1) | 0x1)) {
+	if (i2c_send_slave_addr(bus, delay, (chip << 1) | 0x1)) {
 		debug("i2c_write, no chip responded %02X\n", chip);
 		return -EIO;
 	}
@@ -237,16 +234,14 @@ static int i2c_gpio_write_data(struct i2c_gpio_bus *bus, uchar chip,
 static int i2c_gpio_read_data(struct i2c_gpio_bus *bus, uchar chip,
 			      uchar *buffer, int len)
 {
-	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
-	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
 	unsigned int delay = bus->udelay;
 
 	debug("%s: chip %x buffer: %p len %d\n", __func__, chip, buffer, len);
 
 	while (len-- > 0)
-		*buffer++ = i2c_gpio_read_byte(scl, sda, delay, len == 0);
+		*buffer++ = i2c_gpio_read_byte(bus, delay, len == 0);
 
-	i2c_gpio_send_stop(scl, sda, delay);
+	i2c_gpio_send_stop(bus, delay);
 
 	return 0;
 }
@@ -277,14 +272,12 @@ static int i2c_gpio_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs)
 static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)
 {
 	struct i2c_gpio_bus *bus = dev_get_priv(dev);
-	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
-	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
 	unsigned int delay = bus->udelay;
 	int ret;
 
-	i2c_gpio_send_start(scl, sda, delay);
-	ret = i2c_gpio_write_byte(scl, sda, delay, (chip << 1) | 0);
-	i2c_gpio_send_stop(scl, sda, delay);
+	i2c_gpio_send_start(bus, delay);
+	ret = i2c_gpio_write_byte(bus, delay, (chip << 1) | 0);
+	i2c_gpio_send_stop(bus, delay);
 
 	debug("%s: bus: %d (%s) chip: %x flags: %x ret: %d\n",
 	      __func__, dev->seq, dev->name, chip, chip_flags, ret);
@@ -295,12 +288,10 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags)
 static int i2c_gpio_set_bus_speed(struct udevice *dev, unsigned int speed_hz)
 {
 	struct i2c_gpio_bus *bus = dev_get_priv(dev);
-	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
-	struct gpio_desc *sda = &bus->gpios[PIN_SDA];
 
 	bus->udelay = 1000000 / (speed_hz << 2);
 
-	i2c_gpio_send_reset(scl, sda, bus->udelay);
+	i2c_gpio_send_reset(bus, bus->udelay);
 
 	return 0;
 }
@@ -320,6 +311,10 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 	bus->udelay = fdtdec_get_int(blob, node, "i2c-gpio,delay-us",
 				     DEFAULT_UDELAY);
 
+	bus->get_sda = i2c_gpio_sda_get;
+	bus->set_sda = i2c_gpio_sda_set;
+	bus->set_scl = i2c_gpio_scl_set;
+
 	return 0;
 error:
 	pr_err("Can't get %s gpios! Error: %d", dev->name, ret);
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] dm: i2c-gpio: add support for clock stretching
  2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
@ 2020-02-07 16:55   ` Michael Auchter
  2020-02-18  7:20     ` Heiko Schocher
  2020-03-17  5:12     ` Heiko Schocher
  2020-02-18  7:19   ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Heiko Schocher
  2020-03-17  5:12   ` Heiko Schocher
  2 siblings, 2 replies; 8+ messages in thread
From: Michael Auchter @ 2020-02-07 16:55 UTC (permalink / raw)
  To: u-boot

This adds support for clock stretching to the i2c-gpio driver. This is
accomplished by switching the GPIO used for the SCL line to an input
when it should be driven high, and polling on the SCL line value until
it goes high (indicating that the I2C slave is no longer pulling it
low).

This is enabled by default; for gpios which cannot be configured as
inputs, the i2c-gpio,scl-output-only property can be used to fall back
to the previous behavior.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Cc: Heiko Schocher <hs@denx.de>
---
 doc/device-tree-bindings/i2c/i2c-gpio.txt |  2 ++
 drivers/i2c/i2c-gpio.c                    | 23 ++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/i2c/i2c-gpio.txt b/doc/device-tree-bindings/i2c/i2c-gpio.txt
index ba56ed5dea..36910d26a9 100644
--- a/doc/device-tree-bindings/i2c/i2c-gpio.txt
+++ b/doc/device-tree-bindings/i2c/i2c-gpio.txt
@@ -16,6 +16,8 @@ Optional:
    The resulting transfer speed can be adjusted by setting the delay[us]
    between gpio-toggle operations. Speed [Hz] = 1000000 / 4 * udelay[us],
    It not defined, then default is 5us (~50KHz).
+* i2c-gpio,scl-output-only;
+   Set if SCL is an output only
 
 Example:
 
diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index d989449513..8a8d1ff21b 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -56,6 +56,24 @@ static void i2c_gpio_sda_set(struct i2c_gpio_bus *bus, int bit)
 }
 
 static void i2c_gpio_scl_set(struct i2c_gpio_bus *bus, int bit)
+{
+	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
+	int count = 0;
+
+	if (bit) {
+		dm_gpio_set_dir_flags(scl, GPIOD_IS_IN);
+		while (!dm_gpio_get_value(scl) && count++ < 100000)
+			udelay(1);
+
+		if (!dm_gpio_get_value(scl))
+			pr_err("timeout waiting on slave to release scl\n");
+	} else {
+		dm_gpio_set_dir_flags(scl, GPIOD_IS_OUT);
+	}
+}
+
+/* variant for output only gpios which cannot support clock stretching */
+static void i2c_gpio_scl_set_output_only(struct i2c_gpio_bus *bus, int bit)
 {
 	struct gpio_desc *scl = &bus->gpios[PIN_SCL];
 	ulong flags = GPIOD_IS_OUT;
@@ -313,7 +331,10 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 
 	bus->get_sda = i2c_gpio_sda_get;
 	bus->set_sda = i2c_gpio_sda_set;
-	bus->set_scl = i2c_gpio_scl_set;
+	if (fdtdec_get_bool(blob, node, "i2c-gpio,scl-output-only"))
+		bus->set_scl = i2c_gpio_scl_set_output_only;
+	else
+		bus->set_scl = i2c_gpio_scl_set;
 
 	return 0;
 error:
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions
  2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
  2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
@ 2020-02-18  7:19   ` Heiko Schocher
  2020-03-17  5:12   ` Heiko Schocher
  2 siblings, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2020-02-18  7:19 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 07.02.2020 um 17:55 schrieb Michael Auchter:
> This patch reworks i2c-gpio to make it easier to switch out the
> implementation of the sda/scl get/set functions. This is in preparation
> for a patch to conditionally implement clock stretching support.
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   drivers/i2c/i2c-gpio.c | 133 ++++++++++++++++++++---------------------
>   1 file changed, 64 insertions(+), 69 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] dm: i2c-gpio: add support for clock stretching
  2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
@ 2020-02-18  7:20     ` Heiko Schocher
  2020-03-17  5:12     ` Heiko Schocher
  1 sibling, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2020-02-18  7:20 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 07.02.2020 um 17:55 schrieb Michael Auchter:
> This adds support for clock stretching to the i2c-gpio driver. This is
> accomplished by switching the GPIO used for the SCL line to an input
> when it should be driven high, and polling on the SCL line value until
> it goes high (indicating that the I2C slave is no longer pulling it
> low).
> 
> This is enabled by default; for gpios which cannot be configured as
> inputs, the i2c-gpio,scl-output-only property can be used to fall back
> to the previous behavior.
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   doc/device-tree-bindings/i2c/i2c-gpio.txt |  2 ++
>   drivers/i2c/i2c-gpio.c                    | 23 ++++++++++++++++++++++-
>   2 files changed, 24 insertions(+), 1 deletion(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions
  2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
  2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
  2020-02-18  7:19   ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Heiko Schocher
@ 2020-03-17  5:12   ` Heiko Schocher
  2 siblings, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2020-03-17  5:12 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 07.02.2020 um 17:55 schrieb Michael Auchter:
> This patch reworks i2c-gpio to make it easier to switch out the
> implementation of the sda/scl get/set functions. This is in preparation
> for a patch to conditionally implement clock stretching support.
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   drivers/i2c/i2c-gpio.c | 133 ++++++++++++++++++++---------------------
>   1 file changed, 64 insertions(+), 69 deletions(-)

Applied to u-boot-i2c next, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] dm: i2c-gpio: add support for clock stretching
  2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
  2020-02-18  7:20     ` Heiko Schocher
@ 2020-03-17  5:12     ` Heiko Schocher
  1 sibling, 0 replies; 8+ messages in thread
From: Heiko Schocher @ 2020-03-17  5:12 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 07.02.2020 um 17:55 schrieb Michael Auchter:
> This adds support for clock stretching to the i2c-gpio driver. This is
> accomplished by switching the GPIO used for the SCL line to an input
> when it should be driven high, and polling on the SCL line value until
> it goes high (indicating that the I2C slave is no longer pulling it
> low).
> 
> This is enabled by default; for gpios which cannot be configured as
> inputs, the i2c-gpio,scl-output-only property can be used to fall back
> to the previous behavior.
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   doc/device-tree-bindings/i2c/i2c-gpio.txt |  2 ++
>   drivers/i2c/i2c-gpio.c                    | 23 ++++++++++++++++++++++-
>   2 files changed, 24 insertions(+), 1 deletion(-)

Applied to u-boot-i2c next, thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-17  5:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-23 22:30 [PATCH] dm: i2c-gpio: add support for clock stretching Michael Auchter
2020-01-27  7:00 ` Heiko Schocher
2020-02-07 16:55 ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Michael Auchter
2020-02-07 16:55   ` [PATCH 2/2] dm: i2c-gpio: add support for clock stretching Michael Auchter
2020-02-18  7:20     ` Heiko Schocher
2020-03-17  5:12     ` Heiko Schocher
2020-02-18  7:19   ` [PATCH 1/2] dm: i2c-gpio: rework gpio get/set functions Heiko Schocher
2020-03-17  5:12   ` Heiko Schocher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.