Use I2C2 on Colibri i.MX7D with Aster board

Hi,

I’m working on a project that needs to have the I2C2 bus on the Aster board available on Linux.

From the datasheets of the Colibri i.MX7 SOM and the Aster board I’ve noticed that the PINs needed for the I2C2 bus are configured by default to be used for an SPI bus (ecspi3 on the Aster board).

So I’ve edited the device tree, removing the definition of the SPI bus that was using the same PINs and configuring the new I2C2 bus. This is the patch I’ve implemented:

diff --git a/arch/arm/boot/dts/imx7-colibri-aster.dtsi b/arch/arm/boot/dts/imx7-colibri-aster.dtsi
index 6576ef5..0dddde2 100644
--- a/arch/arm/boot/dts/imx7-colibri-aster.dtsi
+++ b/arch/arm/boot/dts/imx7-colibri-aster.dtsi
@@ -79,30 +79,11 @@
        status = "okay";
 };
 
-&ecspi3 {
-       fsl,spi-num-chipselects = <2>;
-       cs-gpios = <
-               &gpio4 11 GPIO_ACTIVE_HIGH
-               &gpio4 23 GPIO_ACTIVE_HIGH
-       >;
-       pinctrl-names = "default";
-       pinctrl-0 = <&pinctrl_ecspi3 &pinctrl_ecspi3_cs &pinctrl_gpio5>;
+&fec1 {
        status = "okay";
-
-       spidev0: spidev@0 {
-               compatible = "toradex,evalspi";
-               reg = <0>;
-               spi-max-frequency = <23000000>;
-       };
-
-       spidev1: spidev@1 {
-               compatible = "toradex,evalspi";
-               reg = <1>;
-               spi-max-frequency = <23000000>;
-       };
 };
 
-&fec1 {
+&i2c2 {
        status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/imx7-colibri.dtsi b/arch/arm/boot/dts/imx7-colibri.dtsi
index 16505eb..33f4bda 100644
--- a/arch/arm/boot/dts/imx7-colibri.dtsi
+++ b/arch/arm/boot/dts/imx7-colibri.dtsi
@@ -101,14 +101,6 @@
        arm-supply = <&reg_DCDC2>;
 };
 
-/* Colibri SPI */
-&ecspi3 {
-       fsl,spi-num-chipselects = <1>;
-       cs-gpios = <&gpio4 11 GPIO_ACTIVE_HIGH>;
-       pinctrl-names = "default";
-       pinctrl-0 = <&pinctrl_ecspi3 &pinctrl_ecspi3_cs>;
-};
-
 &fec1 {
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&pinctrl_enet1>;
@@ -237,6 +229,12 @@
        };
 };
 
+&i2c2 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c2>;
+};
+
 &i2c4 {
        clock-frequency = <100000>;
        pinctrl-names = "default";
@@ -485,20 +483,6 @@
                >;
        };
 
-       pinctrl_ecspi3_cs: ecspi3-cs-grp {
-               fsl,pins = <
-                       MX7D_PAD_I2C2_SDA__GPIO4_IO11           0x14
-               >;
-       };
-
-       pinctrl_ecspi3: ecspi3-grp {
-               fsl,pins = <
-                       MX7D_PAD_I2C1_SCL__ECSPI3_MISO          0x2
-                       MX7D_PAD_I2C1_SDA__ECSPI3_MOSI          0x2
-                       MX7D_PAD_I2C2_SCL__ECSPI3_SCLK          0x2
-               >;
-       };
-
        pinctrl_flexcan2: flexcan2-grp {
                fsl,pins = <
                        MX7D_PAD_GPIO1_IO14__FLEXCAN2_RX        0x59
@@ -531,6 +515,13 @@
                >;
        };
 
+       pinctrl_i2c2: i2c2-grp {
+                fsl,pins = <
+                       MX7D_PAD_I2C2_SDA__I2C2_SDA             0x4000007f
+                       MX7D_PAD_I2C2_SCL__I2C2_SCL             0x4000007f
+                >;
+       };
+
        pinctrl_i2c4: i2c4-grp {
                fsl,pins = <
                        MX7D_PAD_ENET1_RGMII_TD3__I2C4_SDA      0x4000007f

I’ve connected to the Aster board a device (an accelerometer) to the I2C2 PINs but I’m not able to detect it from userspace:

$ i2cdetect -y 1                                    
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

I’ve tested the same device on the I2C4 bus (removing the touch screen of the Toradex capacitive display that will be needed for this project) with this result:

$ i2cdetect -y 3                                    
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1f 
20: -- 21 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 

This last result is what I’m expecting from this particular device.

Is it possible to use those PINs as I2C with the Aster board?

Thanks,

Roberto

It’s not possible to use I2C on this pins with Aster, due to the levelshifter chip used.

Ok, thanks.

Is it possible to do that with the Iris board? The SODIMM Pin 86 and 88 are available on the X16 connector (PINs 9 and 8) on the Iris board.

Thanks,

Roberto

Yes, it should work on Iris, just make sure that you have pull-up resistors on the board you’re connecting.

Thanks a lot, I did a quick test and it seems that on the Iris board I can detect the device with i2cdetect connecting it to PINs 8 and 9 (plus Vin and GND) on the X16 connector.

Thanks,

Roberto

Your are welcome. Thanks for the update.