OpenWrt support for Netis N6 router

I've connected console and got Stock Boot Log and flash dumps.
I'm not sure that stock flash layout is correct:

[    1.669742] nand: device found, Manufacturer ID: 0xc8, Chip ID: 0xd1
[    1.676115] nand: GD/ESMT PSU1GA30DT
[    1.679689] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    1.687900] Scanning device for bad blocks
[    2.536885] 4 ofpart partitions found on MTD device mtk-nand
[    2.542568] Creating 4 MTD partitions on "mtk-nand":
[    2.547539] 0x000000000000-0x000000080000 : "Bootloader"
[    2.554201] 0x000000080000-0x000000100000 : "Config"
[    2.560293] 0x000000100000-0x000000180000 : "Factory"
[    2.566544] 0x000000180000-0x000007fe0000 : "firmware"
[    3.410846] 2 fit-fw partitions found on MTD device firmware
[    3.416542] 0x000000180000-0x000000560000 : "kernel"
[    3.422800] 0x000000560000-0x000007fe0000 : "rootfs"
[    3.429829] mtd: device 5 (rootfs) set to be root filesystem
[    3.437658] buf:[MTD_INFO_Flag]
[    3.440785] 3 squashfs-split partitions found on MTD device rootfs
[    3.447173] 0x000000fc0000-0x000001000000 : "rootfs_ext"
[    3.453696] 0x000001000000-0x000001020000 : "info"
[    3.459623] 0x000001020000-0x000007fe0000 : "rootfs_data"

Because at block 960 (offset 0x7800000) NMBM remapping table exist:

Initializing NMBM ...
Signature found at block 1023 [0x07fe0000]
First info table with writecount 0 found in block 960
Second info table with writecount 0 found in block 963
NMBM has been successfully attached

Using openwrt gpio docs and tools

Buttons:

  1. Reset - 18 Low active
  2. WPS - 15 Low

LEDs (from left to right)

  1. Power - 17 High
  2. LAN(?) - 14 Low
  3. WAN - 16 Low
  4. wifi2g - wired to RF chip
  5. wifi5g - wired to RF chip
  6. WPS - 13 Low
  7. USB - 4 Low

Than I create test dts-file (extend kernel upto 4M and decrease firmware):

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

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

/ {
	compatible = "netis,n6", "mediatek,mt7621-soc";
	model = "NETIS N6";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
	};

	chosen {
		bootargs = "console=ttyS0,115200";
		bootargs-override = "console=ttyS0,115200";
	};

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "green:power";
			gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
		};

		wan {
			label = "green:wan";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
		};

		lan {
			label = "green:lan";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
		};

		wps {
			label = "green:wps";
			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
		};

		led_usb {
			label = "green:usb";
			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
			trigger-sources = <&ehci_port2>;
			linux,default-trigger = "usbport";
		};
	};

	keys {
		compatible = "gpio-keys";

		key-restart {
			label = "reset";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};

		key-wps {
			label = "wps";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WPS_BUTTON>;
		};
	};
};

&nand {
	status = "okay";

	mediatek,nmbm;
	mediatek,bmt-remap-range =
		<0x000000 0x580000>,
		<0x3380000 0x7800000>;

	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		partition@0 {
			label = "u-boot";
			reg = <0x0 0x80000>;
			read-only;
		};

		partition@80000 {
			label = "u-boot-env";
			reg = <0x80000 0x80000>;
		};

		factory: partition@100000 {
			label = "factory";
			reg = <0x100000 0x80000>;
			read-only;

			compatible = "nvmem-cells";
			#address-cells = <1>;
			#size-cells = <1>;

			macaddr_factory_4: macaddr@4 {
				reg = <0x4 0x6>;
			};
		};

		partition@180000 {
			label = "firmware";
			reg = <0x180000 0x3200000>;
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "kernel";
				reg = <0x0 0x400000>;
			};

			partition@400000 {
				label = "ubi";
				reg = <0x400000 0x2e00000>;
			};
		};

		/* Last 8M (@ 0x7800000) are reserved for NMBM management (bad blocks) */
	};
};

&pcie {
	status = "okay";
};

&pcie1 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x0000>;
		mediatek,disable-radar-background;
	};
};

&gmac0 {
	nvmem-cells = <&macaddr_factory_4>;
	nvmem-cell-names = "mac-address";
	mac-address-increment = <(-1)>;
};

&gmac1 {
	status = "okay";
	label = "wan";
	phy-handle = <&ethphy4>;

	nvmem-cells = <&macaddr_factory_4>;
	nvmem-cell-names = "mac-address";
};

&mdio {
	ethphy4: ethernet-phy@4 {
		reg = <4>;
	};
};

&switch0 {
	ports {
		port@0 {
			status = "okay";
			label = "lan4";
		};

		port@1 {
			status = "okay";
			label = "lan3";
		};

		port@2 {
			status = "okay";
			label = "lan2";
		};

		port@3 {
			status = "okay";
			label = "lan1";
		};
	};
};

&state_default {
	gpio {
		groups = "i2c", "uart2", "uart3", "jtag", "wdt";
		function = "gpio";
	};
};