The NXP {cpu-family} CPU has four 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 v2.1, but the Linux kernel only contains an I2C bus master driver.

On the ConnectCore 8M Mini:

  • I2C1 connects internally to the power management IC (PMIC), the on-module Micro Controller Assist (MCA), and the Atmel Cryptochip at the following addresses:

    Interface Address (7-bit)

    PMIC

    0x4b

    Cryptochip

    0x60

    MCA

    0x63

On the ConnectCore 8M Mini Development Kit:

  • I2C2, I2C3 and I2C4 are available on the J48 expansion connector, where you can connect additional devices.

  • I2C2 is connected to the on-board audio chip, routed to the MIPI camera so it can connect to an image sensor and routed to the LVDS connector so it can connect to a touch controller.

    Interface Address (7-bit)

    Maxim MAX98089 sound chip

    0x10

    Goodix touch controller

    0x14

    OmniVision CSI camera

    0x3C

  • I2C2 is also available on the miniPCIe connector.

  • I2C3 (which operates at 1.8 V) is connected to the on-board LT8912 MIPI-to-HDMI and SN65DSI83 MIPI-to-LVDS display bridges.

    Interface Address (7-bit)

    SN65DSI83 MIPI-to-LVDS bridge

    0x2C

    LT8912 MIPI-to-HDMI bridge

    0x48

  • I2C3 is also available on the HDMI connector, so it connects with HDMI monitors.

Kernel configuration

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

  • IMX I2C interface (CONFIG_I2C_IMX)

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

Kernel driver

The driver for the I2C interface is located at:

File Description

drivers/i2c/busses/i2c-imx.c

i.MX I2C controller driver

Device tree bindings and customization

The {cpu-family} I2C interface device tree binding is documented at Documentation/devicetree/bindings/i2c/i2c-imx.txt.

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

Example: I2C3

Define the bus

{cpu-family} device tree
i2c3: i2c@30a40000 {
	#address-cells = <1>;
	#size-cells = <0>;
	compatible = "fsl,imx8mm-i2c", "fsl,imx21-i2c";
	reg = <0x30a40000 0x10000>;
	interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clk IMX8MM_CLK_I2C3_ROOT>;
	status = "disabled";
};

Configure IOMUX

ConnectCore 8M Mini Development Kit device tree
&iomuxc {
	pinctrl_i2c3: i2c3grp {
		fsl,pins = <
			MX8MM_IOMUXC_I2C3_SCL_I2C3_SCL			0x400001c3
			MX8MM_IOMUXC_I2C3_SDA_I2C3_SDA			0x400001c3
		>;
	};

	pinctrl_i2c3_gpio: i2c3grp-gpio {
		fsl,pins = <
			MX8MM_IOMUXC_I2C3_SCL_GPIO5_IO18		0x1c3
			MX8MM_IOMUXC_I2C3_SDA_GPIO5_IO19		0x1c3
		>;
	};
};

Enable the bus and define attached client devices

ConnectCore 8M Mini Development Kit device tree
&i2c3 {
	clock-frequency = <100000>;
	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_i2c3>;
	pinctrl-1 = <&pinctrl_i2c3_gpio>;
	scl-gpios = <&gpio5 18 GPIO_ACTIVE_HIGH>;
	sda-gpios = <&gpio5 19 GPIO_ACTIVE_HIGH>;
	status = "okay";

	[...]

	dsi_lvds_bridge: sn65dsi84@2c {
		[...]
	};

	lt_bridge: lt8912@48 {
		[...]
	};

	[...]

};

Using the I2C bus

You can access the I2C bus from your Android application. See I2C API for more information about the I2C APIx.

Sample application

The I2C Sample Application demonstrates the usage of the I2C API. In this example you can access and control an external I2C EEPROM memory. The application can perform read, write, and erase actions, displaying results in a hexadecimal list view.

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