// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * at91-sama5d27_wlsom1_ek.dts - Device Tree file for SAMA5D27 WLSOM1 EK
 *
 * Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries
 *
 * Author: Nicolas Ferre <nicolas.ferre@microcihp.com>
 */
/dts-v1/;
#include "at91-sama5d27_wlsom1.dtsi"
#include <dt-bindings/input/input.h>

/ {
	model = "Microchip SAMA5D27 WLSOM1 EK";
	compatible = "microchip,sama5d27-wlsom1-ek", "microchip,sama5d27-wlsom1", "atmel,sama5d27", "atmel,sama5d2", "atmel,sama5";

	aliases {
		serial0 = &uart0;	/* DBGU */
		serial1 = &uart6;	/* BT */
		serial2 = &uart5;	/* mikro BUS 2 */
		serial3 = &uart3;	/* mikro BUS 1 */
		i2c1 = &i2c1;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	gpio-keys {
		compatible = "gpio-keys";

		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_key_gpio_default>;

		button-1 {
			label = "USER BUTTON";
			gpios = <&pioA PIN_PB2 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_PROG1>;
			wakeup-source;
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_led_gpio_default>;
		status = "okay";

		led-red {
			label = "red";
			gpios = <&pioA PIN_PA6 GPIO_ACTIVE_HIGH>;
		};

		led-green {
			label = "green";
			gpios = <&pioA PIN_PA7 GPIO_ACTIVE_HIGH>;
		};

		led-blue {
			label = "blue";
			gpios = <&pioA PIN_PA8 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "heartbeat";
		};
	};
};

&adc {
	vddana-supply = <&vdd_3v3>;
	vref-supply = <&vdd_3v3>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_adc_default>;
	status = "okay";
};

&flx0 {
	atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
	status = "okay";

	uart5: serial@200 {
		pinctrl-0 = <&pinctrl_flx0_default>;
		pinctrl-names = "default";
		atmel,use-dma-rx;
		atmel,use-dma-tx;
		status = "okay";
	};
};

&flx1 {
	status = "okay";

	uart6: serial@200 {
		atmel,use-dma-rx;
		atmel,use-dma-tx;
		status = "okay";
	};
};

&macb0 {
	status = "okay";
};

&pioA {
	/*
	 * There is no real pinmux for ADC, if the pin
	 * is not requested by another peripheral then
	 * the muxing is done when channel is enabled.
	 * Requesting pins for ADC is GPIO is
	 * encouraged to prevent conflicts and to
	 * disable bias in order to be in the same
	 * state when the pin is not muxed to the adc.
	 */
	pinctrl_adc_default: adc_default {
		pinmux = <PIN_PD25__GPIO>,
			 <PIN_PD26__GPIO>;
		bias-disable;
	};

	pinctrl_flx0_default: flx0_usart_default {
		pinmux = <PIN_PB28__FLEXCOM0_IO0>,
			 <PIN_PB29__FLEXCOM0_IO1>;
		bias-disable;
	};

	pinctrl_key_gpio_default: key_gpio_default {
		pinmux = <PIN_PB2__GPIO>;
		bias-pull-up;
	};

	pinctrl_led_gpio_default: led_gpio_default {
		pinmux = <PIN_PA6__GPIO>,
			 <PIN_PA7__GPIO>,
			 <PIN_PA8__GPIO>;
		bias-pull-down;
	};

	pinctrl_sdmmc0_default: sdmmc0_default {
		cmd_data {
			pinmux = <PIN_PA1__SDMMC0_CMD>,
				 <PIN_PA2__SDMMC0_DAT0>,
				 <PIN_PA3__SDMMC0_DAT1>,
				 <PIN_PA4__SDMMC0_DAT2>,
				 <PIN_PA5__SDMMC0_DAT3>;
			bias-disable;
		};

		ck_cd_vddsel {
			pinmux = <PIN_PA0__SDMMC0_CK>,
				 <PIN_PA11__SDMMC0_VDDSEL>,
				 <PIN_PA12__SDMMC0_WP>,
				 <PIN_PA13__SDMMC0_CD>;
			bias-disable;
		};
	};

	pinctrl_uart0_default: uart0_default {
		pinmux = <PIN_PB26__URXD0>,
			 <PIN_PB27__UTXD0>;
		bias-disable;
	};

	pinctrl_uart3_default: uart3_default {
		pinmux = <PIN_PB11__URXD3>,
			 <PIN_PB12__UTXD3>;
		bias-disable;
	};

	pinctrl_pwm0_default: pwm0_default {
		pinmux = <PIN_PA31__PWML0>,
			 <PIN_PA30__PWMH0>;
		bias-disable;
	};

	pinctrl_usb_default: usb_default {
		pinmux = <PIN_PA10__GPIO>;
		bias-disable;
	};

	pinctrl_usba_vbus: usba_vbus {
		pinmux = <PIN_PA16__GPIO>;
		bias-disable;
	};
};

&pwm0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_pwm0_default>;
	status = "okay";
};

&qspi1 {
	status = "okay";

	qspi1_flash: flash@0 {
		status = "okay";
	};
};

&sdmmc0 {
	bus-width = <4>;
	no-1-8-v;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_sdmmc0_default>;
	status = "okay";
};

&shutdown_controller {
	debounce-delay-us = <976>;
	atmel,wakeup-rtc-timer;

	input@0 {
		reg = <0>;
	};
};

&tcb0 {
	timer0: timer@0 {
		compatible = "atmel,tcb-timer";
		reg = <0>;
	};

	timer1: timer@1 {
		compatible = "atmel,tcb-timer";
		reg = <1>;
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart0_default>;
	atmel,use-dma-rx;
	atmel,use-dma-tx;
	status = "okay";
};

&uart3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_uart3_default>;
	atmel,use-dma-rx;
	atmel,use-dma-tx;
	status = "okay";
};

&usb0 {
	atmel,vbus-gpio = <&pioA PIN_PA16 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usba_vbus>;
	status = "okay";
};

&usb1 {
	num-ports = <3>;
	atmel,vbus-gpio = <0
			   &pioA PIN_PA10 GPIO_ACTIVE_HIGH
			   0
			  >;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usb_default>;
	status = "okay";
};

&usb2 {
	phy_type = "hsic";
	status = "okay";
};

&watchdog {
	status = "okay";
};

