blob: 5c40966e4f686d31e44c5c9d6e8142729cf7be67 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lee Leahy0946ec32015-04-20 15:24:54 -07002
Duncan Laurie59be6242016-03-07 13:21:56 -08003#include <bootmode.h>
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +02004#include <bootsplash.h>
Lee Leahy0946ec32015-04-20 15:24:54 -07005#include <console/console.h>
Lee Leahy94b856e2015-10-15 12:07:03 -07006#include <fsp/ramstage.h>
Aaron Durbin789f2b62015-09-09 17:05:06 -05007#include <fsp/util.h>
Patrick Rudolph92106b12020-02-19 12:54:06 +01008#include <framebuffer_info.h>
Lee Leahy0946ec32015-04-20 15:24:54 -07009#include <stage_cache.h>
Aaron Durbin39bdb0b2015-08-04 23:59:43 -050010#include <string.h>
Lee Leahy0946ec32015-04-20 15:24:54 -070011#include <timestamp.h>
12
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040013static void display_hob_info(FSP_INFO_HEADER *fsp_info_header)
14{
15 const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID;
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040016 void *hob_list_ptr = get_hob_list();
17
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040018 /* Verify the HOBs */
19 if (hob_list_ptr == NULL) {
Elyes HAOUAS22ad8f22022-02-04 19:44:16 +010020 printk(BIOS_ERR, "HOB pointer is NULL!\n");
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040021 return;
22 }
23
Frans Hendriks509f4692019-06-28 14:11:41 +020024 if (CONFIG(DISPLAY_HOBS))
25 print_hob_type_structure(0, hob_list_ptr);
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040026
27 /*
28 * Verify that FSP is generating the required HOBs:
29 * 7.1: FSP_BOOTLOADER_TEMP_MEMORY_HOB only produced for FSP 1.0
30 * 7.2: FSP_RESERVED_MEMORY_RESOURCE_HOB verified by raminit
31 * 7.3: FSP_NON_VOLATILE_STORAGE_HOB verified by raminit
32 * 7.4: FSP_BOOTLOADER_TOLUM_HOB verified by raminit
33 * 7.5: EFI_PEI_GRAPHICS_INFO_HOB verified below,
34 * if the ImageAttribute bit is set
35 * FSP_SMBIOS_MEMORY_INFO HOB verified by raminit
36 */
37 if ((fsp_info_header->ImageAttribute & GRAPHICS_SUPPORT_BIT) &&
Arthur Heymansca74d7e2022-03-30 14:41:16 +020038 !get_guid_hob(&graphics_info_guid, hob_list_ptr) &&
Frans Hendriks509f4692019-06-28 14:11:41 +020039 CONFIG(DISPLAY_HOBS)) {
40 printk(BIOS_ERR, "7.5: EFI_PEI_GRAPHICS_INFO_HOB missing!\n");
Elyes HAOUAS22ad8f22022-02-04 19:44:16 +010041 printk(BIOS_ERR, "Missing one or more required FSP HOBs!\n");
Frans Hendriks509f4692019-06-28 14:11:41 +020042 }
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -040043}
44
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +020045static void fsp_run_silicon_init(FSP_INFO_HEADER *fsp_info_header)
Lee Leahy0946ec32015-04-20 15:24:54 -070046{
Lee Leahy0946ec32015-04-20 15:24:54 -070047 FSP_SILICON_INIT fsp_silicon_init;
48 SILICON_INIT_UPD *original_params;
49 SILICON_INIT_UPD silicon_init_params;
50 EFI_STATUS status;
51 UPD_DATA_REGION *upd_ptr;
52 VPD_DATA_REGION *vpd_ptr;
53
Lee Leahycff5f092016-02-08 08:37:53 -080054 /* Display the FSP header */
Lee Leahy0946ec32015-04-20 15:24:54 -070055 if (fsp_info_header == NULL) {
56 printk(BIOS_ERR, "FSP_INFO_HEADER not set!\n");
57 return;
58 }
59 print_fsp_info(fsp_info_header);
60
61 /* Initialize the UPD values */
62 vpd_ptr = (VPD_DATA_REGION *)(fsp_info_header->CfgRegionOffset +
63 fsp_info_header->ImageBase);
Julius Werner540a9802019-12-09 13:03:29 -080064 printk(BIOS_DEBUG, "%p: VPD Data\n", vpd_ptr);
Lee Leahy0946ec32015-04-20 15:24:54 -070065 upd_ptr = (UPD_DATA_REGION *)(vpd_ptr->PcdUpdRegionOffset +
66 fsp_info_header->ImageBase);
Julius Werner540a9802019-12-09 13:03:29 -080067 printk(BIOS_DEBUG, "%p: UPD Data\n", upd_ptr);
Lee Leahy0946ec32015-04-20 15:24:54 -070068 original_params = (void *)((u8 *)upd_ptr +
69 upd_ptr->SiliconInitUpdOffset);
70 memcpy(&silicon_init_params, original_params,
71 sizeof(silicon_init_params));
72 soc_silicon_init_params(&silicon_init_params);
73
74 /* Locate VBT and pass to FSP GOP */
Julius Wernercd49cce2019-03-05 16:53:33 -080075 if (CONFIG(RUN_FSP_GOP))
Kyösti Mälkki0a546852021-01-24 18:06:26 +020076 load_vbt(&silicon_init_params);
Lee Leahy0946ec32015-04-20 15:24:54 -070077 mainboard_silicon_init_params(&silicon_init_params);
78
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +020079 if (CONFIG(BMP_LOGO))
80 bmp_load_logo(&silicon_init_params.PcdLogoPtr,
81 &silicon_init_params.PcdLogoSize);
Frans Hendriks50b999f2019-11-08 13:55:45 +010082
Lee Leahy0946ec32015-04-20 15:24:54 -070083 /* Display the UPD data */
Julius Wernercd49cce2019-03-05 16:53:33 -080084 if (CONFIG(DISPLAY_UPD_DATA))
Lee Leahy0946ec32015-04-20 15:24:54 -070085 soc_display_silicon_init_params(original_params,
86 &silicon_init_params);
87
88 /* Perform silicon initialization after RAM is configured */
89 printk(BIOS_DEBUG, "Calling FspSiliconInit\n");
90 fsp_silicon_init = (FSP_SILICON_INIT)(fsp_info_header->ImageBase
91 + fsp_info_header->FspSiliconInitEntryOffset);
92 timestamp_add_now(TS_FSP_SILICON_INIT_START);
Julius Werner540a9802019-12-09 13:03:29 -080093 printk(BIOS_DEBUG, "Calling FspSiliconInit(%p) at %p\n",
Lee Leahy0946ec32015-04-20 15:24:54 -070094 &silicon_init_params, fsp_silicon_init);
lilacious40cb3fe2023-06-21 23:24:14 +020095 post_code(POSTCODE_FSP_SILICON_INIT);
Lee Leahy0946ec32015-04-20 15:24:54 -070096 status = fsp_silicon_init(&silicon_init_params);
97 timestamp_add_now(TS_FSP_SILICON_INIT_END);
98 printk(BIOS_DEBUG, "FspSiliconInit returned 0x%08x\n", status);
99
Frans Hendriks50b999f2019-11-08 13:55:45 +0100100 /* The logo_entry can be freed up now as it is not required any longer */
Kyösti Mälkki4949a3d2021-01-09 20:38:43 +0200101 if (CONFIG(BMP_LOGO))
102 bmp_release_logo();
Frans Hendriks50b999f2019-11-08 13:55:45 +0100103
Duncan Laurie59be6242016-03-07 13:21:56 -0800104 /* Mark graphics init done after SiliconInit if VBT was provided */
Julius Wernercd49cce2019-03-05 16:53:33 -0800105#if CONFIG(RUN_FSP_GOP)
Duncan Laurie59be6242016-03-07 13:21:56 -0800106 /* GraphicsConfigPtr doesn't exist in Quark X1000's FSP, so this needs
Elyes HAOUAS2e4d8062016-08-25 20:50:50 +0200107 * to be #if'd out instead of using if (). */
Duncan Laurie59be6242016-03-07 13:21:56 -0800108 if (silicon_init_params.GraphicsConfigPtr)
109 gfx_set_init_done(1);
110#endif
111
Patrick Rudolph92106b12020-02-19 12:54:06 +0100112 if (CONFIG(RUN_FSP_GOP)) {
113 const EFI_GUID vbt_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID;
114 u32 *vbt_hob;
115
116 void *hob_list_ptr = get_hob_list();
Arthur Heymansca74d7e2022-03-30 14:41:16 +0200117 vbt_hob = get_guid_hob(&vbt_guid, hob_list_ptr);
Patrick Rudolph92106b12020-02-19 12:54:06 +0100118 if (vbt_hob == NULL) {
119 printk(BIOS_ERR, "FSP_ERR: Graphics Data HOB is not present\n");
120 } else {
121 EFI_PEI_GRAPHICS_INFO_HOB *gop;
122
123 printk(BIOS_DEBUG, "FSP_DEBUG: Graphics Data HOB present\n");
124 gop = GET_GUID_HOB_DATA(vbt_hob);
125
126 fb_add_framebuffer_info(gop->FrameBufferBase,
127 gop->GraphicsMode.HorizontalResolution,
128 gop->GraphicsMode.VerticalResolution,
129 gop->GraphicsMode.PixelsPerScanLine * 4,
130 32);
131 }
132 }
133
Alexandru Gagniuc41c003c2015-08-28 19:07:35 -0400134 display_hob_info(fsp_info_header);
Lee Leahy0946ec32015-04-20 15:24:54 -0700135}
136
Kyösti Mälkkid0bc92d2021-01-10 00:23:58 +0200137static void fsp_load(void)
Lee Leahy0946ec32015-04-20 15:24:54 -0700138{
Aaron Durbin7e7a4df2015-12-08 14:34:35 -0600139 struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin");
Lee Leahy0946ec32015-04-20 15:24:54 -0700140
Kyösti Mälkkie0165fb2021-01-09 13:30:57 +0200141 if (resume_from_stage_cache()) {
Aaron Durbinabf87a22015-08-05 12:26:56 -0500142 stage_cache_load_stage(STAGE_REFCODE, &fsp);
Lee Leahy0946ec32015-04-20 15:24:54 -0700143 } else {
Julius Werner53584672021-01-11 16:44:06 -0800144 fsp_relocate(&fsp);
Kyösti Mälkkie0165fb2021-01-09 13:30:57 +0200145
146 if (prog_entry(&fsp))
147 stage_cache_add(STAGE_REFCODE, &fsp);
Lee Leahy0946ec32015-04-20 15:24:54 -0700148 }
149
Aaron Durbinabf87a22015-08-05 12:26:56 -0500150 /* FSP_INFO_HEADER is set as the program entry. */
151 fsp_update_fih(prog_entry(&fsp));
Furquan Shaikhf4b20af2017-02-20 13:33:32 -0800152}
153
154void intel_silicon_init(void)
155{
156 fsp_load();
Kyösti Mälkkicc93c6e2021-01-09 22:53:52 +0200157 fsp_run_silicon_init(fsp_get_fih());
Lee Leahy0946ec32015-04-20 15:24:54 -0700158}
159
160/* Initialize the UPD parameters for SiliconInit */
Aaron Durbin64031672018-04-21 14:45:32 -0600161__weak void mainboard_silicon_init_params(
Lee Leahy0946ec32015-04-20 15:24:54 -0700162 SILICON_INIT_UPD *params)
163{
Lee Leahy0946ec32015-04-20 15:24:54 -0700164}