1/*
2 * Copyright (c) 2019 STMicroelectronics.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/g4/stm32g474Xe.dtsi>
9#include <st/g4/stm32g474r(b-c-e)tx-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	model = "STMicroelectronics STM32G474RE-NUCLEO board";
16	compatible = "st,stm32g474re-nucleo";
17
18	chosen {
19		zephyr,console = &lpuart1;
20		zephyr,shell-uart = &lpuart1;
21		zephyr,sram = &sram0;
22		zephyr,flash = &flash0;
23		zephyr,canbus = &fdcan1;
24		zephyr,code-partition = &slot0_partition;
25	};
26
27	leds: leds {
28		compatible = "gpio-leds";
29
30		green_led: led_0 {
31			gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
32			label = "User LD2";
33		};
34	};
35
36	pwmleds {
37		compatible = "pwm-leds";
38
39		green_pwm_led: green_pwm_led {
40			pwms = <&pwm2 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
41		};
42	};
43
44	gpio_keys {
45		compatible = "gpio-keys";
46
47		user_button: button {
48			label = "User";
49			gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
50			zephyr,code = <INPUT_KEY_0>;
51		};
52	};
53
54	aliases {
55		led0 = &green_led;
56		mcuboot-led0 = &green_led;
57		pwm-led0 = &green_pwm_led;
58		sw0 = &user_button;
59		watchdog0 = &iwdg;
60		die-temp0 = &die_temp;
61		volt-sensor0 = &vref;
62		volt-sensor1 = &vbat;
63	};
64};
65
66&clk_lsi {
67	status = "okay";
68};
69
70&clk_hsi48 {
71	status = "okay";
72};
73
74&clk_hse {
75	clock-frequency = <DT_FREQ_M(24)>;
76	status = "okay";
77};
78
79&pll {
80	div-m = <6>;
81	mul-n = <85>;
82	div-p = <7>;
83	div-q = <2>;
84	div-r = <2>;
85	clocks = <&clk_hse>;
86	status = "okay";
87};
88
89&rcc {
90	clocks = <&pll>;
91	clock-frequency = <DT_FREQ_M(170)>;
92	ahb-prescaler = <1>;
93	apb1-prescaler = <1>;
94	apb2-prescaler = <1>;
95};
96
97&usart1 {
98	pinctrl-0 = <&usart1_tx_pc4 &usart1_rx_pc5>;
99	pinctrl-names = "default";
100	current-speed = <115200>;
101	status = "okay";
102};
103
104&lpuart1 {
105	pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
106	pinctrl-1 = <&analog_pa2 &analog_pa3>;
107	pinctrl-names = "default", "sleep";
108	current-speed = <115200>;
109	status = "okay";
110};
111
112&i2c1 {
113	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
114	pinctrl-names = "default";
115	status = "okay";
116};
117
118&spi1 {
119	pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>;
120	pinctrl-names = "default";
121	cs-gpios = <&gpiob 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
122	status = "okay";
123};
124
125&spi2 {
126	pinctrl-0 = <&spi2_nss_pb12 &spi2_sck_pb13
127		     &spi2_miso_pb14 &spi2_mosi_pb15>;
128	pinctrl-names = "default";
129	status = "okay";
130};
131
132&spi3 {
133	/* SPI3 on the ST Morpho Connector CN7 pins 17, 1, 2, 3*/
134	pinctrl-0 = <&spi3_nss_pa15 &spi3_sck_pc10
135		     &spi3_miso_pc11 &spi3_mosi_pc12>;
136	pinctrl-names = "default";
137	status = "okay";
138};
139
140&timers2 {
141	status = "okay";
142
143	pwm2: pwm {
144		status = "okay";
145		pinctrl-0 = <&tim2_ch1_pa5>;
146		pinctrl-names = "default";
147	};
148};
149
150&timers3 {
151	st,prescaler = <10000>;
152	status = "okay";
153	pwm3: pwm {
154		status = "okay";
155		pinctrl-0 = <&tim3_ch1_pb4>;
156		pinctrl-names = "default";
157	};
158};
159
160stm32_lp_tick_source: &lptim1 {
161	clocks = <&rcc STM32_CLOCK(APB1, 31)>,
162		<&rcc STM32_SRC_LSI LPTIM1_SEL(1)>;
163	status = "okay";
164};
165
166&rtc {
167	clocks = <&rcc STM32_CLOCK(APB1, 10)>,
168		 <&rcc STM32_SRC_LSI RTC_SEL(2)>;
169	status = "okay";
170};
171
172&flash0 {
173	partitions {
174		compatible = "fixed-partitions";
175		#address-cells = <1>;
176		#size-cells = <1>;
177
178		boot_partition: partition@0 {
179			label = "mcuboot";
180			reg = <0x00000000 DT_SIZE_K(34)>;
181		};
182
183		slot0_partition: partition@8800 {
184			label = "image-0";
185			reg = <0x00008800 DT_SIZE_K(240)>;
186		};
187
188		slot1_partition: partition@44800 {
189			label = "image-1";
190			reg = <0x00044800 DT_SIZE_K(234)>;
191		};
192
193		/* Set 4Kb of storage at the end of the 512Kb of flash */
194		storage_partition: partition@7f000 {
195			label = "storage";
196			reg = <0x0007f000 DT_SIZE_K(4)>;
197		};
198	};
199};
200
201&iwdg {
202	status = "okay";
203};
204
205&rng {
206	status = "okay";
207};
208
209&adc1 {
210	pinctrl-0 = <&adc1_in1_pa0>;
211	pinctrl-names = "default";
212	st,adc-clock-source = "SYNC";
213	st,adc-prescaler = <4>;
214	status = "okay";
215};
216
217&die_temp {
218	status = "okay";
219};
220
221&dac1 {
222	pinctrl-0 = <&dac1_out1_pa4>;
223	pinctrl-names = "default";
224	status = "okay";
225};
226
227&fdcan1 {
228	clocks = <&rcc STM32_CLOCK(APB1, 25)>,
229		 <&rcc STM32_SRC_HSE FDCAN_SEL(0)>;
230	pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
231	pinctrl-names = "default";
232	status = "okay";
233};
234
235&vref {
236	status = "okay";
237};
238
239&vbat {
240	status = "okay";
241};
242