This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: Configure TSC2046 for custom AM625 SOM

Part Number: AM625
Other Parts Discussed in Thread: TSC2046, , SK-AM62B, SK-LCD1

In our custom AM625 SOM we've used touch IC TSC2046 and now I want to configure it using the device tree structure files,  so that I can use touch feature for AM625 SOM

The display we've used is 7" TFT display, which supports resistive touch 

  • Hi Aditya,

    I have assigned your query to the concerned expert, they will get back to you shortly.

    Regards,

    Nitika

  • Hello Aditya,

    You can find the documentation for the device tree node here:

    ti-processor-sdk-linux-am62xx-evm-09.01.00.08/board-support/ti-linux-kernel-6.1.46+gitAUTOINC+247b2535b2-g247b2535b2/Documentation/devicetree/bindings$ grep -r TSC2046
    input/touchscreen/ads7846.txt:Device tree bindings for TI's ADS7843, ADS7845, ADS7846, ADS7873, TSC2046
    input/touchscreen/ads7846.txt:Example for a TSC2046 chip connected to an McSPI controller of an OMAP SoC::
    iio/adc/ti,tsc2046.yaml:title: Texas Instruments TSC2046 touch screen controller.
    iio/adc/ti,tsc2046.yaml:  TSC2046 is a touch screen controller with 8 channels ADC.
    

    And you can search for examples of how people wrote the devicetree node for their own boards by searching for ads78 or tsc2046, like this:

    ti-processor-sdk-linux-am62xx-evm-09.01.00.08/board-support/ti-linux-kernel-6.1.46+gitAUTOINC+247b2535b2-g247b2535b2/arch$ grep -r tsc2046
    arm/mach-pxa/magician.c:struct pxa2xx_spi_chip tsc2046_chip_info = {
    arm/mach-pxa/magician.c:                .controller_data        = &tsc2046_chip_info,
    arm/mach-pxa/hx4700.c:static const struct ads7846_platform_data tsc2046_info = {
    arm/mach-pxa/hx4700.c:static struct pxa2xx_spi_chip tsc2046_chip = {
    arm/mach-pxa/hx4700.c:static struct spi_board_info tsc2046_board_info[] __initdata = {
    arm/mach-pxa/hx4700.c:          .platform_data   = &tsc2046_info,
    arm/mach-pxa/hx4700.c:          .controller_data = &tsc2046_chip,
    arm/mach-pxa/hx4700.c:  spi_register_board_info(ARRAY_AND_SIZE(tsc2046_board_info));
    arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi:        tsc2046@0 {
    arm/boot/dts/omap3-panel-sharp-ls037v7dw01.dtsi:                compatible = "ti,tsc2046";
    arm/boot/dts/imx7d-sdb-reva.dts:                pinctrl_tsc2046_pendown: tsc2046_pendown {
    arm/boot/dts/omap3-evm-common.dtsi:     tsc2046@0 {
    arm/boot/dts/omap3-ldp.dts:     tsc2046@0 {
    arm/boot/dts/imx6qdl-skov-cpu-revc.dtsi:                compatible = "ti,tsc2046e-adc";
    arm/boot/dts/omap3-lilly-a83x.dtsi:     tsc2046@0 {
    arm/boot/dts/omap3-lilly-a83x.dtsi:             compatible = "ti,tsc2046";
    arm/boot/dts/imx6dl-plym2m.dts:         compatible = "ti,tsc2046e-adc";
    arm/boot/dts/imx6dl-plym2m.dts:         pinctrl-0 = <&pinctrl_tsc2046>;
    arm/boot/dts/imx6dl-plym2m.dts: pinctrl_tsc2046: tsc2046grp {
    arm/boot/dts/omap3-pandora-common.dtsi: tsc2046@0 {
    arm/boot/dts/omap3-pandora-common.dtsi:         compatible = "ti,tsc2046";
    arm/boot/dts/dove-cm-a510.dtsi:         compatible = "ti,tsc2046";
    arm/boot/dts/at91sam9261ek.dts:                         tsc2046@2 {
    arm/boot/dts/imx6dl-victgo.dts:         compatible = "ti,tsc2046e-adc";
    arm/boot/dts/imx7d-sdb.dts:     tsc2046@0 {
    arm/boot/dts/imx7d-sdb.dts:             compatible = "ti,tsc2046";
    arm/boot/dts/imx7d-sdb.dts:             pinctrl-0 = <&pinctrl_tsc2046_pendown>;
    arm/boot/dts/imx7d-sdb.dts:             pinctrl_tsc2046_pendown: tsc2046_pendown {
    arm/boot/dts/imx6dl-prtvt7.dts:         compatible = "ti,tsc2046e-adc";
    

    Regards,

    Nick

  • Hi Nick,

    This is my dts function

    &main_spi0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&tsspi0_pins_default>;
    	status = "okay";
    	#address-cells = <1>;
    	#size-cells = <0>;
    	ti,pindir-d0-out-d1-in = <0>;
    
    	tsc2046@0 {
    		pinctrl-names = "default";
    		pinctrl-0 = <&vdd_mmc1_pins_default>;
    
    		reg = <0>;    / CS0 /
    	        compatible = "ti,tsc2046";
            	interrupt-parent= <&main_gpio0>;
    	        interrupts = <41 GPIO_ACTIVE_LOW>;
            	spi-max-frequency = <1250000>;
    		pendown-gpio = <&main_gpio0 41 GPIO_ACTIVE_LOW>;
    		vcc-supply = <&vcc_3v3_sys>;
    
    		ti,x-min = /bits/ 16 <0>;
    		ti,x-max = /bits/ 16 <800>;
    		ti,y-min = /bits/ 16 <0>;
            	ti,y-max = /bits/ 16 <480>;
            	ti,x-plate-ohms = /bits/ 16 <40>;
            	//ti,y-plate-ohms = /bits/ 16 <200>;
            	ti,pressure-max = /bits/ 16 <255>;
    /*
            	ti,vref-delay-usecs = <20000>;
            	ti,vref-mv      = <3300>;
    		ti,keep-vref-on    =  <1>;
    
            	ti,debounce-rep =  <1>;
            	ti,debounce-tol =  <30>;
            	ti,debounce-max =  <10>;
            
            	ti,settle-delay-usec  = /bits/ 16 <150>;
    		ti,penirq-recheck-delay-usecs = /bits/ 16 <20000>;
                
    		touchscreen-x-mm    = <115>;
    		touchscreen-y-mm    = <86>;
    */
    		wakeup-source;
    	};
    };


    This is my pinmux setting
    //TOUCH-Start
    	tsspi0_pins_default: tsspi0-pins-default {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0x1bc, PIN_OUTPUT, 7) / (A14) SPI0_CLK /
    			AM62X_IOPAD(0x1c0, PIN_OUTPUT, 0) / (B13) SPI0_D0 /
    			AM62X_IOPAD(0x1c4, PIN_INPUT, 0) / (B14) SPI0_D1 /
    			AM62X_IOPAD(0x1b4, PIN_OUTPUT, 0) /* (A13) SPI0_CS0 | GPIO1_15*/
    		>;
    	};
    
    	tsc_Int_Busy_pins_default: tsc-Int-pins-default {
    		pinctrl-single,pins = <
    			AM62X_IOPAD(0xa8, PIN_INPUT, 7) / (M21) GPIO0_41 /
    			AM62X_IOPAD(0xac, PIN_INPUT, 7) / (L21) GPIO0_42 /
    		>;
    	};
    //End
    


    Now, after changing all these thins in k3-am62x-sk-common.dtsi, I'm not able to get touch screen enable on my custom AM625 SOM.
    Rather in booting logs, I'm getting only this as output
    [    1.493093] ads7846 spi3.0: touchscreen, irq 335
    [    1.498125] input: ADS7846 Touchscreen as /mailto:devices/platform/bus@f0000/20100000.spi/spi_master/spi3/spi3.0/input/input0
    


    Thanks & Regards,
    Aditya T

  • Hello,

    Is there any updates on configuring TSC2046 further?

    Thanks & Regards,
    Aditya Tandulwadkar

  • Hello Aditya,

    Apologies for the delayed response. I do not have one of those devices to test myself, but I will take a closer look at your devicetree settings tomorrow to see if there is anything that you might want to change.

    Regards,

    Nick

  • Hello Nick,

    I've got success in enabling resistive touch on custom AM625 SOM. But, now I want to calibrate touch for AM625 SOM which is having TSC2046 touch controller IC

    Thanks & Regards,
    Aditya Tandulwadkar

  • Hello Aditya,

    1) To confirm, you are now able to see touch input events? What did you end up changing to fix it?

    In the past, I used evtest to check for touch inputs, as shown in this thread: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/862817/am3358-touchscreen-error/3197806#3197806 

    2) What software are you using for the display? Wayland/Weston? EGFLS? tslib? Something else?

    Regards,

    Nick

  • Hi Nick,

    1) =>The lines, given below worked for me:
             touchscreen-size-x = <4096>;
             touchscreen-size-y = <4096>;

    I've also used to evtest tool and it is recognizing touch on all corners of my display, but how to calibrate using that data?

    2) => The platform I'm using is linuxfb on the wayland display on X11

    Thanks & Regards,
    Aditya Tandulwadkar

  • Edited Feb 28 2024: The information in this response does not seem to apply to AM62x. Please refer to my later response here:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1322404/am625-configure-tsc2046-for-custom-am625-som/5063378#5063378 

    Hello Aditya,

    Several years ago, the weston calibration was saved in a calibration file. So you would delete the old calibration data, and then the calibration tool would run at bootup. These old threads may be helpful:
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/723728/linux-am4378-touchscreen-calibration-problem
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/495706/am572x-touch-screen-calibration 

    Where the text from the wiki that I linked to is here:

    How to Recalibrate the Touchscreen
    
    Weston based Graphic System
    Where is the ws-calibrate.rules file?
    The Processor SDK Linux moves the Weston calibration file for the touchscreen from the default location of /etc/udev/rules.d/ws-calibrate.rules to instead be placed at /run/media/mmcblk0p1/ws-calibrate.rules if the SD device is present. This was done to allow user's to easily delete this file and force a recalibration without requiring a Linux PC to mount the file system or a serial console to access the device. In this case the ws-calibrate.rules file is now written to a FAT partition of the SD card, which can be mounted on both Windows or Linux.
    
    If the ws-calibrate.rules file is created at /run/media/mmcblk0p1/ws-calibrate.rules, and there is not already a file in /etc/udev/rules.d/ws-calibrate.rules then the file is also copied to the old default location.
    
    In the case that there is no SD card available then the ws-calibrate.rules file will be written to the default /etc/udev/rules.d/ws-calibrate.rules.
    
    Recalibrating by Deleting ws-calibrate.rules
    To trigger touchscreen re-calibration, both ws-calbration.rules files need to be deleted. The ws-calbration.rules file which is now written to the FAT partition of the SD card can be deleted by simply inserting the SD card into a PC and deleting the ws-calbration.rules file found on the first partition (assuming the first partition is a FAT partition) and we also need to delete /etc/udev/rules.d/ws-calibrate.rules from the filesystem. After both ws-calibration.rules files are removed, you will be asked to calibrate the touchscreen when the Weston is launched at the first time or relaunched by issuing "/etc/init.d/weston start" command at the console.
    
    Alternatively, you may delete the above listed files directly from the EVM's console by issuing the following commands at EVM's Linux prompt, and reboot the EVM to allow recalibration of the LCD.
    
     rm /etc/udev/rules.d/ws-calibrate.rules
     rm /run/media/mmcblk0p1/ws-calibrate.rules
     reboot
     
     Non-Weston based Graphic System
    Where is the pointercal file?
    The Processor SDK Linux moves the calibration file for the touchscreen from the default location of /etc/pointercal to instead be placed at /run/media/mmcblk0p1/pointercal if the SD device is present. This was done to allow user's to easily delete this file and force a recalibration without requiring a Linux PC to mount the file system or a serial console to access the device. In this case the pointercal file is now written to a FAT partition of the SD card, which can be mounted on both Windows or Linux.
    
    If the pointercal file is created at /run/media/mmcblk0p1/pointercal, and there is not already a file in /etc/pointercal then the file is also copied to the old default location. This is to prevent requiring the export of the TSLIB_CALIBFILE variable as described in later sections of this document.
    
    In the case that there is no SD card available then the pointercal file will be written to the default /etc/pointercal location.
    
    Recalibrating by Deleting pointercal
    Because the pointercal file is now written to the FAT partition of the SD card recalibrating the touchscreen can be done by simply inserting the SD card into a PC and deleting the pointercal file found on the first partition (assuming the first partition is a FAT partition). When the system is then rebooted you will be asked to calibrate the touchscreen.
    
    Recalibrating over Serial Console
    If you do have access to the serial console you can always recalibrate the touchscreen using the ts_calibrate command as normal. However, in this case if you already have a pointercal file on the SD card you will need to export the TSLIB_CALIBFILE variable to point to that location before you run ts_calibrate. i.e.
    
    target# export TSLIB_CALIBFILE=/run/media/mmcblk0p1/pointercal
    target# ts_calibrate
    NOTE: If you have Matrix or any other GUI application already running you should stop that application (How to Stop Matrix) before running ts_calibrate so that you can see the calibration screen.
    
    Exporting TSLIB_CALIBFILE
    The environment variable TSLIB_CALIBFILE is used by the tslib package to indicate the location of the pointercal file. The default value for TSLIB_CALIBFILE is /etc/pointercal. If you are writing a program that uses tslib you should make sure that you export TSLIB_CALIBFILE to point to the location of your pointercal file (as indicated in the previous section), or that you place a copy of the pointercal file at the default /etc/pointercal location.

    I'm not sure if that information still applies nowadays on AM62x?

    Regards,

    Nick

  • Hi Nick,

    Thanks for providing above information. but it didn't helped me much.
    Still I'm getting wrong touch co-ordinates

    Thanks & Regards,
    Aditya Tandulwadkar

  • Hello Aditya,

    I am in the process of setting up a screen on my side that I can run tests on (not the same as yours, it's the one documented here: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_01_00_08/exports/docs/linux/How_to_Guides/Target/How_to_enable_Microtips_LVDS_Panel_on_AM62_SK_EVM.html).

    While I get that set up, please provide me with more information about what you have tried for calibration, and what results you are observing.

    Regards,

    Nick

  • Hi Nick,

    The display I'm working on is 7" TFT RGB display, with 800×480 pixels. It supports 24 bit data i.e. RGB888.

    On the other side, after running the evtest utility I'm able to recognize touch on all corners as well as different points on display, but when I want to execute a QT application on it, with linuxfb platform or any other platform like

    eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, xcb 

    On any of these platforms after clicking any of button which is made using QT it is getting wrong touch recognized.

    Now, I'm not understanding that how to set right parameters of touch events?

    Thanks & Regards,

    Aditya Tandulwadkar 

  • Hello Aditya,

    I will continue working this on my side. I'm on vacation Monday, and then my hardware setup will be ready by Wednesday. However, I would encourage you to try to search the web for other resources on calibrating a touchscreen with whatever software platform you are interested in.

    I can provide guidance on how to get the TI EVM with the Microtips display panel calibrated, using the default software enabled in the SDK. But your solution may be different than what I can test here.

    Either way, this will go faster with both of us running tests, instead of waiting for me to make progress on my side.

    Regards,

    Nick

  • Hi Nick,

    Yes, I'm trying from my side to calibrate the touch and will update here, if any progress on it

    Thanks & Regards,
    Aditya Tandulwadkar

  • Hello Aditya,

    I used weston-touch-calibrator to recalibrate the touchscreen on my side.

    It worked well - when I calibrated by touching directly on the + symbols that showed up on screen, then the test touch application showed touches right under my finger, and when I intentionally touched below the + symbols by about an inch, then the test touch application showed touches about an inch away from my finger.

    Full steps below.

    Hardware & SW versions 

    SK-AM62B - EVM
    SK-LCD1 - Display with capacitive touchscreen
    AM62x Linux SDK 9.1

    Setting up the display & touchscreen 

    Follow the steps documented here: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_01_00_08/exports/docs/linux/How_to_Guides/Target/How_to_enable_Microtips_LVDS_Panel_on_AM62_SK_EVM.html

    Uboot steps:

    Hit any key to stop autoboot:  0
    => name_overlays=k3-am625-sk-microtips-mf101hie-panel.dtbo
    => boot
    

    Touchscreen was nonresponsive until after I followed the instructions in the above documentation, labeled
    "Steps to enable Touch on the Microtips Panel on AM625 SK EVM:"

    Running and testing the touch calibrator 

    The TI Linux SDK uses weston by default. More documentation about interacting with weston and running tests is here:
    https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_01_00_08/exports/docs/linux/Foundational_Components/Graphics/Graphics_and_Display.html#wayland-weston

    First, check that the weston touchscreen calibrator is enabled. On my board, touchscreen_calibrator was already set to true:

    # vi /etc/xdg/weston/weston.ini
    ...
    [libinput]
    touchscreen_calibrator=true
    #enable_tap=true
    

    Just to be safe, stop and re-start weston

    root@am62xx-evm:/# systemctl stop weston
    Warning: Stopping weston.service, but it can still be activated by:
      weston.socket
    root@am62xx-evm:/# systemctl start weston
    [ 1467.604787] audit: type=1006 audit(1501.104:57): pid=5332 uid=0 old-auid=4294967295 auid=1000 tty=tty7 old-ses=4294967295 ses=5 res=1
    [ 1467.617321] audit: type=1300 audit(1501.104:57): arch=c00000b7 syscall=64 success=yes exit=4 a0=8 a1=ffffcd12d128 a2=4 a3=ffff96660020 items=0 ppid=1 pid=5332 auid=1000 u
    id=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=tty7 ses=5 comm="(weston)" exe="/lib/systemd/systemd" key=(null)
    [ 1467.643381] audit: type=1327 audit(1501.104:57): proctitle="(weston)"
    

    Run the calibration

    root@am62xx-evm:/# weston-touch-calibrator
    could not load cursor 'dnd-move'
    could not load cursor 'dnd-copy'
    could not load cursor 'dnd-none'
    device "/sys/devices/platform/bus@f0000/20000000.i2c/i2c-0/0-0041/input/input1/event0" - head "LVDS-1"
    root@am62xx-evm:/# weston-touch-calibrator /sys/devices/platform/bus@f0000/20000000.i2c/i2c-0/0-0041/input/input1/event0
    could not load cursor 'dnd-move'
    could not load cursor 'dnd-copy'
    could not load cursor 'dnd-none'
    // at this point, + symbols appeared on the screen and I was able to press them

    You can test how accurate the calibration was by running one of the weston sample applications:

    root@am62xx-evm:~# /usr/bin/weston-simple-touch
    // Ctrl-C to exit the demo

    or you can just use evtest:

    root@am62xx-evm:~# /usr/bin/evtest

    It looks like the calibration data might not save between reboots. I have not experimented with it yet, but this stackoverflow post might have some helpful information for getting the calibration data to stick:
    https://stackoverflow.com/questions/67162466/where-is-the-calibration-matrix-in-weston-wayland

    Regards,

    Nick