高通Camera点亮1——Camera相关的DTS配置
这里将自己对接高通Camera的一般过程记录下来,作为学习记录。
Camera驱动的DTS配置
所在路径:vendor/qcom/proprietary/camera-devicetree/
具体使用使用哪一个dtsi可以参考该路径下config目录下的配置
这里我是用parrot-camera.dtsi和parrot-camera-sensor-qrd.dtsi
#include <dt-bindings/clock/qcom,camcc-parrot.h>
#include <dt-bindings/msm-camera.h>
&soc {
led_flash_rear: qcom,camera-flash@1 {
cell-index = <1>;
compatible = "qcom,camera-flash";
flash-source = <&pm6150l_flash0 &pm6150l_flash1>;
torch-source = <&pm6150l_torch0 &pm6150l_torch1>;
switch-source = <&pm6150l_switch2>;
status = "ok";
};
led_flash_rear_aux: qcom,camera-flash@2 {
cell-index = <2>;
compatible = "qcom,camera-flash";
flash-source = <&pm6150l_flash0 &pm6150l_flash1>;
torch-source = <&pm6150l_torch0 &pm6150l_torch1>;
switch-source = <&pm6150l_switch2>;
status = "ok";
};
qcom,cam-res-mgr {
compatible = "qcom,cam-res-mgr";
status = "ok";
};
};
&cam_cci0 {
actuator_0: qcom,actuator0 {
cell-index = <0>;
compatible = "qcom,actuator";
cci-master = <CCI_MASTER_0>;
cam_vaf-supply = <&L7I>;
regulator-names = "cam_vaf";
rgltr-cntrl-support;
rgltr-min-voltage = <2800000>;
rgltr-max-voltage = <3000000>;
rgltr-load-current = <103000>;
};
eeprom_0: qcom,eeprom0 {
cell-index = <0>;
compatible = "qcom,eeprom";
cam_vio-supply = <&L6I>;
cam_vana-supply = <&L3I>;
cam_vdig-supply = <&L1I>;
cam_clk-supply = <&cam_cc_camss_top_gdsc>;
cam_vaf-supply = <&L7I>;
regulator-names = "cam_vio", "cam_vana", "cam_vdig",
"cam_clk", "cam_vaf";
rgltr-cntrl-support;
rgltr-min-voltage = <1800000 2760000 1160000 0 2800000>;
rgltr-max-voltage = <1800000 2860000 1240000 0 3000000>;
rgltr-load-current = <10000 52000 140000 0 103000>;
gpio-no-mux = <0>;
pinctrl-names = "cam_default", "cam_suspend";
pinctrl-0 = <&cam_sensor_mclk0_active
&cam_sensor_active_rst0>;
pinctrl-1 = <&cam_sensor_mclk0_suspend
&cam_sensor_suspend_rst0>;
gpios = <&tlmm 39 0>,
<&tlmm 44 0>;
gpio-reset = <1>;
gpio-req-tbl-num = <0 1>;
gpio-req-tbl-flags = <1 0>;
gpio-req-tbl-label = "CAMIF_MCLK0",
"CAM_RESET0";
cci-master = <CCI_MASTER_0>;
clocks = <&camcc CAM_CC_MCLK0_CLK>;
clock-names = "cam_clk";
clock-cntl-level = "nominal";
clock-rates = <24000000>;
status = "ok";
};
qcom,cam-sensor0 {
cell-index = <6>; //与module中的cameraId对应;也与multicamera中的slotId对应
compatible = "qcom,cam-sensor";
csiphy-sd-index = <0>;//Sensor实际连接的是哪一个CSIPHY
sensor-position-roll = <90>;//相机的位姿
sensor-position-pitch = <0>;
sensor-position-yaw = <180>;
eeprom-src = <&eeprom_0>;//EEPROM
actuator-src = <&actuator_0>;//Actuator
led-flash-src = <&led_flash_rear>;//flash
cam_vio-supply = <&L6I>; //Sensor供电,Power of IO;DOVDD
cam_vana-supply = <&L3I>; //Sensor供电,Power of Anlog ,AVDD
cam_vdig-supply = <&L1I>; //Power of Digital供电,DVDD
cam_vaf-supply = <&L7I>; //给AF的VCM供电的
cam_clk-supply = <&cam_cc_camss_top_gdsc>;//CLK
cam_bob-supply = <&BOB>;
regulator-names = "cam_vio", "cam_vana", "cam_vdig",
"cam_vaf", "cam_clk", "cam_bob";
rgltr-cntrl-support;
//各路电压和电流的要求,参照Sensor的datasheet,这里的6路按照regulator-names中的顺序定义
rgltr-min-voltage = <1800000 2760000 1160000 2800000 0 3008000>;
rgltr-max-voltage = <1800000 2860000 12400000 3000000 0 3960000>;
rgltr-load-current = <10000 52000 140000 103000 0 3000000>;
gpio-no-mux = <0>;
pinctrl-names = "cam_default", "cam_suspend";
pinctrl-0 = <&cam_sensor_mclk0_active
&cam_sensor_active_rst0>;
pinctrl-1 = <&cam_sensor_mclk0_suspend
&cam_sensor_suspend_rst0>;
gpios = <&tlmm 39 0>, //MCLK对应的GPIO
<&tlmm 44 0>; //RST对应的GPIO
gpio-reset = <1>;
gpio-req-tbl-num = <0 1>;
gpio-req-tbl-flags = <1 0>;
gpio-req-tbl-label = "CAMIF_MCLK0",
"CAM_RESET0";
cci-master = <CCI_MASTER_0>; //确定CCI是哪一路
clocks = <&camcc CAM_CC_MCLK0_CLK>;
clock-names = "cam_clk";
clock-cntl-level = "nominal";
clock-rates = <24000000>; //CLK频率
status = "ok";
};
};
DTSI的配置需要根据硬件原理图、Sensor的datasheet和高通平台的配置参照来确认。
给Camera供电的配置
##kernel_platform/qcom/proprietary/devicetree/qcom/parrot-pmic-overlay.dtsi
pm8010i@9 {
compatible = "qcom,i2c-pmic";
reg = <0x9>;
#address-cells = <1>;
#size-cells = <0>;
qcom,pm8010i-regulator {
compatible = "qcom,pm8010-regulator";
#address-cells = <1>;
#size-cells = <0>;
pm8008_en-supply = <&PM8010I_EN>; //PM8010 enable管脚
//这里指明了PM8010 LDO输出的来源管脚,比如L1和L2的电来源于S8B。如果S8B没电,那么L1和L2也不会有电,配置不能出错。
vdd_l1_l2-supply = <&S8B>;
vdd_l3_l4-supply = <&BOB>;
vdd_l5-supply = <&S8E>;
vdd_l6-supply = <&S8E>;
vdd_l7-supply = <&BOB>;
L1I: pm8010i_l1: regulator@4000 {
reg = <0x4000>; //PM8010 reg 地址,固定值
regulator-name = "pm8010i_l1";
regulator-min-microvolt = <1000000>; //最小电压,可以自己定义,但是PM8010有最小和最大电压范围,需要在那个范围之内,具体需要多少电压在Sensor dtsi中定义
regulator-max-microvolt = <1300000>;
qcom,min-dropout-voltage = <88000>;
qcom,hpm-min-load = <30000>;
};
L2I: pm8010i_l2: regulator@4100 {
reg = <0x4100>;
regulator-name = "pm8010i_l2";
regulator-min-microvolt = <950000>;
regulator-max-microvolt = <1300000>;
qcom,min-dropout-voltage = <64000>;
qcom,hpm-min-load = <30000>;
};
L3I: pm8010i_l3: regulator@4200 {
reg = <0x4200>;
regulator-name = "pm8010i_l3";
regulator-min-microvolt = <1328000>;
regulator-max-microvolt = <3000000>;
qcom,min-dropout-voltage = <176000>;
qcom,hpm-min-load = <0>;
};
L4I: pm8010i_l4: regulator@4300 {
reg = <0x4300>;
regulator-name = "pm8010i_l4";
regulator-min-microvolt = <1376000>;
regulator-max-microvolt = <2900000>;
qcom,min-dropout-voltage = <128000>;
qcom,hpm-min-load = <0>;
};
L5I: pm8010i_l5: regulator@4400 {
reg = <0x4400>;
regulator-name = "pm8010i_l5";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
qcom,min-dropout-voltage = <128000>;
qcom,init-voltage = <1800000>;
qcom,hpm-min-load = <0>;
regulator-boot-on;
regulator-always-on; //表示该路上电之后就一直供电
};
L6I: pm8010i_l6: regulator@4500 {
reg = <0x4500>;
regulator-name = "pm8010i_l6";
regulator-min-microvolt = <1376000>;
regulator-max-microvolt = <2900000>;
qcom,min-dropout-voltage = <128000>;
qcom,hpm-min-load = <0>;
};
L7I: pm8010i_l7: regulator@4600 {
reg = <0x4600>;
regulator-name = "pm8010i_l7";
regulator-min-microvolt = <1248000>;
regulator-max-microvolt = <3000000>;
qcom,min-dropout-voltage = <256000>;
qcom,hpm-min-load = <0>;
};
};
};
配置好DTS编译烧录之后,如何确认Camera上电部分OK呢?
adb root
adb shell
mount -t debugfs debugfs /sys/kernel/debug
cat /sys/kernel/debug/regulator_summary
regulator use open bypass opmode voltage current min max
---------------------------------------------------------------------------------------
ktb8399nedaa1 0 1 0 unknown 1300mV 0mA 1300mV 1300mV
npc139_1p2 0 1 0 unknown 1200mV 0mA 1200mV 1200mV
ac17000.qcom,cci2:qcom,cam-sensor0-cam_vio 0 0mA 0mV 0mV
这里节选了部分的Camera电源相关的配置,可以看到cam_vio目前没有电压也没有电流,说明这一路目前没有上电。当然确认是否上电最直观的方式还是用万用表量。
如何确认Camere相关的DTS OK
DTS的配置容易出错,单纯靠检查配置很难看出问题所在,那如何确认Camere相关的DTS OK?
DTS编译后生成DTB文件,DTB文件可以通过dtc命令转换回dts文件来查看。
adb root
adb pull /sys/firmware/fdt ./
dtc -I dtb -O dts fdt > neo.dts
这是从板子上的DTB转成的DTS文件中Camera相关部分:
qcom,actuator0 {
phandle = <0x550>;
rgltr-load-current = <0x19258>;
rgltr-max-voltage = <0x2dc6c0>;
rgltr-min-voltage = <0x2ab980>;
rgltr-cntrl-support;
regulator-names = "cam_vaf";
cam_vaf-supply = <0x50f>;
cci-master = <0x00>;
compatible = "qcom,actuator";
cell-index = <0x00>;
};
qcom,eeprom0 {
phandle = <0x54f>;
status = "ok";
clock-rates = <0x16e3600>;
clock-cntl-level = "nominal";
clock-names = "cam_clk";
clocks = <0x12f 0x30>;
cci-master = <0x00>;
gpio-req-tbl-label = "CAMIF_MCLK0\0CAM_RESET0";
gpio-req-tbl-flags = <0x01 0x00>;
gpio-req-tbl-num = <0x00 0x01>;
gpio-reset = <0x01>;
gpios = <0x147 0x27 0x00 0x147 0x2c 0x00>;
pinctrl-1 = <0x3ce 0x3d8>;
pinctrl-0 = <0x3cd 0x3d7>;
pinctrl-names = "cam_default\0cam_suspend";
gpio-no-mux = <0x00>;
rgltr-load-current = <0x2710 0xcb20 0x222e0 0x00 0x19258>;
rgltr-max-voltage = <0x1b7740 0x2ba3e0 0x12ebc0 0x00 0x2dc6c0>;
rgltr-min-voltage = <0x1b7740 0x2a1d40 0x11b340 0x00 0x2ab980>;
rgltr-cntrl-support;
regulator-names = "cam_vio\0cam_vana\0cam_vdig\0cam_clk\0cam_vaf";
cam_vaf-supply = <0x50f>;
cam_clk-supply = <0x300>;
cam_vdig-supply = <0x509>;
cam_vana-supply = <0x50b>;
cam_vio-supply = <0x50e>;
compatible = "qcom,eeprom";
cell-index = <0x00>;
};
qcom,cam-sensor0 {
status = "ok";
clock-rates = <0x16e3600>;
clock-cntl-level = "nominal";
clock-names = "cam_clk";
clocks = <0x12f 0x30>;
cci-master = <0x00>;
gpio-req-tbl-label = "CAMIF_MCLK0\0CAM_RESET0";
gpio-req-tbl-flags = <0x01 0x00>;
gpio-req-tbl-num = <0x00 0x01>;
gpio-reset = <0x01>;
gpios = <0x147 0x27 0x00 0x147 0x2c 0x00>;
pinctrl-1 = <0x3ce 0x3d8>;
pinctrl-0 = <0x3cd 0x3d7>;
pinctrl-names = "cam_default\0cam_suspend";
gpio-no-mux = <0x00>;
rgltr-load-current = <0x2710 0xcb20 0x222e0 0x19258 0x00 0x2dc6c0>;
rgltr-max-voltage = <0x1b7740 0x2ba3e0 0xbd3580 0x2dc6c0 0x00 0x3c6cc0>;
rgltr-min-voltage = <0x1b7740 0x2a1d40 0x11b340 0x2ab980 0x00 0x2de600>;
rgltr-cntrl-support;
regulator-names = "cam_vio\0cam_vana\0cam_vdig\0cam_vaf\0cam_clk\0cam_bob";
cam_bob-supply = <0x2c3>;
cam_clk-supply = <0x300>;
cam_vaf-supply = <0x50f>;
cam_vdig-supply = <0x509>;
cam_vana-supply = <0x50b>;
cam_vio-supply = <0x50e>;
led-flash-src = <0x551>;
actuator-src = <0x550>;
eeprom-src = <0x54f>;
sensor-position-yaw = <0xb4>;
sensor-position-pitch = <0x00>;
sensor-position-roll = <0x5a>;
csiphy-sd-index = <0x00>;
compatible = "qcom,cam-sensor";
cell-index = <0x06>;
};
这里的每一部分都是地址的形式,需要根据地址查找然后与自己配置的是否一致,以此来判断是否是DTS配置或者编译过程中的问题导致的。比如eeprom-src = <0x54f>,与上面的qcom,eeprom0中的phandle = <0x54f>就对应上了。
Camera的配置和上电当然少不了Sensor的驱动配置,这部分下一篇博客讲。