// 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-konka_komi-a31";
	compatible = "mediatek,mt7981", "mediatek,mt7981-rfb";

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

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

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

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

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

	leds {
		compatible = "gpio-leds";

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

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

		led@2 {
			label = "red:system";
			gpios = <&gpio 34 GPIO_ACTIVE_LOW>;
		};
	};
	
	memory@40000000 {
		device_type = "memory";
		reg = <0x40000000 0x10000000>;
	};

	bl2_verify {
		bl2_compatible = "spim-nand";
	};
};

&uart0 {
	status = "okay";
};

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

	fixed-link {
		speed = <2500>;
		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";
};