Skip to content
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

Add support for {Read,Write}NoAddrIncr SPI operations, leverage them in transceivers #1768

Merged
merged 3 commits into from
May 3, 2024

Conversation

Aaron-Hartwig
Copy link
Contributor

Part 1) Adjustments to fpga-api/src/lib.rs, fpga-server/src/main.rs, and fpga.idol for the new SPI operations.

As of oxidecomputer/quartz#139 the FPGA's SPI peripheral supports these operations. Prior to this PR the FPGA drivers did not take an operation argument for read operations because there was only a single type of read. Now that there are two (Read and ReadAddrNoIncr), the intended operation must be specified. Given that up until this point Read was the only option (and will probably remain the primary use 99.9% of the time) that has been made the default for the read operation which the majority of callers use. To utilize the new read operation, one can just call the underlying read_bytes function which takes a ReadOp parameter.

Part 2) Making use of the new SPI operations in the transceivers code

This also implements their use for transceivers I2C buffers for the QSFP FPGA design. All the *_regs.* files are generated from the FPGA build process and are brought in alongside the .bit file. The transceivers code has been reworked to leverage the SPI refactoring from oxidecomputer/quartz#146. This code utilizes the non-address incrementing SPI operations to read/write to the I2C buffers in the FPGA.

same address. These operations are useful for exposing FIFO-like interfaces
via a single memory-mapped address location.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the removed comment a couple lines down, explaining why the enum only contains a subset of the operations, was kinda useful. Adding a single line comment to each op enum saying something like

/// This is just reads; for writes, see WriteOp

would help avoid confusing readers, I think.

Also implement their use for transcievers I2C buffers for the QSFP
FPGA design.
drv/sidecar-front-io/src/transceivers.rs Outdated Show resolved Hide resolved
drv/sidecar-front-io/src/transceivers.rs Outdated Show resolved Hide resolved
@Aaron-Hartwig
Copy link
Contributor Author

My latest push rebases this, fixes an FPGA bug, and addresses the review comments. Thank you both very much! I'll be queuing this up for auto-merge.

@Aaron-Hartwig Aaron-Hartwig enabled auto-merge (squash) May 3, 2024 14:32
@Aaron-Hartwig Aaron-Hartwig merged commit dd68570 into master May 3, 2024
104 checks passed
@Aaron-Hartwig Aaron-Hartwig deleted the aaron/fpga-spi-more-ops branch May 3, 2024 14:37
Aaron-Hartwig added a commit that referenced this pull request May 20, 2024
#1768 did not properly account for the FIFO behavior of the FPGA's data
buffers. The "check the status byte" portion of the loop happened
outside the part where we read the buffer, and since the buffer was just
memory-mapped registers it could be repeatedly without consequence.
Since the data was now in a FIFO, I was inadvertently draining the FIFO
before the transaction was done. This PR consolidates the "is I2C done
yet" logic into the `get_i2c_status_and_read_buffer` so calling code can
just deal with the status register and the data buffer.

Fixes #1786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants