linux_驱动_IIC_设备树配置详解

做驱动的要经常配置i2c,而配置i2c无非就是确定i2c器件挂在哪一个i2c总线上,以及i2c的具体地址.下面以高通8909平台为例子说一下

 

  • 确定i2c机器挂在哪一个i2c总线上
    1. 从原理图得到SDA,SCL对应的gpio,我这个gpio为gpio6,gpio7
    2. 在msm8909-pinctrl.dtsi文件中找到该gpio对应的i2c总线,如下,可见其对应的i2c总线是i2c_1
      
             
             
             
             
      1. pmx_i2c_1 {
      2. i2c_1_active: i2c_1_active {
      3. mux {
      4. pins = "gpio6", "gpio7";
      5. function = "blsp_i2c1";
      6. };
      7. config {
      8. pins = "gpio6", "gpio7";
      9. drive-strength = < 2>; /* 2 MA */
      10. bias-disable; /* No PULL */
      11. };
      12. };
      13. i2c_1_sleep: i2c_1_sleep {
      14. mux {
      15. pins = "gpio6", "gpio7";
      16. function = "blsp_i2c1";
      17. };
      18. config {
      19. pins = "gpio6", "gpio7";
      20. drive-strength = < 2>; /* 2 MA */
      21. bias-disable; /* No PULL */
      22. };
      23. };
      24. };
      	

 



  • 然后在msm8909.dtsi里面查找i2c_1,就可以得到其i2c地址为78b5000

     

  • 	
    1. i2c_1: i2c@78b5000 { /* BLSP1 QUP1 */
    2. compatible = "qcom,i2c-msm-v2";
    3. #address-cells = <1>;
    4. #size-cells = <0>;
    5. reg-names = "qup_phys_addr";
    6. reg = <0x78b5000 0x1000>;
    7. interrupt-names = "qup_irq";
    8. interrupts = <0 95 0>;
    9. clocks = <&clock_gcc clk_gcc_blsp1_ahb_clk>,
    10. <&clock_gcc clk_gcc_blsp1_qup1_i2c_apps_clk>;
    11. clock-names = "iface_clk", "core_clk";
    12. qcom,clk-freq-out = <100000>;
    13. qcom,clk-freq-in  = <19200000>;
    14. pinctrl-names = "i2c_active", "i2c_sleep";
    15. pinctrl-0 = <&i2c_1_active>;
    16. pinctrl-1 = <&i2c_1_sleep>;
    17. qcom,noise-rjct-scl = <0>;
    18. qcom,noise-rjct-sda = <0>;
    19. dmas = <&dma_blsp1 4 64 0x20000020 0x20>,
    20. <&dma_blsp1 5  32 0x20000020 0x20>;
    21. dma-names = "tx", "rx";
    22. qcom,master-id = <86>;
    23. };

     

  • 在msm8909-mtp.dtsi里i2c@78b5000加入其i2c器件的配置

     

    1. i2c@78b5000 { /* BLSP1 QUP1 */
    2. fm2018@60 {
    3. compatible = "fortemedia,fm2018";
    4. reg = <0x60>;
    5. fm2018,vdd-en = <&sn7325_1gpio 5 0x00>;//p1 58////sn7325,5
    6. fm2018,pwd-gpio = <&sn7325_gpio 3 0x00>;//p1 26//sn7325,3
    7. fm2018,rst-gpio = <&sn7325_gpio 2 0x00>;//sn7325,2
    8. fm2018,int-gpio = <&sn7325_gpio 4 0x4>;//sn7325,4
    9. };
    10. };

     

    • i2c器件的具体地址

            这个一般是由器件datasheet提供,如我使用的这个期间的i2c地址是0x60,如果不清楚,可以打电话问FAE。
     

    你可能感兴趣的:(总线类,驱动领域)