// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2026, Thundercomm All rights reserved.
 */

/dts-v1/;
/plugin/;

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

&{/} {
	cam2_imx219_clk: clock-camera2-24m {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <24000000>;
	};

	leds-camera2 {
		compatible = "gpio-leds";

		pinctrl-0 = <&cam2_privacy_led_state>;
		pinctrl-names = "default";

		cam2_privacy_led: led-camera2 {
			function = LED_FUNCTION_INDICATOR;
			function-enumerator = <2>;
			gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>;
			default-state = "off";
		};
	};

	/* Camera module power domain controlled through connector PWR_EN. */
	vreg_cam2_pwr: regulator-camera2-pwr {
		compatible = "regulator-fixed";

		regulator-name = "vreg_camera2_pwr";

		gpio = <&tlmm 58 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		pinctrl-0 = <&cam2_pwr_en>;
		pinctrl-names = "default";

		vin-supply = <&vreg_vcc3v3_output>;
	};
};

&camss {
	vdda-phy-supply = <&vreg_l10c_0p88>;
	vdda-pll-supply = <&vreg_l6b_1p2>;

	status = "okay";

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

		port@4 {
			reg = <4>;

			csiphy4_ep: endpoint {
				data-lanes = <0 1>;
				remote-endpoint = <&cam2_imx219_ep>;
			};
		};
	};
};

&cci0 {
	status = "okay";
};

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

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

		clocks = <&cam2_imx219_clk>;

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

		leds = <&cam2_privacy_led>;
		led-names = "privacy";

		port {
			cam2_imx219_ep: endpoint {
				data-lanes = <1 2>;
				link-frequencies = /bits/ 64 <456000000>;
				remote-endpoint = <&csiphy4_ep>;
			};
		};
	};
};

&tlmm {
	cam2_privacy_led_state: cam2-privacy-led-state {
		pins = "gpio19";
		function = "gpio";
		drive-strength = <8>;
		bias-disable;
	};

	cam2_pwr_en: cam2-pwr-en-state {
		pins = "gpio58";
		function = "gpio";
		drive-strength = <8>;
		bias-disable;
	};
};