1/*
2 * Copyright (c) 2019 Benjamin Valentin
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <atmel/samr21.dtsi>
9#include <atmel/samx2xx18.dtsi>
10#include "atsamr21_xpro-pinctrl.dtsi"
11#include <zephyr/dt-bindings/input/input-event-codes.h>
12
13/ {
14	model = "SAM R21 Xplained Pro";
15	compatible = "atsamr21,xpro", "atmel,samr21g18a", "atmel,samr21";
16
17	chosen {
18		zephyr,console = &sercom0;
19		zephyr,shell-uart = &sercom0;
20		zephyr,sram = &sram0;
21		zephyr,flash = &flash0;
22		zephyr,ieee802154 = &ieee802154;
23	};
24
25	/* These aliases are provided for compatibility with samples */
26	aliases {
27		led0 = &led0;
28		pwm-led0 = &pwm_led0;
29		sw0 = &user_button;
30		i2c-0 = &sercom1;
31	};
32
33	leds {
34		compatible = "gpio-leds";
35		led0: led_0 {
36			gpios = <&porta 19 GPIO_ACTIVE_LOW>;
37			label = "Yellow LED";
38		};
39	};
40
41	pwmleds {
42		compatible = "pwm-leds";
43		pwm_led0: pwm_led_0 {
44			pwms = <&tcc0 3 PWM_MSEC(20)>;
45		};
46	};
47
48	buttons {
49		compatible = "gpio-keys";
50		user_button: button_0 {
51			gpios = <&porta 28 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
52			label = "SW0";
53			zephyr,code = <INPUT_KEY_0>;
54		};
55	};
56
57	ext1_header: xplained-pro-connector1 {
58		compatible = "atmel-xplained-pro-header";
59		#gpio-cells = <2>;
60		gpio-map-mask = <0xffffffff 0xffffffc0>;
61		gpio-map-pass-thru = <0 0x3f>;		/*           Shared */
62		gpio-map =	<0  0 &porta  6 0>,	/* ADC6             */
63				<1  0 &porta  7 0>,	/* ADC7             */
64				<2  0 &porta 13 0>,	/* GPIO             */
65				<3  0 &porta 28 0>,	/* GPIO             */
66				<4  0 &porta 18 0>,	/* PWM_T0_W2        */
67				<5  0 &porta 19 0>,	/* PWM_T0_W3        */
68				<6  0 &porta 22 0>,	/* GPIO             */
69				<7  0 &porta 23 0>,	/* GPIO             */
70				<8  0 &porta 16 0>,	/* TWD1        EXT2 */
71				<9  0 &porta 17 0>,	/* TWCK1       EXT2 */
72				<10 0 &porta  5 0>,	/* RXD0             */
73				<11 0 &porta  4 0>,	/* TXD0             */
74				<12 0 &portb  3 0>,	/* SPI5(SS)         */
75				<13 0 &portb 22 0>,	/* SPI5(MOSI)  EXTx */
76				<14 0 &portb  2 0>,	/* SPI5(MISO)  EXTx */
77				<15 0 &portb 23 0>;	/* SPI5(SCK)   EXTx */
78	};
79
80	ext2_header: xplained-pro-connector2 {
81		compatible = "atmel-xplained-pro-header";
82		#gpio-cells = <2>;
83		gpio-map-mask = <0xffffffff 0xffffffc0>;
84		gpio-map-pass-thru = <0 0x3f>;		/*           Shared */
85		gpio-map =    /*<0  0 -      - 0>,	   -                */
86			      /*<1  0 -      - 0>,	   -                */
87				<2  0 &porta 15 0>,	/* GPIO             */
88			      /*<3  0 -      - 0>,	   -                */
89			      /*<4  0 -      - 0>,	   -                */
90			      /*<5  0 -      - 0>,	   -                */
91			      /*<6  0 -      - 0>,	   -                */
92				<7  0 &porta  8 0>,	/* GPIO             */
93				<8  0 &porta 16 0>,	/* TWD1        EXT1 */
94				<9  0 &porta 17 0>,	/* TWCK1       EXT1 */
95			      /*<11 0 -      - 0>,	   -                */
96			      /*<12 0 -      - 0>,	   -                */
97				<12 0 &porta 14 0>,	/* GPIO             */
98				<13 0 &portb 22 0>,	/* SPI5(MOSI)  EXTx */
99				<14 0 &portb  2 0>,	/* SPI5(MISO)  EXTx */
100				<15 0 &portb 23 0>;	/* SPI5(SCK)   EXTx */
101	};
102};
103
104&cpu0 {
105	clock-frequency = <48000000>;
106};
107
108&tcc0 {
109	status = "okay";
110	compatible = "atmel,sam0-tcc-pwm";
111	prescaler = <4>;
112	#pwm-cells = <2>;
113
114	pinctrl-0 = <&pwm_default>;
115	pinctrl-names = "default";
116};
117
118&sercom0 {
119	status = "okay";
120	compatible = "atmel,sam0-uart";
121	current-speed = <115200>;
122	rxpo = <1>;
123	txpo = <0>;
124
125	pinctrl-0 = <&sercom0_uart_default>;
126	pinctrl-names = "default";
127};
128
129&sercom1 {
130	status = "okay";
131	compatible = "atmel,sam0-i2c";
132	clock-frequency = <I2C_BITRATE_FAST>;
133	#address-cells = <1>;
134	#size-cells = <0>;
135
136	pinctrl-0 = <&sercom1_i2c_default>;
137	pinctrl-names = "default";
138};
139
140&sercom4 {
141	status = "okay";
142	compatible = "atmel,sam0-spi";
143	/*
144	 *	CS-PB31; MOSI-PB30; MISO-PC19; SCLK-PC18
145	 *	PAD[1]; PAD[2]; PAD[0]; PAD[3]
146	 */
147	dipo = <0>;
148	dopo = <1>;
149	#address-cells = <1>;
150	#size-cells = <0>;
151
152	pinctrl-0 = <&sercom4_spi_default>;
153	pinctrl-names = "default";
154
155	cs-gpios = <&portb 31 GPIO_ACTIVE_LOW>;
156
157	ieee802154: rf2xx@0 {
158		compatible = "atmel,rf2xx";
159		reg = <0x0>;
160		spi-max-frequency = <6000000>;
161		irq-gpios = <&portb 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
162		reset-gpios = <&portb 15 GPIO_ACTIVE_LOW>;
163		slptr-gpios = <&porta 20 GPIO_ACTIVE_HIGH>;
164		dig2-gpios = <&portb 17 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
165		status = "okay";
166		tx-pwr-min = [01 11];	/* -17.0 dBm */
167		tx-pwr-max = [00 04];	/*   4.0 dBm */
168		tx-pwr-table = [00 01 03 04 05 05 06 06
169				07 07 07 08 08 09 09 0a
170				0a 0a 0b 0b 0b 0b 0c 0c
171				0c 0c 0d 0d 0d 0d 0d 0d
172				0d 0d 0e 0e 0e 0e 0e 0e
173				0e 0e 0e 0e 0e 0e 0f 0f];
174	};
175};
176
177&sercom5 {
178	status = "okay";
179	compatible = "atmel,sam0-spi";
180	dipo = <0>;
181	dopo = <2>;
182	#address-cells = <1>;
183	#size-cells = <0>;
184
185	pinctrl-0 = <&sercom5_spi_default>;
186	pinctrl-names = "default";
187};
188
189zephyr_udc0: &usb0 {
190	status = "okay";
191
192	pinctrl-0 = <&usb_dc_default>;
193	pinctrl-names = "default";
194};
195
196ext1_spi: &sercom5 {
197};
198
199ext1_i2c: &sercom1 {
200};
201
202ext1_serial: &sercom0 {
203};
204
205ext2_spi: &sercom5 {
206};
207
208ext2_i2c: &sercom1 {
209};
210