[Skiboot] [PATCH 12/15] libstb/drivers/tpm_i2c_nuvoton.c: Set I2C request timeout

Claudio Carvalho cclaudio at linux.vnet.ibm.com
Thu Aug 11 15:23:54 AEST 2016


The I2C master's timeout is too short (1ms per byte) and we get a
master timeout for all I2C request sent to the TPM device at
boot time.

This patch sets the I2C request timeout considering the timeout
of 10 ms per byte.

Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
---
 libstb/drivers/tpm_i2c_nuvoton.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstb/drivers/tpm_i2c_nuvoton.c b/libstb/drivers/tpm_i2c_nuvoton.c
index b615347..4790359 100644
--- a/libstb/drivers/tpm_i2c_nuvoton.c
+++ b/libstb/drivers/tpm_i2c_nuvoton.c
@@ -61,8 +61,7 @@
 #define TCG_PTP_STS_RESPONSE_RETRY	0x02
 #define TCG_PTP_STS_ERR_VAL		0x07
 
-/* from hw/p8-i2c.c */
-#define I2C_TIMEOUT_POLL_MS	4000  /* 4s/byte timeout */
+#define I2C_BYTE_TIMEOUT_MS		10  /* 10ms/byte timeout */
 
 /* TPM Driver values */
 #define MAX_STSVALID_POLLS 	5   /* Max poll of 50ms (5*10ms) */
@@ -133,7 +132,8 @@ static int tpm_i2c_request_send(int read_write, uint32_t offset,
 	req->completion = i2c_request_complete;
 	req->user_data = &rc;
 
-	timeout = (buflen + offset_bytes + 2) * I2C_TIMEOUT_POLL_MS;
+	timeout = (buflen + offset_bytes + 2) * I2C_BYTE_TIMEOUT_MS;
+	i2c_set_req_timeout(req, timeout);
 
 	for (retries = 0; retries <= TPM_MAX_NACK_RETRIES; retries++)
 	{
-- 
1.9.1



More information about the Skiboot mailing list