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

#include "ar7240.dtsi"

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


/ {
	model = "Ruckus ZoneFlex 7025";
	compatible = "ruckus,zf7025", "qca,ar7240";

	aliases {
		led-boot = &led_power_green;
		led-failsafe = &led_power_red;
		led-running = &led_power_green;
		led-upgrade = &led_power_red;
		label-mac-device = &eth0;
	};

	keys {
		compatible = "gpio-keys";

		hard-reset {
			label = "hard-reset";
			linux,code = <KEY_RESTART>;
			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
			debounce-interval = <60>;
		};
	};

	leds: leds {
		compatible = "gpio-leds";

		pinctrl-names = "default";
		pinctrl-0 = <&jtag_disable_pins &switch_led_disable_pins &clks_disable_pins>;

		dir {
			label = "green:dir";
			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
		};

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

		lan2 {
			label = "green:lan2";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
		};

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

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

		lan5 {
			label = "green:lan5";
			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
		};

		opt {
			label = "green:opt";
			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
		};

		led_power_red: power-red {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_RED>;
			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
			panic-indicator;
		};

		led_power_green: power-green {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
			default-state = "on";
		};

		wlan-green {
			function = LED_FUNCTION_WLAN;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0assoc";
		};

		wlan-yellow {
			function = LED_FUNCTION_WLAN;
			color = <LED_COLOR_ID_YELLOW>;
			gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};
	};

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		ruckus-himem@3ff0000 {
			/* Ruckus Himem area used to control
			 * redundant boot image selection
			 */
			compatible = "nvmem-rmem";
			reg = <0x3ff0000 0x10000>;
			no-map;
		};
	};
};

&spi {
	status = "okay";

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

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

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

			/* On stock FW this encompasses rcks_wlan.main,
			 * rcks_wlan.bkup and datafs partitions
			 */
			partition@40000 {
				compatible = "openwrt,uimage", "denx,uimage";
				reg = <0x40000 0xf40000>;
				label = "firmware";
			};

			partition@f80000 {
				compatible = "u-boot,env";
				reg = <0xf80000 0x40000>;
				label = "u-boot-env";
			};

			board_data: partition@fc0000 {
				reg = <0xfc0000 0x40000>;
				label = "board-data";
				read-only;

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

					macaddr_board_data_60: macaddr@60 {
						reg = <0x60 0x6>;
					};

					macaddr_board_data_66: macaddr@66 {
						reg = <0x66 0x6>;
					};

					macaddr_board_data_6c: macaddr@6c {
						reg = <0x6c 0x6>;
					};
				};
			};
		};
	};
};

&eth0 {
	nvmem-cells = <&macaddr_board_data_66>;
	nvmem-cell-names = "mac-address";
};

&eth1 {
	status = "okay";
	nvmem-cells = <&macaddr_board_data_6c>;
	nvmem-cell-names = "mac-address";
};

&pcie {
	status = "okay";

	ath9k: wifi@0,0 {
		compatible = "pci168c,002b";
		reg = <0x0000 0 0 0 0>;
		nvmem-cells = <&macaddr_board_data_60>;
		nvmem-cell-names = "mac-address";
	};
};