1/*
2 * Copyright (c) 2020 Stefano Manni
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/f1/stm32f103Xe.dtsi>
9#include <st/f1/stm32f103z(c-d-e)tx-pinctrl.dtsi>
10#include <zephyr/dt-bindings/input/input-event-codes.h>
11
12/ {
13	model = "Waveshare Open103Z";
14	compatible = "waveshare,open103z";
15
16	chosen {
17		zephyr,console = &usart1;
18		zephyr,shell-uart = &usart1;
19		zephyr,sram = &sram0;
20		zephyr,flash = &flash0;
21		zephyr,canbus = &can1;
22	};
23
24	leds {
25		compatible = "gpio-leds";
26		led_1: led_1 {
27			gpios = <&gpiof 6 GPIO_ACTIVE_HIGH>;
28			label = "User LED1";
29		};
30		led_2: led_2 {
31			gpios = <&gpiof 7 GPIO_ACTIVE_HIGH>;
32			label = "User LED2";
33		};
34		led_3: led_3 {
35			gpios = <&gpiof 8 GPIO_ACTIVE_HIGH>;
36			label = "User LED3";
37		};
38		led_4: led_4 {
39			gpios = <&gpiof 9 GPIO_ACTIVE_HIGH>;
40			label = "User LED4";
41		};
42	};
43
44	gpio_keys {
45		compatible = "gpio-keys";
46		button: button {
47			label = "User button";
48			gpios = <&gpiog 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
49			zephyr,code = <INPUT_KEY_0>;
50		};
51		joystick_enter: joystick_enter {
52			label = "User joystick ENTER";
53			gpios = <&gpiog 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
54			zephyr,code = <INPUT_KEY_ENTER>;
55		};
56		joystick_right: joystick_right {
57			label = "User joystick RIGHT";
58			gpios = <&gpioc 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
59			zephyr,code = <INPUT_KEY_RIGHT>;
60		};
61		joystick_up: joystick_up {
62			label = "User joystick UP";
63			gpios = <&gpioc 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
64			zephyr,code = <INPUT_KEY_UP>;
65		};
66		joystick_down: joystick_down {
67			label = "User joystick DOWN";
68			gpios = <&gpioc 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
69			zephyr,code = <INPUT_KEY_DOWN>;
70		};
71		joystick_left: joystick_left {
72			label = "User joystick LEFT";
73			gpios = <&gpioc 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
74			zephyr,code = <INPUT_KEY_LEFT>;
75		};
76	};
77
78	aliases {
79		led0 = &led_1;
80		led1 = &led_2;
81		led2 = &led_3;
82		led3 = &led_4;
83		sw0 = &button;
84		watchdog0 = &iwdg;
85	};
86};
87
88&clk_hse {
89	clock-frequency = <DT_FREQ_M(8)>;
90	status = "okay";
91};
92
93&pll {
94	mul = <9>;
95	clocks = <&clk_hse>;
96	status = "okay";
97};
98
99&rcc {
100	clocks = <&pll>;
101	clock-frequency = <DT_FREQ_M(72)>;
102	ahb-prescaler = <1>;
103	apb1-prescaler = <2>;
104	apb2-prescaler = <1>;
105	/* usbpre not set: USB clock = 72 / 1.5: 48MHz */
106};
107
108&usart1 {
109	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
110	pinctrl-names = "default";
111	current-speed = <115200>;
112	status = "okay";
113};
114
115&usart2 {
116	pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
117	pinctrl-names = "default";
118	current-speed = <115200>;
119	status = "okay";
120};
121
122&spi1 {
123	pinctrl-0 = <&spi1_nss_master_pa4 &spi1_sck_master_pa5
124		     &spi1_miso_master_pa6 &spi1_mosi_master_pa7>;
125	pinctrl-names = "default";
126	status = "okay";
127};
128
129&spi2 {
130	pinctrl-0 = <&spi2_nss_master_pb12 &spi2_sck_master_pb13
131		     &spi2_miso_master_pb14 &spi2_mosi_master_pb15>;
132	pinctrl-names = "default";
133	status = "okay";
134};
135
136&i2c1 {
137	pinctrl-0 = <&i2c1_sda_pb7 &i2c1_scl_pb6>;
138	pinctrl-names = "default";
139	status = "okay";
140	clock-frequency = <I2C_BITRATE_FAST>;
141};
142
143&i2c2 {
144	pinctrl-0 = <&i2c2_sda_pb11 &i2c2_scl_pb10>;
145	pinctrl-names = "default";
146	status = "okay";
147	clock-frequency = <I2C_BITRATE_FAST>;
148};
149
150&can1 {
151	pinctrl-0 = <&can_rx_remap1_pb8 &can_tx_remap1_pb9>;
152	pinctrl-names = "default";
153	/*
154	 * make sure CAN and USB are not enabled at the same time
155	 * because they share interrupts 19, 20 (stm32f103Xb.dtsi)
156	 * reference: RM0008 rev20 page 205
157	 */
158	status = "disabled";
159};
160
161zephyr_udc0: &usb {
162	/*
163	 * make sure CAN and USB are not enabled at the same time
164	 * because they share interrupts 19, 20 (stm32f103Xb.dtsi)
165	 * reference: RM0008 rev20 page 205
166	 */
167	pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
168	pinctrl-names = "default";
169	status = "okay";
170	disconnect-gpios = <&gpiog 15 GPIO_ACTIVE_HIGH>;
171};
172
173&timers1 {
174	status = "okay";
175
176	pwm1: pwm {
177		status = "okay";
178		pinctrl-0 = <&tim1_ch1_pwm_out_pa8>;
179		pinctrl-names = "default";
180	};
181};
182
183&iwdg {
184	status = "okay";
185};
186
187&adc1 {
188	pinctrl-0 = <&adc1_in0_pa0>;
189	pinctrl-names = "default";
190	status = "okay";
191};
192