说来惭愧,搬砖也有一段时间了,dtsi里面有些配置还没弄清楚含义,
作为一个咸鱼的搬砖行家,就研究一下吧!
平台:8909
主要参考kernel/Documentation/devicetree/bindings/media/video/msm-cci.txt的注释,加上自我的理解!
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>;
qcom,actuator-src = <&actuator0>;
qcom,led-flash-src = <&led_flash0>;
cam_vana-supply = <&pm8916_l2>;
cam_vdig-supply = <&pm8916_s3>;
cam_vio-supply = <&pm8916_l10>;
cam_vaf-supply = <&pm8916_l11>;
qcom,cam-vreg-name = "cam_vana","cam_vdig","cam_vio", "cam_vaf";
qcom,cam-vreg-type = <0 0 0 0>;
qcom,cam-vreg-min-voltage = <2800000 1500000 1800000 2800000>;
qcom,cam-vreg-max-voltage = <2800000 1500000 1800000 2800000>;
qcom,cam-vreg-op-mode = <200000 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>,
<&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,sensor-position = <0>;
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";
};
1. cell-index = <0>;
唯一标识,用来区分多个摄像头。
源码:
kernel/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
static int32_t msm_sensor_driver_get_dt_data(struct msm_sensor_ctrl_t *s_ctrl){
···
/*
* Read cell index - this cell index will be the camera slot where
* this camera will be mounted
*/
rc = of_property_read_u32(of_node, "cell-index", &cell_id);
if (rc < 0) {
pr_err("failed: cell-index rc %d", rc);
goto FREE_SENSOR_DATA;
}
s_ctrl->id = cell_id;
···
}
按照这里的英文注释,cell index标识camera安装的位置,这个值只要唯一即可!
2. compatible = “qcom,camera”;
匹配节点,驱动和设备的compatible属性相同时,才会调用probe函数。
dtsi里面配置就是设备,下面的源码对应的就是驱动,这两个属性相同。
源码:
kernel/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
static const struct of_device_id msm_sensor_driver_dt_match[] = {
{.compatible = "qcom,camera"},
{}
};
MODULE_DEVICE_TABLE(of, msm_sensor_driver_dt_match);
static struct platform_driver msm_sensor_platform_driver = {
.probe = msm_sensor_driver_platform_probe,
.driver = {
.name = "qcom,camera",
.owner = THIS_MODULE,
.of_match_table = msm_sensor_driver_dt_match,
},
.remove = msm_sensor_platform_remove,
};
3. reg = <0x2>;
i2c地址,从经验来看,只要配置成唯一即可,不过还是推荐配成i2c地址!
未找到源码调用的位置
4. qcom,csiphy-sd-index = <0>;
用于接收传感器数据的csiphy实例,
可以配置的值:0,1,2
源码:
kernel/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
5. qcom,csid-sd-index = <0>;
用于接收传感器数据的csid核心实例
可以配置的值:0,1,2
源码:
kernel/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
6. qcom,mount-angle = <90>;
摄像头在设备上的物理安装角度
可以配置的值:0,90,180,360
一般来说 sensor raw图默认的方向都是90或者270!
7. qcom,eeprom-src = <&eeprom0>;
如果支持otp(eeprom)的话,就配置成各种的eeprom节点,否则不配置。
8. qcom,actuator-src = <&actuator0>;
如果支持马达的话,就配置成各自的马达节点,否则不配置。
9. qcom,led-flash-src = <&led_flash0>;
如果支持闪光灯的话,就配置成各自的闪光灯节点,否则不配置。
10. cam_vana-supply = <&pm8916_l2>;
avdd供电,是否是要配置,配置成哪路系统供电,需要和硬件沟通!
11. cam_vdig-supply = <&pm8916_s3>;
dvdd供电,是否是要配置,配置成哪路系统供电,需要和硬件沟通!
12. cam_vio-supply = <&pm8916_l10>;
iovdd供电,是否是要配置,配置成哪路系统供电,需要和硬件沟通!
13. cam_vaf-supply = <&pm8916_l11>;
马达供电,是否是要配置,配置成哪路系统供电,需要和硬件沟通!
14. qcom,cam-vreg-name等
qcom,cam-vreg-name = “cam_vana”,“cam_vdig”,“cam_vio”, “cam_vaf”;
配置sensor需要的所有电源。
可配置选项:“cam_vdig”, “cam_vana”, “cam_vio”, “cam_vaf”
分别代表含义:dvdd,avdd,iovdd,af供电
不一定要全部配置,用到哪路配哪路,有些电路硬件自己拉高了,具体跟硬件沟通。
qcom,cam-vreg-type = <0 0 0 0>;
指定用于此sensor的电源类型,1表示不使用,0表示使用。
默认配0.
其他配置参考
171 qcom,cam-vreg-type = <0 1>;
172 qcom,cam-vreg-min-voltage = <1200000 0>;
173 qcom,cam-vreg-max-voltage = <1200000 0>;
qcom,cam-vreg-min-voltage = <2800000 1500000 1800000 2800000>;
供电电源的最大值,单位mV
第一个dvdd最大值为2800000mA=2.8V,其他同理
qcom,cam-vreg-max-voltage = <2800000 1500000 1800000 2800000>;
供电电源的最小值,单位mV
第一个dvdd最小值为2800000mA=2.8V,其他同理
qcom,cam-vreg-op-mode = <200000100000 80000 100000>;
供电电源的最佳电压水平。
比如第一个dvdd最佳电压水平为200000
常用值:200000 100000 105000 80000 0
这个节点没有完全理解。
注意:
qcom,cam-vreg-name = "cam_vana","cam_vdig","cam_vio", "cam_vaf";
qcom,cam-vreg-type = <0 0 0 0>;
qcom,cam-vreg-min-voltage = <2800000 1500000 1800000 2800000>;
qcom,cam-vreg-max-voltage = <2800000 1500000 1800000 2800000>;
qcom,cam-vreg-op-mode = <200000 100000 80000 100000>;
这些值分别是按顺序一一对应的!
15. pinctrl-names pinctrl-0 pinctrl-1
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>;
这个也是按照顺序一一对应的。
kernel/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
static int msm_camera_pinctrl_init(struct msm_camera_power_ctrl_t *ctrl)
{
struct msm_pinctrl_info *sensor_pctrl = NULL;
sensor_pctrl = &ctrl->pinctrl_info;
sensor_pctrl->pinctrl = devm_pinctrl_get(ctrl->dev);
···
sensor_pctrl->gpio_state_active =
pinctrl_lookup_state(sensor_pctrl->pinctrl,
CAM_SENSOR_PINCTRL_STATE_DEFAULT);
···
sensor_pctrl->gpio_state_suspend
= pinctrl_lookup_state(sensor_pctrl->pinctrl,
CAM_SENSOR_PINCTRL_STATE_SLEEP);
···
return 0;
}
kernel/arch/arm/boot/dts/qcom/msm8909-pinctrl-i18.dtsi
/*sensors */
cam_sensor_mclk0_default: cam_sensor_mclk0_default {
/* MCLK0 */
mux {
/* CLK, DATA */
pins = "gpio26";
function = "cam_mclk";
};
config {
pins = "gpio26";
bias-disable; /* No PULL */
drive-strength = <2>; /* 2 MA */
};
};
cam_sensor_rear_default: cam_sensor_rear_default {
/* RESET, STANDBY */
mux {
pins = "gpio29", "gpio33";
function = "gpio";
};
config {
pins = "gpio29","gpio33";
bias-disable; /* No PULL */
drive-strength = <2>; /* 2 MA */
};
};
这里的gpio配置成多少,和硬件沟通
pinctrl-1 = <&cam_sensor_mclk0_sleep &cam_sensor_rear_sleep>;
cam_sensor_mclk0_sleep: cam_sensor_mclk0_sleep {
/* MCLK0 */
mux {
/* CLK, DATA */
pins = "gpio26";
function = "cam_mclk";
};
config {
pins = "gpio26";
bias-pull-down; /* PULL DOWN */
drive-strength = <2>; /* 2 MA */
};
};
cam_sensor_rear_sleep: cam_sensor_rear_sleep {
/* RESET, STANDBY */
mux {
pins = "gpio29","gpio33";
function = "gpio";
};
config {
pins = "gpio29","gpio33";
bias-disable; /* No PULL */
drive-strength = <2>; /* 2 MA */
};
};
这里的gpio配置成多少,和硬件沟通
16. gpio相关
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";
这里分别是一一对应的
比如:
26 对应 CAMIF_MCLK
29 对应 CAM_RESET0
33 对应 CAM_STANDBY
qcom,gpio-reset = <1>;
传感器 reset脚的索引,这里是1
qcom,gpio-standby = <2>
传感器 standby脚的索引,这里是2
qcom,gpio-req-tbl-num = <0 1 2>;
mclk,reset,stanby的索引,由于mclk为0,qcom,gpio-reset = <1>,qcom,gpio-standby = <2>
因此配置成 <0,1,2>
qcom,gpio-req-tbl-flags = <1 0 0>;
gpio的方向,mclk为1,表示输出,reset和standby为0,表示输入。
qcom,gpio-req-tbl-label
gpio的名称。
常用值:
“CAMIF_MCLK”, “CAM_RESET”,“CAM_STANDBY”;
“CAMIF_MCLK0”, “CAM_RESET0”,“CAM_STANDBY0”;
“CAMIF_MCLK1”, “CAM_RESET1”,“CAM_STANDBY1”;
“CAMIF_MCLK2”, “CAM_RESET2”,“CAM_STANDBY2”;
17. qcom,sensor-position = <0>;
camera位置。
18. qcom,sensor-mode = <0>;
传感器模式支持
19. qcom,cci-master = <0>;
sensor使用的master id。
可选值:
20. clocks相关
clocks = <&clock_gcc clk_mclk0_clk_src>,
<&clock_gcc clk_gcc_camss_mclk0_clk>;
clock-names = "cam_src_clk", "cam_clk";
30 clock_gcc: qcom,gcc@1800000 {
31 compatible = "qcom,dummycc";
32 #clock-cells = <1>;
33 };
#define clk_mclk0_clk_src 0x266b3853
#define clk_mclk1_clk_src 0xa73cad0c
#define clk_mclk2_clk_src 0x42545468
#define clk_mclk3_clk_src 0x2bfbb714
99static struct msm_cam_clk_info cam_8974_clk_info[] = {
100 [SENSOR_CAM_MCLK] = {"cam_src_clk", 24000000},
101 [SENSOR_CAM_CLK] = {"cam_clk", 0},
102};