// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2021 Nuvoton Technology tomer.maimon@nuvoton.com

/dts-v1/;

#include <dt-bindings/phy/nuvoton,npcm-usbphy.h>
#include "nuvoton-npcm845.dtsi"
#include "nuvoton-npcm845-pincfg.dtsi"

/ {
	model = "Nuvoton npcm845 Development Board (Device Tree)";
	compatible = "nuvoton,npcm845-evb", "nuvoton,npcm845";

	aliases {
		serial0 = &serial0;
		ethernet0 = &gmac0;
		ethernet1 = &gmac1;
		ethernet2 = &gmac2;
		ethernet3 = &gmac3;
		i2c0 = &i2c0;
		i2c1 = &i2c1;
		i2c2 = &i2c2;
		i2c3 = &i2c3;
		i2c4 = &i2c4;
		i2c5 = &i2c5;
		i2c6 = &i2c6;
		i2c7 = &i2c7;
		i2c8 = &i2c8;
		i2c9 = &i2c9;
		i2c10 = &i2c10;
		i2c11 = &i2c11;
		i2c12 = &i2c12;
		i2c13 = &i2c13;
		i2c14 = &i2c14;
		i2c15 = &i2c15;
		i2c16 = &i2c16;
		i2c17 = &i2c17;
		i2c18 = &i2c18;
		i2c19 = &i2c19;
		i2c20 = &i2c20;
		i2c21 = &i2c21;
		i2c22 = &i2c22;
		i2c23 = &i2c23;
		i2c24 = &i2c24;
		i2c25 = &i2c25;
		i2c26 = &i2c26;
		spi0 = &fiu0;
		spi1 = &fiu1;
		spi3 = &fiu3;
		spi4 = &fiux;
		spi5 = &pspi;
		usb0 = &udc0;
		usb1 = &ehci1;
		usb2 = &udc8;
	};

	chosen {
		stdout-path = &serial0;
	};

	memory {
		reg = <0x0 0x0 0x0 0x40000000>;
	};

	tpm@0 {
		compatible = "microsoft,ftpm";
	};

	firmware {
		optee {
			compatible = "linaro,optee-tz";
			method = "smc";
		};
	};

	vsbr2: vsbr2 {
		compatible = "regulator-npcm845";
		regulator-name = "vr2";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};

	vsbv8: vsbv8 {
		compatible = "regulator-npcm845";
		regulator-name = "v8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};

	vsbv5: vsbv5 {
		compatible = "regulator-npcm845";
		regulator-name = "v5";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};

};

&serial0 {
	status = "okay";
};

&watchdog1 {
	status = "okay";
};

&fiu0 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&spi0cs1_pins>;
	spi-nor@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;
	};
	spi_flash@1 {
		compatible = "jedec,spi-nor";
		reg = <1>;
		spi-max-frequency = <25000000>;
	};
};

&fiu1 {
	status = "okay";
	spi-nor@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;
	};
};

&fiu3 {
	pinctrl-0 = <&spi3_pins>, <&spi3quad_pins>;
	status = "okay";
	vqspi-supply = <&vsbv5>;
	vqspi-microvolt = <3300000>;
	spi-nor@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <25000000>;
	};
};

&fiux {
	nuvoton,spix-mode;
	status = "okay";
};

&gmac0 {
	phy-mode = "sgmii";
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 1000000>;
	snps,reset-gpio = <&gpio5 30 GPIO_ACTIVE_LOW>;    /* gpio190 */
	status = "okay";
};

&gmac1 {
	phy-mode = "rgmii-id";
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 1000000>;
	snps,reset-gpio = <&gpio5 2 GPIO_ACTIVE_LOW>;    /* gpio162 */
	phy-supply = <&vsbr2>;
	phy-supply-microvolt = <1800000>;
	status = "okay";
};

&gmac2 {
	phy-mode = "NC-SI";
	max-speed = <100>;
	use-ncsi;
	pinctrl-0 = <&r1_pins
		     &r1en_pins
		     &r1oen_pins>;
	status = "disabled";
};

&gmac3 {
	phy-mode = "rmii";
	pinctrl-names = "default";
	pinctrl-0 = <&r2_pins
		     &r2oen_pins
		     &r2en_pins
		     &gpio91o_pins
		     &gpio92o_pins>;
	snps,bitbang-mii;
	snps,mdc-gpio = <&gpio2 27 GPIO_ACTIVE_HIGH>;     /* gpio91 */
	snps,mdio-gpio = <&gpio2 28 GPIO_ACTIVE_HIGH>;    /* gpio92 */
	snps,reset-active-low;
	snps,reset-delays-us = <0 10000 1000000>;
	snps,bitbang-delay = <1>;
	snps,reset-gpio = <&gpio2 29 GPIO_ACTIVE_LOW>;    /* gpio93 */
	status = "okay";
};

&pspi {
	status = "okay";
};

&usbphy1 {
	status = "okay";
};

&usbphy2 {
	status = "okay";
};

&usbphy3 {
	status = "okay";
};

&udc0 {
	status = "okay";
	phys = <&usbphy1 NPCM_UDC0_7>;
};

&sdhci0 {
	bus-width = <0x8>;
	status = "okay";
};

&ehci1 {
	status = "okay";
	phys = <&usbphy2 NPCM_USBH1>;
};

&udc8 {
	status = "okay";
	phys = <&usbphy3 NPCM_UDC8>;
};

&rng {
	status = "okay";
};

&aes {
	status = "okay";
};

&sha {
	status = "okay";
};

&otp {
	status = "okay";
};

&i2c0 {
	status = "okay";
};

&i2c1 {
	status = "okay";
};

&i2c2 {
	status = "okay";
};

&i2c3 {
	status = "okay";
};

&i2c4 {
	status = "okay";
};

&i2c5 {
	status = "okay";
};

&i2c6 {
	status = "okay";
	tmp100@48 {
		compatible = "tmp100";
		reg = <0x48>;
		status = "okay";
	};
};

&i2c7 {
	status = "okay";
};

&i2c8 {
	status = "okay";
};

&i2c9 {
	status = "okay";
};

&i2c10 {
	status = "okay";
};

&i2c11 {
	status = "okay";
};

&i2c12 {
	status = "okay";
};

&i2c13 {
	status = "okay";
};

&i2c14 {
	status = "okay";
};

&i2c15 {
	status = "okay";
};

&i2c16 {
	status = "okay";
};

&i2c17 {
	status = "okay";
};

&i2c18 {
	status = "okay";
};

&i2c19 {
	status = "okay";
};

&i2c20 {
	status = "okay";
};

&i2c21 {
	status = "okay";
};

&i2c22 {
	status = "okay";
};

&i2c23 {
	status = "okay";
};

&i2c24 {
	status = "okay";
};

&i2c25 {
	status = "okay";
};

&i2c26 {
	status = "okay";
};

&pinctrl {
        pinctrl-names = "default";
        pinctrl-0 = <
		&gspi_pins
		&vgadig_pins
		&spix_pins
		&r1_pins
		&r1en_pins
		&r1oen_pins
	>;
};
