All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 4/4] i2c: gpio: Run deblock sequence on probe
Date: Fri,  7 Feb 2020 16:57:52 +0100	[thread overview]
Message-ID: <20200207155752.40930-4-marex@denx.de> (raw)
In-Reply-To: <20200207155752.40930-1-marex@denx.de>

Add deblock dequence for the I2C bus, needed on some devices. This sequence
is issued once, when probing the driver, and is controlled by DT property,
"i2c-gpio,deblock".

Signed-off-by: Marek Vasut <marex@denx.de>
---
 drivers/i2c/i2c-gpio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c
index 4e8fa21473..b6b6ba9ee8 100644
--- a/drivers/i2c/i2c-gpio.c
+++ b/drivers/i2c/i2c-gpio.c
@@ -305,6 +305,20 @@ static int i2c_gpio_set_bus_speed(struct udevice *dev, unsigned int speed_hz)
 	return 0;
 }
 
+static int i2c_gpio_drv_probe(struct udevice *dev)
+{
+	if (dev_read_bool(dev, "i2c-gpio,deblock")) {
+		/* @200kHz 9 clocks = 44us, 62us is ok */
+		const unsigned int DELAY_ABORT_SEQ = 62;
+		struct i2c_gpio_bus *bus = dev_get_priv(dev);
+		return i2c_deblock_gpio_loop(&bus->gpios[PIN_SDA],
+					     &bus->gpios[PIN_SCL],
+					     16, 5, DELAY_ABORT_SEQ);
+	}
+
+	return 0;
+}
+
 static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 {
 	struct i2c_gpio_bus *bus = dev_get_priv(dev);
@@ -341,6 +355,7 @@ U_BOOT_DRIVER(i2c_gpio) = {
 	.name	= "i2c-gpio",
 	.id	= UCLASS_I2C,
 	.of_match = i2c_gpio_ids,
+	.probe	= i2c_gpio_drv_probe,
 	.ofdata_to_platdata = i2c_gpio_ofdata_to_platdata,
 	.priv_auto_alloc_size = sizeof(struct i2c_gpio_bus),
 	.ops	= &i2c_gpio_ops,
-- 
2.24.1

  parent reply	other threads:[~2020-02-07 15:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Marek Vasut [this message]
2020-02-18  7:11   ` [PATCH 4/4] i2c: gpio: Run deblock sequence on probe 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200207155752.40930-4-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.