Two separate i2c transfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a problem that I think cannot be currently easily addressed by I2C framework in the kernel and I'm seeking for an
advice on how to approach this. I have an I2C device that can be accessed from two I2C masters connected to I2C bus
master selector channels. Both masters must do such a sequence before performing long operation:

1. Read status register.
2. If busy flag is not set - write to a register to start operation (this sets busy flag), otherwise exit.

but we cannot call "start operation" if busy flag is already set.

We can solve this problem by keeping our channel selected by BMS between operation 1 and 2 but that is not possible via
i2c framework right now as i2c_mux_master_xfer() will always do select(); i2c_transfer(); deselect() and we need to do
two separate calls to i2c_transfer() (as we have to skip the 2nd one if busy flag is returned by the first one).

There is no way to pass flags to the I2C transfer currently, we can only pass flags to individual messages. A dirty
solution would be to introduce a flag like I2C_M_NO_DESELECT that would be checked in the first (or last) message passed
to i2c_mux_master_xfer() (it would be ignored by normal i2c adapters) before calling deselect(). I'm afraid, however,
that we might need something similar for select as I imagine some i2c muxes might return NAK if you try to select some
channel while other is already selected. But maybe there is some better way of handling that you could suggest?

I imagine this is not a really common scenario but also think we might not be the only ones with such a need technically
this is achievable - the only problem is we cannot express this in current code.

Best regards,
Krzysztof Adamski



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux