// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

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

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

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

	config {
		bootcmd = "mtkboardboot";
		blink_led = "blue:status";
		system_led = "red:status";

		environment {
			bootargs = "root=/dev/mmcblk0p65 rootwait";
			bootconf = "config-1#mt7981b-cmcc-rax3000m-emmc";
		};
	};

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

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

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

		button-mesh {
			label = "mesh";
			gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led-0 {
			label = "green:status";
			gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
		};

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

		led-2 {
			label = "red:status";
			gpios = <&gpio 35 GPIO_ACTIVE_LOW>;
		};
	};

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

&eth {
	status = "okay";
	mediatek,gmac-id = <0>;
	phy-mode = "sgmii";
	mediatek,switch = "mt7531";
	reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;

	fixed-link {
		speed = <1000>;
		full-duplex;
	};
};

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

&pinctrl {
	spic_pins: spi1-pins-func-1 {
		mux {
			function = "spi";
			groups = "spi1_1";
		};
	};

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