Skip to content

Commit

Permalink
Merge branch 'tpmdd-04-17-13' of git://github.com/shpedoikal/linux in…
Browse files Browse the repository at this point in the history
…to my-next
  • Loading branch information
James Morris committed Apr 20, 2013
2 parents df2c2af + 32d33b2 commit b7ae9f0
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 87 deletions.
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/i2c/trivial-devices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ fsl,mc13892 MC13892: Power Management Integrated Circuit (PMIC) for i.MX35/51
fsl,mma8450 MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer
fsl,mpr121 MPR121: Proximity Capacitive Touch Sensor Controller
fsl,sgtl5000 SGTL5000: Ultra Low-Power Audio Codec
infineon,slb9635tt Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
infineon,slb9645tt Infineon SLB9645 I2C TPM (new protocol, max 400khz)
maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator
maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs
maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface
Expand Down
31 changes: 27 additions & 4 deletions drivers/char/tpm/tpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ int tpm_pm_suspend(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
struct tpm_cmd_t cmd;
int rc;
int rc, try;

u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 };

Expand All @@ -1355,9 +1355,32 @@ int tpm_pm_suspend(struct device *dev)
}

/* now do the actual savestate */
cmd.header.in = savestate_header;
rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE,
"sending savestate before suspend");
for (try = 0; try < TPM_RETRY; try++) {
cmd.header.in = savestate_header;
rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL);

/*
* If the TPM indicates that it is too busy to respond to
* this command then retry before giving up. It can take
* several seconds for this TPM to be ready.
*
* This can happen if the TPM has already been sent the
* SaveState command before the driver has loaded. TCG 1.2
* specification states that any communication after SaveState
* may cause the TPM to invalidate previously saved state.
*/
if (rc != TPM_WARN_RETRY)
break;
msleep(TPM_TIMEOUT_RETRY);
}

if (rc)
dev_err(chip->dev,
"Error (%d) sending savestate before suspend\n", rc);
else if (try > 0)
dev_warn(chip->dev, "TPM savestate took %dms\n",
try * TPM_TIMEOUT_RETRY);

return rc;
}
EXPORT_SYMBOL_GPL(tpm_pm_suspend);
Expand Down
3 changes: 3 additions & 0 deletions drivers/char/tpm/tpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ enum tpm_const {
TPM_MINOR = 224, /* officially assigned */
TPM_BUFSIZE = 4096,
TPM_NUM_DEVICES = 256,
TPM_RETRY = 50, /* 5 seconds */
};

enum tpm_timeout {
TPM_TIMEOUT = 5, /* msecs */
TPM_TIMEOUT_RETRY = 100 /* msecs */
};

/* TPM addresses */
Expand All @@ -44,6 +46,7 @@ enum tpm_addr {
TPM_ADDR = 0x4E,
};

#define TPM_WARN_RETRY 0x800
#define TPM_WARN_DOING_SELFTEST 0x802
#define TPM_ERR_DEACTIVATED 0x6
#define TPM_ERR_DISABLED 0x7
Expand Down
Loading

0 comments on commit b7ae9f0

Please sign in to comment.