做驱动的要经常配置i2c,而配置i2c无非就是确定i2c器件挂在哪一个i2c总线上,以及i2c的具体地址.下面以高通8909平台为例子说一下
-
pmx_i2c_1 {
-
i2c_1_active: i2c_1_active {
-
mux {
-
pins =
"gpio6",
"gpio7";
-
function = "blsp_i2c1";
-
};
-
config {
-
pins =
"gpio6",
"gpio7";
-
drive-strength = <
2>;
/* 2 MA */
-
bias-disable;
/* No PULL */
-
};
-
};
-
i2c_1_sleep: i2c_1_sleep {
-
mux {
-
pins =
"gpio6",
"gpio7";
-
function = "blsp_i2c1";
-
};
-
config {
-
pins =
"gpio6",
"gpio7";
-
drive-strength = <
2>;
/* 2 MA */
-
bias-disable;
/* No PULL */
-
};
-
};
-
};
- i2c_1: i2c@78b5000 { /* BLSP1 QUP1 */
- compatible = "qcom,i2c-msm-v2";
- #address-cells = <1>;
- #size-cells = <0>;
- reg-names = "qup_phys_addr";
- reg = <0x78b5000 0x1000>;
- interrupt-names = "qup_irq";
- interrupts = <0 95 0>;
- clocks = <&clock_gcc clk_gcc_blsp1_ahb_clk>,
- <&clock_gcc clk_gcc_blsp1_qup1_i2c_apps_clk>;
- clock-names = "iface_clk", "core_clk";
- qcom,clk-freq-out = <100000>;
- qcom,clk-freq-in = <19200000>;
- pinctrl-names = "i2c_active", "i2c_sleep";
- pinctrl-0 = <&i2c_1_active>;
- pinctrl-1 = <&i2c_1_sleep>;
- qcom,noise-rjct-scl = <0>;
- qcom,noise-rjct-sda = <0>;
- dmas = <&dma_blsp1 4 64 0x20000020 0x20>,
- <&dma_blsp1 5 32 0x20000020 0x20>;
- dma-names = "tx", "rx";
- qcom,master-id = <86>;
- };
在msm8909-mtp.dtsi里i2c@78b5000加入其i2c器件的配置
- i2c@78b5000 { /* BLSP1 QUP1 */
- fm2018@60 {
- compatible = "fortemedia,fm2018";
- reg = <0x60>;
- fm2018,vdd-en = <&sn7325_1gpio 5 0x00>;//p1 58////sn7325,5
- fm2018,pwd-gpio = <&sn7325_gpio 3 0x00>;//p1 26//sn7325,3
- fm2018,rst-gpio = <&sn7325_gpio 2 0x00>;//sn7325,2
- fm2018,int-gpio = <&sn7325_gpio 4 0x4>;//sn7325,4
- };
- };
这个一般是由器件datasheet提供,如我使用的这个期间的i2c地址是0x60,如果不清楚,可以打电话问FAE。