From 20509f5690f9587f20c2a5f1216947e72acfb2fb Mon Sep 17 00:00:00 2001 From: Phil Elwell 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 --- 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(-) diff --git a/arch/arm/boot/dts/overlays/balena-fin-overlay.dts b/arch/arm/boot/dts/overlays/balena-fin-overlay.dts index 249c8202b2ed4e..e7ead7cdf5f5e1 100644 --- 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 + /{ 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; diff --git a/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts b/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts index 39e7bc5fa9d884..63231b5d7c0c11 100644 --- 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 + / { 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>; diff --git a/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts b/arch/arm/boot/dts/overlays/i2c-rtc-gpio-overlay.dts index 23813369093a75..227e3c0fa1cd29 100644 --- 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 + / { 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>;