1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * at91-sama5d2_icp.dts - Device Tree file for SAMA5D2-ICP board
4 *
5 *  Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries
6 *
7 *	Author: Radu Pirea & Razvan Stefanescu,
8 *		Codrin Ciubotariu <codrin.ciubotariu@microchip.com>,
9 *		Cristian Birsan <cristian.birsan@microchip.com>
10 */
11/dts-v1/;
12#include "sama5d2.dtsi"
13#include "sama5d2-pinfunc.h"
14#include <dt-bindings/gpio/gpio.h>
15#include <dt-bindings/input/input.h>
16#include <dt-bindings/mfd/atmel-flexcom.h>
17
18/ {
19	model = "Microchip SAMA5D2-ICP";
20	compatible = "microchip,sama5d2-icp", "atmel,sama5d27", "atmel,sama5d2", "atmel,sama5";
21
22	aliases {
23		serial0 = &uart0;	/* debug uart0 + mikro BUS 1 */
24		serial1 = &uart1;	/* mikro BUS 3 */
25		serial3 = &uart3;	/* mikro BUS 2 */
26		serial5 = &uart7;	/* flx2 */
27		i2c0	= &i2c0;
28		i2c1	= &i2c1;
29	};
30
31	chosen {
32		stdout-path = "serial0:115200n8";
33	};
34
35	clocks {
36		slow_xtal {
37			clock-frequency = <32768>;
38		};
39
40		main_xtal {
41			clock-frequency = <12000000>;
42		};
43	};
44
45	gpio_keys {
46		compatible = "gpio-keys";
47
48		pinctrl-names = "default";
49		pinctrl-0 = <&pinctrl_key_gpio_default>;
50		status = "okay";
51
52		sw4 {
53			label = "USER_PB1";
54			gpios = <&pioA PIN_PD0 GPIO_ACTIVE_LOW>;
55			linux,code = <KEY_PROG1>;
56			wakeup-source;
57		};
58	};
59
60	leds {
61		compatible = "gpio-leds";
62		pinctrl-names = "default";
63		pinctrl-0 = <&pinctrl_led_gpio_default>;
64		status = "okay"; /* conflict with pwm0 */
65
66		red {
67			label = "red";
68			gpios = <&pioA PIN_PB0 GPIO_ACTIVE_HIGH>;
69		};
70
71		green {
72			label = "green";
73			gpios = <&pioA PIN_PB1 GPIO_ACTIVE_HIGH>;
74		};
75
76		blue {
77			label = "blue";
78			gpios = <&pioA PIN_PA31 GPIO_ACTIVE_HIGH>;
79			linux,default-trigger = "heartbeat";
80		};
81	};
82};
83
84&adc {
85	vddana-supply = <&vdd_io_reg>;
86	vref-supply = <&vdd_io_reg>;
87	pinctrl-names = "default";
88	pinctrl-0 = <&pinctrl_adc_default &pinctrl_adtrg_default>;
89	status = "okay";
90};
91
92&can0 {
93	pinctrl-names = "default";
94	pinctrl-0 = <&pinctrl_can0_default>;
95	status = "okay";
96};
97
98&can1 {
99	pinctrl-names = "default";
100	pinctrl-0 = <&pinctrl_can1_default>;
101	status = "okay";
102};
103
104&flx0 { /* mikrobus2 spi */
105	atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_SPI>;
106	status = "okay";
107
108	spi2: spi@400 {
109		dmas = <0>, <0>;
110		cs-gpios = <&pioA PIN_PC0 GPIO_ACTIVE_LOW>;
111		pinctrl-names = "default";
112		pinctrl-0 = <&pinctrl_mikrobus2_spi &pinctrl_ksz_spi_cs>;
113		status = "okay";
114		#address-cells = <1>;
115		#size-cells = <0>;
116
117		switch0: ksz8563@0 {
118			compatible = "microchip,ksz8563";
119			reg = <0>;
120			reset-gpios = <&pioA PIN_PD4 GPIO_ACTIVE_LOW>;
121
122			spi-max-frequency = <500000>;
123			spi-cpha;
124			spi-cpol;
125
126			ports {
127				#address-cells = <1>;
128				#size-cells = <0>;
129				port@0 {
130					reg = <0>;
131					label = "lan1";
132				};
133
134				port@1 {
135					reg = <1>;
136					label = "lan2";
137				};
138
139				port@2 {
140					reg = <2>;
141					label = "cpu";
142					ethernet = <&macb0>;
143					phy-mode = "mii";
144					fixed-link {
145						speed = <100>;
146						full-duplex;
147					};
148				};
149			};
150		};
151	};
152};
153
154&flx2 {
155	atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
156	status = "okay";
157
158	uart7: serial@200 {
159		pinctrl-0 = <&pinctrl_flx2_default>;
160		pinctrl-names = "default";
161		atmel,use-dma-rx;
162		atmel,use-dma-tx;
163		status = "okay"; /* Conflict w/ qspi1. */
164	};
165};
166
167&flx3 { /* mikrobus1 spi */
168	atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_SPI>;
169	status = "okay";
170
171	spi5: spi@400 {
172		dmas = <0>, <0>;
173		pinctrl-names = "default";
174		pinctrl-0 = <&pinctrl_mikrobus1_spi &pinctrl_mikrobus1_spi_cs>;
175		status = "okay";
176	};
177};
178
179&flx4 {
180	atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>;
181	status = "okay";
182
183	i2c6: i2c@600 {
184		dmas = <0>, <0>;
185		pinctrl-names = "default";
186		pinctrl-0 = <&pinctrl_flx4_default>;
187		status = "okay";
188
189		mcp16502@5b {
190			compatible = "microchip,mcp16502";
191			reg = <0x5b>;
192			status = "okay";
193			lpm-gpios = <&pioBU 7 GPIO_ACTIVE_LOW>;
194
195			regulators {
196				vdd_io_reg: VDD_IO {
197					regulator-name = "VDD_IO";
198					regulator-min-microvolt = <1200000>;
199					regulator-max-microvolt = <3700000>;
200					regulator-initial-mode = <2>;
201					regulator-allowed-modes = <2>, <4>;
202					regulator-always-on;
203
204					regulator-state-standby {
205						regulator-on-in-suspend;
206						regulator-mode = <4>;
207					};
208
209					regulator-state-mem {
210						regulator-off-in-suspend;
211						regulator-mode = <4>;
212					};
213				};
214
215				VDD_DDR {
216					regulator-name = "VDD_DDR";
217					regulator-min-microvolt = <600000>;
218					regulator-max-microvolt = <1850000>;
219					regulator-initial-mode = <2>;
220					regulator-allowed-modes = <2>, <4>;
221					regulator-always-on;
222
223					regulator-state-standby {
224						regulator-on-in-suspend;
225						regulator-mode = <4>;
226					};
227
228					regulator-state-mem {
229						regulator-on-in-suspend;
230						regulator-mode = <4>;
231					};
232				};
233
234				VDD_CORE {
235					regulator-name = "VDD_CORE";
236					regulator-min-microvolt = <600000>;
237					regulator-max-microvolt = <1850000>;
238					regulator-initial-mode = <2>;
239					regulator-allowed-modes = <2>, <4>;
240					regulator-always-on;
241
242					regulator-state-standby {
243						regulator-on-in-suspend;
244						regulator-mode = <4>;
245					};
246
247					regulator-state-mem {
248						regulator-off-in-suspend;
249						regulator-mode = <4>;
250					};
251				};
252
253				VDD_OTHER {
254					regulator-name = "VDD_OTHER";
255					regulator-min-microvolt = <600000>;
256					regulator-max-microvolt = <1850000>;
257					regulator-initial-mode = <2>;
258					regulator-allowed-modes = <2>, <4>;
259					regulator-always-on;
260
261					regulator-state-standby {
262						regulator-on-in-suspend;
263						regulator-mode = <4>;
264					};
265
266					regulator-state-mem {
267						regulator-off-in-suspend;
268						regulator-mode = <4>;
269					};
270				};
271
272				LDO1 {
273					regulator-name = "LDO1";
274					regulator-min-microvolt = <1200000>;
275					regulator-max-microvolt = <3700000>;
276					regulator-always-on;
277
278					regulator-state-standby {
279						regulator-on-in-suspend;
280					};
281
282					regulator-state-mem {
283						regulator-off-in-suspend;
284					};
285				};
286
287				LDO2 {
288					regulator-name = "LDO2";
289					regulator-min-microvolt = <1200000>;
290					regulator-max-microvolt = <3700000>;
291					regulator-always-on;
292
293					regulator-state-standby {
294						regulator-on-in-suspend;
295					};
296
297					regulator-state-mem {
298						regulator-off-in-suspend;
299					};
300				};
301
302			};
303		};
304	};
305};
306
307&i2c0 { /* mikrobus i2c */
308	pinctrl-names = "default";
309	pinctrl-0 = <&pinctrl_mikrobus_i2c>;
310	status = "okay";
311};
312
313&i2c1 {
314	dmas = <0>, <0>;
315	pinctrl-names = "default";
316	pinctrl-0 = <&pinctrl_i2c1_default>;
317	status = "okay";
318
319	eeprom@50 {
320		compatible = "atmel,24c32";
321		reg = <0x50>;
322		pagesize = <16>;
323		status = "okay";
324	};
325
326	eeprom@52 {
327		compatible = "atmel,24c32";
328		reg = <0x52>;
329		pagesize = <16>;
330		status = "disabled";
331	};
332
333	eeprom@53 {
334		compatible = "atmel,24c32";
335		reg = <0x53>;
336		pagesize = <16>;
337		status = "disabled";
338	};
339};
340
341&macb0 {
342	pinctrl-names = "default";
343	pinctrl-0 = <&pinctrl_macb0_default &pinctrl_macb0_phy_irq &pinctrl_macb0_rst>;
344	phy-mode = "mii";
345	status = "okay";
346
347	fixed-link {
348		speed = <100>;
349		full-duplex;
350	};
351};
352
353&pioA {
354	pinctrl_adc_default: adc_default {
355		pinmux = <PIN_PD24__GPIO>,
356				<PIN_PD25__GPIO>,
357				<PIN_PD26__GPIO>;
358		bias-disable;
359	};
360
361	/*
362	 * The ADTRG pin can work on any edge type.
363	 * In here it's being pulled up, so need to
364	 * connect it to ground to get an edge e.g.
365	 * Trigger can be configured on falling, rise
366	 * or any edge, and the pull-up can be changed
367	 * to pull-down or left floating according to
368	 * needs.
369	 */
370	pinctrl_adtrg_default: adtrg_default {
371		pinmux = <PIN_PD31__ADTRG>;
372		bias-pull-up;
373	};
374
375	pinctrl_flx4_default: flx4_default {
376		pinmux = <PIN_PC28__FLEXCOM4_IO0>,
377			 <PIN_PC29__FLEXCOM4_IO1>;
378		bias-disable;
379	};
380
381	pinctrl_can0_default: can0_default {
382		pinmux = <PIN_PC10__CANTX0>,
383			 <PIN_PC11__CANRX0>;
384		bias-disable;
385	};
386
387	pinctrl_can1_default: can1_default {
388		pinmux = <PIN_PC26__CANTX1>,
389			 <PIN_PC27__CANRX1>;
390		bias-disable;
391	};
392
393	pinctrl_i2c1_default: i2c1_default {
394		pinmux = <PIN_PD19__TWD1>,
395			 <PIN_PD20__TWCK1>;
396		bias-disable;
397	};
398
399	pinctrl_key_gpio_default: key_gpio_default {
400		pinmux = <PIN_PD0__GPIO>;
401		bias-pull-up;
402	};
403
404	pinctrl_led_gpio_default: led_gpio_default {
405		pinmux = <PIN_PB0__GPIO>,
406			 <PIN_PB1__GPIO>,
407			 <PIN_PA31__GPIO>;
408		bias-pull-up;
409	};
410
411	pinctrl_qspi1_default: qspi1_default {
412		pinmux = <PIN_PA6__QSPI1_SCK>,
413			 <PIN_PA7__QSPI1_IO0>,
414			 <PIN_PA8__QSPI1_IO1>,
415			 <PIN_PA9__QSPI1_IO2>,
416			 <PIN_PA10__QSPI1_IO3>,
417			 <PIN_PA11__QSPI1_CS>;
418		bias-disable;
419	};
420
421	pinctrl_sdmmc0_default: sdmmc0_default {
422		cmd_data {
423			pinmux = <PIN_PA1__SDMMC0_CMD>,
424				 <PIN_PA2__SDMMC0_DAT0>,
425				 <PIN_PA3__SDMMC0_DAT1>,
426				 <PIN_PA4__SDMMC0_DAT2>,
427				 <PIN_PA5__SDMMC0_DAT3>;
428			bias-disable;
429		};
430
431		ck_cd {
432			pinmux = <PIN_PA0__SDMMC0_CK>,
433				 <PIN_PA13__SDMMC0_CD>;
434			bias-disable;
435		};
436	};
437
438	pinctrl_sdmmc1_default: sdmmc1_default {
439		cmd_data {
440			pinmux = <PIN_PA18__SDMMC1_DAT0>,
441				 <PIN_PA19__SDMMC1_DAT1>,
442				 <PIN_PA20__SDMMC1_DAT2>,
443				 <PIN_PA21__SDMMC1_DAT3>;
444			bias-disable;
445		};
446
447		ck_cd {
448			pinmux = <PIN_PA22__SDMMC1_CK>,
449				 <PIN_PA28__SDMMC1_CMD>;
450			bias-disable;
451		};
452	};
453
454	pinctrl_mikrobus_i2c: mikrobus_i2c {
455		pinmux = <PIN_PD22__TWCK0>,
456			 <PIN_PD21__TWD0>;
457		bias-disable;
458	};
459
460	pinctrl_mikrobus1_an: mikrobus1_an {
461		pinmux = <PIN_PD26__GPIO>;
462		bias-disable;
463	};
464
465	pinctrl_mikrobus1_rst: mikrobus1_rst {
466		pinmux = <PIN_PC5__GPIO>;
467		bias-disable;
468	};
469
470	pinctrl_mikrobus1_spi_cs: mikrobus1_spi_cs {
471		pinmux = <PIN_PC21__FLEXCOM3_IO3>;
472		bias-disable;
473	};
474
475	pinctrl_mikrobus1_spi: mikrobus1_spi {
476		pinmux = <PIN_PC20__FLEXCOM3_IO0>,
477			 <PIN_PC19__FLEXCOM3_IO1>,
478			 <PIN_PC18__FLEXCOM3_IO2>;
479		bias-disable;
480	};
481
482	pinctrl_mikrobus1_pwm: mikrobus1_pwm {
483		pinmux = <PIN_PC4__TIOB1>;
484		bias-disable;
485	};
486
487	pinctrl_mikrobus1_int: mikrobus1_int {
488		pinmux = <PIN_PC3__GPIO>;
489		bias-disable;
490	};
491
492	pinctrl_mikrobus1_uart: mikrobus1_uart {
493		pinmux = <PIN_PB26__URXD0>,
494			 <PIN_PB27__UTXD0>;
495		bias-disable;
496	};
497
498	pinctrl_mikrobus2_an: mikrobus2_an {
499		pinmux = <PIN_PD25__GPIO>;
500		bias-disable;
501	};
502
503	pinctrl_mikrobus2_rst: mikrobus2_rst {
504		pinmux = <PIN_PB24__GPIO>;
505		bias-disable;
506	};
507
508	pinctrl_mikrobus2_spi_cs: mikrobus2_spi_cs {
509		pinmux = <PIN_PB31__FLEXCOM0_IO3>;
510		bias-disable;
511	};
512
513	pinctrl_mikrobus2_spi: mikrobus2_spi {
514		pinmux = <PIN_PB28__FLEXCOM0_IO0>,
515			 <PIN_PB29__FLEXCOM0_IO1>,
516			 <PIN_PB30__FLEXCOM0_IO2>;
517		bias-disable;
518	};
519
520	pinctrl_ksz_spi_cs: ksz_spi_cs {
521		pinmux = <PIN_PC0__GPIO>;
522		bias-disable;
523	};
524
525	pinctrl_mikrobus2_pwm: mikrobus2_pwm {
526		pinmux = <PIN_PB23__TIOB2>;
527		bias-disable;
528	};
529
530	pinctrl_mikrobus2_int: mikrobus2_int {
531		pinmux = <PIN_PB22__GPIO>;
532		bias-disable;
533	};
534
535	pinctrl_mikrobus2_uart: mikrobus2_uart {
536		pinmux = <PIN_PC12__URXD3>,
537			 <PIN_PC13__UTXD3>;
538		bias-disable;
539	};
540
541	pinctrl_mikrobus3_an: mikrobus3_an {
542		pinmux = <PIN_PD24__GPIO>;
543		bias-disable;
544	};
545
546	pinctrl_mikrobus3_rst: mikrobus3_rst {
547		pinmux = <PIN_PB21__GPIO>;
548		bias-disable;
549	};
550
551	pinctrl_mikrobus3_spi_cs: mikrobus3_spi_cs {
552		pinmux = <PIN_PA17__SPI0_NPCS0>;
553		bias-disable;
554	};
555
556	pinctrl_mikrobus3_spi: mikrobus3_spi {
557		pinmux = <PIN_PA14__SPI0_SPCK>,
558			 <PIN_PA16__SPI0_MISO>,
559			 <PIN_PA15__SPI0_MOSI>;
560		bias-disable;
561	};
562
563	pinctrl_mikrobus3_pwm: mikrobus3_pwm {
564		pinmux = <PIN_PB20__TIOB3>;
565		bias-disable;
566	};
567
568	pinctrl_mikrobus3_int: mikrobus3_int {
569		pinmux = <PIN_PB18__GPIO>;
570		bias-disable;
571	};
572
573	pinctrl_mikrobus3_uart: mikrobus3_uart {
574		pinmux = <PIN_PC7__URXD1>,
575			 <PIN_PC8__UTXD1>;
576		bias-disable;
577	};
578
579	pinctrl_usb_default: usb_default {
580		pinmux = <PIN_PC17__GPIO>;
581		bias-disable;
582	};
583
584	pinctrl_usba_vbus: usba_vbus {
585		pinmux = <PIN_PD23__GPIO>;
586		bias-disable;
587	};
588
589	pinctrl_pwm0_pwm2_default: pwm0_pwm2_default {
590		pinmux = <PIN_PB5__PWMH2>,
591			 <PIN_PB6__PWML2>;
592		bias-pull-up;
593	};
594
595	pinctrl_macb0_default: macb0_default {
596		pinmux = <PIN_PD1__GRXCK>,
597			 <PIN_PD2__GTXER>,
598			 <PIN_PD5__GRX2>,
599			 <PIN_PD6__GRX3>,
600			 <PIN_PD7__GTX2>,
601			 <PIN_PD8__GTX3>,
602			 <PIN_PD9__GTXCK>,
603			 <PIN_PD10__GTXEN>,
604			 <PIN_PD11__GRXDV>,
605			 <PIN_PD12__GRXER>,
606			 <PIN_PD13__GRX0>,
607			 <PIN_PD14__GRX1>,
608			 <PIN_PD15__GTX0>,
609			 <PIN_PD16__GTX1>,
610			 <PIN_PD17__GMDC>,
611			 <PIN_PD18__GMDIO>;
612		bias-disable;
613	};
614
615	pinctrl_macb0_phy_irq: macb0_phy_irq {
616		pinmux = <PIN_PD3__GPIO>;
617		bias-disable;
618	};
619
620	pinctrl_macb0_rst: macb0_sw_rst {
621		pinmux = <PIN_PD4__GPIO>;
622		bias-disable;
623	};
624
625	pinctrl_flx2_default: flx2_default {
626		pinmux = <PIN_PA6__FLEXCOM2_IO0>,
627			 <PIN_PA7__FLEXCOM2_IO1>,
628			 <PIN_PA9__FLEXCOM2_IO3>,
629			 <PIN_PA10__FLEXCOM2_IO4>;
630		bias-disable;
631	};
632};
633
634&pwm0 {
635	pinctrl-names = "default";
636	pinctrl-0 = <&pinctrl_pwm0_pwm2_default>;
637	status = "disabled"; /* conflict with leds, HSIC */
638};
639
640&qspi1 {
641	pinctrl-names = "default";
642	pinctrl-0 = <&pinctrl_qspi1_default>;
643	status = "disabled"; /* Conflict with wilc_pwrseq, flx2 */
644
645	flash@0 {
646		#address-cells = <1>;
647		#size-cells = <1>;
648		compatible = "jedec,spi-nor";
649		reg = <0>;
650		spi-max-frequency = <80000000>;
651		spi-tx-bus-width = <4>;
652		spi-rx-bus-width = <4>;
653		m25p,fast-read;
654
655		at91bootstrap@0 {
656			label = "qspi: at91bootstrap";
657			reg = <0x00000000 0x00040000>;
658		};
659
660		bootloader@40000 {
661			label = "qspi: bootloader";
662			reg = <0x00040000 0x000c0000>;
663		};
664
665		bootloaderenvred@100000 {
666			label = "qspi: bootloader env redundant";
667			reg = <0x00100000 0x00040000>;
668		};
669
670		bootloaderenv@140000 {
671			label = "qspi: bootloader env";
672			reg = <0x00140000 0x00040000>;
673		};
674
675		dtb@180000 {
676			label = "qspi: device tree";
677			reg = <0x00180000 0x00080000>;
678		};
679
680		kernel@200000 {
681			label = "qspi: kernel";
682			reg = <0x00200000 0x00600000>;
683		};
684	};
685};
686
687&sdmmc0 {
688	no-1-8-v;
689	bus-width = <4>;
690	pinctrl-names = "default";
691	pinctrl-0 = <&pinctrl_sdmmc0_default>;
692	status = "okay";
693};
694
695&shutdown_controller {
696	atmel,shdwc-debouncer = <976>;
697	atmel,wakeup-rtc-timer;
698
699	input@0 {
700		reg = <0>;
701	};
702};
703
704&spi0 {  /* mikrobus3 spi */
705	pinctrl-names = "default";
706	pinctrl-0 = <&pinctrl_mikrobus3_spi &pinctrl_mikrobus3_spi_cs>;
707	status = "okay";
708};
709
710&tcb0 {
711	timer0: timer@0 {
712		compatible = "atmel,tcb-timer";
713		reg = <0>;
714	};
715
716	timer1: timer@1 {
717		compatible = "atmel,tcb-timer";
718		reg = <1>;
719	};
720};
721
722&uart0 {
723	pinctrl-names = "default";
724	pinctrl-0 = <&pinctrl_mikrobus1_uart>;
725	atmel,use-dma-rx;
726	atmel,use-dma-tx;
727	status = "okay";
728};
729
730&uart1 {
731	pinctrl-names = "default";
732	pinctrl-0 = <&pinctrl_mikrobus3_uart>;
733	atmel,use-dma-rx;
734	atmel,use-dma-tx;
735	status = "okay";
736};
737
738&uart3 {
739	pinctrl-names = "default";
740	pinctrl-0 = <&pinctrl_mikrobus2_uart>;
741	atmel,use-dma-rx;
742	atmel,use-dma-tx;
743	status = "okay";
744};
745
746&usb0 {
747	atmel,vbus-gpio = <&pioA PIN_PD23 GPIO_ACTIVE_HIGH>;
748	pinctrl-names = "default";
749	pinctrl-0 = <&pinctrl_usba_vbus>;
750	status = "okay";
751};
752
753&usb1 {
754	num-ports = <3>;
755	pinctrl-names = "default";
756	pinctrl-0 = <&pinctrl_usb_default>;
757	status = "okay";
758};
759
760&usb2 {
761	phy_type = "hsic";
762	status = "okay";
763};
764
765&watchdog {
766	status = "okay";
767};
768