soc/mediatek/mt8196: Initialize SSPM
[coreboot2.git] / src / drivers / intel / fsp2_0 / debug.c
blob9dc964d303ee01a9b715dc04a13c0625dfa65b8b
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <commonlib/helpers.h>
4 #include <console/console.h>
5 #include <console/streams.h>
6 #include <cpu/x86/mtrr.h>
7 #include <fsp/debug.h>
8 #include <fsp/util.h>
10 enum fsp_call_phase {
11 BEFORE_FSP_CALL,
12 AFTER_FSP_CALL,
15 static void fsp_gpio_config_check(enum fsp_call_phase phase, const char *call_str)
17 switch (phase) {
18 case BEFORE_FSP_CALL:
19 printk(BIOS_SPEW, "Snapshot all GPIOs before %s.\n", call_str);
20 gpio_snapshot();
21 break;
22 case AFTER_FSP_CALL:
23 printk(BIOS_SPEW, "Verify GPIO snapshot after %s...", call_str);
24 printk(BIOS_SPEW, "%zd changes detected!\n", gpio_verify_snapshot());
25 break;
26 default:
27 break;
31 enum fsp_log_level fsp_map_console_log_level(void)
33 enum fsp_log_level fsp_debug_level;
35 switch (get_log_level()) {
36 case BIOS_EMERG:
37 case BIOS_ALERT:
38 case BIOS_CRIT:
39 case BIOS_ERR:
40 fsp_debug_level = FSP_LOG_LEVEL_ERR;
41 break;
42 case BIOS_WARNING:
43 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN;
44 break;
45 case BIOS_NOTICE:
46 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN_INFO;
47 break;
48 case BIOS_INFO:
49 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN_INFO_EVENT;
50 break;
51 case BIOS_DEBUG:
52 case BIOS_SPEW:
53 fsp_debug_level = FSP_LOG_LEVEL_VERBOSE;
54 break;
55 default:
56 fsp_debug_level = FSP_LOG_LEVEL_DISABLE;
57 break;
60 if (!CONFIG(DEBUG_RAM_SETUP))
61 fsp_debug_level = MIN(fsp_debug_level, FSP_LOG_LEVEL_ERR_WARN_INFO);
63 return fsp_debug_level;
66 /*-----------
67 * MemoryInit
68 *-----------
70 void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init,
71 const FSPM_UPD *fspm_old_upd,
72 const FSPM_UPD *fspm_new_upd)
74 display_mtrrs();
76 /* Display the UPD values */
77 if (CONFIG(DISPLAY_UPD_DATA))
78 fspm_display_upd_values(fspm_old_upd, fspm_new_upd);
80 /* Display the call entry point and parameters */
81 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
82 return;
83 printk(BIOS_SPEW, "Calling FspMemoryInit: %p\n", memory_init);
84 printk(BIOS_SPEW, "\t%p: raminit_upd\n", fspm_new_upd);
85 printk(BIOS_SPEW, "\t%p: &hob_list_ptr\n", fsp_get_hob_list_ptr());
88 void fsp_debug_after_memory_init(efi_return_status_t status)
90 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
91 fsp_printk(status, BIOS_SPEW, "FspMemoryInit");
93 if (status != FSP_SUCCESS)
94 return;
96 /* Verify that the HOB list pointer was set */
97 if (fsp_get_hob_list() == NULL)
98 die("ERROR - HOB list pointer was not returned!\n");
100 /* Display and verify the HOBs */
101 if (CONFIG(DISPLAY_HOBS))
102 fsp_display_hobs();
103 if (CONFIG(VERIFY_HOBS))
104 fsp_verify_memory_init_hobs();
106 display_mtrrs();
109 /*-----------
110 * SiliconInit
111 *-----------
113 void fsp_debug_before_silicon_init(fsp_silicon_init_fn silicon_init,
114 const FSPS_UPD *fsps_old_upd,
115 const FSPS_UPD *fsps_new_upd)
117 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
118 fsp_gpio_config_check(BEFORE_FSP_CALL, "FSP Silicon Init");
120 display_mtrrs();
122 /* Display the UPD values */
123 if (CONFIG(DISPLAY_UPD_DATA))
124 soc_display_fsps_upd_params(fsps_old_upd, fsps_new_upd);
126 /* Display the call to FSP SiliconInit */
127 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
128 return;
129 printk(BIOS_SPEW, "Calling FspSiliconInit: %p\n", silicon_init);
130 printk(BIOS_SPEW, "\t%p: upd\n", fsps_new_upd);
133 void fsp_debug_after_silicon_init(efi_return_status_t status)
135 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
136 fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Silicon Init");
138 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
139 fsp_printk(status, BIOS_SPEW, "FspSiliconInit");
141 /* Display the HOBs */
142 if (CONFIG(DISPLAY_HOBS))
143 fsp_display_hobs();
145 display_mtrrs();
148 /*-----------
149 * FspNotify
150 *-----------
152 void fsp_before_debug_notify(fsp_notify_fn notify,
153 const struct fsp_notify_params *notify_params)
155 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
156 fsp_gpio_config_check(BEFORE_FSP_CALL, "FSP Notify");
158 /* Display the call to FspNotify */
159 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
160 return;
161 printk(BIOS_SPEW, "0x%08x: notify_params->phase\n",
162 notify_params->phase);
163 printk(BIOS_SPEW, "Calling FspNotify: %p\n", notify);
164 printk(BIOS_SPEW, "\t%p: notify_params\n", notify_params);
167 void fsp_debug_after_notify(efi_return_status_t status)
169 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
170 fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Notify");
172 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
173 fsp_printk(status, BIOS_SPEW, "FspNotify");
175 /* Display the HOBs */
176 if (CONFIG(DISPLAY_HOBS))
177 fsp_display_hobs();
179 display_mtrrs();