How to determine which Linux i2c adaptor is associated with specific bus

59 Views Asked by At

I am building a Linux system based on a SoC that has an FPGA. The system has multiple i2c busses based on both "hard" IP and instances of a soft IP that I am implementing in the FPGA. My attempts to define the order of the adapters in Device Tree are failing. The kernel.org states

Adapter numbers are assigned somewhat dynamically, so you can not assume much about them. They can even change from one boot to the next.

I can view the adapters list

i2cdetect -l
i2c-1   i2c             i2c-ocores                              I2C adapter
i2c-2   i2c             i2c-ocores                              I2C adapter
i2c-0   i2c             Synopsys DesignWare I2C adapter         I2C adapter

or

head /sys/class/i2c-dev/i2c-*/name
==> /sys/class/i2c-dev/i2c-0/name <==
Synopsys DesignWare I2C adapter

==> /sys/class/i2c-dev/i2c-1/name <==
i2c-ocores

==> /sys/class/i2c-dev/i2c-2/name <==
i2c-ocores

(The above is a simplified example but shows that multiple busses may display same name).

I am looking for an explicit method to assign numbers to the busses (through a Device Tree) or reliable way to detect which adapter is associated with which bus

I tried changing the order and descriptors in the Device Tree but that didn't yield results.

Another page at kernel.org gives me a hint that what I am looking for may be possible

Method 1: Declare the I2C devices statically. This method is appropriate when the I2C bus is a system bus as is the case for many embedded systems. On such systems, each I2C bus has a number which is known in advance. It is thus possible to pre-declare the I2C devices which live on this bus.

but I cannot figure out how.

0

There are 0 best solutions below