firmware-utils: bump to git HEAD
[openwrt/staging/ldir.git] / target / linux / bcm27xx / patches-5.4 / 950-0764-overlays-i2c-gpio-Avoid-open-drain-warnings.patch
1 From 11f89a12530471a2b25c71416e106eaa014818c0 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 5 Jun 2020 16:07:07 +0100
4 Subject: [PATCH] overlays: i2c-gpio: Avoid open-drain warnings
5
6 The i2c-gpio driver expects to use a GPIO in open-drain mode. Failure
7 to configure it in that way causes alarming warnings in the kernel log.
8 The BCM283x and BCM2711 GPIO blocks don't support open-drain mode, but
9 gpiolib can emulate it in software if configured correctly.
10
11 Silence the warning by declaring the GPIOs as requiring open-drain
12 mode, trusting gpiolib to manage the emulation. The previous
13 incarnation of this patch took the other approach of telling the
14 i2c-gpio driver that the GPIOs were configured for open-drain, but
15 this had the effect of disabling the emulation. In some cases this
16 appears to work, but examining the waveforms as analogue voltages
17 shows contention, the success or failure depending on drive strengths.
18
19 See: https://github.com/raspberrypi/firmware/issues/1381
20 See: https://github.com/raspberrypi/firmware/issues/1401
21
22 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
23 ---
24 arch/arm/boot/dts/overlays/balena-fin-overlay.dts | 5 ++++-
25 arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts | 6 ++++--
26 arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts | 6 ++++--
27 3 files changed, 12 insertions(+), 5 deletions(-)
28
29 --- a/arch/arm/boot/dts/overlays/balena-fin-overlay.dts
30 +++ b/arch/arm/boot/dts/overlays/balena-fin-overlay.dts
31 @@ -1,6 +1,8 @@
32 /dts-v1/;
33 /plugin/;
34
35 +#include <dt-bindings/gpio/gpio.h>
36 +
37 /{
38 compatible = "brcm,bcm2835";
39
40 @@ -48,7 +50,8 @@
41
42 i2c_soft: i2c@0 {
43 compatible = "i2c-gpio";
44 - gpios = <&gpio 43 0 /* sda */ &gpio 42 0 /* scl */>;
45 + gpios = <&gpio 43 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
46 + &gpio 42 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */>;
47 i2c-gpio,delay-us = <5>;
48 i2c-gpio,scl-open-drain;
49 i2c-gpio,sda-open-drain;
50 --- a/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
51 +++ b/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
52 @@ -2,6 +2,8 @@
53 /dts-v1/;
54 /plugin/;
55
56 +#include <dt-bindings/gpio/gpio.h>
57 +
58 / {
59 compatible = "brcm,bcm2835";
60
61 @@ -12,8 +14,8 @@
62 i2c_gpio: i2c@0 {
63 reg = <0xffffffff>;
64 compatible = "i2c-gpio";
65 - gpios = <&gpio 23 0 /* sda */
66 - &gpio 24 0 /* scl */
67 + gpios = <&gpio 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
68 + &gpio 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */
69 >;
70 i2c-gpio,delay-us = <2>; /* ~100 kHz */
71 #address-cells = <1>;
72 --- a/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts
73 +++ b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts
74 @@ -3,6 +3,8 @@
75 /dts-v1/;
76 /plugin/;
77
78 +#include <dt-bindings/gpio/gpio.h>
79 +
80 / {
81 compatible = "brcm,bcm2835";
82
83 @@ -11,8 +13,8 @@
84 __overlay__ {
85 i2c_gpio: i2c-gpio-rtc@0 {
86 compatible = "i2c-gpio";
87 - gpios = <&gpio 23 0 /* sda */
88 - &gpio 24 0 /* scl */
89 + gpios = <&gpio 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
90 + &gpio 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */
91 >;
92 i2c-gpio,delay-us = <2>; /* ~100 kHz */
93 #address-cells = <1>;