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

/dts-v1/;

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

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

/ {
	aliases {
		serial0 = &blsp1_uart3;
		led-boot = &led_sys_green;
		led-failsafe = &led_sys_yellow;
		led-running = &led_sys_green;
		led-upgrade = &led_sys_yellow;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		bootargs-append = " ubi.block=0,rootfs root=/dev/ubiblock0_1";
	};

	keys {
		compatible = "gpio-keys";

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

	leds {
		compatible = "gpio-leds";

		led_sys_yellow: led-0 {
			function = "system";
			color = <LED_COLOR_ID_YELLOW>;
			gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>;
		};

		led_sys_green: led-1 {
			function = "system";
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>;
		};
	};

	gpio-restart {
		compatible = "gpio-restart";
		gpios = <&tlmm 61 GPIO_ACTIVE_LOW>;
		open-source;
	};
};

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

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

	phy_reset_pin: phy-reset-pin {
		pins = "gpio77";
		function = "gpio";
		bias-pull-up;
	};

	led_enable {
		gpio-hog;
		output-high;
		gpios = <36 GPIO_ACTIVE_HIGH>;
		line-name = "enable-leds";
	};
};

&edma {
	status = "okay";
};

&mdio {
	pinctrl-0 = <&mdio_pins>, <&phy_reset_pin>;
	pinctrl-names = "default";
	reset-gpios = <&tlmm 77 GPIO_ACTIVE_LOW>;
	reset-delay-us = <10000>;
	reset-post-delay-us = <50000>;
	status = "okay";

	rtl8211f_4: ethernet-phy@4 {
		reg = <4>;
		realtek,clkout-disable;
		realtek,aldps-enable;
	};
};

&uniphy1 {
	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;
			};
		};

		swport5: port@5 {
			reg = <5>;
			label = "lan";
			phy-handle = <&rtl8211f_4>;
			phy-mode = "sgmii";
			pcs-handle = <&uniphy1 0>;
		};
	};
};

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

&wifi {
	status = "okay";
};
