soc/amd/common: Add S3 supporting functions
Add functions that the wrapper will call to get and save the S3 data. The wrapper requires two types of data saved: * Non-volatile: Information that is the minimum required for bringing the DRAM controller back online. This change uses the common mrc_cache driver to manage the storage * Volatile: May be stored in DRAM; information required to complete the system restoration process. TEST=Suspend/Resume Kahlee with complete S3 patch stack BUG=b:69614064 Change-Id: Ie60162ea10f053393bc84e927dbd80c9279e6b63 Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/22727 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
047b23fc31
commit
52f5cdce17
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2017 Advanced Micro Devices, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AMD_S3_RESUME_H__
|
||||||
|
#define __AMD_S3_RESUME_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int save_s3_info(void *nv_base, size_t nv_size,
|
||||||
|
void *vol_base, size_t vol_size);
|
||||||
|
void get_s3nv_info(void **base, size_t *size);
|
||||||
|
void get_s3vol_info(void **base, size_t *size);
|
||||||
|
|
||||||
|
#endif /* __AMD_S3_RESUME_H__ */
|
|
@ -1,5 +1,7 @@
|
||||||
config SOC_AMD_COMMON_BLOCK_S3
|
config SOC_AMD_COMMON_BLOCK_S3
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
select CACHE_MRC_SETTINGS
|
||||||
|
select MRC_WRITE_NV_LATE
|
||||||
help
|
help
|
||||||
Select this option to add S3 related functions to the build.
|
Select this option to add S3 related functions to the build.
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_S3),y)
|
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_S3),y)
|
||||||
|
|
||||||
|
romstage-$(CONFIG_HAVE_ACPI_RESUME) += s3_resume.c
|
||||||
|
ramstage-$(CONFIG_HAVE_ACPI_RESUME) += s3_resume.c
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012-2017 Advanced Micro Devices, Inc.
|
||||||
|
* Copyright (C) 2014 Google Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cbmem.h>
|
||||||
|
#include <stage_cache.h>
|
||||||
|
#include <mrc_cache.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <amdblocks/s3_resume.h>
|
||||||
|
|
||||||
|
/* Training data versioning is not supported or tracked. */
|
||||||
|
#define DEFAULT_MRC_VERSION 0
|
||||||
|
|
||||||
|
void get_s3nv_info(void **base, size_t *size)
|
||||||
|
{
|
||||||
|
struct region_device rdev;
|
||||||
|
|
||||||
|
mrc_cache_get_current(MRC_TRAINING_DATA, DEFAULT_MRC_VERSION, &rdev);
|
||||||
|
*base = rdev_mmap_full(&rdev);
|
||||||
|
*size = region_device_sz(&rdev);
|
||||||
|
if (!*base || !*size)
|
||||||
|
printk(BIOS_ERR, "Error: S3 NV data not found\n");
|
||||||
|
else
|
||||||
|
printk(BIOS_SPEW, "S3 NV data @0x%p 0x%0zx total bytes\n",
|
||||||
|
*base, *size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_s3vol_info(void **base, size_t *size)
|
||||||
|
{
|
||||||
|
stage_cache_get_raw(STAGE_S3_DATA, base, size);
|
||||||
|
if (!*base || !*size)
|
||||||
|
printk(BIOS_ERR, "Error: S3 volatile data not found\n");
|
||||||
|
else
|
||||||
|
printk(BIOS_SPEW, "S3 volatile data @0x%p 0x%0zx total bytes\n",
|
||||||
|
*base, *size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int save_s3_info(void *nv_base, size_t nv_size, void *vol_base, size_t vol_size)
|
||||||
|
{
|
||||||
|
if (mrc_cache_stash_data(MRC_TRAINING_DATA, DEFAULT_MRC_VERSION,
|
||||||
|
nv_base, nv_size) < 0) {
|
||||||
|
printk(BIOS_ERR, "Failed to stash MRC data\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_cache_add_raw(STAGE_S3_DATA, vol_base, vol_size);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue