I2C-Tiny-USB icon indicating copy to clipboard operation
I2C-Tiny-USB copied to clipboard

Writing a device tree overlay for a i2c device attached to i2c-tiny-usb

Open hardillb opened this issue 5 years ago • 1 comments

Has anybody managed to write a device tree overlay to use a i2c device kernel driver?

I'm trying to connect a touch screen via a i2c-tiny-usb adapter on a raspberry pi (the normal i2c bus is disabled because I'm using a DPI screen).

I've managed to get the interrupt details setup but it looks like the overlay is getting attached to the disabled built in i2c bus and I need to work out how to write an overlay to add the extra i2c bus.

/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2837", "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

	fragment@0 {
		target = <&i2c>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@1 {
               target = <&gpio>;
                __overlay__ {
                        st16xx_pins: st16xx_pins {
                                brcm,pins = <27>; /* GPIO */
                                brcm,function = <0>; /* in */
                                brcm,pull = <2>; /* up */
                        };
                };
	};

	fragment@2 {
		target = <&i2c>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			st16xx: st16xx@38 {
				compatible = "sitronix,st16xx-ts", "sitronix,st16xx";
				reg = <0x38>;
				pinctrl-names = "default";
				interupt-parent = <&gpio>;
				interrupts = <27 0x8>;
			};
		};
	};

	__overrides__ {
                addr = <&st16xx>, "reg:0";
        };

};

If I've understood the problem is with the target = <&i2c> lines which point to the existing bus. I think I need to create a overlay named i2c3 to match the new bus.

(also asked on rPi Stack Overflow site here: https://raspberrypi.stackexchange.com/q/101823/37180)

hardillb avatar Aug 23 '19 08:08 hardillb

how did you figure out the interrupt stuff? trying to get that set up for an APDS9960 sensor

CorvetteCole avatar Jan 17 '23 21:01 CorvetteCole