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

#include "qcom-ipq4019.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

/ {
	model = "EnGenius EAP2200";
	compatible = "engenius,eap2200";

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

	keys {
		compatible = "gpio-keys";

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

	leds {
		compatible = "gpio-leds";

		led_power: power {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_AMBER>;
			gpios = <&tlmm 43 GPIO_ACTIVE_LOW>;
		};

		lan1 {
			label = "blue:lan1";
			gpios = <&tlmm 44 GPIO_ACTIVE_LOW>;
		};

		lan2 {
			label = "blue:lan2";
			gpios = <&tlmm 45 GPIO_ACTIVE_LOW>;
		};

		wlan2g {
			label = "blue:wlan2g";
			gpios = <&tlmm 46 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		wlan5g {
			label = "yellow:wlan5g";
			gpios = <&tlmm 47 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};

		wlan5g2 {
			label = "yellow:wlan5g2";
			gpios = <&tlmm 48 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy2tpt";
		};

		mode {
			label = "blue:mode";
			gpios = <&tlmm 50 GPIO_ACTIVE_LOW>;
		};
	};
};

&watchdog {
	status = "okay";
};

&prng {
	status = "okay";
};

&crypto {
	status = "okay";
};

&blsp_dma {
	status = "okay";
};

&blsp1_spi1 {
	pinctrl-0 = <&spi_0_pins>;
	pinctrl-names = "default";
	status = "okay";
	cs-gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>;

	flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <24000000>;
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition0@0 {
				label = "0:SBL1";
				reg = <0x00000000 0x00040000>;
				read-only;
			};
			partition1@40000 {
				label = "0:MIBIB";
				reg = <0x00040000 0x00020000>;
				read-only;
			};
			partition2@60000 {
				label = "0:QSEE";
				reg = <0x00060000 0x00060000>;
				read-only;
			};
			partition3@c0000 {
				label = "0:CDT";
				reg = <0x000c0000 0x00010000>;
				read-only;
			};
			partition4@d0000 {
				label = "0:DDRPARAMS";
				reg = <0x000d0000 0x00010000>;
				read-only;
			};
			partition5@e0000 {
				label = "0:APPSBLENV";
				reg = <0x000e0000 0x00010000>;
				read-only;
			};
			partition6@f0000 {
				label = "0:APPSBL";
				reg = <0x000f0000 0x00080000>;
				read-only;
			};
			partition7@170000 {
				label = "0:ART";
				reg = <0x00170000 0x00010000>;
				read-only;

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

					precal_art_1000: precal@1000 {
						reg = <0x1000 0x2f20>;
					};

					precal_art_5000: precal@5000 {
						reg = <0x5000 0x2f20>;
					};

					precal_art_9000: precal@9000 {
						reg = <0x9000 0x2f20>;
					};
				};
			};
		};
	};
};

&blsp1_uart1 {
	pinctrl-0 = <&serial_0_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&cryptobam {
	status = "okay";
};

&nand {
	pinctrl-0 = <&nand_pins>;
	pinctrl-names = "default";
	status = "okay";

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

			partition@0 {
				label = "rootfs1";
				reg = <0x00000000 0x04000000>;
			};
			partition@40000000 {
				label = "ubi";
				reg = <0x04000000 0x04000000>;
			};

		};
	};
};

&pcie0 {
	status = "okay";
	perst-gpio = <&tlmm 38 GPIO_ACTIVE_LOW>;
	wake-gpio = <&tlmm 50 GPIO_ACTIVE_LOW>;

	bridge@0,0 {
		reg = <0x00000000 0 0 0 0>;
		#address-cells = <3>;
		#size-cells = <2>;
		ranges;

		wifi2: wifi@1,0 {
			compatible = "qcom,ath10k";
			reg = <0x00010000 0 0 0 0>;
			nvmem-cell-names = "pre-calibration";
			nvmem-cells = <&precal_art_9000>;
			ieee80211-freq-limit = <5470000 5875000>;
			qcom,ath10k-calibration-variant = "EnGenius-EAP2200";
		};
	};
};

&qpic_bam {
	status = "okay";
};

&tlmm {
	nand_pins: nand_pins {
		pullups {
			pins = "gpio53", "gpio58", "gpio59";
			function = "qpic";
			bias-pull-up;
		};

		pulldowns {
			pins = "gpio54", "gpio55", "gpio56",
				"gpio57", "gpio60", "gpio61",
				"gpio62", "gpio63", "gpio64",
				"gpio65", "gpio66", "gpio67",
				"gpio68", "gpio69";
			function = "qpic";
			bias-pull-down;
		};
	};

	serial_0_pins: serial_pinmux {
		mux {
			pins = "gpio16", "gpio17";
			function = "blsp_uart0";
			bias-disable;
		};
	};

	spi_0_pins: spi_0_pinmux {
		pinmux {
			function = "blsp_spi0";
			pins = "gpio13", "gpio14", "gpio15";
			drive-strength = <12>;
			bias-disable;
		};
		pinmux_cs {
			function = "gpio";
			pins = "gpio12";
			drive-strength = <2>;
			bias-disable;
			output-high;
		};
	};
};

&mdio {
	status = "okay";
};

&wifi0 {
	status = "okay";
	nvmem-cell-names = "pre-calibration";
	nvmem-cells = <&precal_art_1000>;
	qcom,ath10k-calibration-variant = "EnGenius-EAP2200";
};

&wifi1 {
	status = "okay";
	ieee80211-freq-limit = <5170000 5350000>;
	nvmem-cell-names = "pre-calibration";
	nvmem-cells = <&precal_art_5000>;
	qcom,ath10k-calibration-variant = "EnGenius-EAP2200";
};
