Use CCI I2C bus from userspace

Hi,

I have dual OV5645 cameras set up for the db820c. I’d like to be able to use the same i2c bus that controls those cameras (I2C2 on the high speed connector) to control a microcontroller, but when I try to use i2c tools from the command line I can’t see any effect on that i2c2 bus. The results of i2cdetect -l are as follows:

i2c-3  i2c  Qualcomm Camera Control Interface
i2c-1  i2c  QUP I2C adapter
i2c-4  i2c  msm hdmi i2c
i2c-2  i2c  QUP I2C adapter
i2c-0  i2c  QUP I2C adapter

I put a probe on the two I2C busses on the LS expansion connector, as well as the I2C bus on the high speed connector that implements the Camera Control Interface, which I will refer to according to their labels in the 820c user manual that I have: I2C0 and I2C1 on the LS connector, and I2C2 on the HS connector, which controls the cameras.

On boot, there is activity on I2C2, and I can detect and use the cameras normally.

I’m trying to access the I2C busses from the command line. Using i2cdetect, when I try i2c-1, the probe on I2C1 shows activity, but any other bus I try (i2c-0, i2c-2) shows no activity on any of the busses. (In fact, it looks like I2C0 is at ~1V constantly and isn’t pulled up?).

When I try to access i2c-3, I get the following error:
Error: Adapter does not have SMBus write byte capability

I’m not entirely sure how the software side i2c devices match up with the hardware i2c busses (except that i2c-1 and I2C1 correspond).

Is it possible to use the I2C2 bus that controls the cameras? I can’t use other I2C busses due to the constraints of my application.

Which software snapshot/release are you running?

You should look at the db820c schematics for that and the device tree.

LS I2C0  = APQ8096 BLSP1_I2C2 2I2C = linux i2c-0
LS I2C1  = APQ8096 BLSP2_I2C1 I2C  = linux i2c-1
HS I2C3  = APQ8096 BLSP2_I2C0 I2C  = linux i2c-2
HS I2C2  = APQ8096 CCI0 I2C        = linux i2c-3

In older kernel i2c-3 (LS-I2C2/CCI0) is not compatible with SMBus, so you can not use it with i2cdetect (newer kernel enable this). But you can use it as a standard i2c bus.

Right now I’m running 4.14, with the 428 snapshot.

I’m not sure how else to access a standard i2c bus in linux. The only way I’ve seen used before is i2cdetect and other command line tools. Could you point me in the direction of how to use an i2c bus without SMBus?

Thanks again for the help! I was able to use ioctl in a simple c program to successfully access the i2c-3 bus. I used this code as a guideline: https://gist.github.com/JamesDunne/9b7fbedb74c22ccc833059623f47beb7.

It seems like you were right that the CCI bus wasn’t accessible from SMBus.