// SPDX-License-Identifier: GPL-2.0

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

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

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

	config {
		bootcmd = "mtkboardboot";
		blink_led = "red:system";
		system_led = "green:system";
	};

	mtd-layout {
		layout@0 {
			label = "default";
			// mtd layout for stock 48m ubi firmware
			mtdids = "nmbm0=nmbm0";
			mtdparts = "nmbm0:1024k(bl2),512k(u-boot-env),2048k(factory),2048k(fip),49152k(ubi),49152k(ubi1)";
		};

		layout@1 {
			label = "expand(114m)";
			// mtd layout for 114m ubi firmware
			mtdids = "nmbm0=nmbm0";
			mtdparts = "nmbm0:1024k(bl2),512k(u-boot-env),2048k(factory),2048k(fip),116736k(ubi)";
		};

	};

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

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

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

	leds {
		compatible = "gpio-leds";

		led@0 {
			label = "red:system";
			gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
		};

		led@1 {
			label = "green:system";
			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
		};

		led@2 {
			label = "blue:system";
			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
		};
	};
};

&uart0 {
	status = "okay";
};

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

&pinctrl {
	spi_flash_pins: spi0-pins-func-1 {
		mux {
			function = "flash";
			groups = "spi0", "spi0_wp_hold";
		};

		conf-pu {
			pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
			drive-strength = <MTK_DRIVE_8mA>;
			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
		};

		conf-pd {
			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
			drive-strength = <MTK_DRIVE_8mA>;
			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
		};
	};
};

&spi0 {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&spi_flash_pins>;
	status = "okay";
	must_tx;
	enhance_timing;
	dma_ext;
	ipm_design;
	support_quad;
	tick_dly = <2>;
	sample_sel = <0>;

	spi_nand@0 {
		compatible = "spi-nand";
		reg = <0>;
		spi-max-frequency = <52000000>;
	};
};

&watchdog {
	status = "disabled";
};