I2C

The Inter-Integrated Circuit (I2C) interface is a two-wire, bidirectional serial bus that provides a simple and efficient method for data exchange among devices. The phyCORE-i.MX7 SOM supports up to four independent I2C modules. This guide provides information on how to view, access, and interact with the I2C interfaces on the phyBOARD-i.MX7 development kit.

Viewing I2C devices

  • Power on the development kit and boot into Linux.

  • List the available I2C devices. There will be a few devices that appear in /dev/ and each is a different I2C interface.

    Target (Linux)
    ls /dev/i2c*
    
  • You should see some device files, one of which (device /dev/i2c-0) corresponds to the I2C1 interface on the phyCORE-i.MX7.

    I2C Devices

    Hardware Interface

    Sysfs Path

    I2C0

    /dev/i2c-0

    I2C2

    /dev/i2c-1

    I2C3

    /dev/i2c-2

    I2C4

    /dev/i2c-3

    Note

    The I2C3 is disabled by default and it is normal to have the device i2c-2 unlisted in sysfs.

  • List all the I2C busses in the system.

    The i2c-tools package contains a heterogeneous set of I2C tools to interact with I2C slave devices from userspace. BSP images have i2c-tools packaged by default

    Target (Linux)
    i2cdetect -l
    
    Expected Output
    root@phyboard-zeta-imx7d-1:~# i2cdetect -l
    i2c-0   i2c             30a20000.i2c                            I2C adapter
    i2c-3   i2c             30a50000.i2c                            I2C adapter
    

I2C1 Devices

The I2C1 interface is heavily utilized on the phyCORE-i.MX7 development kit. Devices onboard the SOM such as EEPROM, RTC and PMIC are all connected on this bus. In addition, I2C1 is routed out to the Expansion Board with default jumper configurations set.

  • Use i2cdetect from Linux to scan the bus for devices. This command outputs the address of all devices on the I2C1 bus.

    Target (Linux)
    i2cdetect -y -r 0
    
    Expected Output
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- UU -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: UU -- -- -- -- -- -- -- 58 -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --
    

Note

  • UU indicates that the device connected is tied to a driver. You will be unable to talk to this device via i2c command (i2cset and i2cget).

  • The EEPROM M24C32 has two different addresses (0x50 and 0x58) but one has been reserved in the device tree.

  • These detected interfaces match with the devices connected to I2C1 on the development kit.

    I2C1 Interfaces

    Interface

    Address

    Description

    PMIC

    0x08

    Power Management IC

    EEPROM

    0x50

    4kB EEPROM on SOM

    RTC

    0x68

    External RTC on SOM