All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] i2c: Make deblock delay and SCL clock configurable
@ 2020-02-07 15:57 Marek Vasut
  2020-02-07 15:57 ` [PATCH 2/4] i2c: Export i2c_deblock_gpio_loop() Marek Vasut
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Marek Vasut @ 2020-02-07 15:57 UTC (permalink / raw)
  To: u-boot

Make the delay between SCL line changes and the number of SCL clock
changes configurable as a parameter of the deblock function. No
functional change.

Signed-off-by: Marek Vasut <marex@denx.de>
---
 drivers/i2c/i2c-uclass.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 2aa3efe8aa..25af1fabdb 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -502,34 +502,35 @@ static int i2c_gpio_get_pin(struct gpio_desc *pin)
 }
 
 static int i2c_deblock_gpio_loop(struct gpio_desc *sda_pin,
-				 struct gpio_desc *scl_pin)
+				 struct gpio_desc *scl_pin,
+				 unsigned int scl_count,
+				 unsigned int delay)
 {
-	int counter = 9;
 	int ret = 0;
 
 	i2c_gpio_set_pin(sda_pin, 1);
 	i2c_gpio_set_pin(scl_pin, 1);
-	udelay(5);
+	udelay(delay);
 
 	/*  Toggle SCL until slave release SDA */
-	while (counter-- >= 0) {
+	while (scl_count-- >= 0) {
 		i2c_gpio_set_pin(scl_pin, 1);
-		udelay(5);
+		udelay(delay);
 		i2c_gpio_set_pin(scl_pin, 0);
-		udelay(5);
+		udelay(delay);
 		if (i2c_gpio_get_pin(sda_pin))
 			break;
 	}
 
 	/* Then, send I2C stop */
 	i2c_gpio_set_pin(sda_pin, 0);
-	udelay(5);
+	udelay(delay);
 
 	i2c_gpio_set_pin(scl_pin, 1);
-	udelay(5);
+	udelay(delay);
 
 	i2c_gpio_set_pin(sda_pin, 1);
-	udelay(5);
+	udelay(delay);
 
 	if (!i2c_gpio_get_pin(sda_pin) || !i2c_gpio_get_pin(scl_pin))
 		ret = -EREMOTEIO;
@@ -561,7 +562,7 @@ static int i2c_deblock_gpio(struct udevice *bus)
 		goto out_no_pinctrl;
 	}
 
-	ret0 = i2c_deblock_gpio_loop(&gpios[PIN_SDA], &gpios[PIN_SCL]);
+	ret0 = i2c_deblock_gpio_loop(&gpios[PIN_SDA], &gpios[PIN_SCL], 9, 5);
 
 	ret = pinctrl_select_state(bus, "default");
 	if (ret) {
-- 
2.24.1

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

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

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 15:57 [PATCH 1/4] i2c: Make deblock delay and SCL clock configurable Marek Vasut
2020-02-07 15:57 ` [PATCH 2/4] i2c: Export i2c_deblock_gpio_loop() Marek Vasut
2020-02-18  7:05   ` Heiko Schocher
2020-03-17  5:10   ` Heiko Schocher
2020-02-07 15:57 ` [PATCH 3/4] i2c: Add option to send start condition after deblocking Marek Vasut
2020-02-18  7:07   ` Heiko Schocher
2020-02-18 17:21     ` Marek Vasut
2020-03-17  5:11   ` Heiko Schocher
2020-02-07 15:57 ` [PATCH 4/4] i2c: gpio: Run deblock sequence on probe Marek Vasut
2020-02-18  7:11   ` Heiko Schocher
2020-02-18 17:25     ` Marek Vasut
2020-03-17  5:11   ` Heiko Schocher
2020-02-18  7:04 ` [PATCH 1/4] i2c: Make deblock delay and SCL clock configurable Heiko Schocher
2020-03-17  5:10 ` 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.