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