// 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>
#include <dt-bindings/soc/qcom,tcsr.h>

/ {
	model = "D-Link DAP 2610";
	compatible = "dlink,dap-2610";

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

	soc {
		tcsr@1949000 {
			compatible = "qcom,tcsr";
			reg = <0x1949000 0x100>;
			qcom,wifi_glb_cfg = <TCSR_WIFI_GLB_CFG>;
		};

		ess_tcsr@1953000 {
			compatible = "qcom,tcsr";
			reg = <0x1953000 0x1000>;
			qcom,ess-interface-select = <TCSR_ESS_PSGMII>;
		};

		tcsr@1957000 {
			compatible = "qcom,tcsr";
			reg = <0x1957000 0x100>;
			qcom,wifi_noc_memtype_m0_m2 = <TCSR_WIFI_NOC_MEMTYPE_M0_M2>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_red: red {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_RED>;
			gpios = <&tlmm 4 GPIO_ACTIVE_LOW>;
		};

		led_green: green {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&tlmm 5 GPIO_ACTIVE_LOW>;
		};
	};

	keys {
		compatible = "gpio-keys";

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

&watchdog {
	status = "okay";
};

&prng {
	status = "okay";
};

&crypto {
	status = "okay";
};

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

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

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

			partition@0 {
				label = "SBL1";
				reg = <0x0 0x40000>;
				read-only;
			};
			partition@40000 {
				label = "MIBIB";
				reg = <0x40000 0x20000>;
				read-only;
			};
			partition@60000 {
				label = "QSEE";
				reg = <0x60000 0x60000>;
				read-only;
			};
			partition@c0000 {
				label = "CDT";
				reg = <0xc0000 0x10000>;
				read-only;
			};
			partition@d0000 {
				label = "DDRPARAMS";
				reg = <0xd0000 0x10000>;
				read-only;
			};
			partition@e0000 {
				label = "APPSBLENV";
				reg = <0xe0000 0x10000>;
				read-only;
			};
			partition@f0000 {
				label = "APPSBL";
				reg = <0xf0000 0x80000>;
				read-only;
			};
			partition@170000 {
				label = "ART";
				reg = <0x170000 0x10000>;
				read-only;
			};
			partition@180000 {
				compatible = "wrg";
				label = "firmware";
				reg = <0x180000 0xdc0000>;
			};
			partition@fb0000 {
				label = "rgbd";
				reg = <0xfb0000 0x10000>;
				read-only;
			};
			partition@fc0000 {
				label = "bdcfg";
				reg = <0xfc0000 0x10000>;
				read-only;
			};
			partition@fd0000 {
				label = "langpack";
				reg = <0xfd0000 0x20000>;
				read-only;
			};
			partition@ff0000 {
				label = "certificate";
				reg = <0xff0000 0x10000>;
				read-only;
			};
			partition@f40000 {
				label = "captival";
				reg = <0xf40000 0x70000>;
				read-only;
			};
		};
	};
};

&blsp_dma {
	status = "okay";
};

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

&cryptobam {
	status = "okay";
};

&mdio {
	status = "okay";
};

&gmac {
	status = "okay";
};

&switch {
	status = "okay";
};

&swport5 {
	status = "okay";

	label = "lan";
};

&tlmm {
	serial_pins: serial_pinmux {
		mux {
			pins = "gpio60", "gpio61";
			function = "blsp_uart0";
			bias-disable;
		};
	};

	spi_0_pins: spi_0_pinmux {
		mux {
			function = "blsp_spi0";
			pins = "gpio55", "gpio56", "gpio57";
			drive-strength = <12>;
			bias-disable;
		};
		mux_cs {
			function = "gpio";
			pins = "gpio54";
			drive-strength = <2>;
			bias-disable;
			output-high;
		};
	};
};

&wifi0 {
	status = "okay";
	qcom,ath10k-calibration-variant = "dlink,dap-2610";
};

&wifi1 {
	status = "okay";
	qcom,ath10k-calibration-variant = "dlink,dap-2610";
};
