Skip to content

Commit

Permalink
overlays: i2c-gpio: Avoid open-drain warnings
Browse files Browse the repository at this point in the history
The i2c-gpio driver expects to use a GPIO in open-drain mode. Failure
to configure it in that way causes alarming warnings in the kernel log.
The BCM283x and BCM2711 GPIO blocks don't support open-drain mode, but
gpiolib can emulate it in software if configured correctly.

Silence the warning by declaring the GPIOs as requiring open-drain
mode, trusting gpiolib to manage the emulation. The previous
incarnation of this patch took the other approach of telling the
i2c-gpio driver that the GPIOs were configured for open-drain, but
this had the effect of disabling the emulation. In some cases this
appears to work, but examining the waveforms as analogue voltages
shows contention, the success or failure depending on drive strengths.

See: raspberrypi/firmware#1381
See: raspberrypi/firmware#1401

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell authored and popcornmix committed Jun 10, 2020
1 parent 7744086 commit 20509f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion arch/arm/boot/dts/overlays/balena-fin-overlay.dts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>

/{
compatible = "brcm,bcm2835";

Expand Down Expand Up @@ -48,7 +50,8 @@

i2c_soft: i2c@0 {
compatible = "i2c-gpio";
gpios = <&gpio 43 0 /* sda */ &gpio 42 0 /* scl */>;
gpios = <&gpio 43 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
&gpio 42 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */>;
i2c-gpio,delay-us = <5>;
i2c-gpio,scl-open-drain;
i2c-gpio,sda-open-drain;
Expand Down
6 changes: 4 additions & 2 deletions arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>

/ {
compatible = "brcm,bcm2835";

Expand All @@ -12,8 +14,8 @@
i2c_gpio: i2c@0 {
reg = <0xffffffff>;
compatible = "i2c-gpio";
gpios = <&gpio 23 0 /* sda */
&gpio 24 0 /* scl */
gpios = <&gpio 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
&gpio 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */
>;
i2c-gpio,delay-us = <2>; /* ~100 kHz */
#address-cells = <1>;
Expand Down
6 changes: 4 additions & 2 deletions arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>

/ {
compatible = "brcm,bcm2835";

Expand All @@ -11,8 +13,8 @@
__overlay__ {
i2c_gpio: i2c-gpio-rtc@0 {
compatible = "i2c-gpio";
gpios = <&gpio 23 0 /* sda */
&gpio 24 0 /* scl */
gpios = <&gpio 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
&gpio 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */
>;
i2c-gpio,delay-us = <2>; /* ~100 kHz */
#address-cells = <1>;
Expand Down

0 comments on commit 20509f5

Please sign in to comment.