| 6820d578 | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: support more message combinations in transfers
Most prominently, add support for a transfer where a write with no-stop flag is followed by a write with no-start flag. Logically, it's a single
twsi: support more message combinations in transfers
Most prominently, add support for a transfer where a write with no-stop flag is followed by a write with no-start flag. Logically, it's a single larger write, but consumers may want to split it like that because one part can be a register ID and the other part can be data to be written to (or starting at) that register.
Such a transfer can be created by i2c tool and iic(4) driver, e.g., for an EEPROM write at specific offset: i2c -m tr -a 0x50 -d w -w 16 -o 0 -c 8 -v < /dev/random
This should be fixed by new code that handles the end of data transfer for both reads and writes. It handles two existing conditions and one new. Namely: - the last message has been completed -- end of transfer; - a message has been completed and the next one requires the start condition; - a message has been completed and the next one should be sent without the start condition.
In the last case we simply switch to the next message and start sending its data. Reads without the start condition are not supported yet, though. That's because we NACK the last byte of the previous message, so the device stops sending data. To fix this we will need to add a look-ahead at the next message when handling the penultimate byte of the current one.
This change also fixed a bug where msg_idx was not incremented after a read message. Apparently, typically a read message is a last message in a transfer, so the bug did not cause much trouble.
PR: 258994
(cherry picked from commit ff1e8581806f70e54fecddf8a6a23488dc7b968a)
show more ...
|
| 86af87ac | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: make data receiving code safer
Assert that we are not receiving data beyond the requested length. Assert that we have not NACK-ed incoming data prematurely. Abort the current transfer if the i
twsi: make data receiving code safer
Assert that we are not receiving data beyond the requested length. Assert that we have not NACK-ed incoming data prematurely. Abort the current transfer if the incoming data is NACK-ed or not NACK-ed unexpectedly.
Add debug logging of received data to complement logging of sent data.
(cherry picked from commit 00c07d9559c6197957b00811a0b29876a5c8b573)
show more ...
|
| 74f17520 | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: remove redundant write of control register
The write at the end of twsi_intr() already handles all cases, no need to have another write for TWSI_STATUS_START / TWSI_STATUS_RPTD_START.
(cherry
twsi: remove redundant write of control register
The write at the end of twsi_intr() already handles all cases, no need to have another write for TWSI_STATUS_START / TWSI_STATUS_RPTD_START.
(cherry picked from commit aeacf172fd29b16b3661ff057c9abb238baba813)
show more ...
|
| 0f048f19 | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: unify error handling, explicitly handle more conditions
twsi_error() is a new function that stops the current transfer and sets up softc when an error condition is detected. TWSI_STATUS_DATA_W
twsi: unify error handling, explicitly handle more conditions
twsi_error() is a new function that stops the current transfer and sets up softc when an error condition is detected. TWSI_STATUS_DATA_WR_NACK, TWSI_STATUS_BUS_ERROR and TWSI_STATUS_ARBITRATION_LOST are now handled explicitly rather than via the catch-all unknown status.
Also, twsi_intr() now calls wakeup() in a single place when the transfer is finished.
(cherry picked from commit a4fe8922085dfc1e5e6a6bac73ccc738e373165f)
show more ...
|
| 22989451 | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: improve a handful of debug messages
- use 0x prefix for hex values - print indexes and counts as decimals - break too long lines
(cherry picked from commit 578707ed4efda4ec1c91ab1a8f1bace6b1e
twsi: improve a handful of debug messages
- use 0x prefix for hex values - print indexes and counts as decimals - break too long lines
(cherry picked from commit 578707ed4efda4ec1c91ab1a8f1bace6b1eb714a)
show more ...
|
| a138038f | 26-Nov-2021 |
Andriy Gapon <[email protected]> |
twsi: compile in support for debug messages, disabled by default
Debug messages can now be enabled per driver instance via a new sysctl. Also, debug messages in TWSI_READ and TWSI_WRITE require debu
twsi: compile in support for debug messages, disabled by default
Debug messages can now be enabled per driver instance via a new sysctl. Also, debug messages in TWSI_READ and TWSI_WRITE require debug level greater than 1 as they are mostly redundant because callers of those functions already log most interesting results.
NB: the twsi drivers call their device iichb, so the new sysctl will appear under dev.iichb.N.
(cherry picked from commit a2793d6182256b8edf647c11c642ad3c7c83809e)
show more ...
|
| 63050205 | 07-Sep-2020 |
Andriy Gapon <[email protected]> |
twsi: some variants clear interrupt flag by writing 0, others by writing 1
Make that distinction more explicit and regular in the code. The difference in behavior is documented in the respective dat
twsi: some variants clear interrupt flag by writing 0, others by writing 1
Make that distinction more explicit and regular in the code. The difference in behavior is documented in the respective datasheets.
Previously, the code handled the distinction by writing the control register multiple times where at least one write was zero and another was one.
This can be considered a follow-up to r363021.
Reviewed by: manu MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D26308
show more ...
|