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