1.camera电源总开关,一般控制LDO(用于转换sensor相应的电压)输出电压给sensor, 再由pwdn控制sensor是否工作。
vcc_camera: vcc-camera-regulator {
compatible = "regulator-fixed";
gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&camera_pwr>;
regulator-name = "vcc_camera";
enable-active-high;
regulator-always-on;
regulator-boot-on;
};
2.sensor配置样例
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
/* split mode: lane0/1 */
gc2053: gc2053@37 {
status = "okay";
compatible = "galaxycore,gc2053";// 需要与驱动中的匹配字符串一致
reg = <0x37>; // sensor I2C 设备地址,7位
//查看硬件配置引脚,特别注意clocks与pinctrl-0一一对应,
//CLK_CAM0_OUT->cam_clkout0, CLK_CAM1_OUT->cam_clkout1, CLK_CIF_OUT->cif_clk, CLK_MIPICSI_OUT->mipicsi_clk0
clocks = <&cru CLK_CAM0_OUT>; // sensor mclk 配置
clock-names = "xvclk";
power-domains = <&power RK3568_PD_VI>;
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0>;// pinctl设置
// reset管脚分配及有效电平,要适配驱动操作输出
reset-gpios = <&gpio4 RK_PB1 GPIO_ACTIVE_LOW>;
// power管脚分配及有效电平
pwdn-gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>;
/*power-gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>;*/
// 模组编号,该编号不要重复
rockchip,camera-module-index = <0>;
// 模组朝向,有"back"和"front"
rockchip,camera-module-facing = "front";
//module与lens命令要与设备/etc/iqfiles中对应sensor的iq文件名后面相同,如gc2053_YT-RV1109-2-V1_40IR-2MP-F20.xml
rockchip,camera-module-name = "YT-RV1109-2-V1";
rockchip,camera-module-lens-name = "40IR-2MP-F20";
port {
gc2053_out: endpoint {
remote-endpoint = <&dphy1_in>;
data-lanes = <1 2>;
};
};
};
}
3.多路sensor共用时钟注意
a.多路sensor的mclk一定要相同。
b.单个sensor配置时,pinctl相关不要配置,而是将其独立到&pinctl{}大节点中。如gc2053与opn6001共用时钟,配置如下:
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
/* split mode: lane0/1 */
gc2053: gc2053@37 {
status = "okay";
compatible = "galaxycore,gc2053";
reg = <0x37>;
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
/* Set pinctl of xvclk in &pinctl */
power-domains = <&power RK3568_PD_VI>;
reset-gpios = <&gpio4 RK_PB1 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>;
/*power-gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>;*/
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "front";
rockchip,camera-module-name = "rgbd";
rockchip,camera-module-lens-name = "Optics";
port {
gc2053_out: endpoint {
remote-endpoint = <&dphy1_in>;
data-lanes = <1 2>;
};
};
};
};
&i2c4 {
status = "okay";
pinctrl-0 = <&i2c4m0_xfer>;
clock-frequency = <1000000>;
/* split mode: lane:2/3 */
opn6001: opn6001@53 {
status = "okay";
compatible = "opnous,opn6001";
reg = <0x53>;
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
/* Set pinctl of xvclk in &pinctl */
reset-gpios = <&gpio4 RK_PB0 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_LOW>;
power-domains = <&power RK3568_PD_VI>;
rockchip,camera-module-index = <1>;
rockchip,camera-module-facing = "front";
rockchip,camera-module-name = "tof";
rockchip,camera-module-lens-name = "Opnous";
port {
opn6001_out: endpoint {
remote-endpoint = <&dphy2_in>;
data-lanes = <1 2>;
};
};
};
};
&pinctrl {
/* cam_clkout0 used by tof and gc2053 */
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0>;
cam {
camera_pwr: camera-pwr {
rockchip,pins =
/* camera power en */
<0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>;
};
dvp_pwr: dvp-pwr {
rockchip,pins =
/* camera power en */
<0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
}
4.sensor上电时序
a.电源时序:
一般情况下,不需要电源上电时序,设备上电直接给sensor各路电压即可。
b.其他控制时序(mclk/reset/pwdn/sda/scl):
可查看sensor datasheet获取上遇时序,一定要注意各控制信号之前的间隔时间和连续性。例如mclk在reset是消失,可查看dtsi的reset有效电平是否配置正确。在调试期间重点用试波器测试各信号是否正常,以便定位问题。
5.dtsi io有效电平配置与驱动的关系
dtsi: pwdn-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>;
driver: gpiod_set_value_cansleep(gc2053->pwdn_gpio, 0);
一定根据sense datasheet和试波器来确认信号的输出