CHROMIUM: daisy: tpm: fail TPM probe if TPM is not started
authorLuigi Semenzato <semenzato@chromium.org>
Wed, 30 May 2012 22:09:06 +0000 (15:09 -0700)
committerOlof Johansson <olofj@chromium.org>
Wed, 27 Jun 2012 21:56:02 +0000 (14:56 -0700)
Some versions of u-boot don't start the TPM.  We want
the probe to fail in this case.  We could start the TPM
here, but then we would have to set it up compatibly
with what vboot does (including one-time initializations),
or we would hit more confusing errors along the way.

Note: this is tested with non-vboot firmware.  I will try
to test it with vboot firmware as well, but I might hit
snags at this point and might give up.

BUG=chrome-os-partner:8921
TEST=booted with non-vboot u-boot and noted that /dev/tpm0 does not exist

Change-Id: Iea04be737891eb67f428e4627f669301b936cb9e
Reviewed-on: https://gerrit-int.chromium.org/18683
Tested-by: Luigi Semenzato <semenzato@google.com>
Reviewed-by: Jonathan Kliegman <kliegs@google.com>
Reviewed-by: Olof Johansson <olofj@google.com>
Commit-Ready: Luigi Semenzato <semenzato@google.com>

drivers/char/tpm/tpm_tis_i2c.c

index 6548470..43567aa 100644 (file)
@@ -553,7 +553,6 @@ static int tpm_tis_i2c_init(struct device *dev)
        u32 vendor;
        int rc = 0;
        struct tpm_chip *chip;
-       extern void tpm_continue_selftest(struct tpm_chip *);
 
        chip = tpm_register_hardware(dev, &tpm_tis_i2c);
        if (!chip) {
@@ -598,8 +597,17 @@ static int tpm_tis_i2c_init(struct device *dev)
        INIT_LIST_HEAD(&chip->vendor.list);
        tpm_dev.chip = chip;
 
-       tpm_get_timeouts(chip);
-       tpm_continue_selftest(chip);
+       if (tpm_get_timeouts(chip)) {
+               dev_err(dev, "Could not get TPM timeouts and durations\n");
+               rc = -ENODEV;
+               goto out_release;
+       }
+
+       if (tpm_do_selftest(chip)) {
+               dev_err(dev, "TPM self test failed\n");
+               rc = -ENODEV;
+               goto out_release;
+       }
 
        return 0;