linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Two separate i2c transfers
@ 2020-05-14 12:41 Adamski, Krzysztof (Nokia - PL/Wrocław)
  2020-05-14 14:50 ` Wolfram Sang
  0 siblings, 1 reply; 14+ messages in thread
From: Adamski, Krzysztof (Nokia - PL/Wrocław) @ 2020-05-14 12:41 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-19 12:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 12:41 Two separate i2c transfers Adamski, Krzysztof (Nokia - PL/Wrocław)
2020-05-14 14:50 ` Wolfram Sang
2020-05-15  7:04   ` Adamski, Krzysztof (Nokia - PL/Wrocław)
2020-05-15  7:53     ` Wolfram Sang
2020-05-15  8:51       ` Adamski, Krzysztof (Nokia - PL/Wrocław)
2020-05-15  9:20         ` Wolfram Sang
2020-05-15  9:24           ` Peter Rosin
2020-05-15  9:31             ` Wolfram Sang
2020-05-15  9:46           ` Adamski, Krzysztof (Nokia - PL/Wrocław)
2020-05-15  8:02     ` Peter Rosin
2020-05-15  8:36       ` Adamski, Krzysztof (Nokia - PL/Wrocław)
2020-05-15 21:19         ` Peter Rosin
2020-05-17 21:32           ` Peter Rosin
2020-05-19 12:59             ` Adamski, Krzysztof (Nokia - PL/Wrocław)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).