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

/dts-v1/;

#include "ipq8074.dtsi"
#include "ipq8074-hk-cpu.dtsi"
#include "ipq8074-ess.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>

/ {
	model = "Netgear WAX630";
	compatible = "netgear,wax630", "qcom,ipq8074";

	aliases {
		serial0 = &blsp1_uart5;

		ethernet0 = &dp6_syn;
		ethernet1 = &dp4;
		label-mac-device = &dp6_syn;

		led-boot = &led_system_blue;
		led-failsafe = &led_system_red;
		led-running = &led_system_green;
		led-upgrade = &led_system_blue;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		bootargs-append = " root=/dev/ubiblock0_1";
	};

	keys {
		compatible = "gpio-keys";

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

	led-spi {
		compatible = "spi-gpio";
		#address-cells = <1>;
		#size-cells = <0>;

		sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>;
		mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>;

		led_gpio: led-gpio@0 {
			compatible = "fairchild,74hc595";
			reg = <0>;
			gpio-controller;
			#gpio-cells = <2>;
			registers-number = <1>;
			enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>;
			spi-max-frequency = <1000000>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_system_red: system-red {
			label = "system:red";
			gpios = <&tlmm 22 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		led_system_green: system-green {
			label = "system:green";
			gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		led_system_blue: system-blue {
			label = "system:blue";
			gpios = <&tlmm 21 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		lan1-green {
			label = "lan1:green";
			gpios = <&tlmm 26 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		lan1-orange {
			label = "lan1:orange";
			gpios = <&tlmm 27 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		lan2-green {
			label = "lan2:green";
			gpios = <&tlmm 57 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		lan2-orange {
			label = "lan2:orange";
			gpios = <&tlmm 60 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		2g-blue {
			label = "wlan2g:blue";
			gpios = <&tlmm 29 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		2g-green {
			label = "wlan2g:green";
			gpios = <&tlmm 30 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		5g-low-blue {
			label = "wlan5g_low:blue";
			gpios = <&tlmm 33 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		5g-low-green {
			label = "wlan5g_low:green";
			gpios = <&tlmm 34 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		5g-high-blue {
			label = "wlan5g_high:blue";
			gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

		5g-high-green {
			label = "wlan5g_high:green";
			gpios = <&tlmm 32 GPIO_ACTIVE_LOW>;
			default-state = "off";
		};

	};
};

&edma {
	status = "okay";
};

&switch {
	status = "okay";

	switch_lan_bmp = <(ESS_PORT4 | ESS_PORT6)>;
	switch_mac_mode = <MAC_MODE_PSGMII>;
	switch_mac_mode2 = <MAC_MODE_SGMII_PLUS>;

	qcom,port_phyinfo {
		port@4 {
			port_id = <4>;
			phy_address = <3>;
		};

		port@6 {
			port_id = <6>;
			phy_address = <28>;
			port_mac_sel = "QGMAC_PORT";
		};
	};
};

&tlmm {
	mdio_pins: mdio-pins {
		mdc {
			pins = "gpio68";
			function = "mdc";
			drive-strength = <8>;
			bias-pull-up;
		};

		mdio {
			pins = "gpio69";
			function = "mdio";
			drive-strength = <8>;
			bias-pull-up;
		};
	};
};

&mdio {
	status = "okay";

	pinctrl-0 = <&mdio_pins>;
	pinctrl-names = "default";
	reset-gpios = <&tlmm 37 GPIO_ACTIVE_LOW>;

	ethernet-phy-package@0 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "qcom,qca8075-package";
		reg = <0>;

		qca8075_3: ethernet-phy@3 {
			compatible = "ethernet-phy-ieee802.3-c22";
			reg = <3>;
		};
	};

	qca8081: ethernet-phy@28 {
		compatible = "ethernet-phy-id004d.d101";
		reg = <28>;
		reset-deassert-us = <10000>;
		reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>;
	};
};

&dp4 {
	status = "okay";
	phy-handle = <&qca8075_3>;
	label = "lan2";
};

&dp6_syn {
	status = "okay";
	phy-handle = <&qca8081>;
	label = "lan1";
};

&qpic_bam {
	status = "okay";
};

&qpic_nand {
	status = "okay";

	nand@0 {
		reg = <0>;
		nand-ecc-strength = <4>;
		nand-ecc-step-size = <512>;
		nand-bus-width = <8>;

		partitions {
			compatible = "qcom,smem-part";
		};
	};
};

&blsp1_uart5 {
	status = "okay";
};

&wifi {
	status = "okay";

	qcom,ath11k-calibration-variant = "Netgear-WAX630";
};
