SPI Touchscreen Support

Jan BernraderJan Bernrader Posts: 6New Member
edited October 2017 in Peripherals
I was wondering if anyone managed to successfully interfaced a Touchscreen like this one (The touch input)(https://www.waveshare.com/wiki/4inch_HDMI_LCD) over the SPI Pins.

So far i have successfully installed the ads7846_device module (as far as I can tell) and the irqs are correctly registered in /proc/interrupts , but there is no reaction what so ever like pointer movements etc.

Here are some of the used commands:
modprobe -v -i ads7846_device model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=2 verbose=2

This is the Output of dmesg | grep spi
[    0.000000] ACPI: SSDT ACPI table found in initrd [kernel/firmware/acpi/spidev1.1.aml][0xb6]
[    0.000000] ACPI: SSDT ACPI table found in initrd [kernel/firmware/acpi/spidev1.0.aml][0xb6]
[    6.045943] spidev spi-SPT0001:00: do not use this driver in production systems!
[    6.046200] spidev spi-SPT0001:01: do not use this driver in production systems!
[   38.729091] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
[   38.729095] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
[   38.729371] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
[   38.729374] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
[   38.729377] ads7846_device:    ads7846 spi2.1 50kHz 8 bits mode=0x00
[   38.735587] ads7846 spi2.1: touchscreen, irq 245
[   38.758222] input: ADS7846 Touchscreen as /devices/pci0000:00/0000:00:19.1/pxa2xx-spi.12/spi_master/spi2/spi2.1/input/input7

And of dmesg | grep ads:
[   38.727276] ads7846_device: loading out-of-tree module taints kernel.
               ads7846_device: ads7846_device_init()
[   38.729081] ads7846_device: SPI devices registered:
[   38.729091] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
[   38.729095] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
[   38.729096] ads7846_device:
[   38.729102] ads7846_device: Settings:
[   38.729104] ads7846_device:   model = 7846
[   38.729105] ads7846_device:   gpio_pendown = 402
[   38.729107] ads7846_device:   swap_xy = 1
[   38.729109] ads7846_device:   x_min = 200
[   38.729110] ads7846_device:   x_max = 3900
[   38.729112] ads7846_device:   y_min = 200
[   38.729114] ads7846_device:   y_max = 3900
[   38.729115] ads7846_device:   x_plate_ohms = 150
[   38.729117] ads7846_device:   pressure_min = 0
[   38.729119] ads7846_device:   pressure_max = 255
[   38.729120] ads7846_device:   keep_vref_on = 0
[   38.729122] ads7846_device:   vref_delay_usecs = 0
[   38.729124] ads7846_device:   vref_mv = 0
[   38.729125] ads7846_device:   settle_delay_usecs = 0
[   38.729127] ads7846_device:   penirq_recheck_delay_usecs = 0
[   38.729129] ads7846_device:   y_plate_ohms = 0
[   38.729130] ads7846_device:   debounce_max = 0
[   38.729132] ads7846_device:   debounce_tol = 0
[   38.729134] ads7846_device:   debounce_rep = 0
[   38.729367] ads7846_device: SPI devices registered:
[   38.729371] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
[   38.729374] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
[   38.729377] ads7846_device:    ads7846 spi2.1 50kHz 8 bits mode=0x00
[   38.729379] ads7846_device:
[   38.735587] ads7846 spi2.1: touchscreen, irq 245

And of lsmod | grep spi:
spi_pxa2xx_platform    24576  0
spidev                 20480  0

Help would be very much appreciated thanks in advance!

Comments

  • WereCatfWereCatf Posts: 201New Member
    edited October 2017
    You're trying to use SPI-bus 2, but only SPI-bus 0 (spidev 1) is brought out on the 40-pin GPIO-header -- https://up-community.org/wiki/Pinout_UP2 Changing busnum to 0 should fix it.
  • Jan BernraderJan Bernrader Posts: 6New Member
    edited October 2017
    Hi WereCatf,

    I tried that, but it throws an error, when using busnum=1 or busnum=0:
    [email protected]:~# modprobe -v -i ads7846_device model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=1 verbose=2
    insmod /lib/modules/4.9.18-ubilinux+/kernel/drivers/spi/ads7846_device.ko model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=1 verbose=2
    modprobe: ERROR: could not insert 'ads7846_device': Operation not permitted
    
    [email protected]:~# modprobe -v -i ads7846_device model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=0 verbose=2
    insmod /lib/modules/4.9.18-ubilinux+/kernel/drivers/spi/ads7846_device.ko model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=0 verbose=2
    modprobe: ERROR: could not insert 'ads7846_device': Invalid argument
    
    [email protected]:~# dmesg | grep spi
    [    0.000000] ACPI: SSDT ACPI table found in initrd [kernel/firmware/acpi/spidev1.1.aml][0xb6]
    [    0.000000] ACPI: SSDT ACPI table found in initrd [kernel/firmware/acpi/spidev1.0.aml][0xb6]
    [    4.838278] spidev spi-SPT0001:00: do not use this driver in production systems!
    [    4.838517] spidev spi-SPT0001:01: do not use this driver in production systems!
    [  156.587845] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
    [  156.587850] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
    [  156.587910] pxa2xx-spi pxa2xx-spi.11: chipselect 1 already in use
    [  156.594804] ads7846_device: spi_new_device() returned NULL
    [  403.439774] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
    [  403.439778] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
    [  403.439822] ads7846_device: spi_busnum_to_master(0) returned NULL.
    
    [email protected]:~# dmesg | grep ads
    [  156.586111] ads7846_device: loading out-of-tree module taints kernel.
                   ads7846_device: ads7846_device_init()
    [  156.587838] ads7846_device: SPI devices registered:
    [  156.587845] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
    [  156.587850] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
    [  156.587851] ads7846_device:
    [  156.587857] ads7846_device: Settings:
    [  156.587859] ads7846_device:   model = 7846
    [  156.587860] ads7846_device:   gpio_pendown = 402
    [  156.587862] ads7846_device:   swap_xy = 1
    [  156.587864] ads7846_device:   x_min = 200
    [  156.587865] ads7846_device:   x_max = 3900
    [  156.587867] ads7846_device:   y_min = 200
    [  156.587869] ads7846_device:   y_max = 3900
    [  156.587870] ads7846_device:   x_plate_ohms = 150
    [  156.587872] ads7846_device:   pressure_min = 0
    [  156.587874] ads7846_device:   pressure_max = 255
    [  156.587875] ads7846_device:   keep_vref_on = 0
    [  156.587877] ads7846_device:   vref_delay_usecs = 0
    [  156.587879] ads7846_device:   vref_mv = 0
    [  156.587880] ads7846_device:   settle_delay_usecs = 0
    [  156.587882] ads7846_device:   penirq_recheck_delay_usecs = 0
    [  156.587884] ads7846_device:   y_plate_ohms = 0
    [  156.587885] ads7846_device:   debounce_max = 0
    [  156.587887] ads7846_device:   debounce_tol = 0
    [  156.587888] ads7846_device:   debounce_rep = 0
    [  156.594804] ads7846_device: spi_new_device() returned NULL
                   ads7846_device: ads7846_device_init()
    [  403.439766] ads7846_device: SPI devices registered:
    [  403.439774] ads7846_device:    SPT0001 spi-SPT0001:00 1000kHz 8 bits mode=0x00
    [  403.439778] ads7846_device:    SPT0001 spi-SPT0001:01 1000kHz 8 bits mode=0x00
    [  403.439780] ads7846_device:
    [  403.439784] ads7846_device: Settings:
    [  403.439786] ads7846_device:   model = 7846
    [  403.439788] ads7846_device:   gpio_pendown = 402
    [  403.439790] ads7846_device:   swap_xy = 1
    [  403.439792] ads7846_device:   x_min = 200
    [  403.439793] ads7846_device:   x_max = 3900
    [  403.439795] ads7846_device:   y_min = 200
    [  403.439797] ads7846_device:   y_max = 3900
    [  403.439798] ads7846_device:   x_plate_ohms = 150
    [  403.439800] ads7846_device:   pressure_min = 0
    [  403.439802] ads7846_device:   pressure_max = 255
    [  403.439803] ads7846_device:   keep_vref_on = 0
    [  403.439805] ads7846_device:   vref_delay_usecs = 0
    [  403.439806] ads7846_device:   vref_mv = 0
    [  403.439808] ads7846_device:   settle_delay_usecs = 0
    [  403.439810] ads7846_device:   penirq_recheck_delay_usecs = 0
    [  403.439812] ads7846_device:   y_plate_ohms = 0
    [  403.439813] ads7846_device:   debounce_max = 0
    [  403.439815] ads7846_device:   debounce_tol = 0
    [  403.439816] ads7846_device:   debounce_rep = 0
    [  403.439822] ads7846_device: spi_busnum_to_master(0) returned NULL.
    
  • WereCatfWereCatf Posts: 201New Member
    Okay, I finally got around to checking this on my own board and the problem is: the spi-enable - script has already claimed that cs-pin you're trying to use. You have to delete the file /lib/firmware/acpi-upgrades/spidev1.0.aml if you want to use cs0, or /lib/firmware/acpi-upgrades/spidev1.1.aml if you want to use cs1, and run
    sudo update-initramfs -u -k all
    
    to update the initramfs, followed by a reboot. After that you should be able to use SPI-bus 1, ie.
    sudo modprobe -v -i ads7846_device model=7846 cs=1 gpio_pendown=402 speed=50000 keep_vref_on=0 swap_xy=1 pressure_max=255 x_plate_ohms=150 x_min=200 x_max=3900 y_min=200 y_max=3900 busnum=1 verbose=2
    

    PS. Your kernel is also outdated. The current Ubilinux-one is 4.9.45.
  • Jan BernraderJan Bernrader Posts: 6New Member
    That worked perfectly! Thanks a lot ;)
Sign In or Register to comment.