[BPI-R64] OpenWRT | I2C | i2c-gpio-custom | Kernel 4.19

I tried to use I2C for Kernel 4.19 and found this:

make menuconfig (line with Depends on: !LINUX_4_19 [=y] && GPIO_SUPPORT [=y])

Symbol: PACKAGE_kmod-i2c-gpio-custom [=n]
Type  : tristate
Prompt: kmod-i2c-gpio-custom   Custom GPIO-based I2C device
  Location:
    -> Kernel modules
(1)   -> I2C support
  Defined at tmp/.config-package.in:10447
  Depends on: !LINUX_4_19 [=y] && GPIO_SUPPORT [=y]
  Selects: PACKAGE_kmod-i2c-gpio [=y] && PACKAGE_kmod-i2c-core [=y]
  Selected by: MODULE_DEFAULT_kmod-i2c-gpio-custom [=n] && TARGET_PER_DEVICE_ROOTFS [=n] && m && MODULES [=y]

How to resolve that?

Well… This commit explain why gpio-custom has been removed:

I have not found the solution yet. Still cannot understand how to work with custom i2c sensors on a Kernel 4.19.

There is a schema of GPIO Pins: http://wiki.banana-pi.org/Getting_Started_with_R64#GPIO

Also I found this information in the kernel documentation (https://www.kernel.org/doc/Documentation/devicetree/bindings/i2c/i2c-gpio.txt):

Device-Tree bindings for i2c gpio driver

Required properties:
	- compatible = "i2c-gpio";
	- sda-gpios: gpio used for the sda signal, this should be flagged as
	  active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)
	  from <dt-bindings/gpio/gpio.h> since the signal is by definition
	  open drain.
	- scl-gpios: gpio used for the scl signal, this should be flagged as
	  active high using open drain with (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)
	  from <dt-bindings/gpio/gpio.h> since the signal is by definition
	  open drain.

Optional properties:
	- i2c-gpio,scl-output-only: scl as output only
	- i2c-gpio,delay-us: delay between GPIO operations (may depend on each platform)
	- i2c-gpio,timeout-ms: timeout to get data

Deprecated properties, do not use in new device tree sources:
	- gpios: sda and scl gpio, alternative for {sda,scl}-gpios
	- i2c-gpio,sda-open-drain: this means that something outside of our
	  control has put the GPIO line used for SDA into open drain mode, and
	  that something is not the GPIO chip. It is essentially an
	  inconsistency flag.
	- i2c-gpio,scl-open-drain: this means that something outside of our
	  control has put the GPIO line used for SCL into open drain mode, and
	  that something is not the GPIO chip. It is essentially an
	  inconsistency flag.

Example nodes:

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

i2c@0 {
	compatible = "i2c-gpio";
	sda-gpios = <&pioA 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	scl-gpios = <&pioA 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
	i2c-gpio,delay-us = <2>;	/* ~100 kHz */
	#address-cells = <1>;
	#size-cells = <0>;

	rv3029c2@56 {
		compatible = "rv3029c2";
		reg = <0x56>;
	};
};

As I understand based on schema some strings should be corrected for the R64 like this:

sda-gpios = <&pioA 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
scl-gpios = <&pioA 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

But I don’t understand what source file (or files) should be modified?

As document is named devicetree bindings you need to add this to dts(i) of board…here mt7622.dtsi or mt7622*bpi-r64.dts

I found all files you mentioned here:

target/linux/mediatek/files-4.19/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
target/linux/mediatek/files-4.19/arch/arm64/boot/dts/mediatek/mt7622.dtsi

But I am completely not familiar with DTS and DTSI files and do not understand where I have to modify them…

@frank-w, could you explain me step by step what I have to change?

i have not written new nodes…only changed some nodes or ported from 1 kernel version to another…you need some more info about the gpio-device (i don’t have it)

at least you need something like this in dtsi

i2c0 {
  compatible = "i2c-gpio";
  reg= <address size>; //memory address and size for driver
  sda-gpios = <&pio 3 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; //which gpio should  be used and which mode (active high or opendrain) for sda
  scl-gpios = <&pio 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; //like sda now for scl
  status = "okay";
};