// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/*
 * Copyright (C) 2022 MediaTek Inc.
 * Author: Sam.Shih <sam.shih@mediatek.com>
 */

/dts-v1/;
#include "mt7988a.dtsi"
#include <dt-bindings/pinctrl/mt65xx.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/regulator/richtek,rt5190a-regulator.h>

/ {
	model = "MediaTek MT7988A Reference Board";
	compatible = "mediatek,mt7988a-rfb",
		     "mediatek,mt7988a";

	chosen {
		bootargs = "console=ttyS0,115200n1 loglevel=8  \
			    earlycon=uart8250,mmio32,0x11000000 \
			    pci=pcie_bus_perf";
	};

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

	reg_1p8v: regulator-1p8v {
		compatible = "regulator-fixed";
		regulator-name = "fixed-1.8V";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-boot-on;
		regulator-always-on;
	};

	reg_3p3v: regulator-3p3v {
		compatible = "regulator-fixed";
		regulator-name = "fixed-3.3V";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
	};
};

&pio {
	mdio0_pins: mdio0-pins {
		mux {
			function = "eth";
			groups = "mdc_mdio0";
		};

		conf {
			groups = "mdc_mdio0";
			drive-strength = <MTK_DRIVE_8mA>;
		};
	};

	gbe0_led0_pins: gbe0-led0-pins {
		mux {
			function = "led";
			groups = "gbe0_led0";
		};
	};

	gbe1_led0_pins: gbe1-led0-pins {
		mux {
			function = "led";
			groups = "gbe1_led0";
		};
	};

	gbe2_led0_pins: gbe2-led0-pins {
		mux {
			function = "led";
			groups = "gbe2_led0";
		};
	};

	gbe3_led0_pins: gbe3-led0-pins {
		mux {
			function = "led";
			groups = "gbe3_led0";
		};
	};

	i2c1_sfp_pins: i2c1-sfp-pins-g0 {
		mux {
			function = "i2c";
			groups = "i2c1_sfp";
		};
	};

	i2c2_0_pins: i2c2-pins-g0 {
		mux {
			function = "i2c";
			groups = "i2c2_0";
		};
	};

	i2c0_pins: i2c0-pins-g0 {
		mux {
			function = "i2c";
			groups = "i2c0_1";
		};
	};

	i2c1_pins: i2c1-pins-g0 {
		mux {
			function = "i2c";
			groups = "i2c1_0";
		};
	};

	i2p5gbe_led0_pins: 2p5gbe-led0-pins {
		mux {
			function = "led";
			groups = "2p5gbe_led0";
		};
	};

	mmc0_pins_emmc_51: mmc0-pins-emmc-51 {
		mux {
			function = "flash";
			groups = "emmc_51";
		};
	};

	mmc0_pins_sdcard: mmc0-pins-sdcard {
		mux {
			function = "flash";
			groups = "sdcard";
		};
	};

	uart0_pins: uart0-pins {
		mux {
			function = "uart";
			groups =  "uart0";
		};
	};

	spi0_flash_pins: spi0-flash-pins {
		mux {
			function = "spi";
			groups = "spi0", "spi0_wp_hold";
		};
	};

	spi1_pins: spi1-pins {
		mux {
			function = "spi";
			groups = "spi1";
		};
	};
};

&eth {
	pinctrl-0 = <&mdio0_pins>;
	pinctrl-names = "default";
};

&gmac0 {
	status = "okay";
};

&cpu0 {
	proc-supply = <&rt5190_buck3>;
};

&cpu1 {
	proc-supply = <&rt5190_buck3>;
};

&cpu2 {
	proc-supply = <&rt5190_buck3>;
};

&cpu3 {
	proc-supply = <&rt5190_buck3>;
};

&cci {
	proc-supply = <&rt5190_buck3>;
};

&eth {
	status = "okay";
};

&switch {
	status = "okay";
};

&gsw_phy0 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gbe0_led0_pins>;
};

&gsw_port0 {
	label = "lan0";
};

&gsw_phy0_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
	color = <LED_COLOR_ID_GREEN>;
};

&gsw_phy1 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gbe1_led0_pins>;
};

&gsw_port1 {
	label = "lan1";
};

&gsw_phy1_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
	color = <LED_COLOR_ID_GREEN>;
};

&gsw_phy2 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gbe2_led0_pins>;
};

&gsw_port2 {
	label = "lan2";
};

&gsw_phy2_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
	color = <LED_COLOR_ID_GREEN>;
};

&gsw_phy3 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gbe3_led0_pins>;
};

&gsw_port3 {
	label = "lan3";
};

&gsw_phy3_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
	color = <LED_COLOR_ID_GREEN>;
};

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

	rt5190a_64: rt5190a@64 {
		compatible = "richtek,rt5190a";
		reg = <0x64>;
		/*interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>;*/
		vin2-supply = <&rt5190_buck1>;
		vin3-supply = <&rt5190_buck1>;
		vin4-supply = <&rt5190_buck1>;

		regulators {
			rt5190_buck1: buck1 {
				regulator-name = "rt5190a-buck1";
				regulator-min-microvolt = <5090000>;
				regulator-max-microvolt = <5090000>;
				regulator-allowed-modes =
				<RT5190A_OPMODE_AUTO RT5190A_OPMODE_FPWM>;
				regulator-boot-on;
				regulator-always-on;
			};
			buck2 {
				regulator-name = "vcore";
				regulator-min-microvolt = <600000>;
				regulator-max-microvolt = <1400000>;
				regulator-boot-on;
				regulator-always-on;
			};
			rt5190_buck3: buck3 {
				regulator-name = "vproc";
				regulator-min-microvolt = <600000>;
				regulator-max-microvolt = <1400000>;
				regulator-boot-on;
			};
			buck4 {
				regulator-name = "rt5190a-buck4";
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;
				regulator-allowed-modes =
				<RT5190A_OPMODE_AUTO RT5190A_OPMODE_FPWM>;
				regulator-boot-on;
				regulator-always-on;
			};
			ldo {
				regulator-name = "rt5190a-ldo";
				regulator-min-microvolt = <1200000>;
				regulator-max-microvolt = <1200000>;
				regulator-boot-on;
				regulator-always-on;
			};
		};
	};
};

&pcie0 {
	status = "okay";
};

&pcie1 {
	status = "okay";
};

&pcie2 {
	status = "disabled";
};

&pcie3 {
	status = "okay";
};

&ssusb0 {
	status = "okay";
};

&ssusb1 {
	status = "okay";
};

&tphy {
	status = "okay";
};

&serial0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins>;
	status = "okay";
};

&watchdog {
	status = "okay";
};

&xsphy {
	status = "okay";
};
