1/*
2 * Copyright (c) 2023 Joel Guittet
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6/dts-v1/;
7#include <atmel/samd5xx19.dtsi>
8#include "wio_terminal-pinctrl.dtsi"
9#include "grove_connectors.dtsi"
10#include "raspberrypi_40pins_connector.dtsi"
11#include <zephyr/dt-bindings/display/ili9xxx.h>
12#include <zephyr/dt-bindings/input/input-event-codes.h>
13
14/ {
15	model = "Wio Terminal";
16	compatible = "seeed,wio-terminal";
17
18	chosen {
19		zephyr,sram = &sram0;
20		zephyr,flash = &flash0;
21		zephyr,code-partition = &code_partition;
22		zephyr,display = &ili9341;
23	};
24
25	/* These aliases are provided for compatibility with samples */
26	aliases {
27		led0 = &led0;
28		sw0 = &user_button_0;
29		sw1 = &user_button_1;
30		sw2 = &user_button_2;
31		i2c0 = &sercom4;
32		i2c1 = &sercom3;
33		spi0 = &sercom5;
34		uart0 = &sercom2;
35		accel0 = &lis3dh;
36		sdhc0 = &sdhc0;
37	};
38
39	/* LEDs */
40	leds {
41		compatible = "gpio-leds";
42		led0: led_0 {
43			label = "LED";
44			gpios = <&porta 15 GPIO_ACTIVE_HIGH>;
45		};
46	};
47
48	/* Buttons */
49	buttons: buttons {
50		compatible = "gpio-keys";
51		user_button_0: button_0 {
52			label = "User Button 0";
53			gpios = <&portc 26 GPIO_ACTIVE_LOW>;
54			zephyr,code = <INPUT_KEY_0>;
55		};
56		user_button_1: button_1 {
57			label = "User Button 1";
58			gpios = <&portc 27 GPIO_ACTIVE_LOW>;
59			zephyr,code = <INPUT_KEY_1>;
60		};
61		user_button_2: button_2 {
62			label = "User Button 2";
63			gpios = <&portc 28 GPIO_ACTIVE_LOW>;
64			zephyr,code = <INPUT_KEY_2>;
65		};
66	};
67
68	/* Joystick */
69	joystick: joystick {
70		compatible = "gpio-keys";
71		polling-mode;
72		debounce-interval-ms = <100>;
73		joy_sel: joystick_selection {
74			label = "joystick selection";
75			gpios = <&portd 10 GPIO_ACTIVE_LOW>;
76			zephyr,code = <INPUT_KEY_ENTER>;
77		};
78		joy_down: joystick_down {
79			label = "joystick down";
80			gpios = <&portd 8 GPIO_ACTIVE_LOW>;
81			zephyr,code = <INPUT_KEY_DOWN>;
82		};
83		joy_up: joystick_up {
84			label = "joystick up";
85			gpios = <&portd 20 GPIO_ACTIVE_LOW>;
86			zephyr,code = <INPUT_KEY_UP>;
87		};
88		joy_left: joystick_left {
89			label = "joystick left";
90			gpios = <&portd 12 GPIO_ACTIVE_LOW>;
91			zephyr,code = <INPUT_KEY_LEFT>;
92		};
93		joy_right: joystick_right {
94			label = "joystick right";
95			gpios = <&portd 9 GPIO_ACTIVE_LOW>;
96			zephyr,code = <INPUT_KEY_RIGHT>;
97		};
98	};
99
100	/* Regulators */
101	lcd_backlight_en {
102		compatible = "regulator-fixed";
103		regulator-name = "lcd_backlight_enable";
104		enable-gpios = <&portc 5 GPIO_ACTIVE_HIGH>;
105		regulator-boot-on;
106	};
107	rpi_power_3v3_en {
108		compatible = "regulator-fixed";
109		regulator-name = "rpi_power_3v3_enable";
110		enable-gpios = <&portc 15 GPIO_ACTIVE_LOW>;
111		regulator-boot-on;
112	};
113	rpi_power_5v_en {
114		compatible = "regulator-fixed";
115		regulator-name = "rpi_power_5v_enable";
116		enable-gpios = <&portc 14 GPIO_ACTIVE_HIGH>;
117		regulator-boot-on;
118	};
119	usb_power_5v_en {
120		compatible = "regulator-fixed";
121		regulator-name = "usb_power_5v_en";
122		enable-gpios = <&porta 27 GPIO_ACTIVE_LOW>;
123	};
124
125	/* LCD */
126	mipi_dbi {
127		compatible = "zephyr,mipi-dbi-spi";
128		dc-gpios = <&portc 6 GPIO_ACTIVE_HIGH>;
129		reset-gpios = <&portc 7 GPIO_ACTIVE_LOW>;
130		#address-cells = <1>;
131		#size-cells = <0>;
132		spi-dev = <&sercom7>;
133		write-only;
134
135		ili9341: ili9341@0 {
136			compatible = "ilitek,ili9341";
137			mipi-max-frequency = <24000000>;
138			reg = <0>;
139			pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
140			rotation = <270>;
141			width = <320>;
142			height = <240>;
143		};
144	};
145};
146
147&cpu0 {
148	clock-frequency = <120000000>;
149};
150
151&dmac {
152	status = "okay";
153};
154
155&flash0 {
156	partitions {
157		compatible = "fixed-partitions";
158		#address-cells = <1>;
159		#size-cells = <1>;
160
161		boot_partition: partition@0 {
162			label = "uf2";
163			reg = <0x00000000 DT_SIZE_K(16)>;
164			read-only;
165		};
166
167		code_partition: partition@4000 {
168			label = "code";
169			reg = <0x4000 DT_SIZE_K(512-16)>;
170			read-only;
171		};
172	};
173};
174
175/* RTL8720D (Wifi/BLE) */
176&sercom0 {
177	status = "okay";
178	compatible = "atmel,sam0-spi";
179	#address-cells = <1>;
180	#size-cells = <0>;
181	dipo = <2>;
182	dopo = <0>;
183	pinctrl-0 = <&sercom0_spi_default>;
184	pinctrl-names = "default";
185	cs-gpios = <&portc 25 GPIO_ACTIVE_LOW>;
186};
187
188/* RTL8720D (Wifi/BLE) */
189&sercom1 {
190	status = "okay";
191	compatible = "atmel,sam0-uart";
192	current-speed = <115200>;
193	rxpo = <1>;
194	txpo = <0>;
195	pinctrl-0 = <&sercom1_uart_default>;
196	pinctrl-names = "default";
197};
198
199/* UART, Raspberry Pi connector */
200&sercom2 {
201	status = "okay";
202	compatible = "atmel,sam0-uart";
203	current-speed = <115200>;
204	rxpo = <1>;
205	txpo = <0>;
206	pinctrl-0 = <&sercom2_uart_default>;
207	pinctrl-names = "default";
208};
209
210/* I2C1, Raspberry Pi and Groove connectors */
211&sercom3 {
212	status = "okay";
213	compatible = "atmel,sam0-i2c";
214	clock-frequency = <I2C_BITRATE_FAST>;
215	#address-cells = <1>;
216	#size-cells = <0>;
217	pinctrl-0 = <&sercom3_i2c_default>;
218	pinctrl-names = "default";
219};
220
221/* I2C0, LIS3DH, ATECC608, Raspberry Pi connector */
222&sercom4 {
223	status = "okay";
224	compatible = "atmel,sam0-i2c";
225	clock-frequency = <I2C_BITRATE_HIGH>;
226	#address-cells = <1>;
227	#size-cells = <0>;
228	pinctrl-0 = <&sercom4_i2c_default>;
229	pinctrl-names = "default";
230
231	/* LIS3DH */
232	lis3dh: lis3dh@18 {
233		compatible = "st,lis3dh", "st,lis2dh";
234		status = "okay";
235		reg = <0x18>;
236		irq-gpios = <&portc 21 GPIO_ACTIVE_HIGH>;
237	};
238
239	/* ATECC608A */
240	atecc608a@6a {
241		compatible = "atmel,atecc608";
242		reg = <0x6a>;
243	};
244};
245
246/* SPI, Raspberry Pi connector */
247&sercom5 {
248	status = "okay";
249	compatible = "atmel,sam0-spi";
250	#address-cells = <1>;
251	#size-cells = <0>;
252	dipo = <2>;
253	dopo = <0>;
254	pinctrl-0 = <&sercom5_spi_default>;
255	pinctrl-names = "default";
256	cs-gpios = <&portb 1 GPIO_ACTIVE_LOW>;
257};
258
259/* microSD Card */
260&sercom6 {
261	status = "okay";
262	compatible = "atmel,sam0-spi";
263	#address-cells = <1>;
264	#size-cells = <0>;
265	dipo = <2>;
266	dopo = <0>;
267	pinctrl-0 = <&sercom6_spi_default>;
268	pinctrl-names = "default";
269	cs-gpios = <&portc 19 GPIO_ACTIVE_LOW>;
270
271	/* microSD Card */
272	sdhc0: sdhc@0 {
273		compatible = "zephyr,sdhc-spi-slot";
274		reg = <0>;
275		spi-max-frequency = <24000000>;
276		mmc {
277			compatible = "zephyr,sdmmc-disk";
278			disk-name = "SD";
279		};
280	};
281};
282
283/* LCD */
284&sercom7 {
285	status = "okay";
286	compatible = "atmel,sam0-spi";
287	#address-cells = <1>;
288	#size-cells = <0>;
289	dipo = <2>;
290	dopo = <3>;
291	pinctrl-0 = <&sercom7_spi_default>;
292	pinctrl-names = "default";
293	cs-gpios = <&portb 21 GPIO_ACTIVE_LOW>;
294};
295
296/* USB */
297zephyr_udc0: &usb0 {
298	status = "okay";
299	pinctrl-0 = <&usb_dc_default>;
300	pinctrl-names = "default";
301};
302
303#include <../boards/common/usb/cdc_acm_serial.dtsi>
304