summaryrefslogtreecommitdiff
path: root/common/tpm_registers.c
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2016-08-02 12:36:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-05 23:22:13 -0700
commite4f389a275fb81c112b1186df0465e48ff163cfd (patch)
tree8cb4b98a9a79a8f89461f5472c7f8e947e373e9c /common/tpm_registers.c
parentd6c69cef59b9abb31da6ed362b61340a5d8318b9 (diff)
downloadchrome-ec-e4f389a275fb81c112b1186df0465e48ff163cfd.tar.gz
Cr50: Preliminary I2CS TPM2.0 driver
This CL includes changes in Cr50 required to support TPM via the I2CS interface. BRANCH=none BUG=chrome-os-partner:40397 TEST=manual Limited testing so far. Verified that the I2CS interface is initialized properly and that register reads occur when initiated on the AP console via command i2cget -y 8 0x50 0x1 w Change-Id: I16ac17c7c82d420a384908e4b5a9867a3b24bc9e Reviewed-on: https://chromium-review.googlesource.com/356241 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/tpm_registers.c')
-rw-r--r--common/tpm_registers.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/common/tpm_registers.c b/common/tpm_registers.c
index a7dfa84963..0158e22f2f 100644
--- a/common/tpm_registers.c
+++ b/common/tpm_registers.c
@@ -411,6 +411,7 @@ void fifo_reg_read(uint8_t *dest, uint32_t data_size)
{
uint32_t still_in_fifo = tpm_.fifo_write_index -
tpm_.fifo_read_index;
+ uint32_t tpm_sts;
data_size = MIN(data_size, still_in_fifo);
memcpy(dest,
@@ -418,8 +419,23 @@ void fifo_reg_read(uint8_t *dest, uint32_t data_size)
data_size);
tpm_.fifo_read_index += data_size;
- if (tpm_.fifo_write_index == tpm_.fifo_read_index)
- tpm_.regs.sts &= ~(data_avail | command_ready);
+
+ tpm_sts = tpm_.regs.sts;
+ tpm_sts &= ~(burst_count_mask << burst_count_shift);
+ if (tpm_.fifo_write_index == tpm_.fifo_read_index) {
+ tpm_sts &= ~(data_avail | command_ready);
+ /* Birst size for the following write requests. */
+ tpm_sts |= 63 << burst_count_shift;
+ } else {
+ /*
+ * Tell the master how much there is to read in the next
+ * burst.
+ */
+ tpm_sts |= MIN(tpm_.fifo_write_index -
+ tpm_.fifo_read_index, 63) << burst_count_shift;
+ }
+
+ tpm_.regs.sts = tpm_sts;
}
@@ -513,6 +529,11 @@ static void tpm_init(void)
_plat__SetNvAvail();
}
+size_t tpm_get_burst_size(void)
+{
+ return (tpm_.regs.sts >> burst_count_shift) & burst_count_mask;
+}
+
#ifdef CONFIG_EXTENSION_COMMAND
static void call_extension_command(struct tpm_cmd_header *tpmh,
@@ -579,6 +600,7 @@ void tpm_task(void)
CPRINTF("got %d bytes in response\n", response_size);
if (response_size &&
(response_size <= sizeof(tpm_.regs.data_fifo))) {
+ uint32_t tpm_sts;
/*
* TODO(vbendeb): revisit this when
* crosbug.com/p/55667 has been addressed.
@@ -598,8 +620,12 @@ void tpm_task(void)
}
tpm_.fifo_read_index = 0;
tpm_.fifo_write_index = response_size;
- tpm_.regs.sts |= data_avail;
set_tpm_state(tpm_state_completing_cmd);
+ tpm_sts = tpm_.regs.sts;
+ tpm_sts &= ~(burst_count_mask << burst_count_shift);
+ tpm_sts |= (MIN(response_size, 63) << burst_count_shift)
+ | data_avail;
+ tpm_.regs.sts = tpm_sts;
}
}
}