// SPDX-License-Identifier: GPL-2.0+
//
// Copyright 2023 Linaro Ltd.

/dts-v1/;

#include <dt-bindings/pwm/pwm.h>
#include "imx53-sk-imx53-atm0700d4.dtsi"

/ {
	lvds-decoder {
		compatible = "ti,sn65lvds94", "lvds-decoder";

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

			port@0 {
				reg = <0>;

				lvds_decoder_in: endpoint {
					remote-endpoint = <&lvds0_out>;
				};
			};

			port@1 {
				reg = <1>;

				lvds_decoder_out: endpoint {
					remote-endpoint = <&panel_rgb_in>;
				};
			};
		};
	};
};

&iomuxc {
	pinctrl_lvds0: lvds0grp {
		/* LVDS pins only have pin mux configuration */
		fsl,pins = <
			MX53_PAD_LVDS0_CLK_P__LDB_LVDS0_CLK	0x80000000
			MX53_PAD_LVDS0_TX0_P__LDB_LVDS0_TX0	0x80000000
			MX53_PAD_LVDS0_TX1_P__LDB_LVDS0_TX1	0x80000000
			MX53_PAD_LVDS0_TX2_P__LDB_LVDS0_TX2	0x80000000
			MX53_PAD_LVDS0_TX3_P__LDB_LVDS0_TX3	0x80000000
		>;
	};

	pinctrl_spi_gpio: spigrp {
		fsl,pins = <
			MX53_PAD_EIM_A22__GPIO2_16		0x1f4
			MX53_PAD_EIM_A21__GPIO2_17		0x1f4
			MX53_PAD_EIM_A16__GPIO2_22		0x1f4
			MX53_PAD_EIM_A18__GPIO2_20		0x1f4
		>;
	};
};

&ldb {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_lvds0>;
	status = "okay";

	lvds0: lvds-channel@0 {
		reg = <0>;
		fsl,data-mapping = "spwg";
		fsl,data-width = <24>;
		status = "okay";

		port@2 {
			reg = <2>;

			lvds0_out: endpoint {
				remote-endpoint = <&lvds_decoder_in>;
			};
		};
	};
};

&panel_rgb_in {
	remote-endpoint = <&lvds_decoder_out>;
};

&spi_ts {
	pinctrl-0 = <&pinctrl_spi_gpio>;
	pinctrl-names = "default";

	sck-gpios = <&gpio2 16 GPIO_ACTIVE_HIGH>;
	miso-gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>;
	mosi-gpios = <&gpio2 17 GPIO_ACTIVE_HIGH>;
	cs-gpios = <&gpio2 20 GPIO_ACTIVE_HIGH>;
};

&touchscreen {
	interrupts-extended = <&gpio3 22 IRQ_TYPE_EDGE_BOTH>;
	pendown-gpio = <&gpio3 22 GPIO_ACTIVE_LOW>;
};
