Skip to content

Commit

Permalink
[opentitantool] Adjusted operation order
Browse files Browse the repository at this point in the history
HyperDebug firmware has special code to pause during SPI or I2C TPM
transactions, waiting for a pulse on a Google-specific "ready" signal.

This change modifies the way the arguments must be passed to
`spi.run_transaction()` to invoke that feature, such that they more
closely match the sequence of events: Write, TpmPoll, Read, GscReady.

Change-Id: Ia38e142c97f311c27367c916cbcda51af45ad500
Signed-off-by: Jes B. Klinke <[email protected]>
  • Loading branch information
jesultra committed Feb 14, 2025
1 parent ca041a3 commit bf1bc46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sw/host/opentitanlib/src/tpm/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ const SPI_TPM_WRITE: u32 = 0x40000000;
const SPI_TPM_DATA_LEN_POS: u8 = 24;
const SPI_TPM_ADDRESS_OFFSET: u32 = 0x00D40000;

const MAX_TRANSACTION_SIZE: usize = 32;
const MAX_TRANSACTION_SIZE: usize = 64;
const RESPONSE_HEADER_SIZE: usize = 6;
const MAX_RESPONSE_SIZE: usize = 4096;
const TIMEOUT: Duration = Duration::from_millis(500);
Expand All @@ -288,9 +288,9 @@ impl Driver for SpiDriver {
if self.use_gsc_ready {
self.spi.run_transaction(&mut [
spi::Transfer::Write(&req),
spi::Transfer::GscReady,
spi::Transfer::TpmPoll,
spi::Transfer::Read(data),
spi::Transfer::GscReady,
])
} else {
self.spi.run_transaction(&mut [
Expand Down
2 changes: 1 addition & 1 deletion sw/host/opentitanlib/src/transport/hyperdebug/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl Target for HyperdebugSpiTarget {
self.receive(rbuf)?;
return Ok(());
}
[Transfer::Write(wbuf), Transfer::GscReady, Transfer::TpmPoll, Transfer::Read(rbuf)] => {
[Transfer::Write(wbuf), Transfer::TpmPoll, Transfer::Read(rbuf), Transfer::GscReady] => {
// Hyperdebug can do SPI TPM transaction as a single USB
// request/reply.
ensure!(
Expand Down

0 comments on commit bf1bc46

Please sign in to comment.