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

&{/} {
	reg_dsi_hdmi: regulator-dsi-hdmi {
		compatible = "regulator-fixed";
		/* Verdin CTRL_SLEEP_MOCI# (SODIMM 256) */
		gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-boot-on;
		regulator-name = "DSI_1_PWR_EN";
	};
};

&hdmi_connector {
	status = "okay";

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

&hdmi_lontium_lt8912 {
	vdd-supply = <&reg_dsi_hdmi>;

	status = "okay";

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

		port@0 {
			reg = <0>;

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

		port@1 {
			reg = <1>;

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

/* Verdin I2C_2_DSI */
&i2c2 {
	clock-frequency = <10000>;

	status = "okay";
};

&lcdif {
	status = "okay";
};

&mipi_dsi {
	samsung,esc-clock-frequency = <16000000>;

	status = "okay";
};

&mipi_dsi_out {
	remote-endpoint = <&dsi_hdmi_bridge_in>;
};

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