1 // SPDX-License-Identifier: GPL-2.0+
13 #include <acpi/acpi_s3.h>
14 #include <asm/cmos_layout.h>
15 #include <asm/early_cmos.h>
16 #include <asm/global_data.h>
18 #include <asm/mrccache.h>
20 #include <asm/processor.h>
21 #include <asm/fsp1/fsp_support.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 static void *fsp_prepare_mrc_cache(void)
27 struct mrc_data_container *cache;
28 struct mrc_region entry;
31 ret = mrccache_get_region(MRC_TYPE_NORMAL, NULL, &entry);
35 cache = mrccache_find_current(&entry);
39 debug("%s: mrc cache at %p, size %x checksum %04x\n", __func__,
40 cache->data, cache->data_size, cache->checksum);
45 int arch_fsp_init(void)
48 int stack = CONFIG_FSP_TEMP_RAM_ADDR;
49 int boot_mode = BOOT_FULL_CONFIG;
52 if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) {
53 prev_sleep_state = chipset_prev_sleep_state();
54 gd->arch.prev_sleep_state = prev_sleep_state;
57 if (!gd->arch.hob_list) {
58 if (IS_ENABLED(CONFIG_ENABLE_MRC_CACHE))
59 nvs = fsp_prepare_mrc_cache();
63 if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) &&
64 prev_sleep_state == ACPI_S3) {
66 /* If waking from S3 and no cache then */
67 debug("No MRC cache found in S3 resume path\n");
68 post_code(POST_RESUME_FAILURE);
69 /* Clear Sleep Type */
70 chipset_clear_sleep_state();
72 debug("Rebooting..\n");
73 outb(SYS_RST | RST_CPU, IO_PORT_RESET);
74 /* Should not reach here.. */
75 panic("Reboot System");
79 * DM is not available yet at this point, hence call
80 * CMOS access library which does not depend on DM.
82 stack = cmos_read32(CMOS_FSP_STACK_ADDR);
83 boot_mode = BOOT_ON_S3_RESUME;
87 * The first time we enter here, call fsp_init().
88 * Note the execution does not return to this function,
89 * instead it jumps to fsp_continue().
91 fsp_init(stack, boot_mode, nvs);
94 * The second time we enter here, adjust the size of malloc()
95 * pool before relocation. Given gd->malloc_base was adjusted
96 * after the call to board_init_f_init_reserve() in arch/x86/
97 * cpu/start.S, we should fix up gd->malloc_limit here.
99 gd->malloc_limit += CONFIG_FSP_SYS_MALLOC_F_LEN;