高通I2C control及gpio模拟添加I2C设备

来源:互联网 发布:下载默默软件 编辑:程序博客网 时间:2024/06/07 01:10

高通810,要用camera专用的CCI I2C(GPIO19,GPIO20)接口连外设,查看CCI I2C的调用,非常复杂,涉及到camera的子设备什么,不想去研究用法。

GOIO模拟I2c:

内核已经自带i2c-gpio.c支持模拟GPIO,所要做的就是配置。

打开内核的i2c-gpio功能,在defconfig文件中打开CONFIG_I2C_GPIO=y;

配置I2C GPIO及外设

&soc {
 75     i2c@0 {
 76         compatible = "i2c-gpio";
 77         gpios = <&msm_gpio 19 0 /* sda */
 78             &msm_gpio 20 0 /* scl */
 79             >;
 80         i2c-gpio,sda-open-drain;
 81         i2c-gpio,scl-open-drain;
 82         i2c-gpio,delay-us = <5>;
 83         #address-cells = <1>;
 84         #size-cells = <0>;
 85         ndt@50 {
 86             compatible = "ndt,77020";
 87             reg = <0x50>;
 88             ndt_vdd-supply = <&pm8994_l29>;
 89             ndt,vdd = "ndt_vdd";
 90             ndt_vio-supply = <&pm8994_lvs1>;
 91             ndt,vio = "ndt_vio";
 92             ndt,reset_gpio = <&msm_gpio 104 0>;
 93             qcom,slave-address = <0x50>;
 94         };
 95     };
 96 };

附件测试程序,可以编译进内核,通过写ndt_write_i2c节点测量波形输出。


其它尝试

将CCI的I2C配成BLSP QUP方式使用,查看文档,GPIO19,GPIO20可以配成BLSP4 bit0、bit1,添加了I2C control

2679     i2c_4: i2c@f9926000 {
2680         compatible = "qcom,i2c-msm-v2";
2681         #address-cells = <1>;
2682         #size-cells = <0>;
2683         reg-names = "qup_phys_addr";
2684         reg = <0xf9926000 0x1000>;
2685         interrupt-names = "qup_irq";
2686         interrupts = <0 98 0>;
2687         qcom,clk-freq-out = <100000>;
2688         qcom,clk-freq-in  = <19200000>;
2689         clock-names = "iface_clk", "core_clk";
2690         clocks = <&clock_gcc clk_gcc_blsp1_ahb_clk>,
2691              <&clock_gcc clk_gcc_blsp1_qup4_i2c_apps_clk>;
2692 
2693         pinctrl-names = "i2c_active", "i2c_sleep";
2694         pinctrl-0 = <&i2c_4_active>;
2695         pinctrl-1 = <&i2c_4_sleep>;
2696         qcom,noise-rjct-scl = <0>;
2697         qcom,noise-rjct-sda = <0>;
2698         dmas = <&dma_blsp1 16 64 0x20000020 0x20>, //不确定,缺少芯片资料
2699             <&dma_blsp1 17 32 0x20000020 0x20>; //不确定,缺少芯片资料
2700         dma-names = "tx", "rx";
2701         qcom,master-id = <86>;
2702         status = "ok";
2703  };


I2C对应PIN脚指定

1648         pmx_i2c_4 {
1649             qcom,pins = <&gp 19>, <&gp 20>;
1650             qcom,num-grp-pins = <2>;
1651             qcom,pin-func = <3>;
1652             label = "pmx_i2c_4";
1653 
1654             i2c_4_active: i2c_4_active {
1655                 drive-strength = <2>;
1656                 bias-disable;
1657             };
1658 
1659             i2c_4_sleep: i2c_4_sleep {
1660                 drive-strength = <2>;
1661                 bias-disable;
1662             };
1663         };


I2c外设添加

 &soc {
 55     i2c@f9924000 {
 56         status = "ok";
 57         #address-cells = <1>;
 58         #size-cells = <0>;
 59         qcom,clk-freq-out = <100000>;
 60         ndt@50 {
 61             compatible = "ndt,77020";
 62             reg = <0x50>;
 63             ndt_vdd-supply = <&pm8994_l29>;
 64             ndt,vdd = "ndt_vdd";
 65             ndt_vio-supply = <&pm8994_lvs1>;
 66             ndt,vio = "ndt_vio";
 67             ndt,reset_gpio = <&msm_gpio 104 0>;
 68             qcom,slave-address = <0x50>;
 71         };
 72     };
 73 };

写了各测试模块,I2C外设正常添加成功,写节点测试I2C写操作,但每次都fail,提示gpio misconfigure.研究一周无果。

0 0