The STMicroelectronics STM32MP15 CPU has six 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 MP15:

  • I2C4 connects internally to the power management IC (PMIC).

    Interface Address (7-bit)

    PMIC

    0x33

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

On the ConnectCore MP15 Development Kit:

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

    The following table lists the devices on board the ConnectCore MP15 Development Kit I2C2 bus:

    Interface Address (7-bit)

    Audio codec

    0x10

    The ConnectCore MP15 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-lcdh-10 for details on the AUO 10" LCD kit available from Digi.

  • Touch controller at address 0x14, available on Fusion 10"/7" LCD display, (not included in the kit).

  • 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 MP15 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 MP15 Development Kit I2C6 bus:

    Interface Address (7-bit)

    MIPI-to-HDMI bridge LT8912

    0x48,0x49,0x4a

    Real-Time Clock RV3028

    0x52

    I2C6 is also routed to a MikroE 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 MP15 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 STM32MP15 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

STM32MP15 device tree
i2c2: i2c@40013000 {
	compatible = "st,stm32mp15-i2c";
	reg = <0x40013000 0x400>;
	interrupt-names = "event", "error";
	interrupts-extended = <&exti 22 IRQ_TYPE_LEVEL_HIGH>,
			      <&intc GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&rcc I2C2_K>;
	resets = <&rcc I2C2_R>;
	#address-cells = <1>;
	#size-cells = <0>;
	dmas = <&dmamux1 35 0x400 0x80000001>,
	       <&dmamux1 36 0x400 0x80000001>;
	dma-names = "rx", "tx";
	power-domains = <&pd_core>;
	st,syscfg-fmp = <&syscfg 0x4 0x2>;
	wakeup-source;
	i2c-analog-filter;
	status = "disabled";
};

Configure PINCTRL

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

Define attached I2C client devices

ConnectCore MP15 Development Kit device tree
&i2c2 {

	[...]

	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-6   i2c             STM32F7 I2C(0x5c009000)                 I2C adapter
i2c-4   i2c             STM32F7 I2C(0x5c002000)                 I2C adapter
i2c-2   i2c             STM32F7 I2C(0x40013000)                 I2C adapter

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

# i2cdetect 2
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: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
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.

You can dump the registers of any of these devices using the i2cdump command with the I2C bus number as the first argument and the chip address as the second argument:

# i2cdump 2 0x10
i2cdump: 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    0123456789abcdef
00: XX XX XX 04 11 33 43 04 11 33 43 04 11 33 43 04    XXX??3C??3C??3C?
10: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
20: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
30: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
40: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
50: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
60: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
70: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
80: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
90: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
a0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
b0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
c0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
d0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
e0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?
f0: 11 33 43 04 11 33 43 04 11 33 43 04 11 33 43 04    ?3C??3C??3C??3C?

Access 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 MP15 platform.

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

See I2C API for more information about the I2C APIx.