// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) 2020-2023 TQ-Systems GmbH <linux@ew.tq-group.com>,
 * D-82229 Seefeld, Germany.
 * Author: Gregor Herburger
 */

/dts-v1/;

#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/net/ti-dp83867.h>

#include "fsl-lx2160a-tqmlx2160a.dtsi"

/ {
	model = "TQ Systems GmbH MBLX2160A Starterkit";
	compatible = "tq,lx2160a-tqmlx2160a-mblx2160a", "tq,lx2160a-tqmlx2160a",
		     "fsl,lx2160a";

	aliases {
		mmc0 = &esdhc0;
		mmc1 = &esdhc1;
		serial0 = &uart0;
		serial1 = &uart1;
		serial2 = &uart2;
		serial3 = &uart3;
	};

	chosen {
		stdout-path = &uart0;
	};

	gpio-keys {
		compatible = "gpio-keys";

		button-user1 {
			label = "button:user1";
			gpios = <&gpio2 9 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_F1>;
		};

		button-user2 {
			label = "button:user2";
			gpios = <&gpio2 10 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_F2>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led-user1 {
			gpios = <&gpioex1 15 GPIO_ACTIVE_LOW>;
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_HEARTBEAT;
			function-enumerator = <0>;
			linux,default-trigger = "heartbeat";
		};

		led-user2 {
			gpios = <&gpio2 8 GPIO_ACTIVE_LOW>;
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_HEARTBEAT;
			function-enumerator = <1>;
			linux,default-trigger = "heartbeat";
		};
	};

	sfp_xfi1: sfp-xfi1 {
		compatible = "sff,sfp";
		i2c-bus = <&xfi1_i2c>;
		mod-def0-gpios = <&gpioex2 2 GPIO_ACTIVE_LOW>;
		los-gpios = <&gpioex2 3 GPIO_ACTIVE_HIGH>;
		tx-fault-gpios = <&gpioex2 0 GPIO_ACTIVE_HIGH>;
		tx-disable-gpios = <&gpioex2 1 GPIO_ACTIVE_HIGH>;
		status = "disabled";
	};

	sfp_xfi2: sfp-xfi2 {
		compatible = "sff,sfp";
		i2c-bus = <&xfi2_i2c>;
		mod-def0-gpios = <&gpioex2 6 GPIO_ACTIVE_LOW>;
		los-gpios = <&gpioex2 7 GPIO_ACTIVE_HIGH>;
		tx-fault-gpios = <&gpioex2 4 GPIO_ACTIVE_HIGH>;
		tx-disable-gpios = <&gpioex2 5 GPIO_ACTIVE_HIGH>;
		status = "disabled";
	};
};

&can0 {
	status = "okay";
};

&can1 {
	status = "okay";
};

&dpmac17 {
	phy-handle = <&dp83867_2_3>;
	phy-connection-type = "rgmii-id";
};

&dpmac18 {
	phy-handle = <&dp83867_2_4>;
	phy-connection-type = "rgmii-id";
};

&emdio1 {
	status = "okay";

	dp83867_1_1: ethernet-phy@1 {
		reg = <1>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_1_2: ethernet-phy@2 {
		reg = <2>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_1_3: ethernet-phy@3 {
		reg = <3>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_1_4: ethernet-phy@4 {
		reg = <4>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_1_5: ethernet-phy@5 {
		reg = <5>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_1_6: ethernet-phy@6 {
		reg = <6>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};
};

&emdio2 {
	status = "okay";

	dp83867_2_1: ethernet-phy@1 {
		reg = <1>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_2_2: ethernet-phy@2 {
		reg = <2>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_2_3: ethernet-phy@3 {
		reg = <3>;
		ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
		ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};

	dp83867_2_4: ethernet-phy@4 {
		reg = <4>;
		ti,rx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
		ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_25_NS>;
		ti,clk-output-sel = <DP83867_CLK_O_SEL_OFF>;
	};
};

&esdhc0 {
	sd-uhs-sdr104;
	sd-uhs-sdr50;
	sd-uhs-sdr25;
	sd-uhs-sdr12;
	no-mmc;
	no-sdio;
	wp-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
	cd-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
	status = "okay";
};

&i2c0 {
	gpioex3: gpio@20 {
		compatible = "nxp,pca9555";
		reg = <0x20>;
		#gpio-cells = <2>;
		gpio-controller;
		vcc-supply = <&reg_vcc3v3>;
	};
};

&i2c4 {
	status = "okay";

	mux@70 {
		compatible = "nxp,pca9544";
		reg = <0x70>;
		#address-cells = <1>;
		#size-cells = <0>;
		vdd-supply = <&reg_vcc3v3>;

		i2c@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c@2 {
			reg = <2>;
			#address-cells = <1>;
			#size-cells = <0>;

			gpioex0: gpio@20 {
				compatible = "nxp,pca9555";
				reg = <0x20>;
				#gpio-cells = <2>;
				gpio-controller;
				vcc-supply = <&reg_vcc3v3>;
			};

			gpioex1: gpio@21 {
				compatible = "nxp,pca9555";
				reg = <0x21>;
				#gpio-cells = <2>;
				gpio-controller;
				vcc-supply = <&reg_vcc3v3>;
			};

			gpioex2: gpio@22 {
				compatible = "nxp,pca9555";
				reg = <0x22>;
				#gpio-cells = <2>;
				gpio-controller;
				vcc-supply = <&reg_vcc3v3>;
			};
		};

		i2c@3 {
			reg = <3>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};
};

&i2c5 {
	status = "okay";

	mux@70 {
		compatible = "nxp,pca9544";
		reg = <0x70>;
		#address-cells = <1>;
		#size-cells = <0>;
		vdd-supply = <&reg_vcc3v3>;

		i2c@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		xfi1_i2c: i2c@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		xfi2_i2c: i2c@2 {
			reg = <2>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c@3 {
			reg = <3>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};
};

&pcs_mdio17 {
	status = "okay";
};

&pcs_mdio18 {
	status = "okay";
};

&uart0 {
	status = "okay";
};

&uart1 {
	status = "okay";
};

&uart2 {
	status = "okay";
};

&uart3 {
	status = "okay";
};

&usb0 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	hub_2_0: hub@1 {
		compatible = "usb451,8142";
		reg = <1>;
		peer-hub = <&hub_3_0>;
		reset-gpios = <&gpioex1 0 GPIO_ACTIVE_LOW>;
		vcc-supply = <&reg_vcc3v3>;
	};

	hub_3_0: hub@2 {
		compatible = "usb451,8140";
		reg = <2>;
		peer-hub = <&hub_2_0>;
		reset-gpios = <&gpioex1 0 GPIO_ACTIVE_LOW>;
		vcc-supply = <&reg_vcc3v3>;
	};
};

&usb1 {
	dr_mode = "otg";
	status = "okay";
};
