// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2022 Rockchip Electronics Co., Ltd.
 */

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/display/media-bus-format.h>
#include <dt-bindings/clock/rv1106-cru.h>

/ {
	backlight: backlight {
		status = "okay";
		compatible = "gpio-backlight";
		gpios = <&gpio1 RK_PB0 GPIO_ACTIVE_HIGH>;
		default-on;
		power-supply = <&vcc_3v3>;
	};
	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		drm_logo: drm-logo@00000000 {
			compatible = "rockchip,drm-logo";
			reg = <0x0 0x0>;
		};
	};
};

&spi1 {
	status = "okay";
	/delete-property/ pinctrl-0;
	/delete-property/ pinctrl-names;
	/* No pinctrl - pins used as GPIO for 9-bit SPI bitbang */

	panel: panel@0 {
		compatible = "lh,lh24030c50";
		reg = <0>;
		spi-max-frequency = <10000000>;
		reset-gpios = <&gpio1 RK_PB1 GPIO_ACTIVE_LOW>;
		spi-scl-gpios = <&gpio4 RK_PA7 GPIO_ACTIVE_HIGH>;
		spi-sdi-gpios = <&gpio4 RK_PA1 GPIO_ACTIVE_HIGH>;
		spi-cs-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
		power-supply = <&vcc_3v3>;
		backlight = <&backlight>;
		status = "okay";

		display-timings {
			native-mode = <&timing0>;
			timing0: panel-timing {
				clock-frequency = <7000000>;
				hactive = <240>;
				vactive = <320>;
				hfront-porch = <0>;
				hback-porch = <51>;
				hsync-len = <51>;
				vfront-porch = <0>;
				vback-porch = <12>;
				vsync-len = <12>;
				hsync-active = <0>;
				vsync-active = <0>;
				de-active = <1>;
				pixelclk-active = <1>;
			};
		};

		port {
			panel_in_rgb: endpoint {
				remote-endpoint = <&rgb_out_panel>;
			};
		};
	};
};

&display_subsystem {
	status = "okay";
	logo-memory-region = <&drm_logo>;
};

&rgb {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&lcd_pins>;
	ports {
		rgb_out: port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			rgb_out_panel: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&panel_in_rgb>;
			};
		};
	};
};

&rgb_in_vop {
	status = "okay";
};

&route_rgb {
	status = "okay";
};

&vop {
	assigned-clocks = <&cru PLL_CPLL>;
	assigned-clock-rates = <216000000>;
	status = "okay";
};

/*
 * LCD RGB data D8-D17 reuses the SDIO pin group.
 */
&sdio {
	status = "disabled";
};

&emmc {
	status = "disabled";
};