#include <common.h>
#include <command.h>
+#include <dm.h>
#include <malloc.h>
#include <tpm.h>
#include <asm/unaligned.h>
TPM_COMMAND_NO_ARG(tpm_physical_enable)
TPM_COMMAND_NO_ARG(tpm_physical_disable)
+#ifdef CONFIG_DM_TPM
+static int get_tpm(struct udevice **devp)
+{
+ int rc;
+
+ rc = uclass_first_device(UCLASS_TPM, devp);
+ if (rc) {
+ printf("Could not find TPM (ret=%d)\n", rc);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+#endif
+
static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
return CMD_RET_FAILURE;
}
+#ifdef CONFIG_DM_TPM
+ struct udevice *dev;
+
+ rc = get_tpm(&dev);
+ if (rc)
+ return rc;
+
+ rc = tpm_xfer(dev, command, count, response, &response_length);
+#else
rc = tis_sendrecv(command, count, response, &response_length);
+#endif
free(command);
if (!rc) {
puts("tpm response:\n");
*
* @return 0 on success, non-0 on error.
*/
-uint32_t tpm_init(void);
+int tpm_init(void);
/**
* Issue a TPM_Startup command.
*/
#include <common.h>
-#include <stdarg.h>
-#include <u-boot/sha1.h>
+#include <dm.h>
+#include <tis.h>
#include <tpm.h>
#include <asm/unaligned.h>
+#include <u-boot/sha1.h>
/* Internal error of TPM command library */
#define TPM_LIB_ERROR ((uint32_t)~0u)
response = response_buffer;
response_length = sizeof(response_buffer);
}
+#ifdef CONFIG_DM_TPM
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_first_device(UCLASS_TPM, &dev);
+ if (ret)
+ return ret;
+ err = tpm_xfer(dev, command, tpm_command_size(command),
+ response, &response_length);
+#else
err = tis_sendrecv(command, tpm_command_size(command),
response, &response_length);
- if (err)
+#endif
+ if (err < 0)
return TPM_LIB_ERROR;
if (size_ptr)
*size_ptr = response_length;
return tpm_return_code(response);
}
-uint32_t tpm_init(void)
+int tpm_init(void)
{
- uint32_t err;
+ int err;
+#ifdef CONFIG_DM_TPM
+ struct udevice *dev;
+
+ err = uclass_first_device(UCLASS_TPM, &dev);
+ if (err)
+ return err;
+ return tpm_open(dev);
+#else
err = tis_init();
if (err)
return err;
return tis_open();
+#endif
}
uint32_t tpm_startup(enum tpm_startup_type mode)