soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / intel / fsp2_0 / debug.c
blob8c0d67daeb38e8992b1672a1f1b2907c50d1027e
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 asmlinkage size_t fsp_write_line(uint8_t *buffer, size_t number_of_bytes)
12 console_write_line(buffer, number_of_bytes);
13 return number_of_bytes;
16 enum fsp_call_phase {
17 BEFORE_FSP_CALL,
18 AFTER_FSP_CALL,
21 static void fsp_gpio_config_check(enum fsp_call_phase phase, const char *call_str)
23 switch (phase) {
24 case BEFORE_FSP_CALL:
25 printk(BIOS_SPEW, "Snapshot all GPIOs before %s.\n", call_str);
26 gpio_snapshot();
27 break;
28 case AFTER_FSP_CALL:
29 printk(BIOS_SPEW, "Verify GPIO snapshot after %s...", call_str);
30 printk(BIOS_SPEW, "%zd changes detected!\n", gpio_verify_snapshot());
31 break;
32 default:
33 break;
37 enum fsp_log_level fsp_map_console_log_level(void)
39 enum fsp_log_level fsp_debug_level;
41 switch (get_log_level()) {
42 case BIOS_EMERG:
43 case BIOS_ALERT:
44 case BIOS_CRIT:
45 case BIOS_ERR:
46 fsp_debug_level = FSP_LOG_LEVEL_ERR;
47 break;
48 case BIOS_WARNING:
49 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN;
50 break;
51 case BIOS_NOTICE:
52 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN_INFO;
53 break;
54 case BIOS_INFO:
55 fsp_debug_level = FSP_LOG_LEVEL_ERR_WARN_INFO_EVENT;
56 break;
57 case BIOS_DEBUG:
58 case BIOS_SPEW:
59 fsp_debug_level = FSP_LOG_LEVEL_VERBOSE;
60 break;
61 default:
62 fsp_debug_level = FSP_LOG_LEVEL_DISABLE;
63 break;
66 if (!CONFIG(DEBUG_RAM_SETUP))
67 fsp_debug_level = MIN(fsp_debug_level, FSP_LOG_LEVEL_ERR_WARN_INFO);
69 return fsp_debug_level;
72 /*-----------
73 * MemoryInit
74 *-----------
76 void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init,
77 const FSPM_UPD *fspm_old_upd,
78 const FSPM_UPD *fspm_new_upd)
80 display_mtrrs();
82 /* Display the UPD values */
83 if (CONFIG(DISPLAY_UPD_DATA))
84 fspm_display_upd_values(fspm_old_upd, fspm_new_upd);
86 /* Display the call entry point and parameters */
87 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
88 return;
89 printk(BIOS_SPEW, "Calling FspMemoryInit: %p\n", memory_init);
90 printk(BIOS_SPEW, "\t%p: raminit_upd\n", fspm_new_upd);
91 printk(BIOS_SPEW, "\t%p: &hob_list_ptr\n", fsp_get_hob_list_ptr());
94 void fsp_debug_after_memory_init(uint32_t status)
96 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
97 printk(BIOS_SPEW, "FspMemoryInit returned 0x%08x\n", status);
99 if (status != FSP_SUCCESS)
100 return;
102 /* Verify that the HOB list pointer was set */
103 if (fsp_get_hob_list() == NULL)
104 die("ERROR - HOB list pointer was not returned!\n");
106 /* Display and verify the HOBs */
107 if (CONFIG(DISPLAY_HOBS))
108 fsp_display_hobs();
109 if (CONFIG(VERIFY_HOBS))
110 fsp_verify_memory_init_hobs();
112 display_mtrrs();
115 /*-----------
116 * SiliconInit
117 *-----------
119 void fsp_debug_before_silicon_init(fsp_silicon_init_fn silicon_init,
120 const FSPS_UPD *fsps_old_upd,
121 const FSPS_UPD *fsps_new_upd)
123 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
124 fsp_gpio_config_check(BEFORE_FSP_CALL, "FSP Silicon Init");
126 display_mtrrs();
128 /* Display the UPD values */
129 if (CONFIG(DISPLAY_UPD_DATA))
130 soc_display_fsps_upd_params(fsps_old_upd, fsps_new_upd);
132 /* Display the call to FSP SiliconInit */
133 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
134 return;
135 printk(BIOS_SPEW, "Calling FspSiliconInit: %p\n", silicon_init);
136 printk(BIOS_SPEW, "\t%p: upd\n", fsps_new_upd);
139 void fsp_debug_after_silicon_init(uint32_t status)
141 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
142 fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Silicon Init");
144 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
145 printk(BIOS_SPEW, "FspSiliconInit returned 0x%08x\n", status);
147 /* Display the HOBs */
148 if (CONFIG(DISPLAY_HOBS))
149 fsp_display_hobs();
151 display_mtrrs();
154 /*-----------
155 * FspNotify
156 *-----------
158 void fsp_before_debug_notify(fsp_notify_fn notify,
159 const struct fsp_notify_params *notify_params)
161 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
162 fsp_gpio_config_check(BEFORE_FSP_CALL, "FSP Notify");
164 /* Display the call to FspNotify */
165 if (!CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
166 return;
167 printk(BIOS_SPEW, "0x%08x: notify_params->phase\n",
168 notify_params->phase);
169 printk(BIOS_SPEW, "Calling FspNotify: %p\n", notify);
170 printk(BIOS_SPEW, "\t%p: notify_params\n", notify_params);
173 void fsp_debug_after_notify(uint32_t status)
175 if (CONFIG(CHECK_GPIO_CONFIG_CHANGES))
176 fsp_gpio_config_check(AFTER_FSP_CALL, "FSP Notify");
178 if (CONFIG(DISPLAY_FSP_CALLS_AND_STATUS))
179 printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", status);
181 /* Display the HOBs */
182 if (CONFIG(DISPLAY_HOBS))
183 fsp_display_hobs();
185 display_mtrrs();