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

/dts-v1/;
/plugin/;

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

&{/} {
	savdd_cam0: regulator-savdd-cam0 {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-name = "savdd_cam0";
		vin-supply = <&vcc_3v3_s3>;
	};

	sdvdd_cam0: regulator-sdvdd-cam0 {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <1100000>;
		regulator-max-microvolt = <1100000>;
		regulator-name = "sdvdd_cam0";
		vin-supply = <&vcc5v0_sys>;
	};

	siovdd_cam0: regulator-siovdd-cam0 {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-name = "siovdd_cam0";
		vin-supply = <&vcc_3v3_s3>;
	};
};

&i2c3 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	imx415: camera-sensor@1a {
		compatible = "sony,imx415";
		reg = <0x1a>;
		assigned-clocks = <&cru CLK_MIPI_CAMARAOUT_M3>;
		assigned-clock-rates = <37125000>;
		avdd-supply = <&savdd_cam0>;
		clocks = <&cru CLK_MIPI_CAMARAOUT_M3>;
		dvdd-supply = <&sdvdd_cam0>;
		orientation = <MEDIA_ORIENTATION_EXTERNAL>;
		ovdd-supply = <&siovdd_cam0>;
		pinctrl-names = "default";
		pinctrl-0 = <&cam0_rstn &mipim0_camera3_clk>;
		reset-gpios = <&gpio4 RK_PA0 GPIO_ACTIVE_LOW>;

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

&pinctrl {
	cam0 {
		cam0_rstn: cam0-rstn-pinctrl {
			rockchip,pins = <4 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&csi2 {
	status = "okay";
};

&csi2_in {
	csi2_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";
};

&vicap {
	status = "okay";
};

&vicap_mmu {
	status = "okay";
};