Commit af782f33 authored by Christophe Ricard's avatar Christophe Ricard Committed by Jarkko Sakkinen

tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip

Move tpm_vendor_specific data related to TCG PTP specification to tpm_chip.

Move all fields directly linked with well known TCG concepts and used in
TPM drivers (tpm_i2c_atmel, tpm_i2c_infineon, tpm_i2c_nuvoton, tpm_tis
and xen-tpmfront) as well as in TPM core files (tpm-sysfs, tpm-interface
and tpm2-cmd) in tpm_chip.
Signed-off-by: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent 56671c89
...@@ -163,7 +163,7 @@ static int request_locality(struct tpm_chip *chip) ...@@ -163,7 +163,7 @@ static int request_locality(struct tpm_chip *chip)
if (ret < 0) if (ret < 0)
return ret; return ret;
stop = jiffies + chip->vendor.timeout_a; stop = jiffies + chip->timeout_a;
/* Request locality is usually effective after the request */ /* Request locality is usually effective after the request */
do { do {
...@@ -205,7 +205,7 @@ static int get_burstcount(struct tpm_chip *chip) ...@@ -205,7 +205,7 @@ static int get_burstcount(struct tpm_chip *chip)
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip); tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
stop = jiffies + chip->vendor.timeout_d; stop = jiffies + chip->timeout_d;
do { do {
status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS + 1, status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS + 1,
&temp, 1); &temp, 1);
...@@ -337,7 +337,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -337,7 +337,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
while (size < count && while (size < count &&
wait_for_stat(chip, wait_for_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
chip->vendor.timeout_c, chip->timeout_c,
&tpm_dev->read_queue, true) == 0) { &tpm_dev->read_queue, true) == 0) {
burstcnt = get_burstcount(chip); burstcnt = get_burstcount(chip);
if (burstcnt < 0) if (burstcnt < 0)
...@@ -406,7 +406,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf, ...@@ -406,7 +406,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
if ((status & TPM_STS_COMMAND_READY) == 0) { if ((status & TPM_STS_COMMAND_READY) == 0) {
st33zp24_cancel(chip); st33zp24_cancel(chip);
if (wait_for_stat if (wait_for_stat
(chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b, (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
&tpm_dev->read_queue, false) < 0) { &tpm_dev->read_queue, false) < 0) {
ret = -ETIME; ret = -ETIME;
goto out_err; goto out_err;
...@@ -561,10 +561,10 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops, ...@@ -561,10 +561,10 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
tpm_dev->phy_id = phy_id; tpm_dev->phy_id = phy_id;
tpm_dev->ops = ops; tpm_dev->ops = ops;
chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
tpm_dev->locality = LOCALITY0; tpm_dev->locality = LOCALITY0;
...@@ -673,7 +673,7 @@ int st33zp24_pm_resume(struct device *dev) ...@@ -673,7 +673,7 @@ int st33zp24_pm_resume(struct device *dev)
if (gpio_is_valid(tpm_dev->io_lpcpd)) { if (gpio_is_valid(tpm_dev->io_lpcpd)) {
gpio_set_value(tpm_dev->io_lpcpd, 1); gpio_set_value(tpm_dev->io_lpcpd, 1);
ret = wait_for_stat(chip, ret = wait_for_stat(chip,
TPM_STS_VALID, chip->vendor.timeout_b, TPM_STS_VALID, chip->timeout_b,
&tpm_dev->read_queue, false); &tpm_dev->read_queue, false);
} else { } else {
ret = tpm_pm_resume(dev); ret = tpm_pm_resume(dev);
......
...@@ -319,7 +319,7 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, ...@@ -319,7 +319,7 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
duration_idx = tpm_ordinal_duration[ordinal]; duration_idx = tpm_ordinal_duration[ordinal];
if (duration_idx != TPM_UNDEFINED) if (duration_idx != TPM_UNDEFINED)
duration = chip->vendor.duration[duration_idx]; duration = chip->duration[duration_idx];
if (duration <= 0) if (duration <= 0)
return 2 * 60 * HZ; return 2 * 60 * HZ;
else else
...@@ -505,15 +505,15 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -505,15 +505,15 @@ int tpm_get_timeouts(struct tpm_chip *chip)
if (chip->flags & TPM_CHIP_FLAG_TPM2) { if (chip->flags & TPM_CHIP_FLAG_TPM2) {
/* Fixed timeouts for TPM2 */ /* Fixed timeouts for TPM2 */
chip->vendor.timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
chip->vendor.timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B); chip->timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B);
chip->vendor.timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C); chip->timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C);
chip->vendor.timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D); chip->timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D);
chip->vendor.duration[TPM_SHORT] = chip->duration[TPM_SHORT] =
msecs_to_jiffies(TPM2_DURATION_SHORT); msecs_to_jiffies(TPM2_DURATION_SHORT);
chip->vendor.duration[TPM_MEDIUM] = chip->duration[TPM_MEDIUM] =
msecs_to_jiffies(TPM2_DURATION_MEDIUM); msecs_to_jiffies(TPM2_DURATION_MEDIUM);
chip->vendor.duration[TPM_LONG] = chip->duration[TPM_LONG] =
msecs_to_jiffies(TPM2_DURATION_LONG); msecs_to_jiffies(TPM2_DURATION_LONG);
return 0; return 0;
} }
...@@ -561,10 +561,10 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -561,10 +561,10 @@ int tpm_get_timeouts(struct tpm_chip *chip)
* of misreporting. * of misreporting.
*/ */
if (chip->ops->update_timeouts != NULL) if (chip->ops->update_timeouts != NULL)
chip->vendor.timeout_adjusted = chip->timeout_adjusted =
chip->ops->update_timeouts(chip, new_timeout); chip->ops->update_timeouts(chip, new_timeout);
if (!chip->vendor.timeout_adjusted) { if (!chip->timeout_adjusted) {
/* Don't overwrite default if value is 0 */ /* Don't overwrite default if value is 0 */
if (new_timeout[0] != 0 && new_timeout[0] < 1000) { if (new_timeout[0] != 0 && new_timeout[0] < 1000) {
int i; int i;
...@@ -572,12 +572,12 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -572,12 +572,12 @@ int tpm_get_timeouts(struct tpm_chip *chip)
/* timeouts in msec rather usec */ /* timeouts in msec rather usec */
for (i = 0; i != ARRAY_SIZE(new_timeout); i++) for (i = 0; i != ARRAY_SIZE(new_timeout); i++)
new_timeout[i] *= 1000; new_timeout[i] *= 1000;
chip->vendor.timeout_adjusted = true; chip->timeout_adjusted = true;
} }
} }
/* Report adjusted timeouts */ /* Report adjusted timeouts */
if (chip->vendor.timeout_adjusted) { if (chip->timeout_adjusted) {
dev_info(&chip->dev, dev_info(&chip->dev,
HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n", HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n",
old_timeout[0], new_timeout[0], old_timeout[0], new_timeout[0],
...@@ -586,10 +586,10 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -586,10 +586,10 @@ int tpm_get_timeouts(struct tpm_chip *chip)
old_timeout[3], new_timeout[3]); old_timeout[3], new_timeout[3]);
} }
chip->vendor.timeout_a = usecs_to_jiffies(new_timeout[0]); chip->timeout_a = usecs_to_jiffies(new_timeout[0]);
chip->vendor.timeout_b = usecs_to_jiffies(new_timeout[1]); chip->timeout_b = usecs_to_jiffies(new_timeout[1]);
chip->vendor.timeout_c = usecs_to_jiffies(new_timeout[2]); chip->timeout_c = usecs_to_jiffies(new_timeout[2]);
chip->vendor.timeout_d = usecs_to_jiffies(new_timeout[3]); chip->timeout_d = usecs_to_jiffies(new_timeout[3]);
duration: duration:
tpm_cmd.header.in = tpm_getcap_header; tpm_cmd.header.in = tpm_getcap_header;
...@@ -608,11 +608,11 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -608,11 +608,11 @@ int tpm_get_timeouts(struct tpm_chip *chip)
return -EINVAL; return -EINVAL;
duration_cap = &tpm_cmd.params.getcap_out.cap.duration; duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
chip->vendor.duration[TPM_SHORT] = chip->duration[TPM_SHORT] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short)); usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
chip->vendor.duration[TPM_MEDIUM] = chip->duration[TPM_MEDIUM] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium)); usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium));
chip->vendor.duration[TPM_LONG] = chip->duration[TPM_LONG] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long)); usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long));
/* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
...@@ -620,11 +620,11 @@ int tpm_get_timeouts(struct tpm_chip *chip) ...@@ -620,11 +620,11 @@ int tpm_get_timeouts(struct tpm_chip *chip)
* fix up the resulting too-small TPM_SHORT value to make things work. * fix up the resulting too-small TPM_SHORT value to make things work.
* We also scale the TPM_MEDIUM and -_LONG values by 1000. * We also scale the TPM_MEDIUM and -_LONG values by 1000.
*/ */
if (chip->vendor.duration[TPM_SHORT] < (HZ / 100)) { if (chip->duration[TPM_SHORT] < (HZ / 100)) {
chip->vendor.duration[TPM_SHORT] = HZ; chip->duration[TPM_SHORT] = HZ;
chip->vendor.duration[TPM_MEDIUM] *= 1000; chip->duration[TPM_MEDIUM] *= 1000;
chip->vendor.duration[TPM_LONG] *= 1000; chip->duration[TPM_LONG] *= 1000;
chip->vendor.duration_adjusted = true; chip->duration_adjusted = true;
dev_info(&chip->dev, "Adjusting TPM timeout parameters."); dev_info(&chip->dev, "Adjusting TPM timeout parameters.");
} }
return 0; return 0;
......
...@@ -236,14 +236,14 @@ static ssize_t durations_show(struct device *dev, struct device_attribute *attr, ...@@ -236,14 +236,14 @@ static ssize_t durations_show(struct device *dev, struct device_attribute *attr,
{ {
struct tpm_chip *chip = dev_get_drvdata(dev); struct tpm_chip *chip = dev_get_drvdata(dev);
if (chip->vendor.duration[TPM_LONG] == 0) if (chip->duration[TPM_LONG] == 0)
return 0; return 0;
return sprintf(buf, "%d %d %d [%s]\n", return sprintf(buf, "%d %d %d [%s]\n",
jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]), jiffies_to_usecs(chip->duration[TPM_SHORT]),
jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]), jiffies_to_usecs(chip->duration[TPM_MEDIUM]),
jiffies_to_usecs(chip->vendor.duration[TPM_LONG]), jiffies_to_usecs(chip->duration[TPM_LONG]),
chip->vendor.duration_adjusted chip->duration_adjusted
? "adjusted" : "original"); ? "adjusted" : "original");
} }
static DEVICE_ATTR_RO(durations); static DEVICE_ATTR_RO(durations);
...@@ -254,11 +254,11 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr, ...@@ -254,11 +254,11 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
struct tpm_chip *chip = dev_get_drvdata(dev); struct tpm_chip *chip = dev_get_drvdata(dev);
return sprintf(buf, "%d %d %d %d [%s]\n", return sprintf(buf, "%d %d %d %d [%s]\n",
jiffies_to_usecs(chip->vendor.timeout_a), jiffies_to_usecs(chip->timeout_a),
jiffies_to_usecs(chip->vendor.timeout_b), jiffies_to_usecs(chip->timeout_b),
jiffies_to_usecs(chip->vendor.timeout_c), jiffies_to_usecs(chip->timeout_c),
jiffies_to_usecs(chip->vendor.timeout_d), jiffies_to_usecs(chip->timeout_d),
chip->vendor.timeout_adjusted chip->timeout_adjusted
? "adjusted" : "original"); ? "adjusted" : "original");
} }
static DEVICE_ATTR_RO(timeouts); static DEVICE_ATTR_RO(timeouts);
......
...@@ -131,10 +131,6 @@ enum tpm2_startup_types { ...@@ -131,10 +131,6 @@ enum tpm2_startup_types {
struct tpm_chip; struct tpm_chip;
struct tpm_vendor_specific { struct tpm_vendor_specific {
unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
bool timeout_adjusted;
unsigned long duration[3]; /* jiffies */
bool duration_adjusted;
void *priv; void *priv;
}; };
...@@ -171,6 +167,13 @@ struct tpm_chip { ...@@ -171,6 +167,13 @@ struct tpm_chip {
struct mutex tpm_mutex; /* tpm is processing */ struct mutex tpm_mutex; /* tpm is processing */
struct tpm_vendor_specific vendor; struct tpm_vendor_specific vendor;
unsigned long timeout_a; /* jiffies */
unsigned long timeout_b; /* jiffies */
unsigned long timeout_c; /* jiffies */
unsigned long timeout_d; /* jiffies */
bool timeout_adjusted;
unsigned long duration[3]; /* jiffies */
bool duration_adjusted;
struct dentry **bios_dir; struct dentry **bios_dir;
......
...@@ -792,7 +792,7 @@ unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal) ...@@ -792,7 +792,7 @@ unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
index = tpm2_ordinal_duration[ordinal - TPM2_CC_FIRST]; index = tpm2_ordinal_duration[ordinal - TPM2_CC_FIRST];
if (index != TPM_UNDEFINED) if (index != TPM_UNDEFINED)
duration = chip->vendor.duration[index]; duration = chip->duration[index];
if (duration <= 0) if (duration <= 0)
duration = 2 * 60 * HZ; duration = 2 * 60 * HZ;
......
...@@ -169,10 +169,10 @@ static int i2c_atmel_probe(struct i2c_client *client, ...@@ -169,10 +169,10 @@ static int i2c_atmel_probe(struct i2c_client *client,
return -ENOMEM; return -ENOMEM;
/* Default timeouts */ /* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT); chip->timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
/* There is no known way to probe for this device, and all version /* There is no known way to probe for this device, and all version
* information seems to be read via TPM commands. Thus we rely on the * information seems to be read via TPM commands. Thus we rely on the
......
...@@ -321,7 +321,7 @@ static int request_locality(struct tpm_chip *chip, int loc) ...@@ -321,7 +321,7 @@ static int request_locality(struct tpm_chip *chip, int loc)
iic_tpm_write(TPM_ACCESS(loc), &buf, 1); iic_tpm_write(TPM_ACCESS(loc), &buf, 1);
/* wait for burstcount */ /* wait for burstcount */
stop = jiffies + chip->vendor.timeout_a; stop = jiffies + chip->timeout_a;
do { do {
if (check_locality(chip, loc) >= 0) if (check_locality(chip, loc) >= 0)
return loc; return loc;
...@@ -363,7 +363,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip) ...@@ -363,7 +363,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip)
/* wait for burstcount */ /* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */ /* which timeout value, spec has 2 answers (c & d) */
stop = jiffies + chip->vendor.timeout_d; stop = jiffies + chip->timeout_d;
do { do {
/* Note: STS is little endian */ /* Note: STS is little endian */
if (iic_tpm_read(TPM_STS(tpm_dev.locality)+1, buf, 3) < 0) if (iic_tpm_read(TPM_STS(tpm_dev.locality)+1, buf, 3) < 0)
...@@ -465,7 +465,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -465,7 +465,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
goto out; goto out;
} }
wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status); wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
if (status & TPM_STS_DATA_AVAIL) { /* retry? */ if (status & TPM_STS_DATA_AVAIL) { /* retry? */
dev_err(&chip->dev, "Error left over data\n"); dev_err(&chip->dev, "Error left over data\n");
size = -EIO; size = -EIO;
...@@ -501,7 +501,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -501,7 +501,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
tpm_tis_i2c_ready(chip); tpm_tis_i2c_ready(chip);
if (wait_for_stat if (wait_for_stat
(chip, TPM_STS_COMMAND_READY, (chip, TPM_STS_COMMAND_READY,
chip->vendor.timeout_b, &status) < 0) { chip->timeout_b, &status) < 0) {
rc = -ETIME; rc = -ETIME;
goto out_err; goto out_err;
} }
...@@ -531,7 +531,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -531,7 +531,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
} }
wait_for_stat(chip, TPM_STS_VALID, wait_for_stat(chip, TPM_STS_VALID,
chip->vendor.timeout_c, &status); chip->timeout_c, &status);
if ((status & TPM_STS_DATA_EXPECT) == 0) { if ((status & TPM_STS_DATA_EXPECT) == 0) {
rc = -EIO; rc = -EIO;
...@@ -541,7 +541,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -541,7 +541,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */ /* write last byte */
iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1); iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status); wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
if ((status & TPM_STS_DATA_EXPECT) != 0) { if ((status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO; rc = -EIO;
goto out_err; goto out_err;
...@@ -587,10 +587,10 @@ static int tpm_tis_i2c_init(struct device *dev) ...@@ -587,10 +587,10 @@ static int tpm_tis_i2c_init(struct device *dev)
return PTR_ERR(chip); return PTR_ERR(chip);
/* Default timeouts */ /* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT); chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
if (request_locality(chip, 0) != 0) { if (request_locality(chip, 0) != 0) {
dev_err(dev, "could not request locality\n"); dev_err(dev, "could not request locality\n");
......
...@@ -144,7 +144,7 @@ static void i2c_nuvoton_ready(struct tpm_chip *chip) ...@@ -144,7 +144,7 @@ static void i2c_nuvoton_ready(struct tpm_chip *chip)
static int i2c_nuvoton_get_burstcount(struct i2c_client *client, static int i2c_nuvoton_get_burstcount(struct i2c_client *client,
struct tpm_chip *chip) struct tpm_chip *chip)
{ {
unsigned long stop = jiffies + chip->vendor.timeout_d; unsigned long stop = jiffies + chip->timeout_d;
s32 status; s32 status;
int burst_count = -1; int burst_count = -1;
u8 data; u8 data;
...@@ -239,7 +239,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client, ...@@ -239,7 +239,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
while (size < count && while (size < count &&
i2c_nuvoton_wait_for_data_avail(chip, i2c_nuvoton_wait_for_data_avail(chip,
chip->vendor.timeout_c, chip->timeout_c,
&priv->read_queue) == 0) { &priv->read_queue) == 0) {
burst_count = i2c_nuvoton_get_burstcount(client, chip); burst_count = i2c_nuvoton_get_burstcount(client, chip);
if (burst_count < 0) { if (burst_count < 0) {
...@@ -289,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -289,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
* tag, paramsize, and result * tag, paramsize, and result
*/ */
status = i2c_nuvoton_wait_for_data_avail( status = i2c_nuvoton_wait_for_data_avail(
chip, chip->vendor.timeout_c, &priv->read_queue); chip, chip->timeout_c, &priv->read_queue);
if (status != 0) { if (status != 0) {
dev_err(dev, "%s() timeout on dataAvail\n", __func__); dev_err(dev, "%s() timeout on dataAvail\n", __func__);
size = -ETIMEDOUT; size = -ETIMEDOUT;
...@@ -329,7 +329,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -329,7 +329,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
} }
if (i2c_nuvoton_wait_for_stat( if (i2c_nuvoton_wait_for_stat(
chip, TPM_STS_VALID | TPM_STS_DATA_AVAIL, chip, TPM_STS_VALID | TPM_STS_DATA_AVAIL,
TPM_STS_VALID, chip->vendor.timeout_c, TPM_STS_VALID, chip->timeout_c,
NULL)) { NULL)) {
dev_err(dev, "%s() error left over data\n", __func__); dev_err(dev, "%s() error left over data\n", __func__);
size = -ETIMEDOUT; size = -ETIMEDOUT;
...@@ -362,7 +362,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -362,7 +362,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
i2c_nuvoton_ready(chip); i2c_nuvoton_ready(chip);
if (i2c_nuvoton_wait_for_stat(chip, TPM_STS_COMMAND_READY, if (i2c_nuvoton_wait_for_stat(chip, TPM_STS_COMMAND_READY,
TPM_STS_COMMAND_READY, TPM_STS_COMMAND_READY,
chip->vendor.timeout_b, NULL)) { chip->timeout_b, NULL)) {
dev_err(dev, "%s() timeout on commandReady\n", dev_err(dev, "%s() timeout on commandReady\n",
__func__); __func__);
rc = -EIO; rc = -EIO;
...@@ -394,7 +394,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -394,7 +394,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
TPM_STS_EXPECT, TPM_STS_EXPECT,
TPM_STS_VALID | TPM_STS_VALID |
TPM_STS_EXPECT, TPM_STS_EXPECT,
chip->vendor.timeout_c, chip->timeout_c,
NULL); NULL);
if (rc < 0) { if (rc < 0) {
dev_err(dev, "%s() timeout on Expect\n", dev_err(dev, "%s() timeout on Expect\n",
...@@ -419,7 +419,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -419,7 +419,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
rc = i2c_nuvoton_wait_for_stat(chip, rc = i2c_nuvoton_wait_for_stat(chip,
TPM_STS_VALID | TPM_STS_EXPECT, TPM_STS_VALID | TPM_STS_EXPECT,
TPM_STS_VALID, TPM_STS_VALID,
chip->vendor.timeout_c, NULL); chip->timeout_c, NULL);
if (rc) { if (rc) {
dev_err(dev, "%s() timeout on Expect to clear\n", dev_err(dev, "%s() timeout on Expect to clear\n",
__func__); __func__);
...@@ -548,10 +548,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -548,10 +548,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
init_waitqueue_head(&priv->read_queue); init_waitqueue_head(&priv->read_queue);
/* Default timeouts */ /* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT); chip->timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
/* /*
* I2C intfcaps (interrupt capabilitieis) in the chip are hard coded to: * I2C intfcaps (interrupt capabilitieis) in the chip are hard coded to:
...@@ -580,7 +580,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -580,7 +580,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
rc = i2c_nuvoton_wait_for_stat(chip, rc = i2c_nuvoton_wait_for_stat(chip,
TPM_STS_COMMAND_READY, TPM_STS_COMMAND_READY,
TPM_STS_COMMAND_READY, TPM_STS_COMMAND_READY,
chip->vendor.timeout_b, chip->timeout_b,
NULL); NULL);
if (rc == 0) { if (rc == 0) {
/* /*
......
...@@ -133,7 +133,7 @@ static inline int is_itpm(struct acpi_device *dev) ...@@ -133,7 +133,7 @@ static inline int is_itpm(struct acpi_device *dev)
static int wait_startup(struct tpm_chip *chip, int l) static int wait_startup(struct tpm_chip *chip, int l)
{ {
struct priv_data *priv = chip->vendor.priv; struct priv_data *priv = chip->vendor.priv;
unsigned long stop = jiffies + chip->vendor.timeout_a; unsigned long stop = jiffies + chip->timeout_a;
do { do {
if (ioread8(priv->iobase + TPM_ACCESS(l)) & if (ioread8(priv->iobase + TPM_ACCESS(l)) &
TPM_ACCESS_VALID) TPM_ACCESS_VALID)
...@@ -178,7 +178,7 @@ static int request_locality(struct tpm_chip *chip, int l) ...@@ -178,7 +178,7 @@ static int request_locality(struct tpm_chip *chip, int l)
iowrite8(TPM_ACCESS_REQUEST_USE, iowrite8(TPM_ACCESS_REQUEST_USE,
priv->iobase + TPM_ACCESS(l)); priv->iobase + TPM_ACCESS(l));
stop = jiffies + chip->vendor.timeout_a; stop = jiffies + chip->timeout_a;
if (chip->flags & TPM_CHIP_FLAG_IRQ) { if (chip->flags & TPM_CHIP_FLAG_IRQ) {
again: again:
...@@ -232,7 +232,7 @@ static int get_burstcount(struct tpm_chip *chip) ...@@ -232,7 +232,7 @@ static int get_burstcount(struct tpm_chip *chip)
/* wait for burstcount */ /* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */ /* which timeout value, spec has 2 answers (c & d) */
stop = jiffies + chip->vendor.timeout_d; stop = jiffies + chip->timeout_d;
do { do {
burstcnt = ioread8(priv->iobase + burstcnt = ioread8(priv->iobase +
TPM_STS(priv->locality) + 1); TPM_STS(priv->locality) + 1);
...@@ -253,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -253,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
while (size < count && while (size < count &&
wait_for_tpm_stat(chip, wait_for_tpm_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
chip->vendor.timeout_c, chip->timeout_c,
&priv->read_queue, true) &priv->read_queue, true)
== 0) { == 0) {
burstcnt = get_burstcount(chip); burstcnt = get_burstcount(chip);
...@@ -296,7 +296,7 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -296,7 +296,7 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
goto out; goto out;
} }
wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false); &priv->int_queue, false);
status = tpm_tis_status(chip); status = tpm_tis_status(chip);
if (status & TPM_STS_DATA_AVAIL) { /* retry? */ if (status & TPM_STS_DATA_AVAIL) { /* retry? */
...@@ -333,7 +333,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -333,7 +333,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
if ((status & TPM_STS_COMMAND_READY) == 0) { if ((status & TPM_STS_COMMAND_READY) == 0) {
tpm_tis_ready(chip); tpm_tis_ready(chip);
if (wait_for_tpm_stat if (wait_for_tpm_stat
(chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b, (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
&priv->int_queue, false) < 0) { &priv->int_queue, false) < 0) {
rc = -ETIME; rc = -ETIME;
goto out_err; goto out_err;
...@@ -348,7 +348,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -348,7 +348,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
count++; count++;
} }
wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false); &priv->int_queue, false);
status = tpm_tis_status(chip); status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) { if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
...@@ -360,7 +360,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -360,7 +360,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */ /* write last byte */
iowrite8(buf[count], iowrite8(buf[count],
priv->iobase + TPM_DATA_FIFO(priv->locality)); priv->iobase + TPM_DATA_FIFO(priv->locality));
wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false); &priv->int_queue, false);
status = tpm_tis_status(chip); status = tpm_tis_status(chip);
if ((status & TPM_STS_DATA_EXPECT) != 0) { if ((status & TPM_STS_DATA_EXPECT) != 0) {
...@@ -711,10 +711,10 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -711,10 +711,10 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
return PTR_ERR(priv->iobase); return PTR_ERR(priv->iobase);
/* Maximum timeouts */ /* Maximum timeouts */
chip->vendor.timeout_a = TIS_TIMEOUT_A_MAX; chip->timeout_a = TIS_TIMEOUT_A_MAX;
chip->vendor.timeout_b = TIS_TIMEOUT_B_MAX; chip->timeout_b = TIS_TIMEOUT_B_MAX;
chip->vendor.timeout_c = TIS_TIMEOUT_C_MAX; chip->timeout_c = TIS_TIMEOUT_C_MAX;
chip->vendor.timeout_d = TIS_TIMEOUT_D_MAX; chip->timeout_d = TIS_TIMEOUT_D_MAX;
if (wait_startup(chip, 0) != 0) { if (wait_startup(chip, 0) != 0) {
rc = -ENODEV; rc = -ENODEV;
......
...@@ -89,7 +89,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -89,7 +89,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
return -EINVAL; return -EINVAL;
/* Wait for completion of any existing command or cancellation */ /* Wait for completion of any existing command or cancellation */
if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c, if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->timeout_c,
&priv->read_queue, true) < 0) { &priv->read_queue, true) < 0) {
vtpm_cancel(chip); vtpm_cancel(chip);
return -ETIME; return -ETIME;
...@@ -126,7 +126,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -126,7 +126,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return -ECANCELED; return -ECANCELED;
/* In theory the wait at the end of _send makes this one unnecessary */ /* In theory the wait at the end of _send makes this one unnecessary */
if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c, if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->timeout_c,
&priv->read_queue, true) < 0) { &priv->read_queue, true) < 0) {
vtpm_cancel(chip); vtpm_cancel(chip);
return -ETIME; return -ETIME;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment