From 11f89a12530471a2b25c71416e106eaa014818c0 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(-) --- 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; --- 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>; --- 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>;