Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / x86 / lib / fsp / fsp_common.c
index 5276ce6ab1a2f967780054860f13d05d096cce91..cf32b3e512f238ef30fbadafe5fb2ab18c7bcdfb 100644 (file)
@@ -1,11 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <cpu_func.h>
+#include <dm.h>
 #include <errno.h>
+#include <init.h>
+#include <log.h>
+#include <rtc.h>
+#include <acpi/acpi_s3.h>
+#include <asm/cmos_layout.h>
+#include <asm/early_cmos.h>
 #include <asm/io.h>
 #include <asm/mrccache.h>
 #include <asm/post.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+int checkcpu(void)
+{
+       return 0;
+}
+
 int print_cpuinfo(void)
 {
        post_code(POST_CPU_INFO);
@@ -46,55 +58,30 @@ void board_final_cleanup(void)
                debug("fail, error code %x\n", status);
        else
                debug("OK\n");
-
-       return;
 }
 
-static __maybe_unused void *fsp_prepare_mrc_cache(void)
+#ifdef CONFIG_HAVE_ACPI_RESUME
+int fsp_save_s3_stack(void)
 {
-       struct mrc_data_container *cache;
-       struct mrc_region entry;
+       struct udevice *dev;
        int ret;
 
-       ret = mrccache_get_region(NULL, &entry);
-       if (ret)
-               return NULL;
-
-       cache = mrccache_find_current(&entry);
-       if (!cache)
-               return NULL;
-
-       debug("%s: mrc cache at %p, size %x checksum %04x\n", __func__,
-             cache->data, cache->data_size, cache->checksum);
+       if (gd->arch.prev_sleep_state == ACPI_S3)
+               return 0;
 
-       return cache->data;
-}
-
-int x86_fsp_init(void)
-{
-       void *nvs;
+       ret = uclass_get_device(UCLASS_RTC, 0, &dev);
+       if (ret) {
+               debug("Cannot find RTC: err=%d\n", ret);
+               return -ENODEV;
+       }
 
-       if (!gd->arch.hob_list) {
-#ifdef CONFIG_ENABLE_MRC_CACHE
-               nvs = fsp_prepare_mrc_cache();
-#else
-               nvs = NULL;
-#endif
-               /*
-                * The first time we enter here, call fsp_init().
-                * Note the execution does not return to this function,
-                * instead it jumps to fsp_continue().
-                */
-               fsp_init(CONFIG_FSP_TEMP_RAM_ADDR, BOOT_FULL_CONFIG, nvs);
-       } else {
-               /*
-                * The second time we enter here, adjust the size of malloc()
-                * pool before relocation. Given gd->malloc_base was adjusted
-                * after the call to board_init_f_mem() in arch/x86/cpu/start.S,
-                * we should fix up gd->malloc_limit here.
-                */
-               gd->malloc_limit += CONFIG_FSP_SYS_MALLOC_F_LEN;
+       /* Save the stack address to CMOS */
+       ret = rtc_write32(dev, CMOS_FSP_STACK_ADDR, gd->start_addr_sp);
+       if (ret) {
+               debug("Save stack address to CMOS: err=%d\n", ret);
+               return -EIO;
        }
 
        return 0;
 }
+#endif