Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 2 | |
Duncan Laurie | 59be624 | 2016-03-07 13:21:56 -0800 | [diff] [blame] | 3 | #include <bootmode.h> |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 4 | #include <bootsplash.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 6 | #include <console/console.h> |
Lee Leahy | 94b856e | 2015-10-15 12:07:03 -0700 | [diff] [blame] | 7 | #include <fsp/ramstage.h> |
Aaron Durbin | 789f2b6 | 2015-09-09 17:05:06 -0500 | [diff] [blame] | 8 | #include <fsp/util.h> |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 9 | #include <framebuffer_info.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 10 | #include <lib.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 11 | #include <stage_cache.h> |
Aaron Durbin | 39bdb0b | 2015-08-04 23:59:43 -0500 | [diff] [blame] | 12 | #include <string.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 13 | #include <timestamp.h> |
Frans Hendriks | 50b999f | 2019-11-08 13:55:45 +0100 | [diff] [blame] | 14 | #include <cbmem.h> |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 15 | |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 16 | static void display_hob_info(FSP_INFO_HEADER *fsp_info_header) |
| 17 | { |
| 18 | const EFI_GUID graphics_info_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 19 | void *hob_list_ptr = get_hob_list(); |
| 20 | |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 21 | /* Verify the HOBs */ |
| 22 | if (hob_list_ptr == NULL) { |
Elyes HAOUAS | 22ad8f2 | 2022-02-04 19:44:16 +0100 | [diff] [blame] | 23 | printk(BIOS_ERR, "HOB pointer is NULL!\n"); |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 24 | return; |
| 25 | } |
| 26 | |
Frans Hendriks | 509f469 | 2019-06-28 14:11:41 +0200 | [diff] [blame] | 27 | if (CONFIG(DISPLAY_HOBS)) |
| 28 | print_hob_type_structure(0, hob_list_ptr); |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 29 | |
| 30 | /* |
| 31 | * Verify that FSP is generating the required HOBs: |
| 32 | * 7.1: FSP_BOOTLOADER_TEMP_MEMORY_HOB only produced for FSP 1.0 |
| 33 | * 7.2: FSP_RESERVED_MEMORY_RESOURCE_HOB verified by raminit |
| 34 | * 7.3: FSP_NON_VOLATILE_STORAGE_HOB verified by raminit |
| 35 | * 7.4: FSP_BOOTLOADER_TOLUM_HOB verified by raminit |
| 36 | * 7.5: EFI_PEI_GRAPHICS_INFO_HOB verified below, |
| 37 | * if the ImageAttribute bit is set |
| 38 | * FSP_SMBIOS_MEMORY_INFO HOB verified by raminit |
| 39 | */ |
| 40 | if ((fsp_info_header->ImageAttribute & GRAPHICS_SUPPORT_BIT) && |
Frans Hendriks | 509f469 | 2019-06-28 14:11:41 +0200 | [diff] [blame] | 41 | !get_next_guid_hob(&graphics_info_guid, hob_list_ptr) && |
| 42 | CONFIG(DISPLAY_HOBS)) { |
| 43 | printk(BIOS_ERR, "7.5: EFI_PEI_GRAPHICS_INFO_HOB missing!\n"); |
Elyes HAOUAS | 22ad8f2 | 2022-02-04 19:44:16 +0100 | [diff] [blame] | 44 | printk(BIOS_ERR, "Missing one or more required FSP HOBs!\n"); |
Frans Hendriks | 509f469 | 2019-06-28 14:11:41 +0200 | [diff] [blame] | 45 | } |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 48 | static void fsp_run_silicon_init(FSP_INFO_HEADER *fsp_info_header) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 49 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 50 | FSP_SILICON_INIT fsp_silicon_init; |
| 51 | SILICON_INIT_UPD *original_params; |
| 52 | SILICON_INIT_UPD silicon_init_params; |
| 53 | EFI_STATUS status; |
| 54 | UPD_DATA_REGION *upd_ptr; |
| 55 | VPD_DATA_REGION *vpd_ptr; |
| 56 | |
Lee Leahy | cff5f09 | 2016-02-08 08:37:53 -0800 | [diff] [blame] | 57 | /* Display the FSP header */ |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 58 | if (fsp_info_header == NULL) { |
| 59 | printk(BIOS_ERR, "FSP_INFO_HEADER not set!\n"); |
| 60 | return; |
| 61 | } |
| 62 | print_fsp_info(fsp_info_header); |
| 63 | |
| 64 | /* Initialize the UPD values */ |
| 65 | vpd_ptr = (VPD_DATA_REGION *)(fsp_info_header->CfgRegionOffset + |
| 66 | fsp_info_header->ImageBase); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 67 | printk(BIOS_DEBUG, "%p: VPD Data\n", vpd_ptr); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 68 | upd_ptr = (UPD_DATA_REGION *)(vpd_ptr->PcdUpdRegionOffset + |
| 69 | fsp_info_header->ImageBase); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 70 | printk(BIOS_DEBUG, "%p: UPD Data\n", upd_ptr); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 71 | original_params = (void *)((u8 *)upd_ptr + |
| 72 | upd_ptr->SiliconInitUpdOffset); |
| 73 | memcpy(&silicon_init_params, original_params, |
| 74 | sizeof(silicon_init_params)); |
| 75 | soc_silicon_init_params(&silicon_init_params); |
| 76 | |
| 77 | /* Locate VBT and pass to FSP GOP */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 78 | if (CONFIG(RUN_FSP_GOP)) |
Kyösti Mälkki | 0a54685 | 2021-01-24 18:06:26 +0200 | [diff] [blame] | 79 | load_vbt(&silicon_init_params); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 80 | mainboard_silicon_init_params(&silicon_init_params); |
| 81 | |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 82 | if (CONFIG(BMP_LOGO)) |
| 83 | bmp_load_logo(&silicon_init_params.PcdLogoPtr, |
| 84 | &silicon_init_params.PcdLogoSize); |
Frans Hendriks | 50b999f | 2019-11-08 13:55:45 +0100 | [diff] [blame] | 85 | |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 86 | /* Display the UPD data */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 87 | if (CONFIG(DISPLAY_UPD_DATA)) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 88 | soc_display_silicon_init_params(original_params, |
| 89 | &silicon_init_params); |
| 90 | |
| 91 | /* Perform silicon initialization after RAM is configured */ |
| 92 | printk(BIOS_DEBUG, "Calling FspSiliconInit\n"); |
| 93 | fsp_silicon_init = (FSP_SILICON_INIT)(fsp_info_header->ImageBase |
| 94 | + fsp_info_header->FspSiliconInitEntryOffset); |
| 95 | timestamp_add_now(TS_FSP_SILICON_INIT_START); |
Julius Werner | 540a980 | 2019-12-09 13:03:29 -0800 | [diff] [blame] | 96 | printk(BIOS_DEBUG, "Calling FspSiliconInit(%p) at %p\n", |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 97 | &silicon_init_params, fsp_silicon_init); |
Duncan Laurie | fb50983 | 2015-11-22 14:53:57 -0800 | [diff] [blame] | 98 | post_code(POST_FSP_SILICON_INIT); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 99 | status = fsp_silicon_init(&silicon_init_params); |
| 100 | timestamp_add_now(TS_FSP_SILICON_INIT_END); |
| 101 | printk(BIOS_DEBUG, "FspSiliconInit returned 0x%08x\n", status); |
| 102 | |
Frans Hendriks | 50b999f | 2019-11-08 13:55:45 +0100 | [diff] [blame] | 103 | /* The logo_entry can be freed up now as it is not required any longer */ |
Kyösti Mälkki | 4949a3d | 2021-01-09 20:38:43 +0200 | [diff] [blame] | 104 | if (CONFIG(BMP_LOGO)) |
| 105 | bmp_release_logo(); |
Frans Hendriks | 50b999f | 2019-11-08 13:55:45 +0100 | [diff] [blame] | 106 | |
Duncan Laurie | 59be624 | 2016-03-07 13:21:56 -0800 | [diff] [blame] | 107 | /* Mark graphics init done after SiliconInit if VBT was provided */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 108 | #if CONFIG(RUN_FSP_GOP) |
Duncan Laurie | 59be624 | 2016-03-07 13:21:56 -0800 | [diff] [blame] | 109 | /* GraphicsConfigPtr doesn't exist in Quark X1000's FSP, so this needs |
Elyes HAOUAS | 2e4d806 | 2016-08-25 20:50:50 +0200 | [diff] [blame] | 110 | * to be #if'd out instead of using if (). */ |
Duncan Laurie | 59be624 | 2016-03-07 13:21:56 -0800 | [diff] [blame] | 111 | if (silicon_init_params.GraphicsConfigPtr) |
| 112 | gfx_set_init_done(1); |
| 113 | #endif |
| 114 | |
Patrick Rudolph | 92106b1 | 2020-02-19 12:54:06 +0100 | [diff] [blame] | 115 | if (CONFIG(RUN_FSP_GOP)) { |
| 116 | const EFI_GUID vbt_guid = EFI_PEI_GRAPHICS_INFO_HOB_GUID; |
| 117 | u32 *vbt_hob; |
| 118 | |
| 119 | void *hob_list_ptr = get_hob_list(); |
| 120 | vbt_hob = get_next_guid_hob(&vbt_guid, hob_list_ptr); |
| 121 | if (vbt_hob == NULL) { |
| 122 | printk(BIOS_ERR, "FSP_ERR: Graphics Data HOB is not present\n"); |
| 123 | } else { |
| 124 | EFI_PEI_GRAPHICS_INFO_HOB *gop; |
| 125 | |
| 126 | printk(BIOS_DEBUG, "FSP_DEBUG: Graphics Data HOB present\n"); |
| 127 | gop = GET_GUID_HOB_DATA(vbt_hob); |
| 128 | |
| 129 | fb_add_framebuffer_info(gop->FrameBufferBase, |
| 130 | gop->GraphicsMode.HorizontalResolution, |
| 131 | gop->GraphicsMode.VerticalResolution, |
| 132 | gop->GraphicsMode.PixelsPerScanLine * 4, |
| 133 | 32); |
| 134 | } |
| 135 | } |
| 136 | |
Alexandru Gagniuc | 41c003c | 2015-08-28 19:07:35 -0400 | [diff] [blame] | 137 | display_hob_info(fsp_info_header); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Kyösti Mälkki | d0bc92d | 2021-01-10 00:23:58 +0200 | [diff] [blame] | 140 | static void fsp_load(void) |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 141 | { |
Aaron Durbin | 7e7a4df | 2015-12-08 14:34:35 -0600 | [diff] [blame] | 142 | struct prog fsp = PROG_INIT(PROG_REFCODE, "fsp.bin"); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 143 | |
Kyösti Mälkki | e0165fb | 2021-01-09 13:30:57 +0200 | [diff] [blame] | 144 | if (resume_from_stage_cache()) { |
Aaron Durbin | abf87a2 | 2015-08-05 12:26:56 -0500 | [diff] [blame] | 145 | stage_cache_load_stage(STAGE_REFCODE, &fsp); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 146 | } else { |
Julius Werner | 5358467 | 2021-01-11 16:44:06 -0800 | [diff] [blame] | 147 | fsp_relocate(&fsp); |
Kyösti Mälkki | e0165fb | 2021-01-09 13:30:57 +0200 | [diff] [blame] | 148 | |
| 149 | if (prog_entry(&fsp)) |
| 150 | stage_cache_add(STAGE_REFCODE, &fsp); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Aaron Durbin | abf87a2 | 2015-08-05 12:26:56 -0500 | [diff] [blame] | 153 | /* FSP_INFO_HEADER is set as the program entry. */ |
| 154 | fsp_update_fih(prog_entry(&fsp)); |
Furquan Shaikh | f4b20af | 2017-02-20 13:33:32 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void intel_silicon_init(void) |
| 158 | { |
| 159 | fsp_load(); |
Kyösti Mälkki | cc93c6e | 2021-01-09 22:53:52 +0200 | [diff] [blame] | 160 | fsp_run_silicon_init(fsp_get_fih()); |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | /* Initialize the UPD parameters for SiliconInit */ |
Aaron Durbin | 6403167 | 2018-04-21 14:45:32 -0600 | [diff] [blame] | 164 | __weak void mainboard_silicon_init_params( |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 165 | SILICON_INIT_UPD *params) |
| 166 | { |
Lee Leahy | 0946ec3 | 2015-04-20 15:24:54 -0700 | [diff] [blame] | 167 | } |