1/*
2 * Copyright (c) 2017 Piotr Mienkowski
3 * Copyright (c) 2017 Justin Watson
4 * Copyright (c) 2020 Stephanos Ioannidis <root@stephanos.io>
5 * Copyright (c) 2019-2024 Gerson Fernando Budke <nandojve@gmail.com>
6 *
7 * SPDX-License-Identifier: Apache-2.0
8 */
9
10#include "sam_v71_xult-pinctrl.dtsi"
11#include <zephyr/dt-bindings/input/input-event-codes.h>
12
13/ {
14	aliases {
15		i2c-0 = &twihs0;
16		i2c-1 = &twihs2;
17		led0 = &yellow_led1;
18		pwm-led0 = &pwm_led0;
19		pwm-0 = &pwm0;
20		rtc = &rtc;
21		sw0 = &sw0_user_button;
22		sw1 = &sw1_user_button;
23		watchdog0 = &wdt;
24	};
25
26	chosen {
27		zephyr,console = &usart1;
28		zephyr,shell-uart = &usart1;
29		zephyr,sram = &sram0;
30		zephyr,flash = &flash0;
31		zephyr,code-partition = &slot0_partition;
32		zephyr,canbus = &can1;
33	};
34
35	leds {
36		compatible = "gpio-leds";
37		yellow_led0: led_0 {
38			gpios = <&pioa 23 GPIO_ACTIVE_LOW>;
39			label = "User LED 0";
40			status = "disabled";
41		};
42		yellow_led1: led_1 {
43			gpios = <&pioc 9 GPIO_ACTIVE_LOW>;
44			label = "User LED 1";
45		};
46	};
47
48	pwmleds {
49		compatible = "pwm-leds";
50		pwm_led0: pwm_led_0 {
51			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
52		};
53	};
54
55	gpio_keys {
56		compatible = "gpio-keys";
57
58		/* The switch is labeled SW300/301 in the schematic, and
59		 * labeled SW0 on the board, and labeled ERASE User Button
60		 * on docs
61		 */
62		sw0_user_button: button_1 {
63			label = "User Button 0";
64			gpios = <&pioa 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
65			zephyr,code = <INPUT_KEY_0>;
66		};
67		sw1_user_button: button_2 {
68			label = "User Button 1";
69			gpios = <&piob 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
70			zephyr,code = <INPUT_KEY_1>;
71		};
72	};
73
74	ext1_header: xplained-pro-connector1 {
75		compatible = "atmel-xplained-pro-header";
76		#gpio-cells = <2>;
77		gpio-map-mask = <0xffffffff 0xffffffc0>;
78		gpio-map-pass-thru = <0 0x3f>;		/*           Shared */
79		gpio-map =	<0  0 &pioc 31 0>,	/* AFE1 AD6         */
80				<1  0 &pioa 19 0>,	/* AFE0 AD8         */
81				<2  0 &piob  3 0>,	/* RTS0             */
82				<3  0 &piob  2 0>,	/* CTS0             */
83				<4  0 &pioa  0 0>,	/* PWMC0_H0         */
84				<5  0 &pioc 30 0>,	/* TIOB5            */
85				<6  0 &piod 28 0>,	/* WKUP5            */
86				<7  0 &pioa  5 0>,	/* GPIO             */
87				<8  0 &pioa  3 0>,	/* TWD0        EXT2 */
88				<9  0 &pioa  4 0>,	/* TWCK0       EXT2 */
89				<10 0 &piob  0 0>,	/* RXD0             */
90				<11 0 &piob  1 0>,	/* TXD0             */
91				<12 0 &piod 25 0>,	/* SPI0(NPCS1)      */
92				<13 0 &piod 21 0>,	/* SPI0(MOSI)  EXT2 */
93				<14 0 &piod 20 0>,	/* SPI0(MISO)  EXT2 */
94				<15 0 &piod 22 0>;	/* SPI0(SCK)   EXT2 */
95							/* GND              */
96							/* +3.3V            */
97	};
98
99	ext2_header: xplained-pro-connector2 {
100		compatible = "atmel-xplained-pro-header";
101		#gpio-cells = <2>;
102		gpio-map-mask = <0xffffffff 0xffffffc0>;
103		gpio-map-pass-thru = <0 0x3f>;		/*           Shared */
104		gpio-map =	<0  0 &piod 30 0>,	/* AFE0 AD0         */
105				<1  0 &pioc 13 0>,	/* AFE1 AD1         */
106				<2  0 &pioa  6 0>,	/* GPIO             */
107				<3  0 &piod 11 0>,	/* GPIO             */
108				<4  0 &pioc 19 0>,	/* PWMC0_H2         */
109				<5  0 &piod 26 0>,	/* PWMC0_L2         */
110				<6  0 &pioa  2 0>,	/* WKUP2            */
111				<7  0 &pioa 24 0>,	/* GPIO             */
112				<8  0 &pioa  3 0>,	/* TWD0        EXT1 */
113				<9  0 &pioa  4 0>,	/* TWCK0       EXT1 */
114				<10 0 &pioa 21 0>,	/* RXD1             */
115				<11 0 &piob  4 0>,	/* TXD1             */
116				<12 0 &piod 27 0>,	/* SPI0(NPCS3)      */
117				<13 0 &piod 21 0>,	/* SPI0(MOSI)  EXT1 */
118				<14 0 &piod 20 0>,	/* SPI0(MISO)  EXT1 */
119				<15 0 &piod 22 0>;	/* SPI0(SCK)   EXT1 */
120							/* GND              */
121							/* +3.3V            */
122	};
123
124	arduino_header: connector {
125		compatible = "arduino-header-r3";
126		#gpio-cells = <2>;
127		gpio-map-mask = <0xffffffff 0xffffffc0>;
128		gpio-map-pass-thru = <0 0x3f>;		/*           Shared */
129		gpio-map =	<0  0 &piod 26 0>,	/*  A0-TD           */
130				<1  0 &pioc 31 0>,	/*  A1-AFE1 AD6   y */
131				<2  0 &pioa 19 0>,	/*  A2-AFE0 AD8   y */
132				<3  0 &piod 30 0>,	/*  A3-AFE0 AD0   y */
133				<4  0 &pioc 13 0>,	/*  A4-AFE1 AD1   y */
134				<5  0 &pioe  0 0>,	/*  A5-AFE1 AD11    */
135				<6  0 &piod 28 0>,	/*  D0-URXD3        */
136				<7  0 &piod 30 0>,	/*  D1-UTXD3        */
137				<8  0 &pioa  0 0>,	/*  D2-PWMC0_H0     */
138				<9  0 &pioa  6 0>,	/*  D3-GPIO         */
139				<10 0 &piod 27 0>,	/*  D4-SPI0_NPCS3 y */
140				<11 0 &piod 11 0>,	/*  D5-PWMC0_H0     */
141				<12 0 &pioc 19 0>,	/*  D6-PWMC0_H2     */
142				<13 0 &pioa  2 0>,	/*  D7-PWMC0_H1     */
143				<14 0 &pioa  5 0>,	/*  D8-PWMC1_PWML3  */
144				<15 0 &pioc  9 0>,	/*  D9-TIOB7        */
145				<16 0 &piod 25 0>,	/* D10-SPI0_NPCS1 y */
146				<17 0 &piod 21 0>,	/* D11-SPI0_MOSI  y */
147				<18 0 &piod 20 0>,	/* D12-SPI0_MISO  y */
148				<19 0 &piod 22 0>,	/* D13-SPI0_SPCK  y */
149				<20 0 &pioa  3 0>,	/* D14-TWD0       y */
150				<21 0 &pioa  4 0>;	/* D15-TWCK0      y */
151	};
152};
153
154&cpu0 {
155	clock-frequency = <300000000>;
156};
157
158&afec0 {
159	status = "okay";
160
161	pinctrl-0 = <&afec0_default>;
162	pinctrl-names = "default";
163};
164
165&afec1 {
166	status = "okay";
167
168	pinctrl-0 = <&afec1_default>;
169	pinctrl-names = "default";
170};
171
172&dacc {
173	status = "okay";
174};
175
176&twihs0 {
177	status = "okay";
178
179	pinctrl-0 = <&twihs0_default>;
180	pinctrl-names = "default";
181
182	eeprom: eeprom@5f {
183		compatible = "atmel,24mac402";
184		reg = <0x5f>;
185	};
186};
187
188&twihs2 {
189	status = "okay";
190
191	pinctrl-0 = <&twihs2_default>;
192	pinctrl-names = "default";
193};
194
195&spi0 {
196	status = "okay";
197
198	pinctrl-0 = <&spi0_default>;
199	pinctrl-names = "default";
200
201	cs-gpios = <&piod 25 GPIO_ACTIVE_LOW>,
202		   <&piod 27 GPIO_ACTIVE_LOW>;
203
204	dmas = <&xdmac 1 DMA_PERID_SPI0_TX>, <&xdmac 2 DMA_PERID_SPI0_RX>;
205	dma-names = "tx", "rx";
206};
207
208&usart1 {
209	status = "okay";
210	current-speed = <115200>;
211
212	pinctrl-0 = <&usart1_default>;
213	pinctrl-names = "default";
214};
215
216&uart3 {
217	status = "okay";
218	current-speed = <115200>;
219
220
221	pinctrl-0 = <&uart3_default>;
222	pinctrl-names = "default";
223};
224
225&wdt {
226	status = "okay";
227};
228
229zephyr_udc0: &usbhs {
230	status = "okay";
231};
232
233&gmac {
234	status = "okay";
235
236	pinctrl-0 = <&gmac_rmii>;
237	pinctrl-names = "default";
238
239	mac-eeprom = <&eeprom>;
240	phy-handle = <&phy>;
241};
242
243&mdio {
244	status = "okay";
245
246	pinctrl-0 = <&mdio_default>;
247	pinctrl-names = "default";
248
249	phy: ethernet-phy@0 {
250		compatible = "ethernet-phy";
251		status = "okay";
252		reg = <0>;
253	};
254};
255
256&pwm0 {
257	status = "okay";
258
259	pinctrl-0 = <&pwm_default>;
260	pinctrl-names = "default";
261};
262
263&pioa {
264	status = "okay";
265};
266
267&piob {
268	status = "okay";
269};
270
271&pioc {
272	status = "okay";
273};
274
275&piod {
276	status = "okay";
277};
278
279&pioe {
280	status = "okay";
281};
282
283&flash0 {
284	partitions {
285		compatible = "fixed-partitions";
286		#address-cells = <1>;
287		#size-cells = <1>;
288
289		/*
290		 * The first half of sector 0 (64 kbytes)
291		 * is reserved for the bootloader
292		 */
293		boot_partition: partition@0 {
294			label = "mcuboot";
295			reg = <0x0 0x00010000>;
296			read-only;
297		};
298
299		/* From sector 1 to sector 7 (included): slot0 (896 kbytes) */
300		slot0_partition: partition@20000 {
301			label = "image-0";
302			reg = <0x00020000 0x000e0000>;
303		};
304
305		/* From sector 8 to sector 14 (included): slot1 (896 kbytes) */
306		slot1_partition: partition@100000 {
307			label = "image-1";
308			reg = <0x00100000 0x000e0000>;
309		};
310
311		/* Sector 15: scratch (128 kbytes) */
312		scratch_partition: partition@1e0000 {
313			label = "image-scratch";
314			reg = <0x001e0000 0x00020000>;
315		};
316	};
317};
318
319&ssc {
320	status = "okay";
321
322	pinctrl-0 = <&ssc_default>;
323	pinctrl-names = "default";
324
325	dma-names = "rx", "tx";
326	dmas = <&xdmac 22 DMA_PERID_SSC_RX>, <&xdmac 23 DMA_PERID_SSC_TX>;
327};
328
329&can1 {
330	status = "okay";
331
332	pinctrl-0 = <&can1_default>;
333	pinctrl-names = "default";
334
335	can-transceiver {
336		max-bitrate = <5000000>;
337	};
338};
339
340&rtc {
341	status = "okay";
342};
343
344ext1_spi: &spi0 {
345};
346
347ext1_i2c: &twihs0 {
348};
349
350ext1_serial: &usart0 {
351};
352
353ext2_spi: &spi0 {
354};
355
356ext2_i2c: &twihs0 {
357};
358
359ext2_serial: &usart1 {
360};
361
362arduino_spi: &spi0 {
363};
364
365arduino_i2c: &twihs0 {
366};
367
368arduino_serial: &uart3 {
369};
370