xref: /openbmc/u-boot/board/aspeed/ast2600_ibm/ibm.c (revision 1cf1c480)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright 2022 IBM Corp.
4  */
5 
6 #include <common.h>
7 #include <dm/uclass.h>
8 #include <tpm-common.h>
9 #include <tpm-v2.h>
10 
11 int board_late_init(void)
12 {
13 	int rc;
14 	struct udevice *dev;
15 	/*
16 	 * The digest is just an arbitrary sequence for now to ensure that the
17 	 * TPM gets "poisoned."
18 	 */
19 	const unsigned char digest[32] = {
20 		0x6e, 0x65, 0x76, 0x65, 0x72, 0x67, 0x6f, 0x6e,
21 		0x6e, 0x61, 0x67, 0x69, 0x76, 0x65, 0x79, 0x6f,
22 		0x75, 0x75, 0x70, 0x6e, 0x65, 0x76, 0x65, 0x72,
23 		0x67, 0x6f, 0x6e, 0x6e, 0x61, 0x6c, 0x65, 0x74
24 	};
25 
26 	rc = uclass_first_device_err(UCLASS_TPM, &dev);
27 	if (rc)
28 		return 0;
29 
30 	rc = tpm_init(dev);
31 	if (rc)
32 		return 0;
33 
34 	rc = tpm2_startup(dev, TPM2_SU_CLEAR);
35 	if (rc)
36 		return 0;
37 
38 	rc = tpm2_pcr_extend(dev, 0, digest);
39 	if (!rc)
40 		printf("TPM: PCR0 extended.\n");
41 
42 	return 0;
43 }
44