// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright (c) Toradex
 *
 * Common device tree include for Toradex OV5640 CSI camera on Verdin AM62P CSI_1.
 */

#include <dt-bindings/gpio/gpio.h>

&{/} {
	clock_camera: clock-camera {
		compatible = "fixed-clock";
		#clock-cells = <0>;
	};

	regulator_camera: regulator-camera {
		compatible = "regulator-fixed";
		/* Verdin GPIO_8_CSI (SODIMM 222) - CAM_1_CON_PWRCTRL */
		gpio = <&main_gpio0 52 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-name = "V_CSI";
		startup-delay-us = <5000>;
	};
};

&csi0_port0 {
	status = "okay";

	csi2rx0_in_sensor: endpoint {
		remote-endpoint = <&csi2_cam0>;
		bus-type = <4>; /* CSI2 DPHY */
		clock-lanes = <0>;
		data-lanes = <1 2>;
	};
};

&dphy0 {
	status = "okay";
};

/* Verdin I2C_4_CSI */
&main_i2c3 {
	#address-cells = <1>;
	#size-cells = <0>;

	camera@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;

		clocks = <&clock_camera>;
		clock-names = "xclk";
		AVDD-supply = <&regulator_camera>;
		DOVDD-supply = <&regulator_camera>;
		DVDD-supply = <&regulator_camera>;
		/* Verdin GPIO_6 (SODIMM 218) - CAM_1_CON_PWRDWN */
		powerdown-gpios = <&main_gpio0 50 GPIO_ACTIVE_HIGH>;
		/* Verdin GPIO_5 (SODIMM 216) - CAM_1_CON_RST */
		reset-gpios = <&main_gpio0 49 GPIO_ACTIVE_LOW>;

		port {
			csi2_cam0: endpoint {
				remote-endpoint = <&csi2rx0_in_sensor>;
				clock-lanes = <0>;
				data-lanes = <1 2>;
			};
		};
	};
};

&ti_csi2rx0 {
	status = "okay";
};