The STMicroelectronics STM32MP25 CPU has eight I2C buses that operate at up to 400 Kbps. The CPU facilitates the functionality of both I2C master and slave according to the I2C Bus Specification rev03.

On the ConnectCore MP25:

  • I2C1, I2C2 are available for peripherals to use (multiplexed with other functionality).

On the ConnectCore MP25 Development Kit:

  • I2C1 is available on a connector, which you can use to connect additional devices.

    The following table lists the devices on board the ConnectCore MP25 Development Kit I2C1 bus:

    Interface Address (7-bit)

    Audio codec

    0x10

    The ConnectCore MP25 Development Kit device tree defines the following additional I2C devices:

  • Touch controller at address 0x14, available on AUO 10" LCD display. See https://www.digi.com/products/models/cc-acc-lcdw-10 for details on the AUO 10" LCD kit available from Digi.

  • OmniVision OV5640 CSI camera at address 0x3C, (not included in the kit).

    The display touch controller has I2C address 0x10, but since the audio codec on the ConnectCore MP25 Development Kit also has address 0x10, an I2C address translator on the video adapter board moves the touch controller to address 0x14.
  • The following table lists the devices on board the ConnectCore MP25 Development Kit I2C1 bus:

    Interface Address (7-bit)

    MIPI-to-HDMI bridge LT8912

    0x48,0x49,0x4a

    Real-Time Clock RV3028

    0x52

    I2C1 is also routed to a MikroBus connector to allow for the connection of different MikroE-compatible devices.

Kernel configuration

You can manage the I2C driver support through the kernel configuration:

  • STM I2C interface (CONFIG_I2C_STM32F7)

This kernel configuration option is enabled as built-in on the default ConnectCore MP25 kernel configuration file.

Kernel driver

The driver for the I2C interface is located at:

File Description

drivers/i2c/busses/i2c-stm32f7.c

STM32 I2C controller driver

Device tree bindings and customization

The STM32MP25 I2C interface device tree binding is documented at Documentation/devicetree/bindings/i2c/st,stm32-i2c.yaml.

The I2C interfaces are defined in the CPU, system-on-module, and carrier board device tree files.

Example: I2C2

Define the bus

STM32MP25 device tree
i2c2: i2c@40013000 {
	compatible = "st,stm32mp25-i2c";
	reg = <0x40013000 0x400>;
	interrupt-names = "event";
	interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&rcc CK_KER_I2C2>;
	resets = <&rcc I2C2_R>;
	#address-cells = <1>;
	#size-cells = <0>;
	dmas = <&hpdma 30 0x20 0x00003012 0>,
           <&hpdma 31 0x20 0x00003021 0>;
	dma-names = "rx", "tx";
	feature-domains = <&rifsc STM32MP25_RIFSC_I2C2_ID>;
	power-domains = <&RET_PD>;
	status = "disabled";
};

Configure PINCTRL

ConnectCore MP25 device tree
i2c2_pins_a: i2c2-0 {
	pins {
		pinmux = <STM32_PINMUX('B', 5, AF9)>, /* I2C2_SCL */
			<STM32_PINMUX('B', 4, AF9)>; /* I2C2_SDA */
		bias-disable;
		drive-open-drain;
		slew-rate = <0>;
	};
};

Define attached I2C client devices

ConnectCore MP25 Development Kit device tree
&i2c1 {

	[...]

	goodix_touch@14 {
		compatible = "goodix,gt9271";
		reg = <0x14>;
		interrupt-parent = <&gpiog>;
		interrupts = <1 IRQ_TYPE_EDGE_RISING>;
		irq-gpios = <&gpiog 1 GPIO_ACTIVE_LOW>;
	};

	[...]

Use the I2C bus

The I2C bus driver exposes device data through the sysfs at /sys/class/i2c-dev/.

The correct way to access an I2C device is through a kernel driver. Accessing the I2C bus from the file system can confuse your I2C bus and cause data loss on devices like EEPROMs. The following tools are recommended for debugging purposes only.

I2C device interface

You can access I2C devices on an adapter from user space, through the /dev interface. This support requires that you enable the kernel configuration option I2C device interface (CONFIG_I2C_CHARDEV).

Once you have enabled the option, you can use the /dev/i2c-N device node where N corresponds to the adapter number, starting at zero.

i2c-tools

You can install the i2c-tools package to access the I2C devices from user space. The package contains the following tools:

Tool Description

i2cdetect

Bus scanning

i2cdump

Device register dumping

i2cget

Device register reading

i2cset

Device register setting

All I2C tools operate on a specific I2C bus which is identified by number.

To obtain a formatted list of all I2C adapters on your system, run:

# i2cdetect -l
i2c-1   i2c             STM32F7 I2C(0x0000000040130000)         I2C adapter
i2c-0   i2c             STM32F7 I2C(0x0000000040120000)         I2C adapter

Query the I2C bus using the I2C bus number to find devices connected to that bus:

# i2cdetect 0
i2cdetect: WARNING! This program can confuse your I2C bus
Continue? [y/N] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU 49 4a 4b -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

The example above shows a device on the bus at addresses 0x10. The ones showing UU denote this address is currently in use by a driver, while devices without a registered driver show the address.

Accessing the I2C bus using Digi APIx

An example application called apix-i2c-example is included in the dey-examples-digiapix recipe (part of dey-examples package) of the meta-digi layer. This application is an example of how to write data to an external EEPROM (24FC1026) and read it back using Digi APIx library on the ConnectCore MP25 platform.

Go to GitHub to see the application instructions and source code.

See I2C API for more information about the I2C APIx.