/*
 * at91-sama5d2_ptc_ek.dts - Device Tree file for SAMA5D2 PTC EK board
 *
 *  Copyright (C) 2017 Microchip Technology Inc,
 *		       Ludovic Desroches <ludovic.desroches@microchip.com>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */
/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include "sama5d2.dtsi"
#include "sama5d2-pinfunc.h"

/ {
	model = "Atmel SAMA5D2 PTC EK";
	compatible = "atmel,sama5d2-ptc_ek", "atmel,sama5d2", "atmel,sama5";

	chosen {
		bootph-all;
		stdout-path = &uart0;
	};

	onewire_tm: onewire {
		gpios = <&pioA PIN_PB31 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_onewire_tm_default>;
		status = "okay";

		w1_eeprom: w1_eeprom@0 {
			compatible = "maxim,ds24b33";
			status = "okay";
		};
	};

	ahb {
		usb0: gadget@00300000 {
			atmel,vbus-gpio = <&pioA PIN_PA27 GPIO_ACTIVE_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_usba_vbus>;
			status = "okay";
		};

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

		usb2: ehci@500000 {
			status = "okay";
		};

		sdmmc0: sdio-host@a0000000 {
			bus-width = <8>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sdmmc0_default>;
			status = "okay";
			bootph-all;
		};

		sdmmc1: sdio-host@b0000000 {
			bus-width = <4>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sdmmc1_default>;
			status = "disabled"; /* conflicts with nand and qspi0*/
			bootph-all;
		};

		apb {
			macb0: ethernet@f8008000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_macb0_rmii &pinctrl_macb0_phy_irq>;
				phy-mode = "rmii";
				status = "okay";

				ethernet-phy@1 {
					reg = <0x1>;
				};
			};

			uart0: serial@f801c000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_uart0_default>;
				status = "okay";
				bootph-all;
			};

			i2c1: i2c@fc028000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_i2c1_default>;
				status = "okay";

				i2c_eeprom: i2c_eeprom@50 {
					compatible = "atmel,24mac402";
					reg = <0x50>;
				};
			};

			pioA: pinctrl@fc038000 {
				pinctrl_i2c1_default: i2c1_default {
					pinmux = <PIN_PC6__TWD1>,
						 <PIN_PC7__TWCK1>;
					bias-disable;
				};

				pinctrl_macb0_phy_irq: macb0_phy_irq {
					pinmux = <PIN_PB24__GPIO>;
					bias-disable;
				};

				pinctrl_macb0_rmii: macb0_rmii {
					pinmux = <PIN_PB14__GTXCK>,
						 <PIN_PB15__GTXEN>,
						 <PIN_PB16__GRXDV>,
						 <PIN_PB17__GRXER>,
						 <PIN_PB18__GRX0>,
						 <PIN_PB19__GRX1>,
						 <PIN_PB20__GTX0>,
						 <PIN_PB21__GTX1>,
						 <PIN_PB22__GMDC>,
						 <PIN_PB23__GMDIO>;
					bias-disable;
				};

				pinctrl_sdmmc0_default: sdmmc0_default {
					cmd_dat {
						pinmux = <PIN_PA1__SDMMC0_CMD>,
							 <PIN_PA2__SDMMC0_DAT0>,
							 <PIN_PA3__SDMMC0_DAT1>,
							 <PIN_PA4__SDMMC0_DAT2>,
							 <PIN_PA5__SDMMC0_DAT3>,
							 <PIN_PA6__SDMMC0_DAT4>,
							 <PIN_PA7__SDMMC0_DAT5>,
							 <PIN_PA8__SDMMC0_DAT6>,
							 <PIN_PA9__SDMMC0_DAT7>;
						bias-pull-up;
						bootph-all;
					};

					ck_cd {
						pinmux = <PIN_PA0__SDMMC0_CK>,
							 <PIN_PA10__SDMMC0_RSTN>,
							 <PIN_PA11__SDMMC0_VDDSEL>,
							 <PIN_PA13__SDMMC0_CD>;
						bias-disable;
						bootph-all;
					};
				};

				pinctrl_sdmmc1_default: sdmmc1_default {
					cmd_dat {
						pinmux = <PIN_PA28__SDMMC1_CMD>,
							 <PIN_PA18__SDMMC1_DAT0>,
							 <PIN_PA19__SDMMC1_DAT1>,
							 <PIN_PA20__SDMMC1_DAT2>,
							 <PIN_PA21__SDMMC1_DAT3>;
						bias-pull-up;
						bootph-all;
					};

					ck_cd {
						pinmux = <PIN_PA22__SDMMC1_CK>,
							 <PIN_PA30__SDMMC1_CD>;
						bias-disable;
						bootph-all;
					};
				};

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

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

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

				pinctrl_onewire_tm_default: onewire_tm_default {
					pinmux = <PIN_PB31__GPIO>;
					bias-pull-up;
				};
			};
		};
	};
};
