harbaum / I2C-Tiny-USB

Cheap and simple I²C to USB interface
http://www.harbaum.org/till/i2c_tiny_usb
377 stars 79 forks source link

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

Open hardillb opened 5 years ago

hardillb commented 5 years ago

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)

CorvetteCole commented 1 year ago

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