// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/*
 * Device Tree Overlay for an IMX219 camera sensor on connector J1 on R-Car V4H
 * ES3.0 Sparrow Hawk board.
 *
 * Copyright 2025 Renesas Electronics Corp.
 * Copyright 2025 Niklas Söderlund <niklas.soderlund@ragnatech.se>
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/media/video-interfaces.h>
#include <dt-bindings/media/video-interface-devices.h>

&{/} {
	clk_cam_j1: clk-cam-j1 {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <24000000>;
	};

	/* Page 29 / CSI_IF_CN / J1 */
	reg_cam_j1: reg-cam-j1 {
		compatible = "regulator-fixed";
		regulator-name = "cam-J1";
		enable-active-high;
		gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
	};
};

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

	cam@10 {
		compatible = "sony,imx219";
		reg = <0x10>;

		clocks = <&clk_cam_j1>;

		VANA-supply = <&reg_cam_j1>;
		VDIG-supply = <&reg_cam_j1>;
		VDDL-supply = <&reg_cam_j1>;

		orientation = <MEDIA_ORIENTATION_EXTERNAL>;
		rotation = <0>;

		port {
			imx219_j1_out: endpoint {
				clock-noncontinuous;
				link-frequencies = /bits/ 64 <456000000>;
				data-lanes = <1 2>;
				remote-endpoint = <&csi40_in>;
			};
		};
	};
};

/* Page 29 / CSI_IF_CN */
&csi40 {
	status = "okay";

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

		port@0 {
			reg = <0>;

			csi40_in: endpoint {
				bus-type = <MEDIA_BUS_TYPE_CSI2_DPHY>;
				clock-lanes = <0>;
				data-lanes = <1 2>;
				remote-endpoint = <&imx219_j1_out>;
			};
		};
	};
};

&isp0 {
	status = "okay";
};

&vin00 {
	status = "okay";
};

&vin01 {
	status = "okay";
};

&vin02 {
	status = "okay";
};

&vin03 {
	status = "okay";
};

&vin04 {
	status = "okay";
};

&vin05 {
	status = "okay";
};

&vin06 {
	status = "okay";
};

&vin07 {
	status = "okay";
};