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&rcc {
82	clocks = <&pll>;
83	clock-frequency = <DT_FREQ_M(240)>;
84	ahb-prescaler = <1>;
85	apb1-prescaler = <2>;
86	apb2-prescaler = <1>;
87	apb3-prescaler = <2>;
88};
89
90&lpuart1 {
91	pinctrl-0 = <&lpuart1_tx_pb6 &lpuart1_rx_pb7>;
92	pinctrl-names = "default";
93	current-speed = <115200>;
94	status = "okay";
95};
96
97&usart3 {
98	pinctrl-0 = <&usart3_tx_pd8 &usart3_rx_pd9>;
99	pinctrl-names = "default";
100	current-speed = <115200>;
101	status = "okay";
102};
103
104&spi1 {
105	pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pg9 &spi1_mosi_pb5>;
106	pinctrl-names = "default";
107	cs-gpios = <&gpiod 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
108	status = "okay";
109};
110
111&timers3 {
112	st,prescaler = <10000>;
113	status = "okay";
114
115	pwm3: pwm {
116		status = "okay";
117		pinctrl-0 = <&tim3_ch3_pb0>;
118		pinctrl-names = "default";
119	};
120};
121
122&rtc {
123	clocks = <&rcc STM32_CLOCK_BUS_APB3 0x00200000>,
124		 <&rcc STM32_SRC_LSE RTC_SEL(1)>;
125	status = "okay";
126};
127
128&iwdg {
129	status = "okay";
130};
131
132&gpdma1 {
133	status = "okay";
134};
135
136&gpdma2 {
137	status = "okay";
138};
139
140&dac1 {
141	/* outputs only on 2 pins and pa4 is reserved for VBUS_SENSE */
142	pinctrl-0 = <&dac1_out2_pa5>;  /* Zio D13 (on CN7) */
143	pinctrl-names = "default";
144	status = "okay";
145};
146
147&adc1 {
148	pinctrl-0 = <&adc1_inp3_pa6 &adc1_inp15_pa3>; /* Zio A0, Zio D35 */
149	pinctrl-names = "default";
150	st,adc-clock-source = <ASYNC>;
151	st,adc-prescaler = <6>;
152	status = "okay";
153};
154
155&fdcan1 {
156	pinctrl-0 = <&fdcan1_rx_pd0 &fdcan1_tx_pd1>;
157	pinctrl-names = "default";
158	clocks = <&rcc STM32_CLOCK_BUS_APB1_2 0x00000200>,
159		 <&rcc STM32_SRC_PLL1_Q FDCAN_SEL(1)>;
160	clk-divider = <2>;
161	status = "okay";
162};
163
164&flash0 {
165	partitions {
166		compatible = "fixed-partitions";
167		#address-cells = <1>;
168		#size-cells = <1>;
169
170		boot_partition: partition@0 {
171			label = "mcuboot";
172			reg = <0x00000000 DT_SIZE_K(64)>;
173		};
174		slot0_partition: partition@10000 {
175			label = "image-0";
176			reg = <0x00010000 DT_SIZE_K(960)>;
177		};
178		slot1_partition: partition@100000 {
179			label = "image-1";
180			reg = <0x00100000 DT_SIZE_K(960)>;
181		};
182		storage_partition: partition@1f0000 {
183			label = "storage";
184			reg = <0x001f0000 DT_SIZE_K(64)>;
185		};
186	};
187};
188
189zephyr_udc0: &usb {
190	pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
191	pinctrl-names = "default";
192	status = "okay";
193};
194
195&vref {
196	status = "okay";
197};
198
199&vbat {
200	status = "okay";
201};
202
203&clk_lsi {
204	status = "okay";
205};
206
207stm32_lp_tick_source: &lptim4 {
208	clocks = <&rcc STM32_CLOCK_BUS_APB3 0x2000>,
209		 <&rcc STM32_SRC_LSI LPTIM4_SEL(4)>;
210	status = "okay";
211};
212