// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Device tree overlay for the Radxa Camera 4K attached to the camera
 * connector of the Radxa ROCK 4D.
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/rockchip,rk3576-cru.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/media/video-interfaces.h>
#include <dt-bindings/pinctrl/rockchip.h>

&{/} {
	savdd_cam: regulator-savdd-cam {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio3 RK_PD0 GPIO_ACTIVE_HIGH>;
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-name = "savdd_cam";
		vin-supply = <&vcc_3v3_s0>;
	};

	sdvdd_cam: regulator-sdvdd-cam {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <1100000>;
		regulator-max-microvolt = <1100000>;
		regulator-name = "sdvdd_cam";
		vin-supply = <&vcc_5v0_device>;
	};

	siovdd_cam: regulator-siovdd-cam {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-name = "siovdd_cam";
		vin-supply = <&vcc_3v3_s0>;
	};
};

&csi1 {
	status = "okay";
};

&csi1_in {
	csi1_input: endpoint {
		bus-type = <MEDIA_BUS_TYPE_CSI2_DPHY>;
		data-lanes = <1 2 3 4>;
		link-frequencies = /bits/ 64 <445500000>;
		remote-endpoint = <&imx415_output>;
	};
};

&csi_dphy0 {
	status = "okay";
};

&i2c5 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c5m3_xfer>;
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	imx415: camera-sensor@1a {
		compatible = "sony,imx415";
		reg = <0x1a>;
		assigned-clocks = <&cru CLK_MIPI_CAMERAOUT_M1>;
		assigned-clock-rates = <37125000>;
		avdd-supply = <&savdd_cam>;
		clocks = <&cru CLK_MIPI_CAMERAOUT_M1>;
		dvdd-supply = <&sdvdd_cam>;
		orientation = <2>; /* External */
		ovdd-supply = <&siovdd_cam>;
		pinctrl-names = "default";
		pinctrl-0 = <&cam_rstn &cam_clk1m0_clk1>;
		reset-gpios = <&gpio3 RK_PC7 GPIO_ACTIVE_LOW>;

		port {
			imx415_output: endpoint {
				data-lanes = <1 2 3 4>;
				link-frequencies = /bits/ 64 <445500000>;
				remote-endpoint = <&csi1_input>;
			};
		};
	};
};

&pinctrl {
	cam {
		cam_rstn: cam-rstn-pinctrl {
			rockchip,pins = <3 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&vicap {
	status = "okay";
};

&vicap_mmu {
	status = "okay";
};