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

/dts-v1/;

#include "ipq6018-512m.dtsi"
#include "ipq6018-ess.dtsi"
#include "ipq6018-cp-cpu.dtsi"

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

/ {
	model = "Qihoo 360V6";
	compatible = "qihoo,360v6", "qcom,ipq6018";

	aliases {
		serial0 = &blsp1_uart3;
		led-boot = &led_status_red;
		led-failsafe = &led_status_red;
		led-running = &led_status_green;
		led-upgrade = &led_status_orange;
	};

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

	keys {
		compatible = "gpio-keys";

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

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

	leds {
		compatible = "gpio-leds";

		led_status_red: red {
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_STATUS;
			gpios = <&tlmm 71 GPIO_ACTIVE_HIGH>;
		};

		led_status_orange: orange {
			color = <LED_COLOR_ID_ORANGE>;
			function = LED_FUNCTION_STATUS;
			gpios = <&tlmm 72 GPIO_ACTIVE_HIGH>;
		};

		led_status_green: green {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_STATUS;
			gpios = <&tlmm 73 GPIO_ACTIVE_HIGH>;
		};
	};
};

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

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

&blsp1_uart3 {
	pinctrl-0 = <&serial_3_pins>;
	pinctrl-names = "default";
	status = "okay";
};

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

&qusb_phy_0 {
	status = "okay";
};

&ssphy_0 {
	status = "okay";
};

&usb3 {
	status = "okay";
};

&mdio {
	status = "okay";

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

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

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

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

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

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

&uniphy0 {
	status = "okay";
};

&switch {
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			ethernet = <&edma>;
			phy-mode = "internal";

			fixed-link {
				speed = <1000>;
				full-duplex;
			};
		};

		port@1 {
			reg = <1>;
			label = "lan1";
			phy-handle = <&qca8075_0>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 0>;
		};

		port@2 {
			reg = <2>;
			label = "lan2";
			phy-handle = <&qca8075_1>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 1>;
		};

		port@3 {
			reg = <3>;
			label = "lan3";
			phy-handle = <&qca8075_2>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 2>;
		};

		port@4 {
			reg = <4>;
			label = "wan";
			phy-handle = <&qca8075_3>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 3>;
		};
	};
};

&edma {
	status = "okay";
};

&wifi {
	status = "okay";

	qcom,ath11k-fw-memory-mode = <1>;
	qcom,ath11k-calibration-variant = "Qihoo-360V6";
};
