一、環(huán)境
二、imx415簡介
三、驅(qū)動移植
瑞芯微支持的攝像頭,有個support list,
此次從該list中選擇了IMX415
3.1 驅(qū)動源文件及對應腳本
RK提供的默認sdk里面已經(jīng)將支持的所有攝像頭驅(qū)動都添加到了內(nèi)核,所以不需要移植該驅(qū)動了。
需確認下移植驅(qū)動對應的一些信息
- 源程序
 
3588_linux/3588_linux5.10_v1.0.5/kernel/drivers/media/i2c/imx415.c 3588_linux/3588_linux5.10_v1.0.5/kernel/drivers/media/i2c/Makefile 3588_linux/3588_linux5.10_v1.0.5/kernel/drivers/media/i2c/Kconfig 3588_linux/3588_linux5.10_v1.0.5/kernel/arch/arm64/configs/rockchip_linxu_defconfig
- Makefile腳本
 
obj-$(CONFIG_VIDEO_IMX415)	+= imx415.o
- Kconfig腳本
 
config VIDEO_IMX415
	tristate "Sony IMX415 sensor support"
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	depends on MEDIA_CAMERA_SUPPORT
	help
	  This is a Video4Linux2 sensor driver for the Sony
	  IMX415 camera.
	  To compile this driver as a module, choose M here: the
	  module will be called imx415.
- 驅(qū)動對應的宏開關(guān)
 
CONFIG_VIDEO_IMX415=y
3.2 dts設(shè)備樹

1)攝像頭鏈接示意圖
IMX415攝像頭與SOC連接的主要的引腳有:i2c、rst、pwdn、mclk、MIPI Clk、MIPI DATA
2)電路圖

由電路圖可知,幾個關(guān)鍵引腳關(guān)系:
reset信號:gpio4 A0
power0 down信號:gpio1 B0
I2C通道:3
clock:CLK_MIPI_CAMARAOUT_M3
3)設(shè)備樹節(jié)點
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2022 Rockchip Electronics Co., Ltd.
 *
 */
/ {
	compatible = "radxa,rock-5b", "rockchip,rk3588";
	camera_pwdn_gpio: camera-pwdn-gpio {
		status = "okay";
		compatible = "regulator-fixed";
		regulator-name = "camera_pwdn_gpio";
		regulator-always-on;
		regulator-boot-on;
		enable-active-high;
		gpio = < &gpio1 RK_PB0 GPIO_ACTIVE_HIGH >;
		pinctrl-names = "default";
		pinctrl-0 = < &cam_pwdn_gpio >;
	};
	clk_cam_24m: external-camera-clock-24m {
		status = "okay";
		compatible = "fixed-clock";
		clock-frequency = < 24000000 >;
		clock-output-names = "clk_cam_24m";
		#clock-cells = < 0 >;
	};
};
&i2c3 {
	status = "okay";
	imx415: imx415@1a {
		status = "okay";
		compatible = "sony,imx415";
		reg = < 0x1a >;
		clocks = < &cru CLK_MIPI_CAMARAOUT_M3 >;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = < &mipim0_camera3_clk >;
		power-domains = < &power RK3588_PD_VI >;
		pwdn-gpios = < &gpio1 RK_PB0 GPIO_ACTIVE_HIGH >;
		reset-gpios = < &gpio4 RK_PA0 GPIO_ACTIVE_LOW >;
		rockchip,camera-module-index = < 0 >;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "CMK-OT2022-PX1";
		rockchip,camera-module-lens-name = "IR0147-50IRC-8M-F20";
		port {
			imx415_out0: endpoint {
				remote-endpoint = < &mipidphy0_in_ucam0 >;
				data-lanes = < 1 2 3 4 >;
			};
		};
	};
	camera_imx219: camera-imx219@10 {
		status = "disabled";
		compatible = "sony,imx219";
		reg = < 0x10 >;
		clocks = < &clk_cam_24m >;
		clock-names = "xvclk";
		rockchip,camera-module-index = < 0 >;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "rpi-camera-v2";
		rockchip,camera-module-lens-name = "default";
		port {
			imx219_out0: endpoint {
				remote-endpoint = < &mipidphy0_in_ucam1 >;
				data-lanes = < 1 2 >;
			};
		};
	};
};
&csi2_dphy0_hw {
	status = "okay";
};
&csi2_dphy0 {
	status = "okay";
	ports {
		#address-cells = < 1 >;
		#size-cells = < 0 >;
		port@0 {
			reg = < 0 >;
			#address-cells = < 1 >;
			#size-cells = < 0 >;
			mipidphy0_in_ucam0: endpoint@1 {
				reg = < 1 >;
				remote-endpoint = < &imx415_out0 >;
				data-lanes = < 1 2 3 4 >;
			};
			mipidphy0_in_ucam1: endpoint@2 {
				reg = < 2 >;
				remote-endpoint = < &imx219_out0 >;
				data-lanes = < 1 2 >;
			};
		};
		port@1 {
			reg = < 1 >;
			#address-cells = < 1 >;
			#size-cells = < 0 >;
			csidphy0_out: endpoint@0 {
				reg = < 0 >;
				remote-endpoint = < &mipi2_csi2_input >;
			};
		};
	};
};
&mipi2_csi2 {
	status = "okay";
	ports {
		#address-cells = < 1 >;
		#size-cells = < 0 >;
		port@0 {
			reg = < 0 >;
			#address-cells = < 1 >;
			#size-cells = < 0 >;
			mipi2_csi2_input: endpoint@1 {
				reg = < 1 >;
				remote-endpoint = < &csidphy0_out >;
			};
		};
		port@1 {
			reg = < 1 >;
			#address-cells = < 1 >;
			#size-cells = < 0 >;
			mipi2_csi2_output: endpoint@0 {
				reg = < 0 >;
				remote-endpoint = < &cif_mipi2_in0 >;
			};
		};
	};
};
&rkcif {
	status = "okay";
};
&rkcif_mipi_lvds2 {
	status = "okay";
	port {
		cif_mipi2_in0: endpoint {
			remote-endpoint = < &mipi2_csi2_output >;
		};
	};
};
&rkcif_mipi_lvds2_sditf {
	status = "okay";
	port {
		mipi_lvds2_sditf: endpoint {
			remote-endpoint = < &isp0_vir0 >;
		};
	};
};
&rkcif_mmu {
	status = "okay";
};
&rkisp0 {
	status = "okay";
};
&isp0_mmu {
	status = "okay";
};
&rkisp0_vir0 {
	status = "okay";
	port {
		#address-cells = < 1 >;
		#size-cells = < 0 >;
		isp0_vir0: endpoint@0 {
			reg = < 0 >;
			remote-endpoint = < &mipi_lvds2_sditf >;
		};
	};
};
&pinctrl {
	camera {
		cam_pwdn_gpio: cam-pwdn-gpio {
			rockchip,pins = < 1 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up >;
		};
	};
};
          
        
        
rk3588調(diào)試之imx415攝像頭
                
 