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		i2c-digital-filter;
188		i2c-digital-filter-width-ns = <35>;
189		status = "okay";
190
191		mcp16502@5b {
192			compatible = "microchip,mcp16502";
193			reg = <0x5b>;
194			status = "okay";
195			lpm-gpios = <&pioBU 7 GPIO_ACTIVE_LOW>;
196
197			regulators {
198				vdd_io_reg: VDD_IO {
199					regulator-name = "VDD_IO";
200					regulator-min-microvolt = <1200000>;
201					regulator-max-microvolt = <3700000>;
202					regulator-initial-mode = <2>;
203					regulator-allowed-modes = <2>, <4>;
204					regulator-always-on;
205
206					regulator-state-standby {
207						regulator-on-in-suspend;
208						regulator-mode = <4>;
209					};
210
211					regulator-state-mem {
212						regulator-off-in-suspend;
213						regulator-mode = <4>;
214					};
215				};
216
217				VDD_DDR {
218					regulator-name = "VDD_DDR";
219					regulator-min-microvolt = <600000>;
220					regulator-max-microvolt = <1850000>;
221					regulator-initial-mode = <2>;
222					regulator-allowed-modes = <2>, <4>;
223					regulator-always-on;
224
225					regulator-state-standby {
226						regulator-on-in-suspend;
227						regulator-mode = <4>;
228					};
229
230					regulator-state-mem {
231						regulator-on-in-suspend;
232						regulator-mode = <4>;
233					};
234				};
235
236				VDD_CORE {
237					regulator-name = "VDD_CORE";
238					regulator-min-microvolt = <600000>;
239					regulator-max-microvolt = <1850000>;
240					regulator-initial-mode = <2>;
241					regulator-allowed-modes = <2>, <4>;
242					regulator-always-on;
243
244					regulator-state-standby {
245						regulator-on-in-suspend;
246						regulator-mode = <4>;
247					};
248
249					regulator-state-mem {
250						regulator-off-in-suspend;
251						regulator-mode = <4>;
252					};
253				};
254
255				VDD_OTHER {
256					regulator-name = "VDD_OTHER";
257					regulator-min-microvolt = <600000>;
258					regulator-max-microvolt = <1850000>;
259					regulator-initial-mode = <2>;
260					regulator-allowed-modes = <2>, <4>;
261					regulator-always-on;
262
263					regulator-state-standby {
264						regulator-on-in-suspend;
265						regulator-mode = <4>;
266					};
267
268					regulator-state-mem {
269						regulator-off-in-suspend;
270						regulator-mode = <4>;
271					};
272				};
273
274				LDO1 {
275					regulator-name = "LDO1";
276					regulator-min-microvolt = <1200000>;
277					regulator-max-microvolt = <3700000>;
278					regulator-always-on;
279
280					regulator-state-standby {
281						regulator-on-in-suspend;
282					};
283
284					regulator-state-mem {
285						regulator-off-in-suspend;
286					};
287				};
288
289				LDO2 {
290					regulator-name = "LDO2";
291					regulator-min-microvolt = <1200000>;
292					regulator-max-microvolt = <3700000>;
293					regulator-always-on;
294
295					regulator-state-standby {
296						regulator-on-in-suspend;
297					};
298
299					regulator-state-mem {
300						regulator-off-in-suspend;
301					};
302				};
303
304			};
305		};
306	};
307};
308
309&i2c0 { /* mikrobus i2c */
310	pinctrl-names = "default";
311	pinctrl-0 = <&pinctrl_mikrobus_i2c>;
312	i2c-digital-filter;
313	i2c-digital-filter-width-ns = <35>;
314	status = "okay";
315};
316
317&i2c1 {
318	dmas = <0>, <0>;
319	pinctrl-names = "default";
320	pinctrl-0 = <&pinctrl_i2c1_default>;
321	i2c-digital-filter;
322	i2c-digital-filter-width-ns = <35>;
323	status = "okay";
324
325	eeprom@50 {
326		compatible = "atmel,24c32";
327		reg = <0x50>;
328		pagesize = <16>;
329		status = "okay";
330	};
331
332	eeprom@52 {
333		compatible = "atmel,24c32";
334		reg = <0x52>;
335		pagesize = <16>;
336		status = "disabled";
337	};
338
339	eeprom@53 {
340		compatible = "atmel,24c32";
341		reg = <0x53>;
342		pagesize = <16>;
343		status = "disabled";
344	};
345};
346
347&macb0 {
348	pinctrl-names = "default";
349	pinctrl-0 = <&pinctrl_macb0_default &pinctrl_macb0_phy_irq &pinctrl_macb0_rst>;
350	phy-mode = "mii";
351	status = "okay";
352
353	fixed-link {
354		speed = <100>;
355		full-duplex;
356	};
357};
358
359&pioA {
360	pinctrl_adc_default: adc_default {
361		pinmux = <PIN_PD24__GPIO>,
362				<PIN_PD25__GPIO>,
363				<PIN_PD26__GPIO>;
364		bias-disable;
365	};
366
367	/*
368	 * The ADTRG pin can work on any edge type.
369	 * In here it's being pulled up, so need to
370	 * connect it to ground to get an edge e.g.
371	 * Trigger can be configured on falling, rise
372	 * or any edge, and the pull-up can be changed
373	 * to pull-down or left floating according to
374	 * needs.
375	 */
376	pinctrl_adtrg_default: adtrg_default {
377		pinmux = <PIN_PD31__ADTRG>;
378		bias-pull-up;
379	};
380
381	pinctrl_flx4_default: flx4_default {
382		pinmux = <PIN_PC28__FLEXCOM4_IO0>,
383			 <PIN_PC29__FLEXCOM4_IO1>;
384		bias-disable;
385	};
386
387	pinctrl_can0_default: can0_default {
388		pinmux = <PIN_PC10__CANTX0>,
389			 <PIN_PC11__CANRX0>;
390		bias-disable;
391	};
392
393	pinctrl_can1_default: can1_default {
394		pinmux = <PIN_PC26__CANTX1>,
395			 <PIN_PC27__CANRX1>;
396		bias-disable;
397	};
398
399	pinctrl_i2c1_default: i2c1_default {
400		pinmux = <PIN_PD19__TWD1>,
401			 <PIN_PD20__TWCK1>;
402		bias-disable;
403	};
404
405	pinctrl_key_gpio_default: key_gpio_default {
406		pinmux = <PIN_PD0__GPIO>;
407		bias-pull-up;
408	};
409
410	pinctrl_led_gpio_default: led_gpio_default {
411		pinmux = <PIN_PB0__GPIO>,
412			 <PIN_PB1__GPIO>,
413			 <PIN_PA31__GPIO>;
414		bias-pull-up;
415	};
416
417	pinctrl_qspi1_default: qspi1_default {
418		pinmux = <PIN_PA6__QSPI1_SCK>,
419			 <PIN_PA7__QSPI1_IO0>,
420			 <PIN_PA8__QSPI1_IO1>,
421			 <PIN_PA9__QSPI1_IO2>,
422			 <PIN_PA10__QSPI1_IO3>,
423			 <PIN_PA11__QSPI1_CS>;
424		bias-disable;
425	};
426
427	pinctrl_sdmmc0_default: sdmmc0_default {
428		cmd_data {
429			pinmux = <PIN_PA1__SDMMC0_CMD>,
430				 <PIN_PA2__SDMMC0_DAT0>,
431				 <PIN_PA3__SDMMC0_DAT1>,
432				 <PIN_PA4__SDMMC0_DAT2>,
433				 <PIN_PA5__SDMMC0_DAT3>;
434			bias-disable;
435		};
436
437		ck_cd {
438			pinmux = <PIN_PA0__SDMMC0_CK>,
439				 <PIN_PA13__SDMMC0_CD>;
440			bias-disable;
441		};
442	};
443
444	pinctrl_sdmmc1_default: sdmmc1_default {
445		cmd_data {
446			pinmux = <PIN_PA18__SDMMC1_DAT0>,
447				 <PIN_PA19__SDMMC1_DAT1>,
448				 <PIN_PA20__SDMMC1_DAT2>,
449				 <PIN_PA21__SDMMC1_DAT3>;
450			bias-disable;
451		};
452
453		ck_cd {
454			pinmux = <PIN_PA22__SDMMC1_CK>,
455				 <PIN_PA28__SDMMC1_CMD>;
456			bias-disable;
457		};
458	};
459
460	pinctrl_mikrobus_i2c: mikrobus_i2c {
461		pinmux = <PIN_PD22__TWCK0>,
462			 <PIN_PD21__TWD0>;
463		bias-disable;
464	};
465
466	pinctrl_mikrobus1_an: mikrobus1_an {
467		pinmux = <PIN_PD26__GPIO>;
468		bias-disable;
469	};
470
471	pinctrl_mikrobus1_rst: mikrobus1_rst {
472		pinmux = <PIN_PC5__GPIO>;
473		bias-disable;
474	};
475
476	pinctrl_mikrobus1_spi_cs: mikrobus1_spi_cs {
477		pinmux = <PIN_PC21__FLEXCOM3_IO3>;
478		bias-disable;
479	};
480
481	pinctrl_mikrobus1_spi: mikrobus1_spi {
482		pinmux = <PIN_PC20__FLEXCOM3_IO0>,
483			 <PIN_PC19__FLEXCOM3_IO1>,
484			 <PIN_PC18__FLEXCOM3_IO2>;
485		bias-disable;
486	};
487
488	pinctrl_mikrobus1_pwm: mikrobus1_pwm {
489		pinmux = <PIN_PC4__TIOB1>;
490		bias-disable;
491	};
492
493	pinctrl_mikrobus1_int: mikrobus1_int {
494		pinmux = <PIN_PC3__GPIO>;
495		bias-disable;
496	};
497
498	pinctrl_mikrobus1_uart: mikrobus1_uart {
499		pinmux = <PIN_PB26__URXD0>,
500			 <PIN_PB27__UTXD0>;
501		bias-disable;
502	};
503
504	pinctrl_mikrobus2_an: mikrobus2_an {
505		pinmux = <PIN_PD25__GPIO>;
506		bias-disable;
507	};
508
509	pinctrl_mikrobus2_rst: mikrobus2_rst {
510		pinmux = <PIN_PB24__GPIO>;
511		bias-disable;
512	};
513
514	pinctrl_mikrobus2_spi_cs: mikrobus2_spi_cs {
515		pinmux = <PIN_PB31__FLEXCOM0_IO3>;
516		bias-disable;
517	};
518
519	pinctrl_mikrobus2_spi: mikrobus2_spi {
520		pinmux = <PIN_PB28__FLEXCOM0_IO0>,
521			 <PIN_PB29__FLEXCOM0_IO1>,
522			 <PIN_PB30__FLEXCOM0_IO2>;
523		bias-disable;
524	};
525
526	pinctrl_ksz_spi_cs: ksz_spi_cs {
527		pinmux = <PIN_PC0__GPIO>;
528		bias-disable;
529	};
530
531	pinctrl_mikrobus2_pwm: mikrobus2_pwm {
532		pinmux = <PIN_PB23__TIOB2>;
533		bias-disable;
534	};
535
536	pinctrl_mikrobus2_int: mikrobus2_int {
537		pinmux = <PIN_PB22__GPIO>;
538		bias-disable;
539	};
540
541	pinctrl_mikrobus2_uart: mikrobus2_uart {
542		pinmux = <PIN_PC12__URXD3>,
543			 <PIN_PC13__UTXD3>;
544		bias-disable;
545	};
546
547	pinctrl_mikrobus3_an: mikrobus3_an {
548		pinmux = <PIN_PD24__GPIO>;
549		bias-disable;
550	};
551
552	pinctrl_mikrobus3_rst: mikrobus3_rst {
553		pinmux = <PIN_PB21__GPIO>;
554		bias-disable;
555	};
556
557	pinctrl_mikrobus3_spi_cs: mikrobus3_spi_cs {
558		pinmux = <PIN_PA17__SPI0_NPCS0>;
559		bias-disable;
560	};
561
562	pinctrl_mikrobus3_spi: mikrobus3_spi {
563		pinmux = <PIN_PA14__SPI0_SPCK>,
564			 <PIN_PA16__SPI0_MISO>,
565			 <PIN_PA15__SPI0_MOSI>;
566		bias-disable;
567	};
568
569	pinctrl_mikrobus3_pwm: mikrobus3_pwm {
570		pinmux = <PIN_PB20__TIOB3>;
571		bias-disable;
572	};
573
574	pinctrl_mikrobus3_int: mikrobus3_int {
575		pinmux = <PIN_PB18__GPIO>;
576		bias-disable;
577	};
578
579	pinctrl_mikrobus3_uart: mikrobus3_uart {
580		pinmux = <PIN_PC7__URXD1>,
581			 <PIN_PC8__UTXD1>;
582		bias-disable;
583	};
584
585	pinctrl_usb_default: usb_default {
586		pinmux = <PIN_PC17__GPIO>;
587		bias-disable;
588	};
589
590	pinctrl_usba_vbus: usba_vbus {
591		pinmux = <PIN_PD23__GPIO>;
592		bias-disable;
593	};
594
595	pinctrl_pwm0_pwm2_default: pwm0_pwm2_default {
596		pinmux = <PIN_PB5__PWMH2>,
597			 <PIN_PB6__PWML2>;
598		bias-pull-up;
599	};
600
601	pinctrl_macb0_default: macb0_default {
602		pinmux = <PIN_PD1__GRXCK>,
603			 <PIN_PD2__GTXER>,
604			 <PIN_PD5__GRX2>,
605			 <PIN_PD6__GRX3>,
606			 <PIN_PD7__GTX2>,
607			 <PIN_PD8__GTX3>,
608			 <PIN_PD9__GTXCK>,
609			 <PIN_PD10__GTXEN>,
610			 <PIN_PD11__GRXDV>,
611			 <PIN_PD12__GRXER>,
612			 <PIN_PD13__GRX0>,
613			 <PIN_PD14__GRX1>,
614			 <PIN_PD15__GTX0>,
615			 <PIN_PD16__GTX1>,
616			 <PIN_PD17__GMDC>,
617			 <PIN_PD18__GMDIO>;
618		bias-disable;
619	};
620
621	pinctrl_macb0_phy_irq: macb0_phy_irq {
622		pinmux = <PIN_PD3__GPIO>;
623		bias-disable;
624	};
625
626	pinctrl_macb0_rst: macb0_sw_rst {
627		pinmux = <PIN_PD4__GPIO>;
628		bias-disable;
629	};
630
631	pinctrl_flx2_default: flx2_default {
632		pinmux = <PIN_PA6__FLEXCOM2_IO0>,
633			 <PIN_PA7__FLEXCOM2_IO1>,
634			 <PIN_PA9__FLEXCOM2_IO3>,
635			 <PIN_PA10__FLEXCOM2_IO4>;
636		bias-disable;
637	};
638};
639
640&pwm0 {
641	pinctrl-names = "default";
642	pinctrl-0 = <&pinctrl_pwm0_pwm2_default>;
643	status = "disabled"; /* conflict with leds, HSIC */
644};
645
646&qspi1 {
647	pinctrl-names = "default";
648	pinctrl-0 = <&pinctrl_qspi1_default>;
649	status = "disabled"; /* Conflict with wilc_pwrseq, flx2 */
650
651	flash@0 {
652		#address-cells = <1>;
653		#size-cells = <1>;
654		compatible = "jedec,spi-nor";
655		reg = <0>;
656		spi-max-frequency = <80000000>;
657		spi-tx-bus-width = <4>;
658		spi-rx-bus-width = <4>;
659		m25p,fast-read;
660
661		at91bootstrap@0 {
662			label = "qspi: at91bootstrap";
663			reg = <0x00000000 0x00040000>;
664		};
665
666		bootloader@40000 {
667			label = "qspi: bootloader";
668			reg = <0x00040000 0x000c0000>;
669		};
670
671		bootloaderenvred@100000 {
672			label = "qspi: bootloader env redundant";
673			reg = <0x00100000 0x00040000>;
674		};
675
676		bootloaderenv@140000 {
677			label = "qspi: bootloader env";
678			reg = <0x00140000 0x00040000>;
679		};
680
681		dtb@180000 {
682			label = "qspi: device tree";
683			reg = <0x00180000 0x00080000>;
684		};
685
686		kernel@200000 {
687			label = "qspi: kernel";
688			reg = <0x00200000 0x00600000>;
689		};
690	};
691};
692
693&sdmmc0 {
694	no-1-8-v;
695	bus-width = <4>;
696	pinctrl-names = "default";
697	pinctrl-0 = <&pinctrl_sdmmc0_default>;
698	status = "okay";
699};
700
701&shutdown_controller {
702	debounce-delay-us = <976>;
703	atmel,wakeup-rtc-timer;
704
705	input@0 {
706		reg = <0>;
707	};
708};
709
710&spi0 {  /* mikrobus3 spi */
711	pinctrl-names = "default";
712	pinctrl-0 = <&pinctrl_mikrobus3_spi &pinctrl_mikrobus3_spi_cs>;
713	status = "okay";
714};
715
716&tcb0 {
717	timer0: timer@0 {
718		compatible = "atmel,tcb-timer";
719		reg = <0>;
720	};
721
722	timer1: timer@1 {
723		compatible = "atmel,tcb-timer";
724		reg = <1>;
725	};
726};
727
728&uart0 {
729	pinctrl-names = "default";
730	pinctrl-0 = <&pinctrl_mikrobus1_uart>;
731	atmel,use-dma-rx;
732	atmel,use-dma-tx;
733	status = "okay";
734};
735
736&uart1 {
737	pinctrl-names = "default";
738	pinctrl-0 = <&pinctrl_mikrobus3_uart>;
739	atmel,use-dma-rx;
740	atmel,use-dma-tx;
741	status = "okay";
742};
743
744&uart3 {
745	pinctrl-names = "default";
746	pinctrl-0 = <&pinctrl_mikrobus2_uart>;
747	atmel,use-dma-rx;
748	atmel,use-dma-tx;
749	status = "okay";
750};
751
752&usb0 {
753	atmel,vbus-gpio = <&pioA PIN_PD23 GPIO_ACTIVE_HIGH>;
754	pinctrl-names = "default";
755	pinctrl-0 = <&pinctrl_usba_vbus>;
756	status = "okay";
757};
758
759&usb1 {
760	num-ports = <3>;
761	pinctrl-names = "default";
762	pinctrl-0 = <&pinctrl_usb_default>;
763	status = "okay";
764};
765
766&usb2 {
767	phy_type = "hsic";
768	status = "okay";
769};
770
771&watchdog {
772	status = "okay";
773};
774