CHROMIUM: tpm: cr50_spi: fix tpm ready timeouts

Modern cr50 builds use "tpm ready" IRQ to signal that cr50 is done
processing the previous transaction and is ready for the next one.
Old cr50 builds and platforms didn't support this interrupt, so the
driver needed to make sure that some delay is made between transactions.
cr50_spi still needs to support both old and modern cases.

Before this CL, the cr50_spi driver was always waiting for "tpm ready"
IRQ with a 2 msec delay.
In practice, while performing long internal background operations (like
nvmem commit not caused by a command), cr50 may delay processing the
transaction by dozens of milliseconds (up to 150 msec was observed).
If a new transaction header is sent in such case before the previous
transaction is processed, it may be lost. Thus it is more reliable to
wait for "tpm ready" IRQ for much longer, if that IRQ is supported.

This CL does the following:
 - Increases the delay between transactions from 2 msec to 10 msec in
   cases when IRQ is not supported. 10 msec is the value used for this
   purpose by firmware.
 - When IRQ is supported, uses TPM2 Timeout A (750 msec) as the timeout
   while waiting for IRQ.
 - Adds logic to confirm that IRQs are actually triggered if "tpm ready"
   IRQ is configured (to protect from old cr50 revisions, which don't
   trigger it). And switches to the longer timeout only if the IRQ is
   confirmed.
 - Adds a warning if IRQ is confirmed, but waiting for it results in a
   timeout.

BUG=b:73351086
TEST=go through reboot test with fizz, verify that 'Timeout during flow
     control' doesn't happen.

Change-Id: Id6b58af7899d0cdc5fd75b449523dd33fe0941f2
Signed-off-by: Andrey Pronin <apronin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1053593
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
(cherry picked from commit 7e3c1a9938a25fadb5a9fe5b721f49e8176504ef)
Reviewed-on: https://chromium-review.googlesource.com/1056249
1 file changed