// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) 2026 Michael Lotz <mmlr@mlotz.ch>
 */

/dts-v1/;

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

/ {
	aliases {
		led-boot = &lp5562_white;
		led-failsafe = &lp5562_red;
		led-upgrade = &lp5562_blue;
		serial0 = &blsp1_uart5;
		label-mac-device = &swport5;
	};

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

	keys {
		compatible = "gpio-keys";

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

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

	leds {
		compatible = "gpio-leds";

		power_green {
			gpios = <&tlmm 54 GPIO_ACTIVE_LOW>;
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_POWER;
			linux,default-trigger = "default-on";
		};

		power_red {
			gpios = <&tlmm 56 GPIO_ACTIVE_LOW>;
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_POWER;
		};
	};
};

&blsp1_uart5 {
	status = "okay";
};

&prng {
	status = "okay";
};

&cryptobam {
	status = "okay";
};

&crypto {
	status = "okay";
};

&edma {
	status = "okay";
};

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

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

		swport1: port@1 {
			reg = <1>;
			label = "wan";
			phy-handle = <&phy0>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 0>;
			nvmem-cells = <&macaddr_boarddata 1>;
			nvmem-cell-names = "mac-address";
		};

		swport2: port@2 {
			reg = <2>;
			label = "lan3";
			phy-handle = <&phy1>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 1>;
			nvmem-cells = <&macaddr_boarddata 1>;
			nvmem-cell-names = "mac-address";
		};

		swport4: port@4 {
			reg = <4>;
			label = "lan2";
			phy-handle = <&phy3>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 3>;
			nvmem-cells = <&macaddr_boarddata 1>;
			nvmem-cell-names = "mac-address";
		};

		swport5: port@5 {
			reg = <5>;
			label = "lan1";
			phy-handle = <&phy4>;
			phy-mode = "psgmii";
			pcs-handle = <&uniphy0 4>;
			nvmem-cells = <&macaddr_boarddata 0>;
			nvmem-cell-names = "mac-address";
		};
	};
};

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

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

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

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

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

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

			partition-board_data {
				label = "board_data";

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

					macaddr_boarddata: macaddr@40 {
						compatible = "mac-base";
						reg = <0x40 0x6>;
						#nvmem-cell-cells = <1>;
					};
				};
			};

			partition-0-appsblenv {
				label = "0:appsblenv";

				nvmem-layout {
					compatible = "u-boot,env";
					env-size = <0x40000>;
				};
			};
		};
	};
};

&wifi {
	status = "okay";
	qcom,ath11k-calibration-variant = "Netgear-RBK750";
};

&blsp1_i2c2 {
	status = "okay";

	lp5562@31 {
		compatible = "ti,lp5562";
		reg = <0x31>;
		clock-mode = [02];
		#address-cells = <1>;
		#size-cells = <0>;

		lp5562_red: led@0 {
			chan-name = "lp5562_red";
			led-cur = [20];
			max-cur = [60];
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_STATUS;
			reg = <0>;
		};

		lp5562_green: led@1 {
			chan-name = "lp5562_green";
			led-cur = [20];
			max-cur = [60];
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_STATUS;
			reg = <1>;
		};

		lp5562_blue: led@2 {
			chan-name = "lp5562_blue";
			led-cur = [20];
			max-cur = [60];
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_STATUS;
			reg = <2>;
		};

		lp5562_white: led@3 {
			chan-name = "lp5562_white";
			led-cur = [20];
			max-cur = [60];
			color = <LED_COLOR_ID_WHITE>;
			function = LED_FUNCTION_STATUS;
			reg = <3>;
		};
	};
};
