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

#include "mt7620n.dtsi"

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

/ {
	compatible = "netgear,pr2000", "ralink,mt7620n-soc";
	model = "Netgear PR2000";

	aliases {
		label-mac-device = &ethernet;
	};

	leds {
		compatible = "gpio-leds";

		internet {
			label = "green:internet";
			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
		};

		wifi {
			label = "green:wifi";
			gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		usb {
			label = "green:usb";
			gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
			trigger-sources = <&ohci_port1>, <&ehci_port1>;
			linux,default-trigger = "usbport";
		};
	};

	keys {
		compatible = "gpio-keys";

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

		wireless {
			label = "wireless";
			gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_0>;
			linux,input-type = <EV_SW>;
		};

		wired {
			label = "wired";
			gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_0>;
			linux,input-type = <EV_SW>;
		};
	};
};

&gpio2 {
	status = "okay";
};

&gpio3 {
	status = "okay";
};

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

			/* sercomm header for kernel starts at 0x3ffba
			 * can be safely ignored since not used by OpenWRT
			 */

			partition@40000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x40000 0xf20000>;
			};

			factory: partition@f60000 {
				label = "factory";
				reg = <0xf60000 0x10000>;
				read-only;
			};

			board_data: partition@f70000 {
				label = "board_data";
				reg = <0xf70000 0x10000>;
				read-only;
			};

			partition@f80000 {
				label = "POT";
				reg = <0xf80000 0x10000>;
				read-only;
			};

			partition@f90000 {
				label = "Traffic Meter";
				reg = <0xf90000 0x10000>;
				read-only;
			};

			partition@fa0000 {
				label = "Traffic Meter2";
				reg = <0xfa0000 0x10000>;
				read-only;
			};

			partition@fb0000 {
				label = "nvram";
				reg = <0xfb0000 0x10000>;
			};

			partition@fc0000 {
				label = "DPF";
				reg = <0xfc0000 0x10000>;
				read-only;
			};

			partition@fd0000 {
				label = "ralink_nvram";
				reg = <0xfd0000 0x10000>;
				read-only;
			};

			partition@fe0000 {
				label = "reserved1";
				reg = <0xfe0000 0x10000>;
				read-only;
			};

			partition@ff0000 {
				label = "reserved2";
				reg = <0xff0000 0x10000>;
				read-only;
			};
		};
	};
};

&ethernet {
	mtd-mac-address = <&board_data 0xb0>;
	mediatek,portmap = "wllll";
};

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};

&wmac {
	ralink,mtd-eeprom = <&factory 0x0>;
	mtd-mac-address = <&board_data 0xb0>;
};

&state_default {
	default {
		groups = "ephy", "wled", "pa", "i2c";
		function = "gpio";
	};
};
