summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tpm/st33zp24/i2c.c2
-rw-r--r--drivers/char/tpm/st33zp24/spi.c2
-rw-r--r--drivers/char/tpm/st33zp24/st33zp24.h4
-rw-r--r--drivers/char/tpm/tpm_i2c_infineon.c15
-rw-r--r--drivers/char/tpm/tpm_i2c_nuvoton.c16
5 files changed, 19 insertions, 20 deletions
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index be5d1abd3e8e..8390c5b54c3b 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -33,7 +33,7 @@
33 33
34struct st33zp24_i2c_phy { 34struct st33zp24_i2c_phy {
35 struct i2c_client *client; 35 struct i2c_client *client;
36 u8 buf[TPM_BUFSIZE + 1]; 36 u8 buf[ST33ZP24_BUFSIZE + 1];
37 int io_lpcpd; 37 int io_lpcpd;
38}; 38};
39 39
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index d7909ab287a8..ff019a1e3c68 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -63,7 +63,7 @@
63 * some latency byte before the answer is available (max 15). 63 * some latency byte before the answer is available (max 15).
64 * We have 2048 + 1024 + 15. 64 * We have 2048 + 1024 + 15.
65 */ 65 */
66#define ST33ZP24_SPI_BUFFER_SIZE (TPM_BUFSIZE + (TPM_BUFSIZE / 2) +\ 66#define ST33ZP24_SPI_BUFFER_SIZE (ST33ZP24_BUFSIZE + (ST33ZP24_BUFSIZE / 2) +\
67 MAX_SPI_LATENCY) 67 MAX_SPI_LATENCY)
68 68
69 69
diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
index 6f4a4198af6a..20da0a84988d 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.h
+++ b/drivers/char/tpm/st33zp24/st33zp24.h
@@ -18,8 +18,8 @@
18#ifndef __LOCAL_ST33ZP24_H__ 18#ifndef __LOCAL_ST33ZP24_H__
19#define __LOCAL_ST33ZP24_H__ 19#define __LOCAL_ST33ZP24_H__
20 20
21#define TPM_WRITE_DIRECTION 0x80 21#define TPM_WRITE_DIRECTION 0x80
22#define TPM_BUFSIZE 2048 22#define ST33ZP24_BUFSIZE 2048
23 23
24struct st33zp24_dev { 24struct st33zp24_dev {
25 struct tpm_chip *chip; 25 struct tpm_chip *chip;
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 9086edc9066b..3b490d9d90e7 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -26,8 +26,7 @@
26#include <linux/wait.h> 26#include <linux/wait.h>
27#include "tpm.h" 27#include "tpm.h"
28 28
29/* max. buffer size supported by our TPM */ 29#define TPM_I2C_INFINEON_BUFSIZE 1260
30#define TPM_BUFSIZE 1260
31 30
32/* max. number of iterations after I2C NAK */ 31/* max. number of iterations after I2C NAK */
33#define MAX_COUNT 3 32#define MAX_COUNT 3
@@ -63,11 +62,13 @@ enum i2c_chip_type {
63 UNKNOWN, 62 UNKNOWN,
64}; 63};
65 64
66/* Structure to store I2C TPM specific stuff */
67struct tpm_inf_dev { 65struct tpm_inf_dev {
68 struct i2c_client *client; 66 struct i2c_client *client;
69 int locality; 67 int locality;
70 u8 buf[TPM_BUFSIZE + sizeof(u8)]; /* max. buffer size + addr */ 68 /* In addition to the data itself, the buffer must fit the 7-bit I2C
69 * address and the direction bit.
70 */
71 u8 buf[TPM_I2C_INFINEON_BUFSIZE + 1];
71 struct tpm_chip *chip; 72 struct tpm_chip *chip;
72 enum i2c_chip_type chip_type; 73 enum i2c_chip_type chip_type;
73 unsigned int adapterlimit; 74 unsigned int adapterlimit;
@@ -219,7 +220,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
219 .buf = tpm_dev.buf 220 .buf = tpm_dev.buf
220 }; 221 };
221 222
222 if (len > TPM_BUFSIZE) 223 if (len > TPM_I2C_INFINEON_BUFSIZE)
223 return -EINVAL; 224 return -EINVAL;
224 225
225 if (!tpm_dev.client->adapter->algo->master_xfer) 226 if (!tpm_dev.client->adapter->algo->master_xfer)
@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
527 u8 retries = 0; 528 u8 retries = 0;
528 u8 sts = TPM_STS_GO; 529 u8 sts = TPM_STS_GO;
529 530
530 if (len > TPM_BUFSIZE) 531 if (len > TPM_I2C_INFINEON_BUFSIZE)
531 return -E2BIG; /* command is too long for our tpm, sorry */ 532 return -E2BIG;
532 533
533 if (request_locality(chip, 0) < 0) 534 if (request_locality(chip, 0) < 0)
534 return -EBUSY; 535 return -EBUSY;
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 217f7f1cbde8..5700cc2ddee1 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -35,14 +35,12 @@
35#include "tpm.h" 35#include "tpm.h"
36 36
37/* I2C interface offsets */ 37/* I2C interface offsets */
38#define TPM_STS 0x00 38#define TPM_STS 0x00
39#define TPM_BURST_COUNT 0x01 39#define TPM_BURST_COUNT 0x01
40#define TPM_DATA_FIFO_W 0x20 40#define TPM_DATA_FIFO_W 0x20
41#define TPM_DATA_FIFO_R 0x40 41#define TPM_DATA_FIFO_R 0x40
42#define TPM_VID_DID_RID 0x60 42#define TPM_VID_DID_RID 0x60
43/* TPM command header size */ 43#define TPM_I2C_RETRIES 5
44#define TPM_HEADER_SIZE 10
45#define TPM_RETRY 5
46/* 44/*
47 * I2C bus device maximum buffer size w/o counting I2C address or command 45 * I2C bus device maximum buffer size w/o counting I2C address or command
48 * i.e. max size required for I2C write is 34 = addr, command, 32 bytes data 46 * i.e. max size required for I2C write is 34 = addr, command, 32 bytes data
@@ -292,7 +290,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
292 dev_err(dev, "%s() count < header size\n", __func__); 290 dev_err(dev, "%s() count < header size\n", __func__);
293 return -EIO; 291 return -EIO;
294 } 292 }
295 for (retries = 0; retries < TPM_RETRY; retries++) { 293 for (retries = 0; retries < TPM_I2C_RETRIES; retries++) {
296 if (retries > 0) { 294 if (retries > 0) {
297 /* if this is not the first trial, set responseRetry */ 295 /* if this is not the first trial, set responseRetry */
298 i2c_nuvoton_write_status(client, 296 i2c_nuvoton_write_status(client,