commit | 02b2c0a6067cc654457be84ec5faa6ea8e8bdcbc | [log] [tgz] |
---|---|---|
author | Jes B. Klinke <jbk@chromium.org> | Tue May 24 14:21:19 2022 -0700 |
committer | cfrantz <frantzcj+github@gmail.com> | Thu Jun 09 12:03:57 2022 -0700 |
tree | 9313c386d723845cb1e44a7bb1873fcf2b294faf | |
parent | 97ff9d74d47328fc9a0a17947ec1a084ed437776 [diff] |
[opentitantool]: Allow SPI chip select across transactions While implementing TPM communication, I came across a use case in which I wanted to perform a few SPI transfers, inspect the data that was read, and then possibly issue some more SPI transfers, while keeping CS asserted throughout. The current `spi::Target` interface is such that `run_transaction()` keeps CS asserted for the duration of the list of transfers given in the parameter list and then deasserts it unconditionally, with no option to add more based on the result of the previous ones. This PR introduces an explicit `assert_cs()` function, which can be used to keep CS asserted across multiple invocations of `run_transaction()`, like below. ``` let spi = ...; { let _cs_asserted = spi.assert_cs()?; spi.run_transaction(...)?; if ... { spi.run_transaction(...)?; } // CS will automatically deassert here (or earlier if bailing out.) } ``` Furthermore, `assert_cs()` counts its invocations, and releases CS only when every nested assertion has been released, such that if the above code was part of a helper method, and the called wanted to make several invocations of the helper, during a single CS session, then it could put another `assert_cs()` around its logic. Signed-off-by: Jes B. Klinke <jbk@chromium.org> Change-Id: I219f3647d29129c4dfc1fc346f855fb4e9da2e53
OpenTitan is an open source silicon Root of Trust (RoT) project. OpenTitan will make the silicon RoT design and implementation more transparent, trustworthy, and secure for enterprises, platform providers, and chip manufacturers. OpenTitan is administered by lowRISC CIC as a collaborative project to produce high quality, open IP for instantiation as a full-featured product. See the OpenTitan site and OpenTitan docs for more information about the project.
This repository contains hardware, software and utilities written as part of the OpenTitan project. It is structured as monolithic repository, or “monorepo”, where all components live in one repository. It exists to enable collaboration across partners participating in the OpenTitan project.
The project contains comprehensive documentation of all IPs and tools. You can access it online at docs.opentitan.org.
Have a look at [CONTRIBUTING]({{< relref “CONTRIBUTING.md” >}}) and our documentation on project organization and processes for guidelines on how to contribute code to this repository.
Unless otherwise noted, everything in this repository is covered by the Apache License, Version 2.0 (see LICENSE for full text).