// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Device tree overlay for the Radxa Camera 4K attached to the CAM1 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_cam1: regulator-savdd-cam1 {
		compatible = "regulator-fixed";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-name = "savdd_cam1";
		vin-supply = <&vcc_3v3_s3>;
	};

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

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

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

	cam1_imx415: camera-sensor@1a {
		compatible = "sony,imx415";
		reg = <0x1a>;
		assigned-clocks = <&cru CLK_MIPI_CAMARAOUT_M4>;
		assigned-clock-rates = <37125000>;
		avdd-supply = <&savdd_cam1>;
		clocks = <&cru CLK_MIPI_CAMARAOUT_M4>;
		dvdd-supply = <&sdvdd_cam1>;
		orientation = <MEDIA_ORIENTATION_EXTERNAL>;
		ovdd-supply = <&siovdd_cam1>;
		pinctrl-names = "default";
		pinctrl-0 = <&cam1_rstn &mipim0_camera4_clk>;
		reset-gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>;

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

&pinctrl {
	cam1 {
		cam1_rstn: cam1-rstn-pinctrl {
			rockchip,pins = <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&csi4 {
	status = "okay";
};

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

&csi_dphy1 {
	status = "okay";
};

&vicap {
	status = "okay";
};

&vicap_mmu {
	status = "okay";
};