drivers/i2c/tpm/cr50: Simplify and increase init delay to 30 seconds
commit2bc6ad3ff1a376ca6f67e2aca2440f34acdf9b99
authorDuncan Laurie <dlaurie@google.com>
Tue, 7 Nov 2017 17:13:19 +0000 (7 09:13 -0800)
committerVadim Bendebury <vbendeb@chromium.org>
Wed, 22 Nov 2017 15:18:03 +0000 (22 15:18 +0000)
tree0d78212676b312bd54b5c4d83536218bba452048
parent8727e644ea9c53d066f2f289766920b7380dff83
drivers/i2c/tpm/cr50: Simplify and increase init delay to 30 seconds

The Cr50 i2c driver provides separate entry points for probing and
initialization, but probing function does not really do much.

It also claims and releases locality on every coreboot stage, but
there is no need for this - locality should be definitely claimed
after reset and then it could be retained through the boot process.

On top of that the driver does not properly account for long time it
could take the Cr50 chip to come around to reset processing if TPM
reset request was posted during a lengthy TPM operation.

This patch addresses the issues as follows:

  - tpm_vendor_probe() and tpm_vendor_cleanup() become noops, kept
    around to conform to the expected driver API.
  - tpm_vendor_init() invokes a function to process TPM reset only in
    the first stage using TPM (typically verstage), the function
    checks if locality is claimed and if so - waits for it to be
    released, which indicates that TPM reset processing is over.
  - before claiming locality check if it is already taken, and if so -
    just proceed.

BRANCH=none
BUG=b:65867313, b:68729265
TEST=Verified that reef no longer hangs during EC reboot and
     firmware_Cr50ClearTPMOwner (not yet merged) tests.

Change-Id: Iba8445caf1342e3a5fefcb2664b0759a1a8e84e3
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://review.coreboot.org/22554
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
src/drivers/i2c/tpm/cr50.c