1

I'm trying to create a Device Tree overlay for a i2c touch screen.

Things are a bit strange as the screen is a 16bit DPI so all usual i2c pins are consumed. I'm using a i2c-tiny-usb adapter to get an extra i2c bus (/dev/i2c-3).

I have a reset line on BCM 26 and interrupt line on BCM 27 so I've tried the following:

/dts-v1/;
/plugin/;

/ {
    fragment@0 {
        target = <&i2c3>;

        __overlay__ {
            status = "okay";
            #address-cells = <1>;
            #size-cells = <0>;
            st16xx: st16xx@38 {
                compatible = "sitronix,st16xx";
                reg = <0x38>;
                interrupt-gpios = <&gpio 0x1b 0>;
                reset-gpios = <&gpio 0x1a 0>;
            };
        };
    };
};

The device is on address 0x38 and the module registers it's self with the following:

#define ST16XX_TS_NAME  "st16xx-ts"
static const struct i2c_device_id st16xx_ts_id[] = {
    { ST16XX_TS_NAME, 0 },
    { }
};
MODULE_DEVICE_TABLE(i2c, st16xx_ts_id);

#ifdef CONFIG_OF
static const struct of_device_id st16xx_ts_dt_ids[] = {
    { .compatible = "sitronix,st16xx", },
    { }
};
MODULE_DEVICE_TABLE(of, st16xx_ts_dt_ids);
#endif

static struct i2c_driver st16xx_ts_driver = {
    .probe      = st16xx_ts_probe,
    .remove     = st16xx_ts_remove,
    .id_table   = st16xx_ts_id,
    .driver = {
        .name   = ST16XX_TS_NAME,
        .of_match_table = of_match_ptr(st16xx_ts_dt_ids),
        .pm = &st16xx_ts_pm_ops,
    },
};

module_i2c_driver(st16xx_ts_driver);

The driver bails out at startup saying it can't find the irq, which makes me think the driver is not picking up the information in the overlay.

Also should I be using physical or BCM numbers for the GPIO pins?

EDIT:

I've made some progress, the following now actually shows up in /proc/device-tree but looks like it's attached to the bcm-2835-i2c not the i2c-tiny-usb /dev/i2c-3 (which I can't find any reference to in the device-tree.

/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";
        };

};

EDIT2:

This looks promising: https://stackoverflow.com/q/30482180/504554

  • 1
    You should use BCM numbers. – Dougie Aug 22 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.