Skip to content

Commit

Permalink
[opentitantool] Fix crippled I2C TPM support
Browse files Browse the repository at this point in the history
Is seems that PR #21289 introduced a bug that prevents `opentitantool
i2c tpm ...` from working at all.

This CL restores the proper use of `Any<>` to allow passing the I2C
driver object to the TPM command handler in the way that it expects.

Also, a logic condition was accidentally reversed, making the new
--gsc-ready flag ineffective for I2C.

Change-Id: I2b791de25666876c49dccccd83bdbc9369e608be
Signed-off-by: Jes B. Klinke <[email protected]>
  • Loading branch information
jesultra committed Feb 15, 2024
1 parent 10221ef commit 936d2a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sw/host/opentitanlib/src/tpm/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ impl I2cDriver {
}

fn try_read_register(&self, register: Register, data: &mut [u8]) -> Result<()> {
if self.gsc_ready_pin.is_some() {
if self.gsc_ready_pin.is_none() {
// Do two I2C transfers in one call, for lowest latency.
self.i2c.run_transaction(
None, /* default addr */
Expand Down
2 changes: 1 addition & 1 deletion sw/host/opentitantool/src/command/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl CommandDispatch for I2cTpm {
Some(pin) => Some((transport.gpio_pin(pin)?, transport.gpio_monitoring()?)),
None => None,
};
let tpm_driver = Box::new(tpm::I2cDriver::new(
let tpm_driver: Box<dyn tpm::Driver> = Box::new(tpm::I2cDriver::new(
context.params.create(transport, "TPM")?,
ready_pin,
)?);
Expand Down

0 comments on commit 936d2a1

Please sign in to comment.