使用dtb在beaglebone black上启用i2c1

时间:2014-07-18 21:39:17

标签: linux-device-driver beagleboneblack device-tree

我已使用dtb

中的以下行在beagle bone black上启用了I2C总线2
i2c2: i2c@4819c000 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c2_pins>;
    status = "okay";
    clock-frequency = <100000>;
};    

i2c2_pins: pinmux_i2c2_pins {
    pinctrl-single,pins = <
        0x178 0x73  
        0x17c 0x73
    >;
};

但是当我使用下面的代码启用I2C总线时

i2c1: i2c@4802a000 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins>;
    status = "okay";
    clock-frequency = <100000>;
};

i2c1_pins: pinmux_i2c1_pins {
    pinctrl-single,pins = <
        0x154 0x72  /* i2c1_scl.i2c1_scl */
        0x15c 0x72  /* i2c1_sda.i2c1_sda */
    >;
};

总线在i2cdetect -l命令中列出。但是使用i2cdetect -r 1命令探测总线会出现以下错误

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          [   18.322700] omap_i2c 4802a000.i2c: timeout waiting for bus ready
-- [   19.342694] omap_i2c 4802a000.i2c: timeout waiting for bus ready
-- [   20.362695] omap_i2c 4802a000.i2c: timeout waiting for bus ready

我正在使用AM3359芯片的ZCZ封装。任何人都可以指出我在dtb文件中犯的错误吗?

3 个答案:

答案 0 :(得分:1)

问题解决了我启用了错误的行。参考错误的数据表。它应该是

+               i2c1_pins: pinmux_i2c1_pins {
+                       pinctrl-single,pins = <
+                               0x158 0x72      /* uart1_ctsn.i2c2_sda, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
+                               0x15c 0x72      /* uart1_rtsn.i2c2_scl, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
+                       >;
+               };

答案 1 :(得分:0)

@RobHurd

我使用了在这个地方找到的文件https://git.ti.com/ti-linux-kernel/ti-linux-kernel/trees/ti-linux-3.12.y/arch/arm/boot/dts

请找到我添加的补丁

diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index a0efb06..835c973 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -31,6 +31,7 @@
                0x58 (PIN_OUTPUT_PULLUP | MUX_MODE7)    /* gpmc_a6.gpio1_22 */
                0x5c (PIN_OUTPUT_PULLDOWN | MUX_MODE7)  /* gpmc_a7.gpio1_23 */
                0x60 (PIN_OUTPUT_PULLUP | MUX_MODE7)    /* gpmc_a8.gpio1_24 */
+               0x164 (PIN_OUTPUT_PULLUP | MUX_MODE7)
            >;
        };

@@ -41,6 +42,20 @@
            >;
        };

+       i2c1_pins: pinmux_i2c1_pins {
+           pinctrl-single,pins = <
+               0x158 0x72      /* uart1_ctsn.i2c2_sda, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
+                                0x15c 0x72      /* uart1_rtsn.i2c2_scl, SLEWCTRL_SLOW | INPUT_PULLUP | MODE2 */
+           >;
+       };
+
+       i2c2_pins: pinmux_i2c2_pins {
+           pinctrl-single,pins = <
+               0x178 0x73  /* uart1_ctsn.i2c2_sda, SLEWCTRL_SLOW | INPUT_PULLUP | MODE3 */
+               0x17c 0x73  /* uart1_rtsn.i2c2_scl, SLEWCTRL_SLOW | INPUT_PULLUP | MODE3 */
+           >;
+       };
+
        uart0_pins: pinmux_uart0_pins {
            pinctrl-single,pins = <
                0x170 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart0_rxd.uart0_rxd */

@@ -202,6 +223,20 @@
            };

        };
+
+       i2c1: i2c@4802a000 {
+           pinctrl-names = "default";
+           pinctrl-0 = <&i2c1_pins>;
+           status = "okay";
+           clock-frequency = <400000>;
+       };
+
+       i2c2: i2c@4819c000 {
+           pinctrl-names = "default";
+           pinctrl-0 = <&i2c2_pins>;
+           status = "okay";
+           clock-frequency = <400000>;
+       };
    };
diff --git a/arch/arm/boot/dts/am335x-boneblack.dts b/arch/arm/boot/dts/am335x-boneblack.dts
index 2f64afa..0954ac1 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -69,6 +69,15 @@
    };
 };

+&i2c2 {
+   touchcontroller: atmel_maxtouch@4b  {
+       compatible = "atmel,maxtouch";
+       reg = <0x4b>;
+       interrupt-parent = <&gpio2>;
+       interrupts = <1 8>; // gpio2[1] 8
+   };
+};
+
 &lcdc {
    pinctrl-names = "default", "off";
    pinctrl-0 = <&nxp_hdmi_bonelt_pins>;

答案 2 :(得分:-1)

以下命令将启用beaglebone black上的i2c1。 (内核3.8 - 较新的内核不支持bone_capemgr.* 但是

echo BB-I2C1 > /sys/devices/bone_capemgr.8/slots

注意:启用下拉功能。

<强>参考