// SPDX-License-Identifier: (GPL-2.0+ OR MIT)

/dts-v1/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/soc/rockchip,vop2.h>
#include "rk3588-orangepi-5-compact.dtsi"

/ {
	model = "Xunlong Orange Pi 5 Max";
	compatible = "xunlong,orangepi-5-max", "rockchip,rk3588";

	hdmi0-con {
		compatible = "hdmi-connector";
		type = "a";

		port {
			hdmi0_con_in: endpoint {
				remote-endpoint = <&hdmi0_out_con>;
			};
		};
	};

	hdmi1-con {
		compatible = "hdmi-connector";
		type = "a";

		port {
			hdmi1_con_in: endpoint {
				remote-endpoint = <&hdmi1_out_con>;
			};
		};
	};
};

&hdmi0 {
	frl-enable-gpios = <&gpio4 RK_PB1 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&hdmim0_tx0_cec &hdmim0_tx0_hpd
		     &hdmim0_tx0_scl &hdmim0_tx0_sda &hdmi0_tx_on_h>;
	pinctrl-names = "default";
	status = "okay";
};

&hdmi0_in {
	hdmi0_in_vp0: endpoint {
		remote-endpoint = <&vp0_out_hdmi0>;
	};
};

&hdmi0_out {
	hdmi0_out_con: endpoint {
		remote-endpoint = <&hdmi0_con_in>;
	};
};

&hdmi0_sound {
	status = "okay";
};

&hdmi1 {
	frl-enable-gpios = <&gpio4 RK_PB2 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&hdmim0_tx1_cec &hdmim0_tx1_hpd
			     &hdmim1_tx1_scl &hdmim1_tx1_sda &hdmi1_tx_on_h>;
	pinctrl-names = "default";
	status = "okay";
};

&hdmi1_in {
	hdmi1_in_vp1: endpoint {
		remote-endpoint = <&vp1_out_hdmi1>;
	};
};

&hdmi1_out {
	hdmi1_out_con: endpoint {
		remote-endpoint = <&hdmi1_con_in>;
	};
};

&hdmi1_sound {
	status = "okay";
};

&hdptxphy0 {
	status = "okay";
};

&hdptxphy1 {
	status = "okay";
};

&i2s5_8ch {
	status = "okay";
};

&i2s6_8ch {
	status = "okay";
};

&led_blue_pwm {
	pwms = <&pwm4 0 25000 0>;
};

&led_green_pwm {
	pwms = <&pwm5 0 25000 0>;
};

&pinctrl {
	hdmi {
		hdmi0_tx_on_h: hdmi0-tx-on-h {
			rockchip,pins = <4 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		hdmi1_tx_on_h: hdmi1-tx-on-h {
			rockchip,pins = <4 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		usb_otg_pwren: usb-otg-pwren {
			rockchip,pins = <4 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&vp0 {
	vp0_out_hdmi0: endpoint@ROCKCHIP_VOP2_EP_HDMI0 {
		reg = <ROCKCHIP_VOP2_EP_HDMI0>;
		remote-endpoint = <&hdmi0_in_vp0>;
	};
};

&vp1 {
	vp1_out_hdmi1: endpoint@ROCKCHIP_VOP2_EP_HDMI1 {
		reg = <ROCKCHIP_VOP2_EP_HDMI1>;
		remote-endpoint = <&hdmi1_in_vp1>;
	};
};