// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/*
 * Copyright 2025 Josua Mayer <josua@solid-run.com>
 *
 * Overlay for enabling HummingBoard IIoT MIPI-DSI connector
 * with Winstar WJ70N3TYJHMNG0 panel.
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>

&{/} {
	dsi_backlight: dsi-backlight {
		compatible = "gpio-backlight";
		gpios = <&tca6408_u48 3 GPIO_ACTIVE_LOW>;
	};
};

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

	touchscreen@41 {
		compatible = "ilitek,ili2130";
		reg = <0x41>;
		/*
		 * Touchscreen fires short active-low pulses which level trigger
		 * on i2c gpio expander can miss. Trigger on falling edge instead.
		 */
		interrupts-extended = <&tca6416_u21 13 IRQ_TYPE_EDGE_FALLING>;
		reset-gpios = <&tca6408_u48 6 GPIO_ACTIVE_LOW>;
	};
};

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

	panel@0 {
		/* This is a Winstar panel, but the ronbo panel uses same controls. */
		compatible = "ronbo,rb070d30";
		reg = <0>;
		/* reset is active-low but driver inverts it internally */
		reset-gpios = <&tca6408_u48 1 GPIO_ACTIVE_HIGH>;
		backlight = <&dsi_backlight>;
		power-gpios = <&tca6408_u48 2 GPIO_ACTIVE_HIGH>;
		shlr-gpios = <&tca6408_u48 4 GPIO_ACTIVE_LOW>;
		updn-gpios = <&tca6408_u48 5 GPIO_ACTIVE_HIGH>;
		vcc-lcd-supply = <&reg_dsi_panel>;

		port {
			dsi_in_panel: endpoint {
				remote-endpoint = <&mipi_dsi_out>;
			};
		};
	};

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

		port@1 {
			reg = <1>;

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

&du {
	status = "okay";
};