A-P Posted July 1, 2017 Posted July 1, 2017 (edited) Dear @ldiaz, I really appericiate your help. Thanks. As you instructed above I change PA7 to PA10 (pin 26 is my lcd's touch CS and according to conversion chart pin26 is GPIO10 or PA10). At first I changed Whaterver I found as PA7 to PA10. even pendown-gpio = <&pio 0 10 0> Spoiler /* * Generic Device Tree overlay for the ADS7846 touch controller ported from * RPI overlay to sun8i-h3. * Tested on Orange Pi Zero with XPT2046 with two spi slaves: * This DT requires that that spi-add-cs1 overlay is loaded. it * * Notes for customization: * Fragment 0 can be commented as the alias already exists. * Fragment 1: customize you pins to your desired pin out. * pins= "<pin_id>" in this example is set to PA10; * function = "irq" or "gpio_in"; tested with both with similar results * bias-pull-up; comment if your display has no pull-up-resistor. * Fragment 2: * target: spi sub-tree selected, for this example &spi1 * spidev@0: Section for CS=0(reg=<0>) for screen. if managed using fbtft_device * driver this section can be deleted if not a /dev/spiN.0 will be created * * ads7846: * - spi-max-frequency =<Hz> * - reg: <N> CS for the application * - interrupts: <bank gpio type> type=2 IRQ_TYPE_EDGE_FALLING * - pendown-gpio = <&pio bank gpio 0> * * For additional parameters: see https://www.kernel.org/doc/Documentation/devicetree/bindings/input/ads7846.txt * */ /dts-v1/ /plugin/; / { compatible = "allwinner,sun8i-h3"; /* fragment@0 { target-path = "/aliases"; __overlay__ { spi1 = "/soc/spi@01c69000"; }; }; */ fragment@1 { target = <&pio>; __overlay__ { ads7846_pins: ads7846_pins { pins= "PA10"; /* TIRQ of the screen is connected to PA10" */ function = "irq"; /* gpio_in also works */ bias-pull-up; /* pull up resistor present comment this line if not */ }; }; }; fragment@2 { target = <&spi1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; /* Leave the first CS as in template * this section can be removed if other driver is using CS=0 spidev@0 { reg = <0>; // Chip Select 0 compatible = "spidev"; spi-max-frequency = <1600000>; status = "okay"; }; */ /* custom ads7846 definition */ ads7846: ads7846@1 { compatible = "ti,ads7846"; reg = <1>; /* Chip Select 1 */ pinctrl-names = "default"; pinctrl-0 = <&ads7846_pins>; spi-max-frequency = <1600000>; interrupts = <0 10 2>; /* <bank gpio type> bank=0 port=10 (PA10) type=2 -> high-to-low edge triggered */ interrupt-parent = <&pio>; pendown-gpio = <&pio 0 10 0>; /* <&pio bank gpio 0> change to bank=0 port=10 for PA10 */ /* driver defaults */ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0x0FFF>; ti,y-max = /bits/ 16 <0x0FFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; }; }; }; }; And it did not work. Also changed only the section ads7846_pins: ads7846_pins like this Spoiler /* * Generic Device Tree overlay for the ADS7846 touch controller ported from * RPI overlay to sun8i-h3. * Tested on Orange Pi Zero with XPT2046 with two spi slaves: * This DT requires that that spi-add-cs1 overlay is loaded. it * * Notes for customization: * Fragment 0 can be commented as the alias already exists. * Fragment 1: customize you pins to your desired pin out. * pins= "<pin_id>" in this example is set to PA7; * function = "irq" or "gpio_in"; tested with both with similar results * bias-pull-up; comment if your display has no pull-up-resistor. * Fragment 2: * target: spi sub-tree selected, for this example &spi1 * spidev@0: Section for CS=0(reg=<0>) for screen. if managed using fbtft_device * driver this section can be deleted if not a /dev/spiN.0 will be created * * ads7846: * - spi-max-frequency =<Hz> * - reg: <N> CS for the application * - interrupts: <bank gpio type> type=2 IRQ_TYPE_EDGE_FALLING * - pendown-gpio = <&pio bank gpio 0> * * For additional parameters: see https://www.kernel.org/doc/Documentation/devicetree/bindings/input/ads7846.txt * */ /dts-v1/ /plugin/; / { compatible = "allwinner,sun8i-h3"; /* fragment@0 { target-path = "/aliases"; __overlay__ { spi1 = "/soc/spi@01c69000"; }; }; */ fragment@1 { target = <&pio>; __overlay__ { ads7846_pins: ads7846_pins { pins= "PA10"; /* TIRQ of the screen is connected to PA10" */ function = "irq"; /* gpio_in also works */ bias-pull-up; /* pull up resistor present comment this line if not */ }; }; }; fragment@2 { target = <&spi1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; /* Leave the first CS as in template * this section can be removed if other driver is using CS=0 spidev@0 { reg = <0>; // Chip Select 0 compatible = "spidev"; spi-max-frequency = <1600000>; status = "okay"; }; */ /* custom ads7846 definition */ ads7846: ads7846@1 { compatible = "ti,ads7846"; reg = <1>; /* Chip Select 1 */ pinctrl-names = "default"; pinctrl-0 = <&ads7846_pins>; spi-max-frequency = <1600000>; interrupts = <0 7 2>; /* <bank gpio type> bank=0 port=7 (PA7) type=2 -> high-to-low edge triggered */ interrupt-parent = <&pio>; pendown-gpio = <&pio 0 7 0>; /* <&pio bank gpio 0> change to bank=0 port=7 for PA7 */ /* driver defaults */ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0x0FFF>; ti,y-max = /bits/ 16 <0x0FFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; }; }; }; }; Again no luck. I also added the line user_overlays= ads7846-touch to armbianEnv.txt and compiled the dts file. (armbian default dts compilers throws error so I downloaded and compiled a dtc. Both of them does not work. Do I have to change spi number in dts file as in orange pi spi0 is used for spi flash and spi1 is for lcd ? Best regards and thanks again. Edited July 1, 2017 by zador.blood.stained Added spoiler tags
rlsten Posted July 1, 2017 Posted July 1, 2017 Thanks also @ldiaz for your guide! I interpreted the instructions somewhat differently than @A-P but unfortunately, I could not get it to work either. I assumed that the change in the ads7846_pins section of "touch.dt" referred to Physical Pin 11 of the LCD screen, the "TP_IRQ","Touch Panel Interrupt". Since the screen sits as a hat on the Orange Pi Zero, physical pin 11 on the Pi Zero is assigned to "PA1 or GPIO1". So I changed "touch.dt" as follows: /* * Generic Device Tree overlay for the ADS7846 touch controller ported from * RPI overlay to sun8i-h3. * Tested on Orange Pi Zero with XPT2046 with two spi slaves: * This DT requires that that spi-add-cs1 overlay is loaded. it * * Notes for customization: * Fragment 0 can be commented as the alias already exists. * Fragment 1: customize you pins to your desired pin out. * pins= "<pin_id>" in this example is set to PA7; * function = "irq" or "gpio_in"; tested with both with similar results * bias-pull-up; comment if your display has no pull-up-resistor. * Fragment 2: * target: spi sub-tree selected, for this example &spi1 * spidev@0: Section for CS=0(reg=<0>) for screen. if managed using fbtft_device * driver this section can be deleted if not a /dev/spiN.0 will be created * * ads7846: * - spi-max-frequency =<Hz> * - reg: <N> CS for the application * - interrupts: <bank gpio type> type=2 IRQ_TYPE_EDGE_FALLING * - pendown-gpio = <&pio bank gpio 0> * * For additional parameters: see https://www.kernel.org/doc/Documentation/devicetree/bindings/input/ads7846.txt * */ /dts-v1/ /plugin/; / { compatible = "allwinner,sun8i-h3"; /* fragment@0 { target-path = "/aliases"; __overlay__ { spi1 = "/soc/spi@01c69000"; }; }; */ fragment@1 { target = <&pio>; __overlay__ { ads7846_pins: ads7846_pins { pins= "PA1"; /* TIRQ of the screen is connected to PA07" */ function = "irq"; /* gpio_in also works */ bias-pull-up; /* pull up resistor present comment this line if not */ }; }; }; fragment@2 { target = <&spi1>; __overlay__ { #address-cells = <1>; #size-cells = <0>; status = "okay"; /* Leave the first CS as in template * this section can be removed if other driver is using CS=0 spidev@0 { reg = <0>; // Chip Select 0 compatible = "spidev"; spi-max-frequency = <1600000>; status = "okay"; }; */ /* custom ads7846 definition */ ads7846: ads7846@1 { compatible = "ti,ads7846"; reg = <1>; /* Chip Select 1 */ pinctrl-names = "default"; pinctrl-0 = <&ads7846_pins>; spi-max-frequency = <1600000>; interrupts = <0 1 2>; /* <bank gpio type> bank=0 port=7 (PA7) type=2 -> high-to-low edge triggered */ interrupt-parent = <&pio>; pendown-gpio = <&pio 0 1 0>; /* <&pio bank gpio 0> change to bank=0 port=7 for PA7 */ /* driver defaults */ ti,x-min = /bits/ 16 <0>; ti,y-min = /bits/ 16 <0>; ti,x-max = /bits/ 16 <0x0FFF>; ti,y-max = /bits/ 16 <0x0FFF>; ti,pressure-min = /bits/ 16 <0>; ti,pressure-max = /bits/ 16 <0xFFFF>; ti,x-plate-ohms = /bits/ 16 <400>; }; }; }; }; I tried this with the changes to both fragment 1 and fragment 2, and just fragment 1, but neither worked. I also followed all the other steps set out by @ldiaz I suspect the problem is with physical Pin 26, which @A-P rightly points out is assigned to PA10 or GPIO10 on the Orange Pi Zero. According to the Pin-out for the screen, Physical Pin 26 is supposed to be mapped to "TP_CS, Touch Panel chip selection". But physical pin 26 on the Orange Pi Zero is mapped to SIM_DET/PA_EINT10 / PA10 / GPIO10. On the Raspberry Pi 2/3, where the screen works fine, Physical Pin 26 is mapped to "SPI0_CE0, GPIO7". So it seems that something has to be done to tell the Orange Pi that physical pin 26 is assigned to SPI0_CE0. It seems that part of fragment 2 is attempting to do that. I also found this thread, How to enable ads7846, where there is a lot of discussion about needing two SPI busses, one for the screen, we are using Bus 1, and a separate bus for the touch panel, in our case probably bus 0. Should we change fragment 2 to reflect that we are using bus 1 for the screen? I note that I am using the "fbtft_device driver", is it a problem if we don't delete the spidev@0 section of fragment@2? Or should that be spidev@1? I also see that when the ads_7846 module is set out in /etc/modules in the Raspberry Pi, there are numerous settings that are included, for example: ads7846_device model=7846 cs=1 gpio_pendown=17 keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900 On the orange Pi zero, I think gpio_pendown would =1. (On the Raspberry Pi, physical pin 11 is GPIO17.) Does something similar need to be done here? Or does the compiled "ads7846-touch.dbto" overlay handle that? I apologize for my ignorance about a lot of this, but I hope my questions will help show what I am doing wrong. Thanks again for all your efforts to make this work!
rlsten Posted July 1, 2017 Posted July 1, 2017 Update to my prior post: I was able to get touch working using fresh mainline downloaded today, after update and upgrade, with the compiled ads7486-touch.dtbo based the edits I made to touch.dt from my previous post. PA1 is the correct pin for the interrupt. I left everything else as @ldiaz had it. Thanks again to @ldiaz!
rlsten Posted July 3, 2017 Posted July 3, 2017 Hi @A-P: Attached is the touch.dts I used. I have also attached the ads7846-touch.dtbo overlay file. These give me touch responsiveness on mainline. However, I can't seem to rotate the screen to landscape, and the colors and layout are screwed up, so I really haven't been able to calibrate or make real use of touch with this. But it definitely responds to touch. On legacy, the screen rotates fine and looks great, but touch won't work. Let me know how it comes out for you. Best, Rod ads7846-touch.dtbo touch.dts
A-P Posted July 4, 2017 Posted July 4, 2017 Hi @rlsten Thanks you for the files I will test and tell you the result asap. For rotating the screen you should add this to your armbianEnv.txt --> extraargs="fbcon=rotate:2" for rotating the screen in lxde you should add --> Option "Rotate" "CCW" to file /etc/X11/xorg.conf The screen is also screwed up for me. I don't know what is the problem.
adrb Posted July 4, 2017 Posted July 4, 2017 It's screwed because you're trying to have two devices on one bus, without correct CS pins definitions. I can make tutorial for mainline kernel, based on my OPIZ and ili9431+ads7846, but im not sure where I shoud put it so other people can find it easy.
zador.blood.stained Posted July 4, 2017 Posted July 4, 2017 1 hour ago, adrb said: It's screwed because you're trying to have two devices on one bus, without correct CS pins definitions. Additional CS should be added by the "spi-add-cs1" overlay, as referenced in the overlay source On 01.07.2017 at 4:41 PM, rlsten said: * This DT requires that that spi-add-cs1 overlay is loaded. assuming that CS1 pin added by this overlay is correct for the discussed display pinout.
rlsten Posted July 4, 2017 Posted July 4, 2017 2 hours ago, adrb said: I can make tutorial for mainline kernel, based on my OPIZ and ili9431+ads7846, but im not sure where I shoud put it so other people can find it easy. A tutorial would be great! Maybe you can start a new thread with some kind of sticky, with a reference to the tutorial in this thread. Anyway, we'd really appreciate a step-by-step for this--we seem to be close but are obviously missing something.
glow Posted July 5, 2017 Author Posted July 5, 2017 @adrb A tutorial would be greatly appreciated. Since mainline topics are now separated from legacy it'll be much easier to find. I suggest starting a new thread in h2 & h3 mainline section (the section this thread is in) and go from there. And thank you!
adrb Posted July 5, 2017 Posted July 5, 2017 20 hours ago, glow said: I suggest starting a new thread in h2 & h3 mainline section (the section this thread is in) and go from there Ok, seems reasonable. Look here
glow Posted July 7, 2017 Author Posted July 7, 2017 Nice work @adrb! Thank you for taking the time to capture the information. It'll be very useful.
Kevin Wietzorek Posted March 20, 2018 Posted March 20, 2018 Hey guys, I need help with my 3.5" TFT with touch (ili9486 + ads7846) Here are some basic infos, using the mainline kernel on an Orange Pi Zero (Chip: H2+): root@orangepizero:~# cat /etc/armbian-release # PLEASE DO NOT EDIT THIS FILE BOARD=orangepizero BOARD_NAME="Orange Pi Zero" BOARDFAMILY=sun8i VERSION=5.38 LINUXFAMILY=sunxi BRANCH=next ARCH=arm IMAGE_TYPE=stable BOARD_TYPE=conf INITRD_ARCH=arm KERNEL_IMAGE_TYPE=zImage On the legacy kernel I used: fbtft_device custom name=fb_ili9486 gpios=dc:18,reset:2 speed=16000000 rotate=90 busnum=1 fps=25 to get the screen working, but on the mainline kernel I get some weird image (see attachment) with rotate=90. I need rotate=90 cause I need the landscape mode. It seems that there is something with the spi speed or the regwidth or so? But I don't know where to change the regwidth in the mainline. Here is my /boot/armbianEnv.txt: verbosity=1 logo=disabled console=both disp_mode=1920x1080p60 overlay_prefix=sun8i-h3 overlays=spi-add-cs1 spi-spidev usbhost2 usbhost3 w1-gpio param_spidev_spi_bus=1 rootdev=UUID=a2c25aee-d15d-4aa7-8f41-ab6bb511776f rootfstype=ext4 user_overlays=touch extraargs="fbcon=map:0" usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u And here is my dmesg | grep spi: [ 8.096553] spi spi1.1: ads7846 spi1.1 1600kHz 8 bits mode=0x00 [ 8.096569] spi spi1.0: spidev spi1.0 1000kHz 8 bits mode=0x00 [ 8.096689] spi spi1.0: Deleting spi1.0 [ 8.097278] spi spi1.1: ads7846 spi1.1 1600kHz 8 bits mode=0x00 [ 8.097286] spi spi1.0: fb_ili9486 spi1.0 16000kHz 8 bits mode=0x00 [ 9.627170] graphics fb0: fb_ili9486 frame buffer, 480x320, 300 KiB video memory, 4 KiB buffer memory, fps=25, spi1.0 at 16 MHz [ 9.821973] ads7846 spi1.1: spi1.1 supply vcc not found, using dummy regulator [ 9.822643] ads7846 spi1.1: touchscreen, irq 52 [ 9.824499] input: ADS7846 Touchscreen as /devices/platform/soc/1c69000.spi/spi_master/spi1/spi1.1/input/input0 And here for dmesg | grep fb: [ 0.000000] Kernel command line: root=UUID=a2c25aee-d15d-4aa7-8f41-ab6bb511776f rootwait rootfstype=ext4 console=tty1 console=ttyS0,115200 hdmi.audio=EDID:0 disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 loglevel=1 ubootpart=378fc799-01 ubootsource=mmc usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u "fbcon=rotate:2" sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16 cgroup_enable=memory swapaccount=1 [ 8.086756] fbtft: module is from the staging directory, the quality is unknown, you have been warned. [ 8.095296] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned. [ 8.097236] fbtft_device: GPIOS used by 'fb_ili9486': [ 8.097252] fbtft_device: 'dc' = GPIO18 [ 8.097260] fbtft_device: 'reset' = GPIO2 [ 8.097286] spi spi1.0: fb_ili9486 spi1.0 16000kHz 8 bits mode=0x00 [ 9.022484] fb_ili9486: module is from the staging directory, the quality is unknown, you have been warned. [ 9.627170] graphics fb0: fb_ili9486 frame buffer, 480x320, 300 KiB video memory, 4 KiB buffer memory, fps=20, spi1.0 at 16 MHz As I said, on the legacy kernel the screen worked nice (without touch) but I need to use the mainline for touch. I am thankful for every help.
Recommended Posts