-
Notifications
You must be signed in to change notification settings - Fork 11
ot_i2c_transport
: implement device for external I2C communication
#190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ziuziakowska
wants to merge
4
commits into
lowRISC:ot-9.2.0
Choose a base branch
from
ziuziakowska:ot_i2c_transport
base: ot-9.2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
44c2f0c
[ot] hw/opentitan: ot_i2c_transport: OT I2C Transport implementation
ziuziakowska 9ba6699
[ot] hw: opentitan: add I2C transport device to Kconfig and meson
ziuziakowska d5b0bf8
[ot] docs: opentitan: document I2C transport in `i2c_transport.md`
ziuziakowska f3c8d36
[ot] hw/opentitan: ot_i2c: implement `I2CSlaveClass` `send`
ziuziakowska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# OpenTitan I2C Transport | ||
|
||
The `ot-i2c-transport` device provides a way to execute I2C transactions with QEMU I2C bus devices | ||
through an externally driven `chardev` interface. | ||
|
||
The device can perform read or write transactions with bus devices and is intended to be used to | ||
drive the Opentitan I2C device Target mode functionality through `opentitanlib`. | ||
|
||
## Configuration | ||
|
||
A chardev and transport device can be created in QEMU with the following arguments: | ||
|
||
`-chardev pty,i2ctp -device ot-i2c-transport,bus=<bus>,chardev=i2ctp` | ||
|
||
Where `bus` is any of the system's I2C buses. On earlgrey for example, these are `ot-i2c0`, | ||
`ot-i2c1`, and `ot-i2c2`. | ||
|
||
## Protocol | ||
|
||
- The protocol over the chardev mirrors the I2C specification closely. | ||
|
||
- A start and repeated start condition is signalled with a `s` byte, followed by a byte containing | ||
the 7-bit target address of the transaction and the read/write bit as the least significant bit | ||
(0 indicates a write transfer, 1 indicates a read transfer). | ||
|
||
- On a repeated start condition, the I2C target address of the first transfer will be used, and | ||
the provided address is ignored (transfer direction can be changed). This is a limitation of QEMU. | ||
|
||
- When a read transfer is active, a `R` byte can be sent to read a byte of data from the target | ||
I2C device. | ||
|
||
- When a write transfer is active, a `W` byte, followed by a data byte, can be sent to write that | ||
byte to the target I2C device. | ||
|
||
- A stop condition to end the transaction is signalled with a `S` byte. | ||
|
||
- Following a start/repeated start condition and the address byte, as well as after every byte | ||
written during a write transfer, an ACK is signalled with a `.` byte, and a NACK is signalled with | ||
a `!` byte. If the start of a transfer is NACKed, the transaction should be terminated with a stop | ||
condition. | ||
|
||
- On a parser error, a `x` byte will be returned, and the parser will not accept any more command | ||
bytes until reset. | ||
|
||
- The implementation will throttle processing of written bytes to allow control to return to the | ||
vCPU, so that OT I2C may process the current transaction and prepare response bytes for upcoming | ||
reads. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand how you discriminate signaling (START/STOP/RESTART/ACK/NACK) from payload.
For example in
b's123s123S'
, is the seconds
a restart or the 4th byte of the payload?