Commit https://svnweb.freebsd.org/base?view=revision&revision=356609 breaks the I2C on my Allwinner H5 based NanoPI NEO2. If i revert this one commit, I'm able to use the I2C 0.96" OLED again (CURRENT v362543).
Unfortunately i'm not able to provide much debug information because all the programs using i2c (i2c -s for example) do simply not return. They do provide no error messages, they cannot be aborted via ctrl-c. top(1) shows as state for those processes "twi".
Created attachment 216223 [details]
Fix twsi bug
Could you test the attached patch ?
This fix two things :
When we don't receive an ack we still send a stop bit, some (most/all ?) device don't send a ack for the last transmitted bit. Not doing this make the controller goes crazy.
Some IP (Like H3/H5) have a bug where we need to write to the control register with the interrupt enabled flag after each interrupts have fired once.
This patch works for me.
(In reply to Manuel Stühn from comment #2)
That's good that it works for you but it's still not good :)
I've fixed more bug and will post a new patch tonight (even if not finished).
Created attachment 216261 [details]
Fix twsi bug
Could you test this patch too ?
I still have weird stuff happening but it might be that I'm not talking correctly to the device.
Also the new patch works (was the eeprom@50 change in sun8i-h3-i2c0.dtso intentional?). Nevertheless, i2c -s finds the display at address 0x3C and to the display can be written to.
(In reply to Manuel Stühn from comment #5)
No the dtso was just a local change that I included by mistake.
Thanks for testing, I'll do more work into this and will commit a proper version before saturday after more testing.
A commit references this bug:
Date: Wed Jul 8 19:14:44 UTC 2020
New revision: 363021
twsi: Fix for > Allwinner A20
Every revision of twsi after the A20 have a bug where we need to
write again the control register after each interrupts. We also need
to add some delay before writing to this register, a simple read of the
same register does the job so do that.
Also fix the case when we have finish sending all the bytes, it only worked
for 1 byte transfer (the same kind that we do for talking to the PMIC on A20
While here add more debug messages and rework some of them.
This was tested by talking to a AT23C32 eeprom and a DS3231 RTC from an
H3 and A20 board.
Reported by: Manuel St?hn (email@example.com)
MFC after: 1 week
Tested the commited revision. Works fine for me.