1/*
2 * Copyright 2024 Felipe Neves
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/h7/stm32h747Xi_m7.dtsi>
9#include <st/h7/stm32h747a(g-i)ix-pinctrl.dtsi>
10#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
11#include "arduino_nicla_vision.dtsi"
12
13/ {
14	model = "Arduino Nicla Vision Board (M7)";
15	compatible = "arduino,nicla-vision";
16
17	chosen {
18		zephyr,console = &lpuart1;
19		zephyr,shell-uart = &lpuart1;
20		zephyr,uart-mcumgr = &lpuart1;
21		zephyr,bt-hci = &bt_hci_uart;
22		zephyr,sram = &sram0;
23		zephyr,flash = &flash0;
24		zephyr,code-partition = &slot0_partition;
25		zephyr,camera = &dcmi;
26	};
27
28	aliases {
29		led0 = &red_led;
30		led1 = &green_led;
31	};
32
33	otghs_ulpi_phy: otghs_ulpis_phy {
34		compatible = "usb-ulpi-phy";
35		#phy-cells = <0>;
36	};
37};
38
39&clk_hse {
40	status = "okay";
41	hse-bypass;
42	clock-frequency = <DT_FREQ_M(25)>;
43};
44
45&clk_lse {
46	lse-bypass;
47	status = "okay";
48};
49
50&clk_hsi48 {
51	status = "okay";
52};
53
54&pll {
55	div-m = <5>;
56	mul-n = <192>;
57	div-p = <2>;
58	div-q = <4>;
59	div-r = <2>;
60	clocks = <&clk_hse>;
61	status = "okay";
62};
63
64&rcc {
65	clocks = <&pll>;
66	clock-frequency = <DT_FREQ_M(480)>;
67};
68
69&lpuart1 {
70	status = "okay";
71	pinctrl-0 = <&lpuart1_tx_pa9 &lpuart1_rx_pa10>;
72	pinctrl-names = "default";
73	current-speed = <115200>;
74};
75
76&usart1 {
77	pinctrl-0 = <&usart1_rx_pb7 &usart1_tx_pb6
78		     &usart1_rts_pa12 &usart1_cts_pa11>;
79	pinctrl-names = "default";
80	current-speed = <115200>;
81	status = "okay";
82	hw-flow-control;
83
84	bt_hci_uart: bt_hci_uart {
85		compatible = "zephyr,bt-hci-uart";
86		status = "okay";
87
88		murata-1dx {
89			compatible = "infineon,cyw43xxx-bt-hci";
90			bt-reg-on-gpios = <&gpiof 14 GPIO_ACTIVE_HIGH>;
91			bt-host-wake-gpios = <&gpiod 14 GPIO_ACTIVE_HIGH>;
92			bt-dev-wake-gpios = <&gpioe 9 GPIO_ACTIVE_HIGH>;
93			fw-download-speed = <115200>;
94		};
95	};
96};
97
98&i2c1 {
99	status = "disabled";
100	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
101	pinctrl-names = "default";
102	clock-frequency = <I2C_BITRATE_FAST>;
103};
104
105&i2c2 {
106	status = "okay";
107	pinctrl-0 = <&i2c2_scl_pf1 &i2c2_sda_pf0>;
108	pinctrl-names = "default";
109	clock-frequency = <I2C_BITRATE_FAST>;
110
111	vl53l1x: vl53l1x@52 {
112		compatible = "st,vl53l1x";
113		reg = <0x52>;
114		status = "okay";
115		xshut-gpios = <&gpiog 10 GPIO_ACTIVE_HIGH>;
116		int-gpios = <&gpiod 8 GPIO_ACTIVE_HIGH>;
117	};
118};
119
120&spi4 {
121	status = "okay";
122	pinctrl-0 = <&spi4_nss_pe11 &spi4_sck_pe12
123		     &spi4_miso_pe13 &spi4_mosi_pe14>;
124	pinctrl-names = "default";
125};
126
127&spi5 {
128	status = "okay";
129	pinctrl-0 = <&spi5_nss_pf6 &spi5_sck_pf7
130		     &spi5_miso_pf8 &spi5_mosi_pf11>;
131	pinctrl-names = "default";
132
133	lsm6dso: lsm6dso@0 {
134		compatible = "st,lsm6dso";
135		status = "okay";
136		reg = <0x0>;
137		irq-gpios = <&gpioa 1 GPIO_ACTIVE_LOW>;
138		spi-max-frequency = <4000000>;
139	};
140};
141
142&flash0 {
143	partitions {
144		compatible = "fixed-partitions";
145		#address-cells = <1>;
146		#size-cells = <1>;
147
148		boot_partition: partition@0 {
149			label = "bootloader";
150			reg = <0x0 0x40000>;
151			read-only;
152		};
153
154		slot0_partition: partition@40000 {
155			label = "image-0";
156			reg = <0x40000 0x000c0000>;
157		};
158	};
159};
160
161&quadspi {
162	pinctrl-0 = <&quadspi_clk_pf10 &quadspi_bk1_ncs_pg6
163		     &quadspi_bk1_io0_pd11 &quadspi_bk1_io1_pf9
164		     &quadspi_bk1_io2_pe2 &quadspi_bk1_io3_pd13>;
165	pinctrl-names = "default";
166	status = "okay";
167
168	n25q128a1: qspi-nor-flash@90000000 {
169		compatible = "st,stm32-qspi-nor";
170		reg = <0x90000000 DT_SIZE_M(16)>; /* 128 Mbits */
171		qspi-max-frequency = <72000000>;
172		status = "okay";
173
174		partitions {
175			compatible = "fixed-partitions";
176			#address-cells = <1>;
177			#size-cells = <1>;
178
179			slot1_partition: partition@0 {
180				label = "image-1";
181				reg = <0x00000000 DT_SIZE_M(1)>;
182			};
183
184			storage_partition: partition@100000 {
185				label = "storage";
186				reg = <0x00100000 DT_SIZE_M(15)>;
187			};
188		};
189	};
190};
191
192&rng {
193	status = "okay";
194};
195
196zephyr_udc0: &usbotg_hs {
197	pinctrl-0 = <&usb_otg_hs_ulpi_ck_pa5
198			&usb_otg_hs_ulpi_d0_pa3
199			&usb_otg_hs_ulpi_d1_pb0
200			&usb_otg_hs_ulpi_d2_pb1
201			&usb_otg_hs_ulpi_d3_pb10
202			&usb_otg_hs_ulpi_d4_pb11
203			&usb_otg_hs_ulpi_d5_pb12
204			&usb_otg_hs_ulpi_d6_pb13
205			&usb_otg_hs_ulpi_d7_pb5
206			&usb_otg_hs_ulpi_stp_pc0
207			&usb_otg_hs_ulpi_dir_pc2_c
208			&usb_otg_hs_ulpi_nxt_pc3_c>;
209	pinctrl-names = "default";
210	maximum-speed = "high-speed";
211	phys = <&otghs_ulpi_phy>;
212	status = "okay";
213};
214
215&i2c3 {
216	status = "okay";
217	pinctrl-0 = <&i2c3_scl_pa8 &i2c3_sda_pc9>;
218	pinctrl-names = "default";
219	clock-frequency = <I2C_BITRATE_FAST>;
220
221	gc2145: gc2145@3c {
222		compatible = "galaxycore,gc2145";
223		reg = <0x3c>;
224		status = "okay";
225
226		port {
227			gc2145_ep_out: endpoint {
228				remote-endpoint = <&dcmi_ep_in>;
229			};
230		};
231
232	};
233};
234
235&dcmi {
236	pinctrl-0 = <&dcmi_d0_pc6 &dcmi_d1_pc7 &dcmi_d2_pe0 &dcmi_d3_pe1
237		     &dcmi_d4_pe4 &dcmi_d5_pd3 &dcmi_d6_pe5 &dcmi_d7_pe6
238		     &dcmi_pixclk_pa6 &dcmi_hsync_pa4 &dcmi_vsync_pg9>;
239
240	pinctrl-names = "default";
241	status = "okay";
242
243	sensor = <&gc2145>;
244	bus-width = <8>;
245	hsync-active = <0>;
246	vsync-active = <0>;
247	pixelclk-active = <0>;
248	capture-rate = <1>;
249	dmas = <&dma1 0 38 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC |
250		STM32_DMA_MEM_INC | STM32_DMA_PERIPH_8BITS | STM32_DMA_MEM_32BITS |
251		STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_1_4>;
252
253	port {
254		dcmi_ep_in: endpoint {
255			remote-endpoint = <&gc2145_ep_out>;
256		};
257	};
258};
259
260/* The Arduino nicla uses a PWM output to generate the clock for the
261 * GC2145 sensor, so we need to configure the PWM generator...
262 */
263&timers3 {
264	status = "okay";
265	st,prescaler = <0>;
266
267	cam_clock_pwm: pwm {
268		status = "okay";
269		pinctrl-0 = <&tim3_ch2_pa7>;
270		pinctrl-names = "default";
271	};
272};
273
274&cam_clock_pwm {
275	/* ...then use the pwmclock node to start the clock generation */
276	pwmclock: pwmclock {
277		status = "okay";
278		compatible = "pwm-clock";
279		clock-frequency = <0>;
280		#clock-cells = <1>;
281		pwms = <&cam_clock_pwm 2 PWM_HZ(10000000) PWM_POLARITY_NORMAL>;
282	};
283};
284
285&dma1 {
286	status = "okay";
287};
288
289&dmamux1 {
290	status = "okay";
291};
292