1/*
2 * Copyright (c) 2021 Linaro Limited
3 * Copyright (c) 2023 Thomas Stranger
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#include <st/h5/stm32h563Xi.dtsi>
9#include <st/h5/stm32h563zitx-pinctrl.dtsi>
10#include "arduino_r3_connector.dtsi"
11#include "st_morpho_connector.dtsi"
12#include <zephyr/dt-bindings/input/input-event-codes.h>
13
14/ {
15	leds: leds {
16		compatible = "gpio-leds";
17		green_led_1: led_1 {
18			gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
19			label = "User LD1";
20		};
21		yellow_led_1: led_2 {
22			gpios = <&gpiof 4 GPIO_ACTIVE_HIGH>;
23			label = "User LD2";
24		};
25		red_led_1: led_3 {
26			gpios = <&gpiog 4 GPIO_ACTIVE_HIGH>;
27			label = "User LD3";
28		};
29	};
30
31	gpio_keys {
32		compatible = "gpio-keys";
33		user_button: button {
34			label = "User";
35			gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>;
36			zephyr,code = <INPUT_KEY_0>;
37		};
38	};
39
40	pwmleds: pwmleds {
41		compatible = "pwm-leds";
42		status = "disabled";
43
44		pwm_led_1: green_led_1 {
45			pwms = <&pwm3 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
46			label = "green led";
47		};
48	};
49};
50
51&clk_hse {
52	clock-frequency = <DT_FREQ_M(8)>; /* STLink 8MHz clock */
53	hse-bypass;
54	status = "okay";
55};
56
57&clk_hsi48 {
58	status = "okay";
59};
60
61&clk_lse {
62	status = "okay";
63};
64
65&pll {
66	div-m = <2>;
67	mul-n = <120>;
68	div-p = <2>;
69	div-q = <3>;
70	div-r = <2>;
71	clocks = <&clk_hse>;
72	status = "okay";
73};
74
75&i2c1 {
76	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
77	pinctrl-names = "default";
78	status = "okay";
79};
80
81&i3c1 {
82	pinctrl-0 =  <&i3c1_scl_pd12 &i3c1_sda_pd13>;
83	pinctrl-names = "default";
84	i3c-scl-hz = <12500000>;
85	status = "okay";
86};
87
88&rcc {
89	clocks = <&pll>;
90	clock-frequency = <DT_FREQ_M(240)>;
91	ahb-prescaler = <1>;
92	apb1-prescaler = <2>;
93	apb2-prescaler = <1>;
94	apb3-prescaler = <2>;
95};
96
97&lpuart1 {
98	pinctrl-0 = <&lpuart1_tx_pb6 &lpuart1_rx_pb7>;
99	pinctrl-names = "default";
100	current-speed = <115200>;
101	status = "okay";
102};
103
104&usart3 {
105	pinctrl-0 = <&usart3_tx_pd8 &usart3_rx_pd9>;
106	pinctrl-names = "default";
107	current-speed = <115200>;
108	status = "okay";
109};
110
111&spi1 {
112	pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pg9 &spi1_mosi_pb5>;
113	pinctrl-names = "default";
114	cs-gpios = <&gpiod 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
115	status = "okay";
116};
117
118&timers3 {
119	st,prescaler = <10000>;
120	status = "okay";
121
122	pwm3: pwm {
123		status = "okay";
124		pinctrl-0 = <&tim3_ch3_pb0>;
125		pinctrl-names = "default";
126	};
127};
128
129&rtc {
130	clocks = <&rcc STM32_CLOCK_BUS_APB3 0x00200000>,
131		 <&rcc STM32_SRC_LSE RTC_SEL(1)>;
132	status = "okay";
133};
134
135&iwdg {
136	status = "okay";
137};
138
139&gpdma1 {
140	status = "okay";
141};
142
143&gpdma2 {
144	status = "okay";
145};
146
147&dac1 {
148	/* outputs only on 2 pins and pa4 is reserved for VBUS_SENSE */
149	pinctrl-0 = <&dac1_out2_pa5>;  /* Zio D13 (on CN7) */
150	pinctrl-names = "default";
151	status = "okay";
152};
153
154&adc1 {
155	clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00000400>,
156		 <&rcc STM32_SRC_HCLK ADCDAC_SEL(0)>;
157	pinctrl-0 = <&adc1_inp3_pa6 &adc1_inp15_pa3>; /* Zio A0, Zio D35 */
158	pinctrl-names = "default";
159	st,adc-clock-source = "ASYNC";
160	st,adc-prescaler = <6>;
161	status = "okay";
162};
163
164&fdcan1 {
165	pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>;
166	pinctrl-names = "default";
167	clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00000200>,
168		 <&rcc STM32_SRC_PLL1_Q FDCAN_SEL(1)>;
169	clk-divider = <2>;
170	status = "okay";
171};
172
173&flash0 {
174	partitions {
175		compatible = "fixed-partitions";
176		#address-cells = <1>;
177		#size-cells = <1>;
178
179		boot_partition: partition@0 {
180			label = "mcuboot";
181			reg = <0x00000000 DT_SIZE_K(64)>;
182		};
183		slot0_partition: partition@10000 {
184			label = "image-0";
185			reg = <0x00010000 DT_SIZE_K(960)>;
186		};
187		slot1_partition: partition@100000 {
188			label = "image-1";
189			reg = <0x00100000 DT_SIZE_K(960)>;
190		};
191		storage_partition: partition@1f0000 {
192			label = "storage";
193			reg = <0x001f0000 DT_SIZE_K(64)>;
194		};
195	};
196};
197
198zephyr_udc0: &usb {
199	pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
200	pinctrl-names = "default";
201	status = "okay";
202};
203
204&vref {
205	status = "okay";
206};
207
208&vbat {
209	status = "okay";
210};
211
212&clk_lsi {
213	status = "okay";
214};
215
216stm32_lp_tick_source: &lptim4 {
217	clocks = <&rcc STM32_CLOCK_BUS_APB3 0x2000>,
218		 <&rcc STM32_SRC_LSI LPTIM4_SEL(4)>;
219	status = "okay";
220};
221