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

/dts-v1/;
#include "mt7981.dtsi"
#include <dt-bindings/gpio/gpio.h>

/ {
	#address-cells = <1>;
	#size-cells = <1>;
	model = "mt7981-glinet_gl-mt2500";
	compatible = "mediatek,mt7981", "mediatek,mt7981-rfb";

	chosen {
		stdout-path = &uart0;
		tick-timer = &timer0;
	};

	config {
		bootcmd = "mtkboardboot";
		blink_led = "blue:run";
		system_led = "white:system";
	};

	memory@40000000 {
		device_type = "memory";
		reg = <0x40000000 0x40000000>;
	};

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

		button-reset {
			label = "reset";
			linux,code = <KEY_RESTART>;
			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";

		led-0 {
			label = "white:system";
			gpios = <&gpio 30 GPIO_ACTIVE_LOW>;
		};

		led-1 {
			label = "blue:run";
			gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
		};
	};

	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;
	};

	bl2_verify {
		bl2_compatible = "emmc";
	};
};

&eth {
	status = "okay";
	mediatek,gmac-id = <1>;
	phy-mode = "gmii";
	phy-handle = <&phy0>;

	mdio {
		phy0: ethernet-phy@0 {
			compatible = "ethernet-phy-id03a2.9461";
			reg = <0x0>;
			phy-mode = "gmii";
		};
	};
};

&mmc0 {
	pinctrl-names = "default";
	pinctrl-0 = <&mmc0_pins_default>;
	bus-width = <8>;
	max-frequency = <52000000>;
	cap-mmc-highspeed;
	cap-mmc-hw-reset;
	vmmc-supply = <&reg_3p3v>;
	non-removable;
	status = "okay";
};

&pinctrl {
	mmc0_pins_default: mmc0default {
		mux {
			function = "flash";
			groups = "emmc_45";
		};
		conf-cmd-dat {
			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO",
				"SPI0_CS",  "SPI0_HOLD", "SPI0_WP",
				"SPI1_CLK", "SPI1_MOSI", "SPI1_MISO";
			input-enable;
			drive-strength = <MTK_DRIVE_4mA>;
			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
		};
		conf-clk {
			pins = "SPI1_CS";
			drive-strength = <MTK_DRIVE_6mA>;
			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
		};
		conf-rst {
			pins = "PWM0";
			drive-strength = <MTK_DRIVE_4mA>;
			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
		};
	};
};

&uart0 {
	status = "okay";
};

&watchdog {
	status = "disabled";
};

&usb_phy {
  status = "okay";
};

&xhci {
  status = "okay";
};
