aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0764-overlays-i2c-gpio-Avoid-open-drain-warnings.patch
blob: 9b6cb1d564463cd44e2eea6dd5c4477eb8088e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 11f89a12530471a2b25c71416e106eaa014818c0 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Fri, 5 Jun 2020 16:07:07 +0100
Subject: [PATCH] overlays: i2c-gpio: Avoid open-drain warnings

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: https://github.com/raspberrypi/firmware/issues/1381
See: https://github.com/raspberrypi/firmware/issues/1401

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/balena-fin-overlay.dts   | 5 ++++-
 arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts     | 6 ++++--
 arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts | 6 ++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

--- a/arch/arm/boot/dts/overlays/balena-fin-overlay.dts
+++ b/arch/arm/boot/dts/overlays/balena-fin-overlay.dts
@@ -1,6 +1,8 @@
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/gpio/gpio.h>
+
 /{
 	compatible = "brcm,bcm2835";
 
@@ -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;
--- a/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
+++ b/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
@@ -2,6 +2,8 @@
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	compatible = "brcm,bcm2835";
 
@@ -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>;
--- a/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts
+++ b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts
@@ -3,6 +3,8 @@
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	compatible = "brcm,bcm2835";
 
@@ -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>;