\kernel\arch\arm\boot\dts\qcom\
dtsi文件在这个路径下面。
sensor ,eeporm,actuator都在这个文件里面配置。包括上电时序,每路电是配置多大的电压。下面一一讲解:
eeprom0: qcom,eeprom@5a {
cell-index = <0>;
reg = <0x5A>;
qcom,eeprom-name = "sunwin_s5k4h7";
compatible = "qcom,eeprom";
qcom,slave-addr = <0x5A>;
qcom,cci-master = <0>;
qcom,num-blocks = <3>;
qcom,page0 = <1 0x0A02 2 0x15 1 1>;/*set the page21 of otp*/
qcom,poll0 = <0 0x0 1 0x0 1 1>;
qcom,mem0 = <0 0x0 1 0x0 1 1>;
qcom,page1 = <1 0x0A00 2 0x0100 2 1>;/*OTP enable and read start*/
qcom,poll1 = <0 0x0 1 0x0 1 1>;
qcom,mem1 = <60 0x0A04 2 0x0000 2 1>;
qcom,page2 = <1 0x0A00 2 0x0000 2 1>;/*OTP enable and read end*/
qcom,poll2 = <0 0x0 1 0x0 1 1>;
qcom,mem2 = <0 0x0 1 0x0 1 1>;
cam_vio-supply = <&pm8916_l10>;
cam_vaf-supply = <&pm8916_l11>;
qcom,cam-vreg-name = "cam_vio", "cam_vaf";
qcom,cam-vreg-type = <0 0>;
qcom,cam-vreg-min-voltage = <1800000 2800000>;
qcom,cam-vreg-max-voltage = <1800000 2800000>;
qcom,cam-vreg-op-mode = <80000 100000>;
pinctrl-names = "cam_default", "cam_suspend";
pinctrl-0 = <&cam_sensor_mclk0_default &cam_sensor_rear_default>;
pinctrl-1 = <&cam_sensor_mclk0_sleep &cam_sensor_rear_sleep>;
gpios = <&msm_gpio 26 0>,
<&msm_gpio 29 0>,
<&msm_gpio 33 0>;
qcom,gpio-reset = <1>;
qcom,gpio-standby = <2>;
qcom,gpio-req-tbl-num = <0 1 2>;
qcom,gpio-req-tbl-flags = <1 0 0>;
qcom,gpio-req-tbl-label = "CAMIF_MCLK",
"CAM_RESET0",
"CAM_STANDBY";
qcom,cam-power-seq-type =
"sensor_vreg","sensor_gpio", "sensor_gpio","sensor_clk";
qcom,cam-power-seq-val =
"cam_vio",
"sensor_gpio_standby",
"sensor_gpio_reset",
"sensor_cam_mclk";
qcom,cam-power-seq-cfg-val = <1 1 1 24000000>;
qcom,cam-power-seq-delay = <10 10 10 5>;
clocks = <&clock_gcc clk_mclk0_clk_src>,
<&clock_gcc clk_gcc_camss_mclk0_clk>;
clock-names = "cam_src_clk", "cam_clk";
};
上面的是eeprom的,
cell-index = <0>; 这个是作为区分使用的,dtsi里面的cell_index都不能一样
reg = <0x5A>; 这个就是i2c地址了,和sensor驱动保持一致
qcom,eeprom-name = "sunwin_s5k4h7"; 这个就是eeprom的name,也是和snesor驱动保持一致
compatible = "qcom,eeprom";
qcom,slave-addr = <0x5A>; 这个是i2c地址
qcom,cci-master = <0>;
qcom,num-blocks = <3>; num_blocks代表的是你下面配置了几个,比如这个是page0 page1 page2,所以这里就是3
qcom,page1 = <1 0x0A00 2 0x0100 2 1>;/*OTP enable and read start*/
qcom,poll1 = <0 0x0 1 0x0 1 1>;
qcom,mem1 = <60 0x0A04 2 0x0000 2 1>; 表示在寄存器0x0A04写值0x0000,读取的数据是60个,其实0x0A04就是otp的起始地址,从起始地址读取60个数据。
qcom,cam-vreg-name = "cam_vio", "cam_vaf";表示上电,iovdd,af这2路电,由于硬件的设计,所以sensor其他的2路电一起就上了,设计的比较扯淡。
qcom,cam-vreg-type = <0 0>;
qcom,cam-vreg-min-voltage = <1800000 2800000>;表示iovdd上电1.8v,af上电2.8v
qcom,cam-vreg-max-voltage = <1800000 2800000>;
qcom,cam-vreg-op-mode = <80000 100000>;
首先是在kernel读取数据,kernel会对dtsi文件进行解析。
kernel/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c 这个文件里面的msm_eeprom_i2c_probe函数里面进行解析,读数据是在read_eeprom_memory函数里面,直接在kernel_log里面搜索memory_data就可以打印出全部的otp数据。然后会把这个数据传到eeprom驱动里面,就是我们在vendor下面自己加的eeprom驱动。
下面看sensor的
qcom,camera@0 {
cell-index = <0>;
compatible = "qcom,camera";
reg = <0x2>;
qcom,csiphy-sd-index = <0>;
qcom,csid-sd-index = <0>;
qcom,mount-angle = <90>;
qcom,eeprom-src = <&eeprom0 &eeprom2>;
qcom,actuator-src = <&actuator0>;
cam_vdig-supply = <&pm8916_s3>; dvdd
cam_vio-supply = <&pm8916_l10>; iovdd
cam_vaf-supply = <&pm8916_l11>;af
qcom,cam-vreg-name = "cam_vdig","cam_vio", "cam_vaf";
qcom,cam-vreg-type = <0 0 0>; 这里表示的是这路电是LDO 还是LVS的
qcom,cam-vreg-min-voltage = <1400000 1800000 2800000>;
qcom,cam-vreg-max-voltage = <1400000 1800000 2800000>;
qcom,cam-vreg-op-mode = <100000 80000 100000>;
pinctrl-names = "cam_default", "cam_suspend";
pinctrl-0 = <&cam_sensor_mclk0_default &cam_sensor_rear_default>;
pinctrl-1 = <&cam_sensor_mclk0_sleep &cam_sensor_rear_sleep>;
gpios = <&msm_gpio 26 0>, gpios数组是和下面的gpio_req_tbl_lable数组对应 比如gpio26 对应的是CAMIF_MCLK
<&msm_gpio 29 0>, 29对应的是CAM_RESET0
<&msm_gpio 33 0>; 33对应的是CAM_STANDBY
qcom,gpio-reset = <1>;
qcom,gpio-standby = <2>;
qcom,gpio-req-tbl-num = <0 1 2>;
qcom,gpio-req-tbl-flags = <1 0 0>;
qcom,gpio-req-tbl-label = "CAMIF_MCLK",
"CAM_RESET0",
"CAM_STANDBY";
qcom,sensor-position = <0>; position前摄还是后摄
qcom,sensor-mode = <0>;
qcom,cci-master = <0>;
status = "ok";
clocks = <&clock_gcc clk_mclk0_clk_src>,
<&clock_gcc clk_gcc_camss_mclk0_clk>;
clock-names = "cam_src_clk", "cam_clk";
};
上面这个是sensor的
qcom,camera@0 { 0代表后摄
cell-index = <0>;保持和别的不一样
compatible = "qcom,camera";
reg = <0x2>;i2c地址,和sensor驱动保持一致
qcom,csiphy-sd-index = <0>; csi这个需要看硬件原来图,来确认,一般来说,后摄是接在csi0上,所以这里配0,前摄是接在csi1上,所以这里要配置1
qcom,csid-sd-index = <0>;
qcom,mount-angle = <90>;sensor安装角度,90度,如果预览的时候,图像是倒着的或者方向不对,等都可以配置这里
qcom,eeprom-src = <&eeprom0 &eeprom2>;表示和后摄绑定的otp,这个地方有2个,是我当时做后摄的时候,进行二供otp兼容做的,这里表示一供的otp是eeprom0,二供的otp是eeporm2。
qcom,actuator-src = <&actuator0>;这个是表示和后摄绑定的actuator.
sensor的dtsi会在/kernel/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c这个文件里面进行解析,具体可以进去看代码。
下面看actuator的:
actuator0: qcom,actuator@18 {
cell-index = <0>;
reg = <0x18>; i2c地址
compatible = "qcom,actuator";
qcom,cci-master = <0>;
qcom,slave-addr = <0x18>;
cam_vaf-supply = <&pm8916_l11>;
qcom,cam-vreg-name = "cam_vaf";
qcom,cam-vreg-type = <0>;
qcom,cam-vreg-min-voltage = <2800000>;
qcom,cam-vreg-max-voltage = <2800000>;
qcom,cam-vreg-op-mode = <100000>;
};