2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-01-28 05:13:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2017-04-21 14:24:39 +00:00
|
|
|
#include <dm.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
#include <errno.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2017-04-21 14:24:39 +00:00
|
|
|
#include <rtc.h>
|
2020-04-08 22:57:35 +00:00
|
|
|
#include <acpi/acpi_s3.h>
|
2017-04-21 14:24:39 +00:00
|
|
|
#include <asm/cmos_layout.h>
|
|
|
|
#include <asm/early_cmos.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
#include <asm/io.h>
|
2015-10-12 04:37:42 +00:00
|
|
|
#include <asm/mrccache.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
#include <asm/post.h>
|
|
|
|
#include <asm/processor.h>
|
2019-09-25 14:00:11 +00:00
|
|
|
#include <asm/fsp1/fsp_support.h>
|
2015-01-28 05:13:39 +00:00
|
|
|
|
2015-07-31 15:31:31 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2019-12-07 04:42:10 +00:00
|
|
|
static void *fsp_prepare_mrc_cache(void)
|
|
|
|
{
|
|
|
|
struct mrc_data_container *cache;
|
|
|
|
struct mrc_region entry;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mrccache_get_region(MRC_TYPE_NORMAL, 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);
|
|
|
|
|
|
|
|
return cache->data;
|
|
|
|
}
|
|
|
|
|
2017-03-28 16:27:18 +00:00
|
|
|
int arch_fsp_init(void)
|
2015-06-07 03:33:14 +00:00
|
|
|
{
|
2015-10-12 04:37:42 +00:00
|
|
|
void *nvs;
|
2017-04-21 14:24:39 +00:00
|
|
|
int stack = CONFIG_FSP_TEMP_RAM_ADDR;
|
2017-04-21 14:24:31 +00:00
|
|
|
int boot_mode = BOOT_FULL_CONFIG;
|
2020-07-10 00:43:16 +00:00
|
|
|
int prev_sleep_state;
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) {
|
|
|
|
prev_sleep_state = chipset_prev_sleep_state();
|
|
|
|
gd->arch.prev_sleep_state = prev_sleep_state;
|
|
|
|
}
|
2015-10-12 04:37:42 +00:00
|
|
|
|
2015-08-20 13:40:19 +00:00
|
|
|
if (!gd->arch.hob_list) {
|
2019-09-25 14:11:27 +00:00
|
|
|
if (IS_ENABLED(CONFIG_ENABLE_MRC_CACHE))
|
|
|
|
nvs = fsp_prepare_mrc_cache();
|
|
|
|
else
|
|
|
|
nvs = NULL;
|
2017-04-21 14:24:31 +00:00
|
|
|
|
2020-07-10 00:43:16 +00:00
|
|
|
if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) &&
|
|
|
|
prev_sleep_state == ACPI_S3) {
|
2017-04-21 14:24:31 +00:00
|
|
|
if (nvs == NULL) {
|
|
|
|
/* If waking from S3 and no cache then */
|
|
|
|
debug("No MRC cache found in S3 resume path\n");
|
|
|
|
post_code(POST_RESUME_FAILURE);
|
|
|
|
/* Clear Sleep Type */
|
|
|
|
chipset_clear_sleep_state();
|
|
|
|
/* Reboot */
|
|
|
|
debug("Rebooting..\n");
|
2018-07-19 10:07:32 +00:00
|
|
|
outb(SYS_RST | RST_CPU, IO_PORT_RESET);
|
2017-04-21 14:24:31 +00:00
|
|
|
/* Should not reach here.. */
|
|
|
|
panic("Reboot System");
|
|
|
|
}
|
|
|
|
|
2017-04-21 14:24:39 +00:00
|
|
|
/*
|
2019-05-03 22:28:37 +00:00
|
|
|
* DM is not available yet at this point, hence call
|
2017-04-21 14:24:39 +00:00
|
|
|
* CMOS access library which does not depend on DM.
|
|
|
|
*/
|
|
|
|
stack = cmos_read32(CMOS_FSP_STACK_ADDR);
|
2017-04-21 14:24:31 +00:00
|
|
|
boot_mode = BOOT_ON_S3_RESUME;
|
|
|
|
}
|
2020-07-10 00:43:16 +00:00
|
|
|
|
2015-08-20 13:40:19 +00:00
|
|
|
/*
|
|
|
|
* The first time we enter here, call fsp_init().
|
|
|
|
* Note the execution does not return to this function,
|
|
|
|
* instead it jumps to fsp_continue().
|
|
|
|
*/
|
2017-04-21 14:24:39 +00:00
|
|
|
fsp_init(stack, boot_mode, nvs);
|
2015-08-20 13:40:19 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* The second time we enter here, adjust the size of malloc()
|
|
|
|
* pool before relocation. Given gd->malloc_base was adjusted
|
2015-11-25 16:56:32 +00:00
|
|
|
* after the call to board_init_f_init_reserve() in arch/x86/
|
|
|
|
* cpu/start.S, we should fix up gd->malloc_limit here.
|
2015-08-20 13:40:19 +00:00
|
|
|
*/
|
|
|
|
gd->malloc_limit += CONFIG_FSP_SYS_MALLOC_F_LEN;
|
|
|
|
}
|
2015-06-07 03:33:14 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|