Re: Sony IMX290/462 image sensors I2C xfer peculiarity

Krzysztof Hałasa
2023-10-11T11:26:07Z

Stefan,

> I cannot answer whether the delay is needed for atomic transfer or not.
> But I can give a bit of context for I2C atomic transfers in general.
>
> These where only introduced for a very narrow and special uses shutting
> down the device/power with external PMICs in the kernel's shutdown
> handlers.

Well, I guess I'm abusing this code a bit.

The problem is I use Sony IMX290 and IMX462 image sensors, and they have
an apparently hard-coded timeout of about 2^18 their master clock cycles
(= ca. 7 ms with my setup). After the timeout they simply disconnect
from the I2C bus. Of course, this isn't mentioned in the docs.
Unfortunately, "normal" I2C accesses take frequently more than those
7 ms (mostly due to scheduling when all CPU cores are in use). So I
hacked the IMX I2C driver a bit and now all accesses to the sensor use
the atomic paths and local_irq_save() (inside the driver only).

> My understand is that an ordinary I2C device would just use normal (and
> sleepable) I2C transfers while the device is in use.

You are spot-on here :-) Now I use IMX 290 and 462.

OTOH I wonder if such issues are limited to those sensors only.

Thanks for your immediate response,