// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 *
 */
#include "dt-bindings/usb/pd.h"
#include "rk3588-nvr-demo.dtsi"


/ {
	ite_pwr_en: ite-pwr-en {
		compatible = "regulator-fixed";
		regulator-name = "ITE-PWR_EN";
		regulator-min-microvolt = <1200000>;
		regulator-max-microvolt = <1200000>;
		regulator-boot-on;
		regulator-always-on;
		enable-active-high;
		gpio = <&gpio3 RK_PB2 GPIO_ACTIVE_HIGH>;
	};
};

&dp0 {
	/delete-property/ pinctrl-0;
	/delete-property/ pinctrl-names;
	status = "okay";
};

&dp0_sound {
	status = "okay";
};

&dp1 {
	pinctrl-0 = <&dp1m2_pins &dp1_hdmi_reset>;
	pinctrl-names = "default";
	status = "okay";
};

&dsi1 {
	status = "okay";

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

		port@1 {
			reg = <1>;
			dsi1_out_panel: endpoint {
				remote-endpoint = <&panel_in_dsi1>;
			};
		};
	};
};

&dsi1_in_vp2 {
	status = "okay";
};

&dsi1_in_vp3 {
	status = "okay";
};

&i2c6 {
	status = "okay";

	it6161: it6161@6c {
		status = "okay";
		compatible = "ite,it6161";
		#sound-dai-cells = <0>;
		reg = <0x6c>;
		it6161-addr-hdmi-tx = <0x4C>;
		it6161-addr-cec = <0x4E>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PC4 IRQ_TYPE_LEVEL_HIGH>;
		enable-gpios = <&gpio0 RK_PC5 GPIO_ACTIVE_HIGH>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				panel_in_dsi1: endpoint {
					remote-endpoint = <&dsi1_out_panel>;
				};
			};
		};
	};

	usbc0: fusb302@22 {
		compatible = "fcs,fusb302";
		reg = <0x22>;
		interrupt-parent = <&gpio1>;
		interrupts = <RK_PA0 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "default";
		pinctrl-0 = <&usbc0_int>;
		vbus-supply = <&vcc5v0_otg>;
		status = "okay";

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

			port@0 {
				reg = <0>;
				usbc0_role_sw: endpoint@0 {
					remote-endpoint = <&dwc3_0_role_switch>;
				};
			};
		};

		usb_con: connector {
			compatible = "usb-c-connector";
			label = "USB-C";
			data-role = "dual";
			power-role = "dual";
			try-power-role = "sink";
			op-sink-microwatt = <1000000>;
			sink-pdos =
				<PDO_FIXED(5000, 1000, PDO_FIXED_USB_COMM)>;
			source-pdos =
				<PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>;

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

				altmode@0 {
					reg = <0>;
					svid = <0xff01>;
					vdo = <0xffffffff>;
				};
			};

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

				port@0 {
					reg = <0>;
					usbc0_orien_sw: endpoint {
						remote-endpoint = <&usbdp_phy0_orientation_switch>;
					};
				};

				port@1 {
					reg = <1>;
					dp_altmode_mux: endpoint {
						remote-endpoint = <&usbdp_phy0_dp_altmode_mux>;
					};
				};
			};
		};
	};
};

&mipi_dcphy1 {
	status = "okay";
};

&route_dp0 {
	status = "disabled";
};

&usbdp_phy0 {
	status = "okay";
	orientation-switch;
	svid = <0xff01>;
	sbu1-dc-gpios = <&gpio0 RK_PC6 GPIO_ACTIVE_HIGH>;
	sbu2-dc-gpios = <&gpio0 RK_PD3 GPIO_ACTIVE_HIGH>;

	port {
		#address-cells = <1>;
		#size-cells = <0>;
		usbdp_phy0_orientation_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_orien_sw>;
		};

		usbdp_phy0_dp_altmode_mux: endpoint@1 {
			reg = <1>;
			remote-endpoint = <&dp_altmode_mux>;
		};
	};
};

&usbdrd_dwc3_0 {
	dr_mode = "otg";
	usb-role-switch;
	port {
		#address-cells = <1>;
		#size-cells = <0>;
		dwc3_0_role_switch: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&usbc0_role_sw>;
		};
	};
};

&spdif_tx2 {
	status = "okay";
};

&pinctrl {
	dp {
		dp1_hdmi_reset: dp-hdmi-reset {
			rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	usb-typec {
		usbc0_int: usbc0-int {
			rockchip,pins = <1 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};
};
