1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootstate.h>
4 #include <console/console.h>
5 #include <types.h>
6 #include "psp_def.h"
7
psp_set_spl_fuse(void * unused)8 static void psp_set_spl_fuse(void *unused)
9 {
10 int cmd_status = 0;
11 struct mbox_cmd_late_spl_buffer buffer = {
12 .header = {
13 .size = sizeof(buffer)
14 }
15 };
16 uint32_t c2p38 = soc_read_c2p38();
17
18 if (c2p38 & CORE_2_PSP_MSG_38_FUSE_SPL) {
19 printk(BIOS_DEBUG, "PSP: SPL Fusing may be updated.\n");
20 } else {
21 printk(BIOS_DEBUG, "PSP: SPL Fusing not currently required.\n");
22 return;
23 }
24
25 if (c2p38 & CORE_2_PSP_MSG_38_SPL_FUSE_ERROR) {
26 printk(BIOS_ERR, "PSP: SPL Table does not meet fuse requirements.\n");
27 return;
28 }
29
30 if (c2p38 & CORE_2_PSP_MSG_38_SPL_ENTRY_ERROR) {
31 printk(BIOS_ERR, "PSP: Critical SPL entry missing or current firmware does"
32 " not meet requirements.\n");
33 return;
34 }
35
36 if (c2p38 & CORE_2_PSP_MSG_38_SPL_ENTRY_MISSING) {
37 printk(BIOS_ERR, "PSP: Table of critical SPL values is missing.\n");
38 return;
39 }
40
41 if (!CONFIG(PERFORM_SPL_FUSING))
42 return;
43
44 printk(BIOS_DEBUG, "PSP: SPL Fusing Update Requested.\n");
45 cmd_status = send_psp_command(MBOX_BIOS_CMD_SET_SPL_FUSE, &buffer);
46 psp_print_cmd_status(cmd_status, NULL);
47 }
48
49 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_ENTRY, psp_set_spl_fuse, NULL);
50