1/*
2 * Copyright (c) 2019 Richard Osterloh <richard.osterloh@gmail.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/g4/stm32g431Xb.dtsi>
9#include <st/g4/stm32g431r(6-8-b)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 STM32G431RB-NUCLEO board";
16	compatible = "st,stm32g431rb-nucleo";
17
18	chosen {
19		zephyr,console = &lpuart1;
20		zephyr,shell-uart = &lpuart1;
21		zephyr,sram = &sram0;
22		zephyr,flash = &flash0;
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_HIGH>;
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	};
58};
59
60&clk_lsi {
61	status = "okay";
62};
63
64&clk_lse {
65	status = "okay";
66};
67
68&clk_hsi48 {
69	status = "okay";
70};
71
72&clk_hse {
73	clock-frequency = <DT_FREQ_M(24)>;
74	status = "okay";
75};
76
77&pll {
78	div-m = <6>;
79	mul-n = <85>;
80	div-p = <7>;
81	div-q = <2>;
82	div-r = <2>;
83	clocks = <&clk_hse>;
84	status = "okay";
85};
86
87&rcc {
88	clocks = <&pll>;
89	clock-frequency = <DT_FREQ_M(170)>;
90	ahb-prescaler = <1>;
91	apb1-prescaler = <1>;
92	apb2-prescaler = <1>;
93};
94
95&rng {
96	clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x04000000>,
97		 <&rcc STM32_SRC_HSI48 CLK48_SEL(0)>;
98	status = "okay";
99};
100
101&usart1 {
102	pinctrl-0 = <&usart1_tx_pc4 &usart1_rx_pc5>;
103	pinctrl-names = "default";
104	current-speed = <115200>;
105	status = "okay";
106};
107
108&lpuart1 {
109	pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
110	pinctrl-names = "default";
111	current-speed = <115200>;
112	status = "okay";
113};
114
115&i2c1 {
116	pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
117	pinctrl-names = "default";
118	status = "okay";
119};
120
121&spi1 {
122	pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>;
123	pinctrl-names = "default";
124	cs-gpios = <&gpiob 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
125	status = "okay";
126};
127
128&spi2 {
129	pinctrl-0 = <&spi2_nss_pb12 &spi2_sck_pb13
130		     &spi2_miso_pb14 &spi2_mosi_pb15>;
131	pinctrl-names = "default";
132	status = "okay";
133};
134
135&spi3 {
136	/* SPI3 on the ST Morpho Connector CN7 pins 17, 1, 2, 3*/
137	pinctrl-0 = <&spi3_nss_pa15 &spi3_sck_pc10
138		     &spi3_miso_pc11 &spi3_mosi_pc12>;
139	pinctrl-names = "default";
140	status = "okay";
141};
142
143&timers2 {
144	status = "okay";
145
146	pwm2: pwm {
147		status = "okay";
148		pinctrl-0 = <&tim2_ch1_pa5>;
149		pinctrl-names = "default";
150	};
151};
152
153stm32_lp_tick_source: &lptim1 {
154	clocks = <&rcc STM32_CLOCK_BUS_APB1 0x80000000>,
155		 <&rcc STM32_SRC_LSE LPTIM1_SEL(3)>;
156	status = "okay";
157};
158
159&rtc {
160	clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000400>,
161		 <&rcc STM32_SRC_LSI RTC_SEL(2)>;
162	status = "okay";
163};
164
165&flash0 {
166
167	partitions {
168		compatible = "fixed-partitions";
169		#address-cells = <1>;
170		#size-cells = <1>;
171
172		boot_partition: partition@0 {
173			label = "mcuboot";
174			reg = <0x00000000 DT_SIZE_K(34)>;
175		};
176		slot0_partition: partition@8800 {
177			label = "image-0";
178			reg = <0x00008800 DT_SIZE_K(48)>;
179		};
180		slot1_partition: partition@14800 {
181			label = "image-1";
182			reg = <0x00014800 DT_SIZE_K(42)>;
183		};
184		/* Set 4Kb of storage at the end of the 128Kb of flash */
185		storage_partition: partition@1f000 {
186			label = "storage";
187			reg = <0x0001f000 DT_SIZE_K(4)>;
188		};
189	};
190};
191
192&iwdg {
193	status = "okay";
194};
195
196&dac1 {
197	status = "okay";
198	pinctrl-0 = <&dac1_out1_pa4>;
199	pinctrl-names = "default";
200};
201