Working: SainSmart 2.8" TFT LCD Module 320*240

Post Reply
mlinuxguy
Posts: 793
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Contact:

Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by mlinuxguy » Fri Jan 23, 2015 10:20 am

I have a SainSmart 2.8" TFT LCD Module 320*240+Touch Screen Display that I got working on the Odroid-c1
ref: http://www.sainsmart.com/sainsmart-2-8- ... board.html
(its also available on ebay a bit cheaper)

To get it to work requires the TFT driver in the kernel for: LCD controller ILI9341
It uses a touch controller which can be found in the HK kernel tree at: /usr/src/linux/drivers/mfd/stmpe.c
(I have not rebuilt my kernel yet with it enabled)

To enable the TFT display under Ubuntu on the Odroid-C1:
I put the following in /etc/modules:

Code: Select all

fb_ili9341
fbtft
fbtft_device name=pitft  rotate=90 gpios=dc:103 speed=8000000 cs=0
With the HDMI port enabled I have the following framebuffers:

Code: Select all

# ll /dev/fb*
crw-rw---- 1 root video 29, 0 Dec 31  1969 /dev/fb0
crw-rw---- 1 root video 29, 1 Dec 31  1969 /dev/fb1
crw-rw---- 1 root video 29, 2 Jan 22 19:02 /dev/fb2
lrwxrwxrwx 1 root root      3 Dec 31  1969 /dev/fb6 -> fb1
The TFT is /dev/fb2

I brought X up on the little TFT by creating the following in this directory: /usr/share/X11/xorg.conf.d/

Code: Select all

# cat 99-fbdev.conf
Section "Device"
        Identifier "myfb"
        Driver "fbdev"
        Option "fbdev" "/dev/fb2"
EndSection
However to use it as just an adjunct display to the HDMI do not create that file

Here is some python code I use to test that TFT
It requires pygame be installed

Code: Select all

import os, sys, pygame
from pygame.locals import *
from math import pi

WHITE = 255,255,255
GREEN = 0,255,0
BLACK = 0,0,0
BLUE  = 0,0,255
RED   = 255,0,0

#function to convert radians to degrees
def deg(rad):
    return rad * pi/180

size = width, height = 320, 240

os.putenv('SDL_FBDEV', '/dev/fb2')
os.putenv('SDL_VIDEODRIVER', 'fbcon')
os.putenv('SDL_NOMOUSE', '1')
screen = pygame.display.set_mode(size)
pygame.display.set_caption("pygame.draw functions ~ examples")
pygame.init()

#draw a few rectangles
rect1 = pygame.draw.rect(screen, WHITE, (20,20,60,60),0) #filled = 0
rect2 = pygame.draw.rect(screen, WHITE, (100,20,60,60),3) # not filled

#draw a few polygons
points = []
points.append((20,100))
points.append((80,100))
points.append((80,160))
poly1 = pygame.draw.polygon(screen, WHITE, points, 0) #filled
points=[]
points.append((100,100))
points.append((160,100))
points.append((160,160))
points.append((100,160))
poly2 = pygame.draw.polygon(screen, WHITE, points, 3) #not filled

#draw a few circles
circ1 = pygame.draw.circle(screen, WHITE, (50,180), 30, 0) #filled
circ2 = pygame.draw.circle(screen, WHITE, (130,180), 30, 3) #filled

#draw an ellipse
ellipse1 = pygame.draw.ellipse(screen, WHITE, (20,220,140,60), 3)

#draw a few arcs
arc1 = pygame.draw.arc(screen, WHITE, (20,290,60,60),deg(0), deg(90), 3)
arc2 = pygame.draw.arc(screen, WHITE, (100,290,60,60),deg(90), deg(270), 3)

#draw a few lines
for n in range(5):
    pygame.draw.line(screen, WHITE, (20,350+(10*n)), (100,350), 2)
    pygame.draw.line(screen, GREEN, (20,390), (100,350+(10*n)), 2)

#draw a few anti aliased lines
#for n in range(5):
#    pygame.draw.aaline(screen, WHITE, (120,390), (250,350+(10*n)), 1)

#draw a few aaline sequences
CLOSED = 1
OPEN = 0
points=[]
points.append((180,100))
points.append((240,100))
points.append((240,160))
points.append((180,160))
#pygame.draw.aalines(screen, GREEN, OPEN, points, 1)
points.append((260,100))
points.append((320,100))
points.append((320,160))
points.append((260,160))
#pygame.draw.aalines(screen, GREEN, CLOSED, points, 1)

#now we draw onto a new surface, and blit the result to the screen

#create myimage and set transparancy to top left pixel
newsurface = pygame.Surface((80,80))
myimage = newsurface.convert()
ckey = myimage.get_at((0,0))
myimage.set_colorkey(ckey, RLEACCEL)

#draw onto myimage
myimage.fill(BLACK)
pygame.draw.rect(myimage, BLUE, (5,5,70,70),0)   # A BLUE block
pygame.draw.rect(myimage, RED, (20,20,40,40),0)  # A RED block
pygame.draw.line(myimage, WHITE, (10,70), (70,10), 5) #white line
pygame.draw.line(myimage, WHITE, (10,10), (70,70), 5) #white line

#blit 2 copies of myimage to screen
screen.blit(myimage,(175,10))
screen.blit(myimage,(250,10))

#Lets create some text. We could use a loop, but lets keep it simple
font = pygame.font.Font(None, 35)
fontimg1 = font.render("pygame.draw",1,WHITE)
fontimg2 = font.render("functions",1,WHITE)
fontimg3 = font.render("working",1,GREEN)
fontimg4 = font.render("examples",1,GREEN)
screen.blit(fontimg1, (170,196))
screen.blit(fontimg2, (185,230))
screen.blit(fontimg3, (190,260))
screen.blit(fontimg4, (185,290))
while 1:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.display.quit()
            sys.exit(0)
        elif event.type == KEYDOWN and event.key == K_ESCAPE:
            pygame.display.quit()
            sys.exit(0)
    pygame.display.update()
    pygame.time.delay(500)
The only problem with it is my HDMI display blanks during the TFT use.
If you do not mind that it works fine, and would also as your standalone display
It is probably some config I'm missing to stop it from blanking HDMI during TFT use.


Update: for the touchscreen driver
STMPE610 --> http://lxr.free-electrons.com/ident?i=stmpe610
On odroid-c1 source:

Code: Select all

# ll /usr/src/linux/drivers/mfd/stmpe*
-rw-r--r-- 1 root root 30514 Jan 21 23:40 /usr/src/linux/drivers/mfd/stmpe.c
-rw-r--r-- 1 root root  8801 Jan 21 23:40 /usr/src/linux/drivers/mfd/stmpe.h
-rw-r--r-- 1 root root  2645 Jan 21 23:40 /usr/src/linux/drivers/mfd/stmpe-i2c.c
-rw-r--r-- 1 root root 62916 Jan 22 22:23 /usr/src/linux/drivers/mfd/stmpe-i2c.o
-rw-r--r-- 1 root root 73184 Jan 22 22:23 /usr/src/linux/drivers/mfd/stmpe.o
-rw-r--r-- 1 root root  3254 Jan 21 23:40 /usr/src/linux/drivers/mfd/stmpe-spi.c
-rw-r--r-- 1 root root 65548 Jan 22 22:23 /usr/src/linux/drivers/mfd/stmpe-spi.o
I compiled it into the kernel... now to figure out how to get it working

update: I found what is needed:

Code: Select all

# ll /usr/src/linux/drivers/input/touchscreen/stmpe-ts.c
-rw-r--r-- 1 root root 10375 Jan 21 23:40 /usr/src/linux/drivers/input/touchscreen/stmpe-ts.c
In your kernel build under: Input device support --> Touchscreens --> STMicroelectronics STMPE touchscreen

Load stmpe-ts module in /etc/modules, then you will have to configure a touch input and calibrate it:
https://learn.adafruit.com/adafruit-pit ... -calibrate
odroidlcd.jpg
Sainsmart 2.8" TFT on Odroid-c1
odroidlcd.jpg (92.05 KiB) Viewed 4480 times

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Mon Jul 20, 2015 12:33 am

Hi,


I just got this 2,8" TFT module and I am wondering how to wire it to the C1 gpios?
The odroid wiki http://odroid.com/dokuwiki/doku.php?id=en:c1_lcdshield refers to the odroid tft board and not this one, and the PIN names on the TFT assembly board does not match what we have on the wiki except of course for the SPI in/out and clock. (

Any help would be appreciated, including the wiring for the touch screen part as well.
Fab

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Wed Aug 05, 2015 1:50 am

Hi,


I am trying to include stmpe-ts module in the kernel as explained above. Making a make menuconfig from the latest kernel src, I did not find any "STMicroelectronics STMPE touchscreen" under "touchscreen" input device driver.
Nevertheless, the stmpe-ts.c source file IS there (in linux/drivers/input/touchscreen/)
So what should I do, to have it in the menuconfig, to be able to select it?

Fab

mlinuxguy
Posts: 793
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by mlinuxguy » Wed Aug 05, 2015 3:34 pm

To enable STMPE
Depends on: HAS_IOMEM [=y] && MFD_STMPE [=n] && SPI_MASTER [=y]

So you need to enable each of those if not already enabled
MFD_STMPE ->
Device Drivers │
│ (2) -> Multifunction device drivers │

Note: you can find the other dependencies by:
bring up: make menuconfig
hit: /
then enter: SMTPE

look at all the dependencies and make sure you enable them, then SMTPE will show up.

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Wed Aug 05, 2015 8:50 pm

Code: Select all

To enable STMPE
Depends on: HAS_IOMEM [=y] && MFD_STMPE [=n] && SPI_MASTER [=y] 

So you need to enable each of those if not already enabled
MFD_STMPE -> 
Device Drivers │
│ (2) -> Multifunction device drivers │
Thanks a lot! I did not enable multifunction device drivers before going to the touchscreen modules section.:-(

So now the modprobe stmpe-ts is ok. lsmod shows that the module is loaded and I got this from dmesg:
[ 8.578791@0] ==touch_ts_init==
[ 12.167098@3] ads7846 spi0.1: touchscreen, irq 96
I created a udev file:
/etc/udev/rules.d/95-stmpe.rules

with the following content:
SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
then rebooting the C1 to take the input event into account, but when I did this:
ls -l /dev/input/touchscreen
I do not see any touchscreen event device!

What did I miss?

Fab

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Thu Aug 06, 2015 12:07 am

Looking at dmes again:
[ 12.000110@2] spicc spicc: cs_gpios[0] = GPIOX_20(117)
[ 12.000120@2] spicc spicc: cs_gpios[1] = GPIOX_21(118)
[ 12.000136@2] spicc spicc: regs = fe108d80
[ 12.000557@2] spicc spicc: master is unqueued, this is deprecated
[ 12.053215@2] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 2000000, spi->chip_select = 0, spi->mode = 0x00
[ 12.070846@2] spi spi0.1: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 1000000, spi->chip_select = 1, spi->mode = 0x00
[ 12.071318@2] ads7846 spi0.1: touchscreen, irq 96
[ 12.071851@2] input: ADS7846 Touchscreen as /devices/platform/spicc/spi_master/spi0/spi0.1/input/input1
[ 12.072282@2] spicc spicc: SPICC init ok
[ 12.169287@1] fbtft_device: spidev spi0.0 2000kHz 8 bits mode=0x00
[ 12.169296@1] fbtft_device: ads7846 spi0.1 1000kHz 8 bits mode=0x00
It seems that the touchscreen driver used is ads7846 on the second SPI channel (spi0.1) and unfortunetely not the stmpe one!, even that stmpe module is properly loaded.... :?:

mlinuxguy
Posts: 793
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by mlinuxguy » Thu Aug 06, 2015 3:13 pm

In directory: root@odroid-dev:/usr/src/linux/arch/arm/boot/dts
# vi meson8b_odroidc.dts
In this section:

Code: Select all

        /* SPI Touch Screen Define */
        ads7846@1 {
            spi-max-frequency = <1000000>;
change this register value to 0:

Code: Select all

            /*
                SPI Chip Select : (0 ~ 1)
                    Chip Select = GPIOX_21 (CS1)
            */
            reg = <1>;
Rebuild dts, copy to boot etc...

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Thu Aug 06, 2015 6:04 pm

Mlinuxguy, Again, thx a lot for your help...

I changed the register value and reset it to 0, rebuild dts, and copy the new dtb into /media/boot.

Still not working for the moment.
This is what I get from dmesg regarding spi: (dmesg | grep spi)
[ 11.931915@0] spicc spicc: device_id = 0
[ 11.931996@0] spicc spicc: pinctrl_name = default
[ 11.932006@0] spicc spicc: num_chipselect = 2
[ 11.932023@0] spicc spicc: cs_gpios[0] = GPIOX_20(117)
[ 11.932033@0] spicc spicc: cs_gpios[1] = GPIOX_21(118)
[ 11.932052@0] spicc spicc: regs = fe108d80
[ 11.932847@0] spicc spicc: master is unqueued, this is deprecated
[ 11.970461@0] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 2000000, spi->chip_select = 0, spi->mode = 0x00
[ 12.003890@0] spicc spicc: chipselect 0 already in use
[ 12.003982@0] spi_master spi0: spi_device register error /spi@c1108d80/ads7846@1
[ 12.010905@0] spicc spicc: SPICC init ok
[ 12.171752@2] fbtft_device: spidev spi0.0 2000kHz 8 bits mode=0x00
[ 12.171836@2] fbtft_device: Deleting spi0.0
[ 12.173324@2] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 8000000, spi->chip_select = 0, spi->mode = 0x00
[ 12.173945@2] fbtft_device: fb_ili9340 spi0.0 8000kHz 8 bits mode=0x00
[ 12.695120@2] graphics fb2: fb_ili9340 frame buffer, 320x240, 152 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 8 MHz
So compare to before, with register set to 1, I now got an error, regarding ads7846 registering. spi0.1 is no longer valid too. And it seems that there is conflictual situation between the chip select between display and touchscreeen.

and obviously:
dmesg | grep touch
give me:
[ 8.588785@0] ==touch_ts_init==
so stmpe-ts seems to be not used again....:-(

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Fri Aug 07, 2015 4:03 am

In order to go ahead, and find out why stmpe_ts is loaded but never used, I modified the DTS SPI Touch screen section like this:

Code: Select all

        spidev@0 {
            spi-max-frequency = <2000000>;
            compatible = "spidev";
            reg = <0>;
        };
                /* SPI Touch Screen Define */
                stmpe_ts@1 {
                        spi-max-frequency = <1000000>;

            /*
                            Driver Select : "ti,tsc2046", "ti,ads7843", "ti,ads7845", "ti,ads7846", "ti,ads7873"
                                kernel/drivers/hardkernel/ads7846.c
                        */
                        compatible = "stmpe_ts";

            /*
                SPI Chip Select : (0 ~ 1)
                    Chip Select = GPIOX_21 (CS1)
            */
                        reg = <1>;
(Just replaced ar7346 with stmpe_ts in order to force to use it)
(Please note that from the previous post, I set reg=<1> again, otherwise I got a conflictual situation with the display as I explained in my previous post)

I have a 95-stmpe_ts.rules file in /etc/udev/rules.d/ which looks like:

Code: Select all

SUBSYSTEM=="input", ATTRS{name}=="stmpe_ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"

and dmesg | grep spi returns something like this:

Code: Select all

[   11.901159@2] spicc spicc: device_id = 0 
[   11.901216@2] spicc spicc: pinctrl_name = default
[   11.901224@2] spicc spicc: num_chipselect = 2
[   11.901238@2] spicc spicc: cs_gpios[0] = GPIOX_20(117)
[   11.901248@2] spicc spicc: cs_gpios[1] = GPIOX_21(118)
[   11.901263@2] spicc spicc: regs = fe108d80
[   11.901551@2] spicc spicc: master is unqueued, this is deprecated
[   11.932184@2] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 2000000, spi->chip_select = 0, spi->mode = 0x00
[   11.938834@0] spi spi0.1: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 1000000, spi->chip_select = 1, spi->mode = 0x00
[   11.938964@0] spicc spicc: SPICC init ok 
[   12.379708@1] fbtft_device:      spidev spi0.0 2000kHz 8 bits mode=0x00
[   12.379713@1] fbtft_device:      stmpe_ts spi0.1 1000kHz 8 bits mode=0x00
[   12.379772@1] fbtft_device: Deleting spi0.0
[   12.380099@2] spi spi0.0: spicc_setup : spi->bits_per_word = 8, spi->max_spped_hz = 8000000, spi->chip_select = 0, spi->mode = 0x00
[   12.380188@2] fbtft_device:      stmpe_ts spi0.1 1000kHz 8 bits mode=0x00
[   12.380192@2] fbtft_device:      fb_ili9340 spi0.0 8000kHz 8 bits mode=0x00
[   13.222887@1] graphics fb2: fb_ili9340 frame buffer, 320x240, 152 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 8 MHz
So everthing seems to be nearly ok, as the touchscreen is on SPI CS1 (gpio#118), stmpe_ts seems to be used instead of ar7346

lsmod gives me:

Code: Select all

uinput                  6669  1 
ir_lirc_codec           4243  3 
lirc_dev               10110  1 ir_lirc_codec
ir_mce_kbd_decoder      3092  0 
ir_sony_decoder         1667  0 
ir_sanyo_decoder        1638  0 
ir_jvc_decoder          1664  0 
ir_rc5_decoder          1552  0 
ir_rc6_decoder          2024  0 
ir_nec_decoder          1776  0 
meson_ir                2902  0 
fb_ili9340              3577  1 
fuse                   70879  2 
stmpe_ts                3807  0 
fbtft_device           37443  0 
fb_ili9341              3976  0 
fbtft                  33563  3 fb_ili9340,fb_ili9341,fbtft_device
aml_gpio                7838  0 
syscopyarea             2961  1 fbtft
sysfillrect             3330  1 fbtft
sysimgblt               2067  1 fbtft
fb_sys_fops             1312  1 fbtft
spidev                  5505  0 
spicc                   7846  0 
aml_i2c                18975  0 
nls_cp437               5125  1 
but unfortunetely, running an evtest returns:

Code: Select all

Available devices:
/dev/input/event0:	cec_input
/dev/input/event1:	meson-ir
/dev/input/event2:	MCE IR Keyboard/Mouse (meson-ir)
/dev/input/event3:	lircd
so again no touchscreen available!!

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Sun Aug 09, 2015 7:13 pm

Going further to have this pitft touchscreen working on the C1

I modified mesonb_dts in order to have stmpe_ts instead of the ads7846 object:
spidev@0 {
spi-max-frequency = <2000000>;
compatible = "spidev";
reg = <0>;
};
/* SPI Touch Screen Define */
stmpe-ts@1 {
spi-max-frequency = <1000000>;
compatible = "ti,stmpe610";
/*
SPI Chip Select : (0 ~ 1)
Chip Select = GPIOX_21 (CS1)
*/
reg = <1>;
/* AMLogic Interrupt Define */
/*
IRQ Source : (GPIO_IRQ0(0) ~ GPIO_IRQ7(7))
*/
irq-source = <0>;
/*
IRQ Filter Select : (0 ~ 7)
Value 0 : No Filtering, Value 1 ~ 7 : value * 3 * 111nS(delay)
*/
irq-filter = <7>; /* 258.741us Delay */
/*
IRQ Trigger Select : (0 ~ 3)
GPIO_IRQ_HIGH = 0, GPIO_IRQ_LOW = 1, GPIO_IRQ_RISING = 2, GPIO_IRQ_FALLING = 3
*/
irq-trigger = <3>; /* GPIO_IRQ_FALLING (Trigger Interrupt) */
/* FIFO-TH is irq name for stmpe-ts IRQ*/
FIFO-TH = "GPIOX_5";
linux,wakeup;
};
};

and yet get nothing related to stmpe in dmesg. So it seems that stmpe-ts even loaded, does not detect the stmpe610 on spi. Should I change the parent name for the stmpe-ts object.? (spidev to stmpe-dev?)

Fab

fab
Posts: 212
Joined: Mon Apr 28, 2014 3:51 pm
languages_spoken: english French
ODROIDs: Odroid W + Odroid C0 + Odroid C1 + Odroid C2
Location: France Orleans
Contact:

Re: Working: SainSmart 2.8" TFT LCD Module 320*240

Unread post by fab » Mon Aug 10, 2015 1:32 am

Next step: stmpe-ts is now started and gave me a chip ID error, when looking into dmesg:
[ 7.545771@1] stmpe-spi spi0.1: unknown chip id: 0x2010
[ 7.548393@1] stmpe-spi: probe of spi0.1 failed with error -22
Looking into stmpe.c here:

Code: Select all

static int stmpe_chip_init(struct stmpe *stmpe)
{
        unsigned int irq_trigger = stmpe->pdata->irq_trigger;
        int autosleep_timeout = stmpe->pdata->autosleep_timeout;
        struct stmpe_variant_info *variant = stmpe->variant;
        u8 icr = 0;
        unsigned int id;
        u8 data[2];
        int ret;

        ret = stmpe_block_read(stmpe, stmpe->regs[STMPE_IDX_CHIP_ID],
                               ARRAY_SIZE(data), data);
        if (ret < 0)
                return ret;

        id = (data[0] << 8) | data[1];
        if ((id & variant->id_mask) != variant->id_val) {
                dev_err(stmpe->dev, "unknown chip id: %#x\n", id);
                return -EINVAL;
        }

        dev_info(stmpe->dev, "%s detected, chip id: %#x\n", variant->name, id);
I am very closed for the stmpe-ts chip to be detected!
(The ST datasheet gives 0x0811 for a chip ID and not that fancy ID 0X2010 I got...)

I did a lot of changes in the meson8b-odroidc.dts in order to acheive this:
spidev@0 {
spi-max-frequency = <2000000>;
compatible = "spidev";
reg = <0>;
};
/* SPI Touch Screen Define */
stmpe-ts@1 {
spi-max-frequency = <500000>;
compatible = "st,stmpe610";

/*
SPI Chip Select : (0 ~ 1)
Chip Select = GPIOX_21 (CS1)
*/
reg = <1>;


/* AMLogic Interrupt Define */
/*
IRQ Source : (GPIO_IRQ0(0) ~ GPIO_IRQ7(7))
*/
interrupts = <0>;


/*
IRQ Filter Select : (0 ~ 7)
Value 0 : No Filtering, Value 1 ~ 7 : value * 3 * 111nS(delay)
*/
irq-filter = <7>; /* 258.741us Delay */

/*
IRQ Trigger Select : (0 ~ 3)
GPIO_IRQ_HIGH = 0, GPIO_IRQ_LOW = 1, GPIO_IRQ_RISING = 2, GPIO_IRQ_FALLING = 3
*/
irq-trigger = <3>; /* GPIO_IRQ_FALLING (Trigger Interrupt) */

linux,wakeup;
stmpe_touchscreen {
compatible = "st,stmpe-ts";
st,sample-time = <4>;
st,mod-12b = <1>;
st,ref-sel = <0>;
st,adc-freq = <1>;
st,ave-ctrl = <1>;
st,touch-det-delay = <2>;
st,settling = <2>;
st,fraction-z = <7>;
st,i-drive = <1>;
};
};
};
and because the stmpe.c version from the hardkernel github is so old, and did not include the latest stmpe patches regarding the GPIO interrupt capabilities, I had to perform this:
echo 102 > /sys/class/aml_gpio/export
This did a link between GPIO#102 (GPIOX-BITS5) and interrupt 0 defined in this device tree.
(In the latest stmpe.c patch, we can add the key irq-gpio="GPIOX-BIT5" to the device tree, which avoid the export above.

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 4 guests