1/*
2 * Copyright (c) 2017 Linaro Limited
3 * Copyright (c) 2024 STMicroelectronics
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8/dts-v1/;
9#include <st/f4/stm32f429Xi.dtsi>
10#include <st/f4/stm32f429zitx-pinctrl.dtsi>
11#include <zephyr/dt-bindings/display/ili9xxx.h>
12#include <zephyr/dt-bindings/input/input-event-codes.h>
13
14/ {
15	model = "STMicroelectronics STM32F429I_DISC1 board";
16	compatible = "st,stm32f4discovery";
17
18	chosen {
19		zephyr,console = &usart1;
20		zephyr,shell-uart = &usart1;
21		zephyr,sram = &sram0;
22		zephyr,flash = &flash0;
23		zephyr,ccm = &ccm0;
24		zephyr,display = &ltdc;
25		zephyr,touch = &stmpe811;
26	};
27
28	sdram2: sdram@d0000000 {
29		compatible = "zephyr,memory-region", "mmio-sram";
30		device_type = "memory";
31		reg = <0xd0000000 DT_SIZE_M(8)>;
32		zephyr,memory-region = "SDRAM2";
33	};
34
35	leds {
36		compatible = "gpio-leds";
37		green_led_3: led_3 {
38			gpios = <&gpiog 13 GPIO_ACTIVE_HIGH>;
39			label = "User LD3";
40		};
41		red_led_4: led_4 {
42			gpios = <&gpiog 14 GPIO_ACTIVE_HIGH>;
43			label = "User LD4";
44		};
45	};
46
47	gpio_keys {
48		compatible = "gpio-keys";
49		user_button: button {
50			label = "User";
51			gpios = <&gpioa 0 GPIO_ACTIVE_LOW>;
52			zephyr,code = <INPUT_KEY_0>;
53		};
54	};
55
56	aliases {
57		led0 = &green_led_3;
58		sw0 = &user_button;
59	};
60
61	lvgl_pointer {
62		compatible = "zephyr,lvgl-pointer-input";
63		input = <&stmpe811>;
64	};
65
66	mipi_dbi {
67		compatible = "zephyr,mipi-dbi-spi";
68		dc-gpios = <&gpiod 13 GPIO_ACTIVE_HIGH>;
69		write-only;
70		#address-cells = <1>;
71		#size-cells = <0>;
72		spi-dev = <&spi5>;
73
74		ili9341: ili9341@0 {
75			compatible = "ilitek,ili9341";
76			mipi-max-frequency = <5625000>;
77			reg = <0>;
78			width = <240>;
79			height = <320>;
80			rotation = <180>;
81			pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
82			pwctrla = [39 2c 00 34 02];
83			pwctrlb = [00 c1 30];
84			timctrla = [85 00 78];
85			timctrlb = [00 00];
86			pwseqctrl = [64 03 12 81];
87			pumpratioctrl = [20];
88			disctrl = [08 82 27 04];
89			vmctrl1 = [45 15];
90			vmctrl2 = [90];
91			enable3g = [00];
92			ifctl = [01 00 06];
93			ifmode = [c2];
94			gamset = [01];
95			frmctr1 = [00 1b];
96			pwctrl1 = [10];
97			pwctrl2 = [10];
98			pgamctrl = [0F 29 24 0c 0e 09 4e 78 3c 09 13 05 17 11 00];
99			ngamctrl = [00 16 1b 04 11 07 31 33 42 05 0c 0a 28 2f 0f];
100		};
101	};
102};
103
104&clk_lsi {
105	status = "okay";
106};
107
108&clk_hse {
109	clock-frequency = <DT_FREQ_M(8)>;
110	status = "okay";
111};
112
113&pll {
114	div-m = <8>;
115	mul-n = <336>;
116	div-p = <2>;
117	div-q = <7>;
118	clocks = <&clk_hse>;
119	status = "okay";
120};
121
122&rcc {
123	clocks = <&pll>;
124	clock-frequency = <DT_FREQ_M(168)>;
125	ahb-prescaler = <1>;
126	apb1-prescaler = <4>;
127	apb2-prescaler = <2>;
128};
129
130&usart1 {
131	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
132	pinctrl-names = "default";
133	current-speed = <115200>;
134	status = "okay";
135};
136
137&rtc {
138	clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>,
139		 <&rcc STM32_SRC_LSI RTC_SEL(2)>;
140	status = "okay";
141};
142
143&i2c1 {
144	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
145	pinctrl-names = "default";
146	status = "okay";
147	clock-frequency = <I2C_BITRATE_FAST>;
148};
149
150&i2c2 {
151	pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>;
152	pinctrl-names = "default";
153	status = "okay";
154	clock-frequency = <I2C_BITRATE_FAST>;
155};
156
157&i2c3 {
158	pinctrl-0 = <&i2c3_scl_pa8 &i2c3_sda_pc9>;
159	pinctrl-names = "default";
160	status = "okay";
161	clock-frequency = <I2C_BITRATE_FAST>;
162
163	stmpe811: stmpe811@41 {
164		compatible = "st,stmpe811";
165		status = "okay";
166		reg = <0x41>;
167		int-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>;
168		screen-width = <240>;
169		screen-height = <320>;
170		raw-x-min = <240>;
171		raw-y-min = <200>;
172		raw-x-max = <3680>;
173		raw-y-max = <3800>;
174		panel-driver-settling-time-us = <1000>;
175		touch-detect-delay-us = <5000>;
176		touch-average-control = <8>;
177		tracking-index = <127>;
178		inverted-x;
179		inverted-y;
180	};
181};
182
183&spi5 {
184	pinctrl-0 = <&spi5_nss_pf6 &spi5_sck_pf7
185		     &spi5_miso_pf8 &spi5_mosi_pf9>;
186	pinctrl-names = "default";
187	status = "okay";
188	cs-gpios = <&gpioc 2 GPIO_ACTIVE_LOW>;
189};
190
191&fmc {
192	status = "okay";
193	pinctrl-0 = <&fmc_nbl0_pe0 &fmc_nbl1_pe1
194		     &fmc_sdclk_pg8 &fmc_sdnwe_pc0 &fmc_sdcke1_pb5
195		     &fmc_sdne1_pb6 &fmc_sdnras_pf11 &fmc_sdncas_pg15
196		     &fmc_a0_pf0 &fmc_a1_pf1 &fmc_a2_pf2 &fmc_a3_pf3
197		     &fmc_a4_pf4 &fmc_a5_pf5 &fmc_a6_pf12 &fmc_a7_pf13
198		     &fmc_a8_pf14 &fmc_a9_pf15 &fmc_a10_pg0 &fmc_a11_pg1
199		     &fmc_a12_pg2 &fmc_a13_pg3 &fmc_a14_pg4 &fmc_a15_pg5
200		     &fmc_d0_pd14 &fmc_d1_pd15 &fmc_d2_pd0 &fmc_d3_pd1
201		     &fmc_d4_pe7 &fmc_d5_pe8 &fmc_d6_pe9 &fmc_d7_pe10
202		     &fmc_d8_pe11 &fmc_d9_pe12 &fmc_d10_pe13 &fmc_d11_pe14
203		     &fmc_d12_pe15 &fmc_d13_pd8 &fmc_d14_pd9 &fmc_d15_pd10>;
204	pinctrl-names = "default";
205
206	sdram {
207		status = "okay";
208
209		power-up-delay = <100>;
210		num-auto-refresh = <1>;
211		mode-register = <0>;
212		refresh-rate = <1386>;
213
214		bank@1 {
215			reg = <1>;
216
217			st,sdram-control = <STM32_FMC_SDRAM_NC_8
218					    STM32_FMC_SDRAM_NR_12
219					    STM32_FMC_SDRAM_MWID_16
220					    STM32_FMC_SDRAM_NB_4
221					    STM32_FMC_SDRAM_CAS_2
222					    STM32_FMC_SDRAM_SDCLK_PERIOD_3
223					    STM32_FMC_SDRAM_RBURST_DISABLE
224					    STM32_FMC_SDRAM_RPIPE_1>;
225			st,sdram-timing = <2 7 4 7 2 2 2>;
226		};
227	};
228};
229
230&ltdc {
231	pinctrl-0 = <&ltdc_r2_pc10 &ltdc_r3_pb0 &ltdc_r4_pa11 &ltdc_r5_pa12
232		     &ltdc_r6_pb1 &ltdc_r7_pg6 &ltdc_g2_pa6 &ltdc_g3_pg10
233		     &ltdc_g4_pb10 &ltdc_g5_pb11 &ltdc_g6_pc7 &ltdc_g7_pd3
234		     &ltdc_b2_pd6 &ltdc_b3_pg11 &ltdc_b4_pg12 &ltdc_b5_pa3
235		     &ltdc_b6_pb8 &ltdc_b7_pb9 &ltdc_de_pf10 &ltdc_clk_pg7
236		     &ltdc_hsync_pc6 &ltdc_vsync_pa4>;
237	pinctrl-names = "default";
238	ext-sdram = <&sdram2>;
239	display-controller = <&ili9341>;
240	status = "okay";
241
242	width = <240>;
243	height = <320>;
244	pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>;
245	display-timings {
246		compatible = "zephyr,panel-timing";
247		de-active = <0>;
248		pixelclk-active = <0>;
249		hsync-active = <0>;
250		vsync-active = <0>;
251		hsync-len = <10>;
252		vsync-len = <2>;
253		hback-porch= <20>;
254		vback-porch = <2>;
255		hfront-porch = <10>;
256		vfront-porch = <4>;
257	};
258	def-back-color-red = <0xFF>;
259	def-back-color-green = <0xFF>;
260	def-back-color-blue = <0xFF>;
261};
262
263zephyr_udc0: &usbotg_hs {
264	pinctrl-0 = <&usb_otg_hs_dm_pb14 &usb_otg_hs_dp_pb15 &usb_otg_hs_id_pb12>;
265	pinctrl-names = "default";
266	status = "okay";
267};
268