[Letux-kernel] jz4730-i2c

H. Nikolaus Schaller hns at goldelico.com
Sun Feb 14 17:29:04 CET 2021

Hi Paul,

> Am 13.02.2021 um 16:22 schrieb Paul Boddie <paul at boddie.org.uk>:
>> sends out data packets with 0 bytes. So it should just send STA + address +
>> ACK + STO.
> This is indeed one of the annoying problems. What my code does is this...
> 1. Send start (STA)
> 2. Set address
> 3. Indicate data valid (DRF)
> 4. Wait for interrupt condition...
> 5. If transferring (STX), keep waiting (return to #4)
> 6. Otherwise, if neither DRF or NACK are set, keep waiting (return to #4)
> As I noted before, waiting for an interrupt condition is just "handle an 
> interrupt request" in the given context. Technically, I have a timeout, but 
> this is hardly ever needed, and I don't do anything other than report it and 
> keep testing for the flags if it does occur.

* why do you wait for interrupt at all?
* polling for STX doesn't seem necessary from the Flow Chart

I have tried to make the IRQ go away when I do not want to send more data but
had no success so far. Neither setting the DR but not DRF oder just setting DRF
without providing new value for DR did help.

So I tried to wait for DRF=0 in the interrupt handler but it does not seem to
influence how interrupts work. So mixing poling into a completely interrupt driven
driver doesn't seem to work well...

New idea: I could add another logging mechanism to jz4730_i2c_readb/jz4730_i2c_updateb
to check after each operation if the I2C IRQ status changes. Tracing this should reveal
if there really is a clear mapping of status bits and register read/write activities
to IRQ.


More information about the Letux-kernel mailing list