// SPDX-License-Identifier: GPL-2.0

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

/ {
	model = "TP-Link EAP225 v5";
	compatible = "tplink,eap225-v5", "mediatek,mt7629";

	aliases {
		led-boot = &led_status_green;
		led-failsafe = &led_status_amber;
		led-running = &led_status_green;
		led-upgrade = &led_status_amber;
		serial0 = &uart0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		bootargs-override = "console=ttyS0,115200n8";
	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&pio 21 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_status_green: status_green {
			label = "green:status";
			gpios = <&pio 55 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};

		led_status_amber: status_amber {
			label = "amber:status";
			gpios = <&pio 56 GPIO_ACTIVE_HIGH>;
		};
	};
};

&eth {
	pinctrl-names = "default";
	pinctrl-0 = <&eth_pins>;
	pinctrl-1 = <&ephy_leds_pins>;
	status = "okay";

	mac@1 {
		compatible = "mediatek,eth-mac";
		reg = <1>;
		phy-mode = "gmii";
		phy-handle = <&phy0>;
		nvmem-cells = <&macaddr_factory_8>;
		nvmem-cell-names = "mac-address";
	};

	mdio-bus {
		#address-cells = <1>;
		#size-cells = <0>;

		phy0: ethernet-phy@0 {
			reg = <0>;
		};
	};
};

&qspi {
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = <&qspi_pins>;

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;

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

			partition@0 {
				label = "Bootloader";
				reg = <0x0 0x00080000>;
				read-only;
			};

			partition@80000 {
				label = "Partition";
				reg = <0x00080000 0x00010000>;
				read-only;
			};

			partition@90000 {
				label = "Factory";
				reg = <0x00090000 0x00010000>;
				compatible = "nvmem-cells";
				read-only;

				macaddr_factory_8: macaddr@8 {
					reg = <0x8 0x6>;
				};
			};

			partition@A0000 {
				label = "Radio";
				reg = <0x000A0000 0x00010000>;
				read-only;
			};

			partition@B0000 {
				label = "Extra";
				reg = <0x000B0000 0x00010000>;
				read-only;
			};

			/* Vendor layout: kernel (0x000C0000 0x001A0000) - rootfs (0x00260000 0x00BE0000) */
			/* OpenWrt flash layout: combine kernel and rootfs from OEM layout */
			partition@C0000 {
				label = "firmware";
				reg = <0x000C0000 0x00D80000>;
			};

			partition@E40000 {
				label = "Config";
				reg = <0x00E40000 0x0001B0000>;
				read-only;
			};
		};
	};
};

&pio {
	eth_pins: eth-pins {
		mux {
			function = "eth";
			groups = "mdc_mdio";
		};
	};

	ephy_leds_pins: ephy-leds-pins {
		mux {
			function = "led";
			groups = "ephy_leds";
		};
	};

	qspi_pins: qspi-pins {
		mux {
			function = "flash";
			groups = "spi_nor";
		};
	};

	uart0_pins: uart0-pins {
		mux {
			function = "uart";
			groups = "uart0_txd_rxd" ;
		};
	};

	watchdog_pins: watchdog-pins {
		mux {
			function = "watchdog";
			groups = "watchdog";
		};
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins>;
	status = "okay";
};

&watchdog {
	pinctrl-names = "default";
	pinctrl-0 = <&watchdog_pins>;
	status = "okay";
};