// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/dts-v1/;

#include <dt-bindings/leds/common.h>
#include <dt-bindings/gpio/gpio.h>
#include "an7581.dtsi"

&afe {
	status = "okay";
};

&sound {
	audio-routing = "Headphone", "HP_L",
			"Headphone", "HP_R",
			"LINPUT1", "AMIC",
			"RINPUT1", "AMIC";

	status = "okay";

	codec {
		sound-dai = <&wm8960>;
	};
};

&en7581_pinctrl {
	gpio-ranges = <&en7581_pinctrl 0 13 47>;

	mdio_pins: mdio-pins {
		mux {
			function = "mdio";
			groups = "mdio";
		};

		conf {
			pins = "gpio2";
			output-high;
		};
	};

	pcie0_rst_pins: pcie0-rst-pins {
		conf {
			pins = "pcie_reset0";
			drive-open-drain = <1>;
		};
	};

	pcie1_rst_pins: pcie1-rst-pins {
		conf {
			pins = "pcie_reset1";
			drive-open-drain = <1>;
		};
	};

	gswp1_led0_pins: gswp1-led0-pins {
		mux {
			function = "phy1_led0";
			pins = "gpio33";
		};
	};

	gswp2_led0_pins: gswp2-led0-pins {
		mux {
			function = "phy2_led0";
			pins = "gpio34";
		};
	};

	gswp3_led0_pins: gswp3-led0-pins {
		mux {
			function = "phy3_led0";
			pins = "gpio35";
		};
	};

	gswp4_led0_pins: gswp4-led0-pins {
		mux {
			function = "phy4_led0";
			pins = "gpio42";
		};
	};

	pwm_gpio18_idx10_pins: pwm-gpio18-idx10-pins {
		function = "pwm";
		pins = "gpio18";
		output-enable;
	};

	mmc_pins: mmc-pins {
		mux {
			function = "emmc";
			groups = "emmc";
		};
	};
};

&usb0 {
	status = "okay";
};

&usb1 {
	status = "okay";

	mediatek,u3p-dis-msk = <0x1>;
	phys = <&usb1_phy PHY_TYPE_USB2>;
};

&mmc0 {
	pinctrl-names = "default", "state_uhs";
	pinctrl-0 = <&mmc_pins>;
	pinctrl-1 = <&mmc_pins>;
	status = "okay";

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

	card@0 {
		compatible = "mmc-card";
		reg = <0>;

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

			bootloader@0 {
				label = "bootloader";
				reg = <0x00000000 0x00080000>;
			};

			tclinux@80000 {
				label = "tclinux";
				reg = <0x00080000 0x02800000>;
			};

			tclinux_slave@2880000 {
				label = "tclinux_slave";
				reg = <0x02880000 0x02800000>;
			};

			rootfs_data@5080000 {
				label = "rootfs_data";
				reg = <0x5080000 0x00800000>;
			};
		};
	};
};

&i2c0 {
	status = "okay";

	wm8960: codec@1a {
		compatible = "wlf,wm8960";
		reg = <0x1a>;
	};
};

&pcie0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pcie0_rst_pins>;
	status = "okay";

	pcie@0,0 {
		reg = <0x0000 0 0 0 0>;
		wifi@0,0 {
			compatible = "mediatek,mt76";
			reg = <0x0000 0 0 0 0>;
			airoha,npu = <&npu>;
			airoha,eth = <&eth>;
		};
	};
};

&pcie1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pcie1_rst_pins>;
	status = "okay";

	pcie@1,0 {
		reg = <0x0000 0 0 0 0>;
		wifi@0,0 {
			compatible = "mediatek,mt76";
			reg = <0x0000 0 0 0 0>;
			airoha,npu = <&npu>;
			airoha,eth = <&eth>;
		};
	};
};

&mdio {
	as21xx_1: ethernet-phy@1d {
		compatible = "ethernet-phy-ieee802.3-c45";
		reg = <0x1d>;

		firmware-name = "as21x1x_fw.bin";

		reset-deassert-us = <1000000>;
		reset-assert-us = <1000000>;
		reset-gpios = <&en7581_pinctrl 31 GPIO_ACTIVE_LOW>;

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

			led@0 {
				reg = <0>;
				color = <LED_COLOR_ID_GREEN>;
				function = LED_FUNCTION_LAN;
				function-enumerator = <0>;
				default-state = "keep";
			};

			led@1 {
				reg = <1>;
				color = <LED_COLOR_ID_GREEN>;
				function = LED_FUNCTION_LAN;
				function-enumerator = <1>;
				default-state = "keep";
			};
		};
	};
};

&npu {
	status = "okay";
};

&eth {
	status = "okay";
};

&gdm1 {
	status = "okay";
};

&gdm4 {
	status = "okay";

	managed = "in-band-status";
	phy-handle = <&as21xx_1>;
	phy-mode = "usxgmii";
};

&switch {
	pinctrl-names = "default";
	pinctrl-0 = <&mdio_pins>;
	status = "okay";
};

&gsw_port1 {
	status = "okay";
	label = "lan1";
};

&gsw_phy1 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gswp1_led0_pins>;
	status = "okay";
};

&gsw_phy1_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
};

&gsw_port2 {
	status = "okay";
	label = "lan2";
};

&gsw_phy2 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gswp2_led0_pins>;
	status = "okay";
};

&gsw_phy2_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
};

&gsw_port3 {
	status = "okay";
	label = "lan3";
};

&gsw_phy3 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gswp3_led0_pins>;
	status = "okay";
};

&gsw_phy3_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
};

&gsw_port4 {
	status = "okay";
	label = "lan4";
};

&gsw_phy4 {
	pinctrl-names = "gbe-led";
	pinctrl-0 = <&gswp4_led0_pins>;
	status = "okay";
};

&gsw_phy4_led0 {
	status = "okay";
	function = LED_FUNCTION_LAN;
};
