i.MX8Dx I2C disable in Linux Yocto

Hi Folks,

Can someone help me with how I can disable the I2C in Linux OS via DTS (by using overlay[dtbo]) without creating a new image by creating some recipe for it?

you can find the required information down here:

Software summary

Bootloader: U-Boot
Kernel version: 5.15.148-6.7.0-devel+git.bfdbfb2c85fb #1 SMP PREEMPT Thu Jun 20 15:59:41 UTC 2024
Kernel command line: root=PARTUUID=fde2e373-02 ro rootwait console=tty1 console=ttyLP3,115200 consoleblank=0 earlycon video=imxdpufb5:off video=imxdpufb6:off video=imxdpufb7:off
Distro name: NAME=“TDX Wayland with XWayland”
Distro version: VERSION_ID=6.7.0-devel-20240704105404-build.0
Distro variant: -

Hardware info

HW model: Toradex Colibri iMX8DX on Colibri Evaluation Board V3
Toradex version: 0052 V1.0D
Processor arch: aarch64

Regards

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


To disable the I2C interface on your Toradex Colibri iMX8DX platform using a Device Tree Source (DTS) overlay without creating a new image or recipe, you can follow these steps:

  1. Create a Device Tree Overlay (DTBO): You need to create a DTS file that modifies the I2C node properties by setting the status property to disabled. Here is an example of what your overlay file might look like:

    /dts-v1/;
    /plugin/;
    / {
        fragment@0 {
            target-path = "/i2c@xxxx";
            __overlay__ {
                status = "disabled";
            };
        };
    };
    

    Replace xxxx with the appropriate address of the I2C controller for your specific hardware setup.

  2. Compile the Overlay: Use the device tree compiler (DTC) to compile your DTS file into a DTBO file. You can do this with a command like:

    dtc -I dts -O dtb -o my_overlay.dtbo my_overlay.dts
    
  3. Load the Overlay at Boot: Ensure that your compiled DTBO file is placed in a location where U-Boot can access it. You will need to modify the U-Boot environment variables to load this overlay during the boot process. This typically involves adding a line to your U-Boot configuration that points to your DTBO file.

  4. Verify the Changes: After rebooting, verify that the I2C interface is disabled by checking the system logs or using tools like i2cdetect to ensure that no I2C devices are detected.

This approach allows you to disable the I2C interface dynamically at runtime without recompiling the entire kernel or creating a new image, which should meet your requirements. Make sure your kernel version supports device tree overlays, and refer to Toradex documentation for any specific configurations related to the I2C interface on your platform.

Please, also check if these links can help you solve your problem:

Touch I2C for Goodix GT928.

Hi @pkg_su!

Sorry for the delayed response.

First, you need to create an overlay that disables the I2C, and to do it, you need to find which node is responsible for the I2C and set the variable status = "disabled". You’ll have something like below:

/dts-v1/;
/plugin/;

&i2c_node {
        status = "disabled";
};

Please refer to the following articles for more information about device trees:
First Steps with Device Trees | Toradex Developer Center
How to Write Device Tree Overlays | Toradex Developer Center

After you have written the overlay, you must create a meta-layer and a .bbappend recipe to add it to an image. Please refer to this article to learn how to create a custom meta-layer. You can see the meta-layer that I created to test it below:

.
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-kernel
    └── linux
        ├── device-tree-overlays
        │   └── verdin-imx8mp_custom-overlay.dts
        └── device-tree-overlays_%.bbappend

And the .bbappend that I used:

FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"

SRC_URI:append = " file://verdin-imx8mp_custom-overlay.dts"

do_collect_overlays:prepend () {
    cp ${WORKDIR}/verdin-imx8mp_custom-overlay.dts ${S}
}

TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT:append = " verdin-imx8mp_custom-overlay.dtbo"

After you’ve added your layer to bblayers.conf and written the .bbappend, you need to build the image. I used tdx-reference-minimal-image, but you can try with tdx-reference-multimedia-image:

MACHINE=verdin-imx8mp bitbake tdx-reference-minimal-image

Feel free to ask if you have any doubts or issues.

Best regards.
Lucas Azeituno.

Hello, so I’m trying to disable i2c2 in the verdin-imx8mm module. I thought that by simply doing this:

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,verdin-imx8mm";

	fragment@0 {
		target = <&i2c2>;
		__overlay__ {
			status = "disabled";
		};
	};
};

It should free up the GPIO, but here’s the output of some commands inside my image that show that these pins are still not freed up:

root@a1b5f757774d:/app# gpioinfo|grep SODIMM_55
        line  16:  "SODIMM_55"        "scl"  output  active-high [used open-drain]
root@a1b5f757774d:/app# gpioinfo|grep SODIMM_53
        line  17:  "SODIMM_53"        "sda"   input  active-high [used open-drain]

Furthermore

root@a1b5f757774d:/app# cat /sys/kernel/debug/pinctrl/pinctrl-handles | grep -A 10 "30a30000.i2c"
device: 30a30000.i2c current state: default
  state: default
    type: MUX_GROUP controller 30330000.pinctrl group: i2c2grp (24) function: pinctrl (0)
    type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_I2C2_SCL (135)config 00000146
    type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_I2C2_SDA (136)config 00000146
  state: gpio
    type: MUX_GROUP controller 30330000.pinctrl group: i2c2gpiogrp (25) function: pinctrl (0)
    type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_I2C2_SCL (135)config 00000146
    type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_I2C2_SDA (136)config 00000146
device: 30a40000.i2c current state: default
  state: default

Any help or guidance as to how I can repurpose these pins as GPIO?

Thanks!

Hi @mateosegura!

Since this topic is solved, I’ll ask you to open another topic in our community. This way we can organize our support and focus on your issue.

For now, I’ll close this topic.

Best regards.
Lucas Azeituno.