i2c: gpio: Enforce open drain through gpiolib
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 10 Sep 2017 17:54:21 +0000 (19:54 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 30 Oct 2017 07:42:37 +0000 (08:42 +0100)
commit7bb75029ef34838604357350b4f24d6535e9d01f
tree308c8bd845eacf62c4fbc29b03783cd569f83fdd
parentf926dfc112bc6cf41d7068ee5e3f261e13a5bec8
i2c: gpio: Enforce open drain through gpiolib

The I2C GPIO bitbang driver currently emulates open drain
behaviour by implementing what the gpiolib already does:
not actively driving the line high, instead setting it to
input.

This makes no sense. Use the new facility in gpiolib to
request the lines enforced into open drain mode, and let
the open drain emulation already present in the gpiolib
kick in and handle this.

As a bonus: if the GPIO driver in the back-end actually
supports open drain in hardware using the .set_config()
callback, it will be utilized. That's correct: we never
used that hardware feature before, instead relying on
emulating open drain even if the GPIO controller could
actually handle this for us.

Users will sometimes get messages like this:
gpio-485 (?): enforced open drain please flag it properly
  in DT/ACPI DSDT/board file
gpio-486 (?): enforced open drain please flag it properly
  in DT/ACPI DSDT/board file
i2c-gpio gpio-i2c: using lines 485 (SDA) and 486 (SCL)

Which is completely proper: since the line is used as
open drain, it should actually be flagged properly with
e.g.

gpios = <&gpio0 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>,
        <&gpio0 6 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

Or similar facilities in board file descriptor tables
or ACPI DSDT.

Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/i2c/busses/i2c-gpio.c