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

/dts-v1/;

#include "ipq6010-re-cs.dtsi"

/ {
	model = "JDCloud RE-CS-02";
	compatible = "jdcloud,re-cs-02", "qcom,ipq6018";

	aliases {
		ethernet0 = &dp1;
		ethernet1 = &dp2;
		ethernet2 = &dp3;
		ethernet3 = &dp4;
		ethernet4 = &dp5;

		label-mac-device = &dp1;
		serial0 = &blsp1_uart3;
		serial1 = &blsp1_uart6;
	};

	keys {
		compatible = "gpio-keys";
		pinctrl-0 = <&button_pins>;
		pinctrl-names = "default";

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

		screen {
			label = "screen";
			linux,code = <BTN_1>;
			gpios = <&tlmm 71 GPIO_ACTIVE_LOW>;
		};

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

&tlmm {
	button_pins: button-pins {
		mux {
			pins = "gpio56", "gpio71", "gpio72";
			function = "gpio";
			drive-strength = <8>;
			bias-pull-up;
		};
	};

	btuart_pins: btuart-pins {
		mux {
			pins = "gpio48", "gpio49";
			function = "blsp5_uart";
			drive-strength = <8>;
			bias-pull-up;
		};
	};
};

&blsp1_uart6 {
	pinctrl-0 = <&btuart_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&pcie_phy {
	status = "okay";
};

&pcie0 {
	perst-gpio = <&tlmm 53 GPIO_ACTIVE_LOW>;
	status = "okay";

	pcie@0 {
		wifi@0,0 {
			compatible = "pci17cb,1104";
			reg = <0x00010000 0 0 0 0>;
			qcom,ath11k-calibration-variant = "JDC-RE-CS-02";
		};
	};
};

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

&switch {
	status = "okay";

	switch_lan_bmp = <(ESS_PORT1 | ESS_PORT2 | ESS_PORT3 | ESS_PORT4)>;
	switch_wan_bmp = <ESS_PORT5>;
	switch_mac_mode = <MAC_MODE_PSGMII>;
	switch_mac_mode1 = <MAC_MODE_SGMII_PLUS>;

	qcom,port_phyinfo {
		port@1 {
			port_id = <1>;
			phy_address = <24>;
		};
		port@2 {
			port_id = <2>;
			phy_address = <25>;
		};
		port@3 {
			port_id = <3>;
			phy_address = <26>;
		};
		port@4 {
			port_id = <4>;
			phy_address = <27>;
		};
		port@5 {
			port_id = <5>;
			phy_address = <12>;
			port_mac_sel = "QGMAC_PORT";
		};
	};
};

&edma {
	status = "okay";
};

&dp1 {
	status = "okay";
	phy-handle = <&qca8075_0>;
	label = "lan1";
};

&dp2 {
	status = "okay";
	phy-handle = <&qca8075_1>;
	label = "lan2";
};

&dp3 {
	status = "okay";
	phy-handle = <&qca8075_2>;
	label = "lan3";
};

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

&dp5 {
	status = "okay";
	phy-mode = "sgmii";
	phy-handle = <&qca8081>;
	label = "wan";
};

&wifi {
	status = "okay";

	qcom,ath11k-calibration-variant = "JDC-RE-CS-02";
};
