// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) Toradex
 *
 * Toradex DSI to HDMI Adapter on Verdin DSI_1
 *
 * https://developer.toradex.com/hardware/accessories/add-ons/dsi-hdmi-adapter
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>

&{/} {
	hdmi-connector {
		compatible = "hdmi-connector";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_pwm3_dsi_gpio>;
		ddc-i2c-bus = <&main_i2c2>;
		/* Verdin PWM_3_DSI (SODIMM 19) */
		hpd-gpios = <&main_gpio1 17 GPIO_ACTIVE_HIGH>;
		type = "a";

		port {
			hdmi_connector_in: endpoint {
				remote-endpoint = <&dsi_hdmi_bridge_out>;
			};
		};
	};
};

&dsi_bridge {
	status = "okay";
};

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

	port@1 {
		reg = <1>;

		dsi_bridge_out: endpoint {
			remote-endpoint = <&dsi_hdmi_bridge_in>;
		};
	};
};

&dss {
	status = "okay";
};

/* Verdin PWM_3_DSI (SODIMM 19) repurposed as HDMI HPD GPIO */
&epwm1 {
	status = "disabled";
};

/* Verdin I2C_1 */
&main_i2c1 {
	#address-cells = <1>;
	#size-cells = <0>;

	hdmi@48 {
		compatible = "lontium,lt8912b";
		reg = <0x48>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_dsi1_bkl_en>;
		/* Verdin GPIO_10_DSI (SODIMM 21) */
		reset-gpios = <&main_gpio0 30 GPIO_ACTIVE_LOW>;

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

			port@0 {
				reg = <0>;

				dsi_hdmi_bridge_in: endpoint {
					data-lanes = <1 2 3 4>;
					remote-endpoint = <&dsi_bridge_out>;
				};
			};

			port@1 {
				reg = <1>;

				dsi_hdmi_bridge_out: endpoint {
					remote-endpoint = <&hdmi_connector_in>;
				};
			};
		};
	};
};