Help with device-tree for i2c-gpio

Hello,

im trying to map the i2c-2 to some GPIO ports and have to rewrite the device-tree on armbian 22.04. I’m failing miserably and have no idea how-to do it. I managed to compile the i2c-gpio.ko kernel module as it is not part of the armbian 5.15.89-sunxi kernel.

However, here i’m stuck and cant manage to make it happen. On RPi it was simple adding an overlay.

dtoverlay=i2c-gpio,bus=2,i2c_gpio_sda=27,i2c_gpio_scl=17
/boot/overlays/i2c-gpio.dtbo  

is the overlay file that is then customized.

I’m trying to replicate that for armbian, here is my dts file:

// Overlay for i2c_gpio bitbanging host bus.
/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun8i-h3";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			i2c_gpio: i2c@2 {
				reg = <0>;
				compatible = "i2c-gpio";
				gpios = <&pio 17 0 	/* sda */
					 &pio 27 0	/* scl */
				>;	
				i2c-gpio,delay-us = <2>;
				#address-cells = <1>;
				#size-cells = <0>;
			};
		};
	};

	fragment@1 {
		target-path = "/aliases";
		__overlay__ {
			i2c_gpio = "/i2c@2";
		};
	};

	fragment@2 {
		target-path = "/__symbols__";
		__overlay__ {
			i2c_gpio = "/i2c@2";
		};
	};

	__overrides__ {
		i2c_gpio_sda = <&i2c_gpio>,"gpios:4";
		i2c_gpio_scl = <&i2c_gpio>,"gpios:16";
		i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";
		bus = <&i2c_gpio>, "reg:0";
	};
};

What am I doing wrong?

a pitty noone was able to help. this is a waste of time but eventually I made a step further. Now just the “bus” @2 doesnt work. It should be placed on /dev/i2c-2 but is placed on the next free device:

// Overlay for i2c_gpio bitbanging host bus.

/dts-v1/; /plugin/;

/ { compatible = “allwinner,sun8i-h3”;

fragment@0 {
	target-path = "/";
	__overlay__ {
		i2c_gpio: i2c@2 {
			reg = <2>;
			bus = <2>;
			compatible = "i2c-gpio";
			sda-gpios = <&pio 0 0 0>;
			scl-gpios = <&pio 0 1 0>;
			i2c-gpio,delay-us = <2>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};
};

fragment@1 {
	target-path = "/aliases";
	__overlay__ {
		i2c_gpio = "/i2c@2";
	};
};

fragment@2 {
	target-path = "/__symbols__";
	__overlay__ {
		i2c_gpio = "/i2c@2";
	};
};

__overrides__ {
	i2c_gpio_sda = <&i2c_gpio>,"gpios:4";
	i2c_gpio_scl = <&i2c_gpio>,"gpios:16";
	i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";
	bus = <&i2c_gpio>, "reg:0";
};
};

Is this code used to add an I2C port on your device? Can be used also on BPI-M5? You have the same my problem.