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