// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 *
 */
&csi2_dphy0_hw {
	status = "okay";
};

&csi2_dphy0 {
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi_in_ucam0: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&ucam_out0>;
				data-lanes = <1 2 3 4>;
			};
		};
		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			csidphy0_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&mipi2_csi2_input>;
			};
		};
	};
};

&i2c3 {
	status = "okay";
	dw9714: dw9714@c {
		compatible = "silicon touch,dw9714";
		status = "okay";
		reg = <0x0c>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,vcm-start-current = <20>;
		rockchip,vcm-rated-current = <120>;
		rockchip,vcm-step-mode = <13>;
	};

	imx258_eeprom: imx258_eeprom@50 {
		compatible = "otp,imx258_eeprom";
		status = "okay";
		reg = <0x50>;
	};

	imx258: imx258@10 {
		compatible = "sony,imx258";
		reg = <0x10>;
		clocks = <&cru CLK_MIPI_CAMARAOUT_M3>;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = <&mipim0_camera3_clk>;
		power-domains = <&power RK3588_PD_VI>;
		avdd-supply = <&vcc_mipicsi0>;
		pwdn-gpios = <&gpio1 RK_PB0 GPIO_ACTIVE_LOW>;
		reset-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_LOW>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "GEIR180089";
		rockchip,camera-module-lens-name = "LG500627G";
		eeprom-ctrl = <&imx258_eeprom>;
		lens-focus = <&dw9714>;
		port {
			ucam_out0: endpoint {
				remote-endpoint = <&mipi_in_ucam0>;
				data-lanes = <1 2 3 4>;
			};
		};
	};
};

&mipi2_csi2 {
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi2_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&csidphy0_out>;
			};
		};
		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi2_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in2>;
			};
		};
	};
};

&rkcif {
	status = "okay";
};

&rkcif_mipi_lvds2 {
	status = "okay";
	port {
		cif_mipi_in2: endpoint {
			remote-endpoint = <&mipi2_csi2_output>;
		};
	};
};

&rkcif_mipi_lvds2_sditf {
	status = "okay";
	port {
		mipi_lvds_sditf: endpoint {
			remote-endpoint = <&isp0_vir0>;
		};
	};
};

&rkcif_mmu {
	status = "okay";
};

&rkisp0 {
	status = "okay";
};

&isp0_mmu {
	status = "okay";
};

&rkisp0_vir0 {
	status = "okay";
	port {
		#address-cells = <1>;
		#size-cells = <0>;
		isp0_vir0: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi_lvds_sditf>;
		};
	};
};

&csi2_dcphy0 {
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi_in_1_ucam0: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&imx258_1_out0>;
				data-lanes = <1 2 3 4>;
			};
		};
		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			csidcphy0_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&mipi0_csi2_input>;
			};
		};
	};
};

&i2c5 {
	status = "okay";
	dw9714_1: dw9714_1@c {
		compatible = "silicon touch,dw9714";
		status = "okay";
		reg = <0x0c>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,vcm-start-current = <20>;
		rockchip,vcm-rated-current = <120>;
		rockchip,vcm-step-mode = <13>;
	};

	imx258_1_eeprom: imx258_1_eeprom@50 {
		compatible = "otp,imx258_eeprom";
		status = "okay";
		reg = <0x50>;
	};

	imx258_1: imx258_1@1a {
		compatible = "sony,imx258";
		reg = <0x1a>;
		clocks = <&cru CLK_MIPI_CAMARAOUT_M1>;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = <&mipim0_camera1_clk>;
		power-domains = <&power RK3588_PD_VI>;
		avdd-supply = <&vcc_mipidcphy0>;
		pwdn-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>;
		reset-gpios = <&gpio2 RK_PC4 GPIO_ACTIVE_LOW>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "GEIR180089";
		rockchip,camera-module-lens-name = "LG500627G";
		eeprom-ctrl = <&imx258_1_eeprom>;
		lens-focus = <&dw9714_1>;
		port {
			imx258_1_out0: endpoint {
				remote-endpoint = <&mipi_in_1_ucam0>;
				data-lanes = <1 2 3 4>;
			};
		};
	};
};

// use dcphy0 isp1
&mipi_dcphy0 {
	status = "okay";
};

&mipi0_csi2 {
	status = "okay";
	ports {
		#address-cells = <1>;
		#size-cells = <0>;
		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi0_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&csidcphy0_out>;
			};
		};
		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
			mipi0_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in0>;
			};
		};
	};
};

&rkcif_mipi_lvds {
	status = "okay";
	port {
		cif_mipi_in0: endpoint {
			remote-endpoint = <&mipi0_csi2_output>;
		};
	};
};

#if 0

&rkcif_mipi_lvds_sditf {
	status = "okay";
	port {
		mipi_lvds_sditf_1: endpoint {
			remote-endpoint = <&isp0_vir1>;
		};
	};
};

&rkisp0_vir1 {
	status = "okay";

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

		isp0_vir1: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi_lvds_sditf_1>;
		};
	};
};

#endif

&rkisp1 {
	status = "okay";
};

&isp1_mmu {
	status = "okay";
};

&rkcif_mipi_lvds_sditf {
	status = "okay";

	port {
		mipi1_lvds_sditf: endpoint {
			remote-endpoint = <&isp1_vir0>;
		};
	};
};

&rkisp1_vir0 {
	status = "okay";

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

		isp1_vir0: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi1_lvds_sditf>;
		};
	};
};
