return rc;
if ((buf & mask) == mask) {
- chip->vendor.locality = loc;
+ chip->locality = loc;
return loc;
}
/* Wait for burstcount */
start = get_timer(0);
- stop = chip->vendor.timeout_a;
+ stop = chip->timeout_a;
do {
if (check_locality(chip, loc) >= 0)
return loc;
/* NOTE: Since i2c read may fail, return 0 in this case --> time-out */
u8 buf;
- if (iic_tpm_read(TPM_STS(chip->vendor.locality), &buf, 1) < 0)
+ if (iic_tpm_read(TPM_STS(chip->locality), &buf, 1) < 0)
return 0;
else
return buf;
u8 buf = TPM_STS_COMMAND_READY;
debug("%s\n", __func__);
- rc = iic_tpm_write_long(TPM_STS(chip->vendor.locality), &buf, 1);
+ rc = iic_tpm_write_long(TPM_STS(chip->locality), &buf, 1);
if (rc)
debug("%s: rc=%d\n", __func__, rc);
}
/* Wait for burstcount */
/* XXX: Which timeout value? Spec has 2 answers (c & d) */
start = get_timer(0);
- stop = chip->vendor.timeout_d;
+ stop = chip->timeout_d;
do {
/* Note: STS is little endian */
- addr = TPM_STS(chip->vendor.locality) + 1;
+ addr = TPM_STS(chip->locality) + 1;
if (iic_tpm_read(addr, buf, 3) < 0)
burstcnt = 0;
else
if (burstcnt > (count - size))
burstcnt = count - size;
- rc = iic_tpm_read(TPM_DATA_FIFO(chip->vendor.locality),
+ rc = iic_tpm_read(TPM_DATA_FIFO(chip->locality),
&(buf[size]), burstcnt);
if (rc == 0)
size += burstcnt;
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? */
error("Error left over data\n");
size = -EIO;
* so we sleep rather than keeping the bus busy
*/
udelay(2000);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, chip->locality, 0);
return size;
}
if ((status & TPM_STS_COMMAND_READY) == 0) {
tpm_tis_i2c_ready(chip);
if (wait_for_stat(chip, TPM_STS_COMMAND_READY,
- chip->vendor.timeout_b, &status) < 0) {
+ chip->timeout_b, &status) < 0) {
rc = -ETIME;
goto out_err;
}
burstcnt = CONFIG_TPM_TIS_I2C_BURST_LIMITATION;
#endif /* CONFIG_TPM_TIS_I2C_BURST_LIMITATION */
- rc = iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality),
+ rc = iic_tpm_write(TPM_DATA_FIFO(chip->locality),
&(buf[count]), burstcnt);
if (rc == 0)
count += burstcnt;
goto out_err;
}
rc = wait_for_stat(chip, TPM_STS_VALID,
- chip->vendor.timeout_c, &status);
+ chip->timeout_c, &status);
if (rc)
goto out_err;
}
/* Go and do it */
- iic_tpm_write(TPM_STS(chip->vendor.locality), &sts, 1);
+ iic_tpm_write(TPM_STS(chip->locality), &sts, 1);
debug("done\n");
return len;
* so we sleep rather than keeping the bus busy
*/
udelay(2000);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, chip->locality, 0);
return rc;
}
-static struct tpm_vendor_specific tpm_tis_i2c = {
- .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- .req_canceled = TPM_STS_COMMAND_READY,
-};
-
-
static enum i2c_chip_type tpm_vendor_chip_type(void)
{
#if CONFIG_IS_ENABLED(OF_CONTROL)
int tpm_vendor_init(struct udevice *dev)
{
- struct tpm_chip *chip;
+ struct tpm_chip *chip = &g_chip;
u32 vendor;
u32 expected_did_vid;
tpm_dev.dev = dev;
tpm_dev.chip_type = tpm_vendor_chip_type();
-
- chip = tpm_register_hardware(&tpm_tis_i2c);
- if (chip < 0)
- return -ENODEV;
+ chip->is_open = 1;
/* Disable interrupts (not supported) */
- chip->vendor.irq = 0;
+ chip->irq = 0;
/* Default timeouts */
- chip->vendor.timeout_a = TIS_SHORT_TIMEOUT;
- chip->vendor.timeout_b = TIS_LONG_TIMEOUT;
- chip->vendor.timeout_c = TIS_SHORT_TIMEOUT;
- chip->vendor.timeout_d = TIS_SHORT_TIMEOUT;
+ chip->timeout_a = TIS_SHORT_TIMEOUT;
+ chip->timeout_b = TIS_LONG_TIMEOUT;
+ chip->timeout_c = TIS_SHORT_TIMEOUT;
+ chip->timeout_d = TIS_SHORT_TIMEOUT;
+ chip->req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID;
+ chip->req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID;
+ chip->req_canceled = TPM_STS_COMMAND_READY;
if (request_locality(chip, 0) < 0)
return -ENODEV;
void tpm_vendor_cleanup(struct tpm_chip *chip)
{
- release_locality(chip, chip->vendor.locality, 1);
+ release_locality(chip, chip->locality, 1);
}
/* Returns max number of milliseconds to wait */
}
if (duration_idx != TPM_UNDEFINED)
- duration = chip->vendor.duration[duration_idx];
+ duration = chip->duration[duration_idx];
if (duration <= 0)
return 2 * 60 * HZ; /* Two minutes timeout */
goto out;
}
- if (chip->vendor.irq)
+ if (chip->irq)
goto out_recv;
start = get_timer(0);
do {
debug("waiting for status... %ld %ld\n", start, stop);
u8 status = tpm_tis_i2c_status(chip);
- if ((status & chip->vendor.req_complete_mask) ==
- chip->vendor.req_complete_val) {
+ if ((status & chip->req_complete_mask) ==
+ chip->req_complete_val) {
debug("...got it;\n");
goto out_recv;
}
- if (status == chip->vendor.req_canceled) {
+ if (status == chip->req_canceled) {
error("Operation Canceled\n");
rc = -ECANCELED;
goto out;
return 0;
}
-struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *entry)
-{
- struct tpm_chip *chip;
-
- /* Driver specific per-device data */
- chip = &g_chip;
- memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));
- chip->is_open = 1;
-
- return chip;
-}
-
int tis_init(void)
{
if (tpm.inited)