]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: gpio: Run deblock sequence on probe
authorMarek Vasut <marex@denx.de>
Fri, 7 Feb 2020 15:57:52 +0000 (16:57 +0100)
committerHeiko Schocher <hs@denx.de>
Mon, 16 Mar 2020 06:46:31 +0000 (07:46 +0100)
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>
Reviewed-by: Heiko Schocher <hs@denx.de>
drivers/i2c/i2c-gpio.c

index 4e8fa214739a4bee0faa963bac3717f5090a9aae..d56540b4621b4acd8939c383f72a2a1288241b65 100644 (file)
@@ -305,6 +305,21 @@ 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 +356,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,