// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Device Tree file for Marvell Armada 3720 development board
 * (DB-88F3720-DDR3)
 * Copyright (C) 2016 Marvell
 *
 * Gregory CLEMENT <gregory.clement@free-electrons.com>
 *
 * This file is compatible with the version 1.4 and the version 2.0 of
 * the board, however the CON numbers are different between the 2
 * version
 */

/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include "armada-372x.dtsi"

/ {
	model = "Marvell Armada 3720 Development Board DB-88F3720-DDR3";
	compatible = "marvell,armada-3720-db", "marvell,armada3720", "marvell,armada3700";

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

	memory@0 {
		device_type = "memory";
		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
	};

	exp_usb3_vbus: usb3-vbus {
		compatible = "regulator-fixed";
		regulator-name = "usb3-vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		enable-active-high;
		regulator-always-on;
		gpio = <&gpio_exp 1 GPIO_ACTIVE_HIGH>;
	};

	usb3_phy: usb3-phy {
		compatible = "usb-nop-xceiv";
		vcc-supply = <&exp_usb3_vbus>;
	};

	vcc_sd_reg1: regulator {
		compatible = "regulator-gpio";
		regulator-name = "vcc_sd1";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;

		gpios = <&gpiosb 23 GPIO_ACTIVE_HIGH>;
		gpios-states = <0>;
		states = <1800000 0x1
			  3300000 0x0>;
		enable-active-high;
	};

	vcc_sd_reg2: regulator-vmcc {
		compatible = "regulator-fixed";
		regulator-name = "vcc_sd2";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		enable-active-high;
		gpio = <&gpio_exp 4 GPIO_ACTIVE_HIGH>;
	};
};

/* Gigabit module on CON19(V2.0)/CON21(V1.4) */
&eth0 {
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii_pins>;
	phy-mode = "rgmii-id";
	phy = <&phy0>;
	status = "okay";
};

/* Gigabit module on CON18(V2.0)/CON20(V1.4) */
&eth1 {
	phy-mode = "sgmii";
	phy = <&phy1>;
	status = "okay";
};

&i2c0 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1_pins>;
	status = "okay";

	gpio_exp: pca9555@22 {
		compatible = "nxp,pca9555";
		gpio-controller;
		#gpio-cells = <2>;

		reg = <0x22>;
		/*
		 * IO0_0: PWR_EN_USB2	IO1_0: PWR_EN_VTT
		 * IO0_1: PWR_EN_USB23	IO1_1: MPCIE_WDISABLE
		 * IO0_2: PWR_EN_SATA	IO1_2: RGMII_DEV_RSTN
		 * IO0_3: PWR_EN_PCIE	IO1_3: SGMII_DEV_RSTN
		 * IO0_4: PWR_EN_SD
		 * IO0_5: PWR_EN_EMMC
		 * IO0_6: PWR_EN_RGMII	IO1_6: SATA_USB3.0_SEL
		 * IO0_7: PWR_EN_SGMII	IO1_7: PWR_MCI_PS
		 */
	};

	rtc@68  {
		/* PT7C4337A from pericom fully compatible with the ds1337 */
		compatible = "dallas,ds1337";
		reg = <0x68>;
	};
};

&mdio {
	status = "okay";
	phy0: ethernet-phy@0 {
		reg = <0>;
	};

	phy1: ethernet-phy@1 {
		reg = <1>;
	};
};

/* CON15(V2.0)/CON17(V1.4) : PCIe / CON15(V2.0)/CON12(V1.4) :mini-PCIe */
&pcie0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pcie_reset_pins &pcie_clkreq_pins>;
	reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>;
	status = "okay";
};

/* CON3 */
&sata {
	status = "okay";
};

&sdhci0 {
	non-removable;
	bus-width = <8>;
	mmc-ddr-1_8v;
	mmc-hs400-1_8v;
	marvell,pad-type = "fixed-1-8v";
	status = "okay";
};

/* SD slot module on CON14(V2.0)/CON15(V1.4) */
&sdhci1 {
	wp-inverted;
	cd-gpios = <&gpiosb 2 GPIO_ACTIVE_LOW>;
	bus-width = <4>;
	marvell,pad-type = "sd";
	vqmmc-supply = <&vcc_sd_reg1>;
	vmmc-supply = <&vcc_sd_reg2>;
	status = "okay";
};

&spi0 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&spi_quad_pins>;

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <108000000>;
		spi-rx-bus-width = <4>;
		spi-tx-bus-width = <4>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;
			partition@0 {
				label = "bootloader";
				reg = <0x0 0x200000>;
			};
			partition@200000 {
				label = "U-boot Env";
				reg = <0x200000 0x10000>;
			};
			partition@210000 {
				label = "Linux";
				reg = <0x210000 0xDF0000>;
			};
		};
	};
};

/*
 * Exported on the micro USB connector CON30(V2.0)/CON32(V1.4) through
 * an FTDI (also on CON24(V2.0)/CON26(V1.4)).
 */
&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_pins>;
	status = "okay";
};

/* CON26(V2.0)/CON28(V1.4) */
&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart2_pins>;
	status = "okay";
};

/* CON27(V2.0)/CON29(V1.4) */
&usb2 {
	status = "okay";
};

/* CON29(V2.0)/CON31(V1.4) */
&usb3 {
	status = "okay";
	usb-phy = <&usb3_phy>;
};