1/*
2 * Copyright (c) 2024 Klaus Nagel, <nagelkl01@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/stm32g431k(6-8-b)tx-pinctrl.dtsi>
10
11/ {
12	model = "STMicroelectronics STM32G431KB-NUCLEO board";
13	compatible = "st,stm32g431kb-nucleo";
14
15	chosen {
16		zephyr,console = &lpuart1;
17		zephyr,shell-uart = &lpuart1;
18		zephyr,sram = &sram0;
19		zephyr,flash = &flash0;
20	};
21
22	leds: leds {
23		compatible = "gpio-leds";
24
25		green_led: led_0 {
26			gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>;
27			label = "User LD2";
28		};
29
30	};
31
32	pwmleds {
33		compatible = "pwm-leds";
34
35		green_pwm_led: green_pwm_led {
36			pwms = <&pwm4 3 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
37		};
38	};
39
40
41	aliases {
42		led0 = &green_led;
43		pwm-led0 = &green_pwm_led;
44		watchdog0 = &iwdg;
45	};
46};
47
48&clk_hsi {
49	status = "okay";
50};
51
52&clk_lsi {
53	status = "okay";
54};
55
56stm32_lp_tick_source: &lptim1 {
57	clocks = <&rcc STM32_CLOCK(APB1, 31)>,
58			 <&rcc STM32_SRC_LSI LPTIM1_SEL(3)>;
59	status = "okay";
60};
61
62/* Adjust the pll for a SYSTEM Clock of 170MHz  */
63&pll {
64	div-m = <4>;
65	mul-n = <85>;
66	div-p = <7>;
67	div-q = <2>;
68	div-r = <2>;
69	clocks = <&clk_hsi>;
70	status = "okay";
71};
72
73&rcc {
74	clocks = <&pll>;
75	clock-frequency = <DT_FREQ_M(170)>;
76	ahb-prescaler = <1>;
77	apb1-prescaler = <1>;
78	apb2-prescaler = <1>;
79};
80
81&lpuart1 {
82	pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
83	pinctrl-names = "default";
84	current-speed = <115200>;
85	status = "okay";
86};
87
88&timers4 {
89	st,prescaler = <10000>;
90	status = "okay";
91
92	pwm4: pwm {
93		status = "okay";
94		pinctrl-0 = <&tim4_ch3_pb8>;
95		pinctrl-names = "default";
96	};
97};
98
99&i2c2 {
100	pinctrl-0 = <&i2c2_scl_pa9 &i2c2_sda_pa8>;
101	pinctrl-names = "default";
102	status = "okay";
103};
104
105&flash0 {
106	partitions {
107		compatible = "fixed-partitions";
108		#address-cells = <1>;
109		#size-cells = <1>;
110
111		/* Set 4Kb of storage at the end of the 128Kb of flash */
112		storage_partition: partition@1f000 {
113			label = "storage";
114			reg = <0x0001f000 DT_SIZE_K(4)>;
115		};
116	};
117};
118