Skip to content

Commit

Permalink
tpm: do not suspend/resume if power stays on
Browse files Browse the repository at this point in the history
The suspend/resume behavior of the TPM can be controlled by setting
"powered-while-suspended" in the DTS. This is useful for the cases
when hardware does not power-off the TPM.

Signed-off-by: Sonny Rao <[email protected]>
Signed-off-by: Enric Balletbo i Serra <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: Jarkko Sakkinen <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Enric Balletbo i Serra authored and James Morris committed Jul 6, 2017
1 parent 28707bf commit b5d0ebc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,9 @@ int tpm_pm_suspend(struct device *dev)
if (chip == NULL)
return -ENODEV;

if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
return 0;

if (chip->flags & TPM_CHIP_FLAG_TPM2) {
tpm2_shutdown(chip, TPM2_SU_STATE);
return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum tpm_chip_flags {
TPM_CHIP_FLAG_IRQ = BIT(2),
TPM_CHIP_FLAG_VIRTUAL = BIT(3),
TPM_CHIP_FLAG_HAVE_TIMEOUTS = BIT(4),
TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
};

struct tpm_bios_log {
Expand Down
3 changes: 3 additions & 0 deletions drivers/char/tpm/tpm_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ int tpm_read_log_of(struct tpm_chip *chip)
else
return -ENODEV;

if (of_property_read_bool(np, "powered-while-suspended"))
chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;

sizep = of_get_property(np, "linux,sml-size", NULL);
basep = of_get_property(np, "linux,sml-base", NULL);
if (sizep == NULL && basep == NULL)
Expand Down

0 comments on commit b5d0ebc

Please sign in to comment.