blob: 3b68020bd1b795ab4c959bdcb6e4001abb7004ae [file] [log] [blame]
Subrata Banik73505f12023-12-27 21:13:25 +05301/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <console/console.h>
4#include <security/tpm/tss.h>
5#include <vendorcode/google/chromeos/chromeos.h>
6
7int64_t chromeos_get_factory_config(void)
8{
9 static int64_t factory_config = -1;
10
11 if (factory_config >= 0)
12 return factory_config;
13
14 /* Initialize TPM driver. */
15 tpm_result_t rc = tlcl_lib_init();
16 if (rc != TPM_SUCCESS) {
17 printk(BIOS_ERR, "%s:%d - tlcl_lib_init() failed: %#x\n",
18 __func__, __LINE__, rc);
19 return -1;
20 }
21
22 rc = tlcl_cr50_get_factory_config((uint64_t *)&factory_config);
23
24 if (rc != TPM_SUCCESS) {
25 printk(BIOS_ERR, "%s:%d - tlcl_cr50_get_factory_config() failed: %#x\n",
26 __func__, __LINE__, rc);
27 return -1;
28 }
29
30 return factory_config;
31}