mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 16:52:14 +02:00
tpm: Export the open/close functions
At present these functions are not accessible outside the TPM library, but in some cases we need to call them. Export them in the header file and add a define for the SHA1 digest size. Also adjust tpm_open() to call tpm_close() first so that the TPM is in a known state before opening (e.g. by a previous phase of U-Boot). Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -388,31 +388,6 @@ static int tis_readresponse(struct udevice *dev, u8 *buffer, size_t len)
|
||||
return offset;
|
||||
}
|
||||
|
||||
static int tpm_tis_lpc_open(struct udevice *dev)
|
||||
{
|
||||
struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
|
||||
struct tpm_locality *regs = priv->regs;
|
||||
u8 locality = 0; /* we use locality zero for everything. */
|
||||
int ret;
|
||||
|
||||
/* now request access to locality. */
|
||||
tpm_write_word(priv, TIS_ACCESS_REQUEST_USE, ®s[locality].access);
|
||||
|
||||
/* did we get a lock? */
|
||||
ret = tis_wait_reg(priv, ®s[locality].access,
|
||||
TIS_ACCESS_ACTIVE_LOCALITY,
|
||||
TIS_ACCESS_ACTIVE_LOCALITY);
|
||||
if (ret == -ETIMEDOUT) {
|
||||
printf("%s:%d - failed to lock locality %d\n",
|
||||
__FILE__, __LINE__, locality);
|
||||
return ret;
|
||||
}
|
||||
|
||||
tpm_write_word(priv, TIS_STS_COMMAND_READY,
|
||||
®s[locality].tpm_status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tpm_tis_lpc_close(struct udevice *dev)
|
||||
{
|
||||
struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
|
||||
@@ -434,6 +409,38 @@ static int tpm_tis_lpc_close(struct udevice *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tpm_tis_lpc_open(struct udevice *dev)
|
||||
{
|
||||
struct tpm_tis_lpc_priv *priv = dev_get_priv(dev);
|
||||
struct tpm_locality *regs = priv->regs;
|
||||
u8 locality = 0; /* we use locality zero for everything. */
|
||||
int ret;
|
||||
|
||||
ret = tpm_tis_lpc_close(dev);
|
||||
if (ret) {
|
||||
printf("%s: Failed to close TPM\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* now request access to locality. */
|
||||
tpm_write_word(priv, TIS_ACCESS_REQUEST_USE, ®s[locality].access);
|
||||
|
||||
/* did we get a lock? */
|
||||
ret = tis_wait_reg(priv, ®s[locality].access,
|
||||
TIS_ACCESS_ACTIVE_LOCALITY,
|
||||
TIS_ACCESS_ACTIVE_LOCALITY);
|
||||
if (ret == -ETIMEDOUT) {
|
||||
printf("%s:%d - failed to lock locality %d\n",
|
||||
__FILE__, __LINE__, locality);
|
||||
return ret;
|
||||
}
|
||||
|
||||
tpm_write_word(priv, TIS_STS_COMMAND_READY,
|
||||
®s[locality].tpm_status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tpm_tis_get_desc(struct udevice *dev, char *buf, int size)
|
||||
{
|
||||
ulong chip_type = dev_get_driver_data(dev);
|
||||
|
Reference in New Issue
Block a user