guscrown
Posts: 9
Joined: Mon Sep 24, 2018 8:46 pm

Overlay for TSC2007 Touch controller

Wed Oct 03, 2018 10:04 pm

I'm having issues creating an overlay for the TSC2007 chip (for now I'm testing with the TSC2007EVM board), this is what I have:

Code: Select all

/dts-v1/;
/plugin/;
 
/ {
        compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
 
        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        tsc2007_pins: tsc2007_pins {
                                brcm,pins = <25>;
                                brcm,function = <0>; /* in */
                                /*brcm,pull = <2 0>; / * pullup none */
                        };
                };
        };
 
        [email protected] {
                target = <&i2c1>;
                __overlay__ {
            #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
 
              tsc2007: [email protected] {
              			#address-cells = <1>;
                            	#size-cells = <0>;
                                compatible = "ti,tsc2007";
                                reg = <0x48>;
                		interrupt-parent = <&gpio25>;
                		interrupts = <0x0 0x2>;
                		gpios = <&gpio25 0 0>;
                		ti,x-plate-ohms = <180>;
                                };
                        };
                };
       
 
        __overrides__ {
                irq_pin = <&tsc2007>, "irq-gpio:4",
                          <&tsc2007_pins>, "brcm,pins:0";
        };
};
I am basing this on a functional overlay I have for the STMPE610 and other threads I found in this forum. And also using the reference example here: https://www.kernel.org/doc/Documentatio ... sc2007.txt

It compiles fine, but when I tried to load it with

Code: Select all

sudo dtoverlay tsc2007


I get the follow error:
[10028.373231] OF: resolver: overlay phandle fixup failed: -22
[10028.373242] create_overlay: Failed to resolve tree
Any ideas?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1906
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Overlay for TSC2007 Touch controller

Thu Oct 04, 2018 9:47 am

That's a good attempt, but you were misled by the GPIO and interrupt declarations in the example - "<&gpio4 0 0>". The "4" in "gpio4" is presumably GPIO controller number 4, rather than GPIO 4. The two integers after that are the index of the GPIO on that controller and the flags - 0 means active high.

The normal on-board GPIOs on BCM2835 are controlled by the node called "gpio", and the index is the number of the GPIO, which gives you a "gpios" property of:

Code: Select all

                		gpios = <&gpio 25 0>;
Applying similar logic to the interrupt-parent and interrupts properties, fixing up the irq_pin declaration, and removing the unnecessary #address-cells and #size-cells from inside the [email protected] node results in:

Code: Select all

/dts-v1/;
/plugin/;
 
/ {
        compatible = "brcm,bcm2835";
 
        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        tsc2007_pins: tsc2007_pins {
                                brcm,pins = <25>;
                                brcm,function = <0>; /* in */
                                /*brcm,pull = <2 0>; / * pullup none */
                        };
                };
        };
 
        [email protected] {
                target = <&i2c1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
 
                        tsc2007: [email protected] {
                                compatible = "ti,tsc2007";
                                reg = <0x48>;
                		interrupt-parent = <&gpio>;
                		interrupts = <25 0x2>; /* falling edge */
                		gpios = <&gpio 25 0>;
                		ti,x-plate-ohms = <180>;
                        };
                };
        };
       
 
        __overrides__ {
                irq_pin = <&tsc2007>, "interrupts:0",
                          <&tsc2007>, "gpios:4",
                          <&tsc2007_pins>, "brcm,pins:0";
        };
};
Your next problem is likely to be that the stock Raspbian kernels don't include the tsc2007 module. You will need to add "CONFIG_TOUCHSCREEN_TXC2007=m" to your kernel configuration if you are building your own kernel, and/or open an Issue at https://github.com/raspberrypi/linux/issues asking for it to be made a standard module.

guscrown
Posts: 9
Joined: Mon Sep 24, 2018 8:46 pm

Re: Overlay for TSC2007 Touch controller

Thu Oct 04, 2018 7:43 pm

PhilE wrote:
Thu Oct 04, 2018 9:47 am
That's a good attempt, but you were misled by the GPIO and interrupt declarations in the example - "<&gpio4 0 0>". The "4" in "gpio4" is presumably GPIO controller number 4, rather than GPIO 4. The two integers after that are the index of the GPIO on that controller and the flags - 0 means active high.

The normal on-board GPIOs on BCM2835 are controlled by the node called "gpio", and the index is the number of the GPIO, which gives you a "gpios" property of:

Code: Select all

                		gpios = <&gpio 25 0>;
Applying similar logic to the interrupt-parent and interrupts properties, fixing up the irq_pin declaration, and removing the unnecessary #address-cells and #size-cells from inside the [email protected] node results in:

Code: Select all

/dts-v1/;
/plugin/;
 
/ {
        compatible = "brcm,bcm2835";
 
        [email protected] {
                target = <&gpio>;
                __overlay__ {
                        tsc2007_pins: tsc2007_pins {
                                brcm,pins = <25>;
                                brcm,function = <0>; /* in */
                                /*brcm,pull = <2 0>; / * pullup none */
                        };
                };
        };
 
        [email protected] {
                target = <&i2c1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
 
                        tsc2007: [email protected] {
                                compatible = "ti,tsc2007";
                                reg = <0x48>;
                		interrupt-parent = <&gpio>;
                		interrupts = <25 0x2>; /* falling edge */
                		gpios = <&gpio 25 0>;
                		ti,x-plate-ohms = <180>;
                        };
                };
        };
       
 
        __overrides__ {
                irq_pin = <&tsc2007>, "interrupts:0",
                          <&tsc2007>, "gpios:4",
                          <&tsc2007_pins>, "brcm,pins:0";
        };
};
Your next problem is likely to be that the stock Raspbian kernels don't include the tsc2007 module. You will need to add "CONFIG_TOUCHSCREEN_TXC2007=m" to your kernel configuration if you are building your own kernel, and/or open an Issue at https://github.com/raspberrypi/linux/issues asking for it to be made a standard module.
This worked. I had to go research how to build my own Kernel but managed to do it. The fixes to the dts file also worked.

I did

Code: Select all

sudo evtest
And I can see the touchscreen as /dev/input/event3 and I can see the touch events. However, no activity is being triggered on the cursor itself.

I checked under xinput and it's not listed there. Do I have to create some kind of udev rule for it?

guscrown
Posts: 9
Joined: Mon Sep 24, 2018 8:46 pm

Re: Overlay for TSC2007 Touch controller

Thu Oct 04, 2018 8:15 pm

Code: Select all

lsmod
Shows the tsc2007 module being loaded, but it shows "0" for
Used by

guscrown
Posts: 9
Joined: Mon Sep 24, 2018 8:46 pm

Re: Overlay for TSC2007 Touch controller

Thu Oct 04, 2018 9:11 pm

Alright, making some progress. I went and added the following to an xorg conf file:

Code: Select all

Section "InputClass"
   Identifier "TSC2007 touchscreen class"
   MatchProduct "TSC2007 Touchscreen"
   MatchDevicePath "/dev/input/event*"
   Driver "evdev"
EndSection
Now it's being picked up by X. Screen is mirrored and rotated. Now I need to figure that out.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 20924
Joined: Sat Jul 30, 2011 7:41 pm

Re: Overlay for TSC2007 Touch controller

Thu Oct 04, 2018 9:22 pm

There may be a device tree entry for that particular TS driver to do flips etc. I can never remember where DT docuemnation is stored, but you coudl checkthe driver itself to see if it reads any DT entries for flips/swaps.

Failing that, there are X conf entries for flips, there are a number of forum posts about it, but again, I don;t remember exactly what to do. Soz!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

Return to “Device Tree”