Jump to content

Overlay for NanoPi Neo with ILI9341; Shared SPI with two CS; Allwinner H3


Recommended Posts

Hi,

 

after having a hard time getting the ILI9341 touchscreen working with the NanoPi Neo (Allwinner H3)  it seems to work now.

 

To have more GPIOs available for other stuff the touch and display need to share SPI0

 

I would like to upload it to github because there is basically nothing out of the box available but I'm a total noob with NanoPi, Armbian and overlays so maybe someone could look at it.

 

root@nanopineo:~# uname -a
Linux nanopineo 5.15.93-sunxi #23.02.2 SMP Fri Feb 17 00:00:00 UTC 2023 armv7l armv7l armv7l GNU/Linux

 

 

This is the wiring between ILI9341 and NanoPi Neo:

 

 

/*
   3.3v <-->  VCC & LED
   GND  <-->  GND
   PC2  <-->  SCK       & T_CLK
   PC1  <-->  SDO<MISO> & T_DO
   PC0  <-->  SDI<MOSI> & T_DIN
   PA1  <-->  DC
   PG8  <-->  RESET
   PC3  <-->  CS
   PA3  <-->  T_CS
   PG9  <-->  T_IRG
 */

 

 

 

This is the overlay:

 

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun8i-h3";

	fragment@0 {
		target = <&pio>;
		__overlay__ {
			spi0_cs1: spi0_cs1 {
				pins = "PC3"; 
				function = "gpio_out";
				output-high;
			};

			spi1_cs1: spi1_cs1 {
				pins = "PA3"; 
				function = "gpio_out";
				output-high;
			};

			opiz_display_pins: opiz_display_pins {
                pins = "PA1", "PG8", "PA6";
                function = "gpio_out";
            };

            ads7846_pins: ads7846_pins {
                pins = "PG9";
                function = "irq";
            };


		};
	};

	fragment@1 {
		target = <&spi1>;
		__overlay__ {
			pinctrl-names = "default", "default";
			pinctrl-1 = <&spi1_cs1>;
			cs-gpios = <0>, <&pio 0 3 0>; /* PA3 */
		};
	};

	fragment@2 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			pinctrl-names = "default", "default";
			cs-gpios= <&pio 2 3 0>, <&pio 0 3 1>;

			opizdisplay: opiz-display@0 {
			    pinctrl-1 = <&spi0_cs1>;
				reg = <0>; /* Chip Select 0 */
                compatible = "ilitek,ili9341";
				spi-max-frequency = <1000000>;
				status = "okay";
                pinctrl-names = "default";
                pinctrl-0 = <&opiz_display_pins>;
                rotate = <90>;
                bgr = <0>;
                fps = <33>;
                buswidth = <8>;
                dc-gpios = <&pio 0 1 0>;      /* PIN_22  GPIOA1 > */
                reset-gpios = <&pio 6 8 1 >; /*    GPIOG8> */
                /*led-gpios=<&pio 0 6 0>;        PIN_12  GPIOA6 > */
                debug=<4>;                        
			};

			ads7846: ads7846@1 {
				reg = <1>; /* Chip Select 1 */
				compatible = "ti,ads7846";
				spi-max-frequency = <1000000>;
				status = "okay";
                pinctrl-2=<&spi1_cs1 &spi1_cs1>;
                pinctrl-names = "default";
                pinctrl-3 = <&ads7846_pins>;
                interrupt-parent = <&pio>;
                interrupts = <6 9 2>; /* PG9 IRQ_TYPE_EDGE_FALLING */
                pendown-gpio = <&pio 6 9 0>; /* PG9 */
                /* driver defaults, optional */
                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>;
			};

		};

	};

};

 

 

 

 

 

This is the /boot/armbianEnv.txt

 

verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=usbhost1 usbhost2 spi0
param_spidev_spi_bus=0
param_spidev_spi_cs=1
param_spidev_spi_cs=0
rootdev=UUID=XYZ-LONG-UUID-IS-LONG
rootfstype=ext4
user_overlays=ili-touch-spi
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

 

 

After connecting via ssh and starting evtest it shows this when touched ( not sure if it shows the correct coordinates yet )

 

Event: time 1682020476.763295, -------------- SYN_REPORT ------------
Event: time 1682020476.775286, type 3 (EV_ABS), code 0 (ABS_X), value 535
Event: time 1682020476.775286, type 3 (EV_ABS), code 1 (ABS_Y), value 3553
Event: time 1682020476.775286, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 65169

 

 

 

 

So it looks like everything is working but to be on the safe side I would like to wait until some pro reviewed the overlay.

 

Thanks.

Link to comment
Share on other sites

Does that really work?

It looks like the overlay mixes SPI0 and SPI1 which are two different separated SPI controllers inside the SOC

(of course the NEO only has SPI0 on it's pins)

 

Beside that the dts uses PA6 which isn't wired. What's its purpose?

 

 

 

T.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines