| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #ifndef _FSP2_0_API_H_ |
| 4 | #define _FSP2_0_API_H_ |
| 5 | |
| 6 | #include <stddef.h> |
| 7 | #include <stdint.h> |
| 8 | #include <fsp/soc_binding.h> |
| 9 | #include <soc/intel/common/mma.h> |
| 10 | |
| 11 | #define FSP_SUCCESS EFI_SUCCESS |
| 12 | #define FSP_INVALID_PARAMETER EFI_INVALID_PARAMETER |
| 13 | #define FSP_DEVICE_ERROR EFI_DEVICE_ERROR |
| 14 | #define FSP_NOT_FOUND EFI_NOT_FOUND |
| 15 | #define FSP_NOT_STARTED EFI_NOT_STARTED |
| 16 | #define FSP_UNSUPPORTED EFI_UNSUPPORTED |
| 17 | |
| 18 | enum fsp_boot_mode { |
| 19 | FSP_BOOT_WITH_FULL_CONFIGURATION = 0x00, |
| 20 | FSP_BOOT_WITH_MINIMAL_CONFIGURATION = 0x01, |
| 21 | FSP_BOOT_ASSUMING_NO_CONFIGURATION_CHANGES = 0x02, |
| 22 | FSP_BOOT_ON_S4_RESUME = 0x05, |
| 23 | FSP_BOOT_ON_S3_RESUME = 0x11, |
| 24 | FSP_BOOT_ON_FLASH_UPDATE = 0x12, |
| 25 | FSP_BOOT_IN_RECOVERY_MODE = 0x20 |
| 26 | }; |
| 27 | |
| 28 | enum fsp_notify_phase { |
| 29 | AFTER_PCI_ENUM = 0x20, |
| 30 | READY_TO_BOOT = 0x40, |
| 31 | END_OF_FIRMWARE = 0xF0 |
| 32 | }; |
| 33 | |
| 34 | /* Main FSP stages */ |
| 35 | void preload_fspm(void); |
| 36 | void fsp_memory_init(bool s3wake); |
| 37 | void preload_fsps(void); |
| 38 | void fsp_silicon_init(void); |
| 39 | |
| 40 | /* |
| 41 | * Load FSP-S from stage cache or CBFS. This allows SoCs to load FSPS-S |
| 42 | * separately from calling silicon init. It might be required in cases where |
| 43 | * stage cache is no longer available by the point SoC calls into silicon init. |
| 44 | */ |
| 45 | void fsps_load(void); |
| 46 | |
| 47 | /* Callbacks for updating stage-specific parameters */ |
| 48 | void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version); |
| 49 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd); |
| 50 | /* Callbacks for SoC/Mainboard specific overrides */ |
| 51 | void platform_fsp_memory_multi_phase_init_cb(uint32_t phase_index); |
| 52 | void platform_fsp_silicon_multi_phase_init_cb(uint32_t phase_index); |
| 53 | /* |
| 54 | * Displays an early shutdown notification to the user. |
| 55 | * |
| 56 | * This function is responsible to perform the needful operations for informing |
| 57 | * the user that the system is about to shut down prematurely. The implementation |
| 58 | * might be different depending upon the underlying technology that can be used for |
| 59 | * implementing eSOL for user notification. |
| 60 | * |
| 61 | * Argument: NULL for platform with libgfxinit and FSP-M UPD pointer for uGOP. |
| 62 | * |
| 63 | * Note: This function should be called before the actual shutdown process begins, |
| 64 | * allowing the user to potentially save data or take other necessary actions. |
| 65 | */ |
| 66 | #if CONFIG(PLATFORM_HAS_EARLY_LOW_BATTERY_INDICATOR) |
| 67 | void platform_display_early_shutdown_notification(void *arg); |
| 68 | #else |
| 69 | static inline void platform_display_early_shutdown_notification(void *arg) { /* nop */ } |
| 70 | #endif |
| 71 | |
| 72 | /* Check if MultiPhase Si Init is enabled */ |
| 73 | bool fsp_is_multi_phase_init_enabled(void); |
| 74 | /* |
| 75 | * The following functions are used when FSP_PLATFORM_MEMORY_SETTINGS_VERSION |
| 76 | * is employed allowing the mainboard and SoC to supply their own version |
| 77 | * for memory settings respectively. The valid values are 0-15 for each |
| 78 | * function. |
| 79 | */ |
| 80 | uint8_t fsp_memory_mainboard_version(void); |
| 81 | uint8_t fsp_memory_soc_version(void); |
| 82 | |
| 83 | /* Callback after processing FSP notify */ |
| 84 | void platform_fsp_notify_status(enum fsp_notify_phase phase); |
| 85 | |
| 86 | /* Initialize memory margin analysis settings. */ |
| 87 | void setup_mma(FSP_M_CONFIG *memory_cfg); |
| 88 | /* |
| 89 | * Populate UPD entries for the logo if the platform utilizes |
| 90 | * the FSP's capability for rendering bitmap (BMP) images. |
| 91 | */ |
| 92 | void soc_load_logo_by_fsp(FSPS_UPD *supd); |
| 93 | /* |
| 94 | * API that allows coreboot to perform native logo rendering after FSP display initialization. |
| 95 | * |
| 96 | * This implementation handles rendering the boot logo directly within coreboot. |
| 97 | * It depends on the FSP to initialize the display panel. |
| 98 | * Once the FSP completes display initialization and transfers control, coreboot |
| 99 | * renders the logo. |
| 100 | * |
| 101 | * Note: This native approach may introduce a ~10-30ms delay in displaying |
| 102 | * BMP images compared to rendering via FSP (when `USE_COREBOOT_FOR_BMP_RENDERING` |
| 103 | * Kconfig is not enable). |
| 104 | * |
| 105 | * coreboot native logo rendering provides greater flexibility for platform-specific |
| 106 | * logo customizations (e.g., alignment) that are not feasible or practical to implement |
| 107 | * within the FSP (silicon firmware) depending upon the OEM device need. |
| 108 | */ |
| 109 | #if CONFIG(USE_COREBOOT_FOR_BMP_RENDERING) |
| 110 | void soc_load_logo_by_coreboot(void); |
| 111 | int soc_mark_gfx_memory(void); |
| 112 | #else |
| 113 | static inline void soc_load_logo_by_coreboot(void) { /* nop */ } |
| 114 | static inline int soc_mark_gfx_memory(void) { return -1; } |
| 115 | #endif |
| 116 | |
| 117 | /* Update the SOC specific memory config param for mma. */ |
| 118 | void soc_update_memory_params_for_mma(FSP_M_CONFIG *memory_cfg, |
| 119 | struct mma_config_param *mma_cfg); |
| 120 | |
| 121 | /* |
| 122 | * As per FSP integration guide: |
| 123 | * If bootloader needs to take control of APs back, a full AP re-initialization is |
| 124 | * required after FSP-S is completed and control has been transferred back to bootloader |
| 125 | */ |
| 126 | void do_mpinit_after_fsp(void); |
| 127 | |
| 128 | /* |
| 129 | * # DOCUMENTATION: |
| 130 | * |
| 131 | * This file defines the interface between coreboot and the FSP 2.0 wrapper |
| 132 | * fsp_memory_init(), fsp_silicon_init(), and fsp_notify() are the main entry |
| 133 | * points and map 1:1 to the FSP entry points of the same name. |
| 134 | * |
| 135 | * ### fsp_memory_init(): |
| 136 | * - s3wake: boolean indicating if the system is waking from resume |
| 137 | * |
| 138 | * This function is responsible for loading and executing the memory |
| 139 | * initialization code from the FSP-M binary. It expects this binary to reside |
| 140 | * in cbfs as FSP_M_FILE. |
| 141 | * |
| 142 | * The function takes one parameter, which is described above, but does not |
| 143 | * take in memory parameters as an argument. The memory parameters can be filled |
| 144 | * in with platform_fsp_memory_init_params_cb(). This is a callback symbol |
| 145 | * that fsp_memory_init() will call. The platform must provide this symbol. |
| 146 | * |
| 147 | * |
| 148 | * ### fsp_silicon_init(): |
| 149 | * |
| 150 | * This function is responsible for loading and executing the silicon |
| 151 | * initialization code from the FSP-S binary. It expects this binary to reside |
| 152 | * in cbfs as FSP_S_FILE. |
| 153 | * |
| 154 | * Like fsp_memory_init(), it provides a callback to fill in FSP-specific |
| 155 | * parameters, via platform_fsp_silicon_init_params_cb(). The platform must |
| 156 | * also provide this symbol. |
| 157 | * |
| 158 | * |
| 159 | * ### fsp_notify(): |
| 160 | * - phase: Which FSP notification phase |
| 161 | * |
| 162 | * This function is responsible for loading and executing the notify code from |
| 163 | * the FSP-S binary. It expects that fsp_silicon_init() has already been called |
| 164 | * successfully, and that the FSP-S binary is still loaded into memory. |
| 165 | */ |
| 166 | |
| 167 | #endif /* _FSP2_0_API_H_ */ |