// 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>

/ {
	model = "Linksys MR7350";
	compatible = "linksys,mr7350", "qcom,ipq6018";

	aliases {
		serial0 = &blsp1_uart3;
		serial1 = &blsp1_uart2;
		led-boot = &led_system_blue;
		led-running = &led_system_blue;
		led-failsafe = &led_system_red;
		led-upgrade = &led_system_green;
	};

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

	keys {
		compatible = "gpio-keys";

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

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

	leds {
		compatible = "gpio-leds";

		usb {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_USB;
			gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>;
			trigger-sources = <&usb3_port1>, <&usb3_port2>;
			linux,default-trigger = "usbport";
		};
	};

	reg_usb_vbus: regulator-usb-vbus {
		compatible = "regulator-fixed";
		regulator-name = "usb_vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&tlmm 61 GPIO_ACTIVE_LOW>;
		regulator-boot-on;
	};
};

&tlmm {
	hsuart_pins: hsuart-pins {
		mux {
			pins = "gpio69", "gpio70",
				"gpio71", "gpio72";
			function = "blsp1_uart";
			drive-strength = <8>;
			bias-disable;
		};
	};

	i2c_pins: i2c-pins {
		mux {
			pins = "gpio42", "gpio43";
			function = "blsp2_i2c";
			drive-strength = <8>;
			bias-pull-down;
		};
	};

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

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

&blsp1_i2c3 {
	pinctrl-0 = <&i2c_pins>;
	pinctrl-names = "default";
	status = "okay";

	led-controller@62 {
		compatible = "nxp,pca9633";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0x62>;

		led_system_red: led@0 {
			reg = <0>;
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_STATUS;
		};

		led_system_green: led@1 {
			reg = <1>;
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_STATUS;
		};

		led_system_blue: led@2 {
			reg = <2>;
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_STATUS;
		};
	};
};

&blsp1_uart2 {
	pinctrl-0 = <&hsuart_pins>;
	pinctrl-names = "default";
	status = "okay";
};

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

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

	usb3_port1: port@1 {
		reg = <1>;
		#trigger-source-cells = <0>;
	};

	usb3_port2: port@2 {
		reg = <2>;
		#trigger-source-cells = <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>;

		partitions {
			compatible = "qcom,smem-part";
		};
	};
};

&qusb_phy_0 {
	status = "okay";

	vdd-supply = <&reg_usb_vbus>;
};

&ssphy_0 {
	status = "okay";
};

&usb3 {
	vbus-supply = <&reg_usb_vbus>;
	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>;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

				led@0 {
					reg = <0>;
					color = <LED_COLOR_ID_ORANGE>;
					function = LED_FUNCTION_WAN;
					default-state = "keep";
				};

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

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

	qcom,port_phyinfo {
		port@1 {
			port_id = <1>;
			phy_address = <0>;
		};
		port@2 {
			port_id = <2>;
			phy_address = <1>;
		};
		port@3 {
			port_id = <3>;
			phy_address = <2>;
		};
		port@4 {
			port_id = <4>;
			phy_address = <3>;
		};
		port@5 {
			port_id = <5>;
			phy_address = <4>;
		};
	};
};

&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-handle = <&qca8075_4>;
	label = "wan";
};

&wifi {
	status = "okay";

	qcom,ath11k-calibration-variant = "Linksys-MR7350";
	qcom,ath11k-fw-memory-mode = <1>;
};
