// 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>

/ {
	compatible = "asus,rp-ac87", "mediatek,mt7621-soc";
	model = "ASUS RP-AC87";

	aliases {
		led-boot = &led_wps;
		led-failsafe = &led_wps;
		led-running = &led_wps;
		led-upgrade = &led_wps;
		label-mac-device = &gmac0;
	};

	keys {
		compatible = "gpio-keys";

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

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

	leds {
		compatible = "gpio-leds";

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

		rssilow-wlan0 {
			label = "green:rssilow-wlan0";
			gpios = <&gpio 42 GPIO_ACTIVE_LOW>;
		};

		rssimedlow-wlan0 {
			label = "green:rssimedlow-wlan0";
			gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
		};

		rssimed-wlan0 {
			label = "green:rssimed-wlan0";
			gpios = <&gpio 41 GPIO_ACTIVE_LOW>;
		};

		rssihigh-wlan0 {
			label = "green:rssihigh-wlan0";
			gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
		};

		rssilow-wlan1 {
			label = "green:rssilow-wlan1";
			gpios = <&gpio 45 GPIO_ACTIVE_LOW>;
		};

		rssimedlow-wlan1 {
			label = "green:rssimedlow-wlan1";
			gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
		};

		rssimed-wlan1 {
			label = "green:rssimed-wlan1";
			gpios = <&gpio 47 GPIO_ACTIVE_LOW>;
		};

		rssihigh-wlan1 {
			label = "green:rssihigh-wlan1";
			gpios = <&gpio 48 GPIO_ACTIVE_LOW>;
		};
	};
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <50000000>;
		m25p,fast-read;

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

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

			partition@30000 {
				label = "u-boot-env";
				reg = <0x30000 0x10000>;
				read-only;
			};

			factory: partition@40000 {
				label = "factory";
				reg = <0x40000 0x10000>;
				read-only;

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

				macaddr_factory_8004: macaddr@8004 {
					reg = <0x8004 0x6>;
				};
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0xfb0000>;
			};
		};
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x0>;
		ieee80211-freq-limit = <2400000 2500000>;
	};
};

&pcie1 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x8000>;
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

&gmac0 {
	nvmem-cells = <&macaddr_factory_8004>;
	nvmem-cell-names = "mac-address";
};

&switch0 {
	ports {
		port@4 {
			status = "okay";
			label = "lan";
		};
	};
};

&xhci {
	status = "disabled";
};