From 899be1b3529b391c430504589649f0ec9452a1d9 Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Fri, 5 Feb 2021 15:50:20 -0700 Subject: soc/amd/picasso: Move memmap_early_dram to common blocks We need the same functionality for cezanne. TEST=Boot ezknil Signed-off-by: Raul E Rangel Change-Id: I0800c662bb473eb571c74e76a8247298f534b53f Reviewed-on: https://review.coreboot.org/c/coreboot/+/50337 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held Reviewed-by: Angel Pons --- src/soc/amd/common/block/cpu/noncar/Makefile.inc | 2 ++ src/soc/amd/common/block/cpu/noncar/memmap.c | 29 ++++++++++++++++++++++ .../amd/common/block/include/amdblocks/memmap.h | 19 ++++++++++++++ src/soc/amd/picasso/include/soc/memmap.h | 19 -------------- src/soc/amd/picasso/memmap.c | 25 ------------------- src/soc/amd/picasso/romstage.c | 2 +- src/soc/amd/picasso/root_complex.c | 2 +- 7 files changed, 52 insertions(+), 46 deletions(-) create mode 100644 src/soc/amd/common/block/cpu/noncar/memmap.c create mode 100644 src/soc/amd/common/block/include/amdblocks/memmap.h delete mode 100644 src/soc/amd/picasso/include/soc/memmap.h diff --git a/src/soc/amd/common/block/cpu/noncar/Makefile.inc b/src/soc/amd/common/block/cpu/noncar/Makefile.inc index ed08d2a1c4..dd959417f1 100644 --- a/src/soc/amd/common/block/cpu/noncar/Makefile.inc +++ b/src/soc/amd/common/block/cpu/noncar/Makefile.inc @@ -2,5 +2,7 @@ ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_NONCAR),y) bootblock-y += pre_c.S bootblock-y += write_resume_eip.c +romstage-y += memmap.c +ramstage-y += memmap.c endif # CONFIG_SOC_AMD_COMMON_BLOCK_NONCAR diff --git a/src/soc/amd/common/block/cpu/noncar/memmap.c b/src/soc/amd/common/block/cpu/noncar/memmap.c new file mode 100644 index 0000000000..9efe959d4d --- /dev/null +++ b/src/soc/amd/common/block/cpu/noncar/memmap.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +void memmap_stash_early_dram_usage(void) +{ + struct memmap_early_dram *e; + + e = cbmem_add(CBMEM_ID_CB_EARLY_DRAM, sizeof(*e)); + + if (!e) + die("ERROR: Failed to stash early dram usage!\n"); + + e->base = (uint32_t)(uintptr_t)_early_reserved_dram; + e->size = REGION_SIZE(early_reserved_dram); +} + +const struct memmap_early_dram *memmap_get_early_dram_usage(void) +{ + struct memmap_early_dram *e = cbmem_find(CBMEM_ID_CB_EARLY_DRAM); + + if (!e) + die("ERROR: Failed to read early dram usage!\n"); + + return e; +} diff --git a/src/soc/amd/common/block/include/amdblocks/memmap.h b/src/soc/amd/common/block/include/amdblocks/memmap.h new file mode 100644 index 0000000000..a748e57316 --- /dev/null +++ b/src/soc/amd/common/block/include/amdblocks/memmap.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef AMD_BLOCK_MEMMAP_H +#define AMD_BLOCK_MEMMAP_H + +#include +#include + +DECLARE_REGION(early_reserved_dram) + +struct memmap_early_dram { + uint32_t base; + uint32_t size; +}; + +void memmap_stash_early_dram_usage(void); +const struct memmap_early_dram *memmap_get_early_dram_usage(void); + +#endif /* AMD_BLOCK_MEMMAP_H */ diff --git a/src/soc/amd/picasso/include/soc/memmap.h b/src/soc/amd/picasso/include/soc/memmap.h deleted file mode 100644 index 53c9d310b0..0000000000 --- a/src/soc/amd/picasso/include/soc/memmap.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#ifndef AMD_PICASSO_MEMMAP_H -#define AMD_PICASSO_MEMMAP_H - -#include -#include - -DECLARE_REGION(early_reserved_dram) - -struct memmap_early_dram { - uint32_t base; - uint32_t size; -}; - -void memmap_stash_early_dram_usage(void); -const struct memmap_early_dram *memmap_get_early_dram_usage(void); - -#endif /* AMD_PICASSO_MEMMAP_H */ diff --git a/src/soc/amd/picasso/memmap.c b/src/soc/amd/picasso/memmap.c index 74a6c702c0..04c2fd8533 100644 --- a/src/soc/amd/picasso/memmap.c +++ b/src/soc/amd/picasso/memmap.c @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -12,7 +11,6 @@ #include #include #include -#include /* * For data stored in TSEG, ensure TValid is clear so R/W access can reach @@ -79,26 +77,3 @@ void bert_reserved_region(void **start, size_t *size) *start = (void *)(uintptr_t)range_entry_base(&bert); *size = range_entry_size(&bert); } - -void memmap_stash_early_dram_usage(void) -{ - struct memmap_early_dram *e; - - e = cbmem_add(CBMEM_ID_CB_EARLY_DRAM, sizeof(*e)); - - if (!e) - die("ERROR: Failed to stash early dram usage!\n"); - - e->base = (uint32_t)(uintptr_t)_early_reserved_dram; - e->size = REGION_SIZE(early_reserved_dram); -} - -const struct memmap_early_dram *memmap_get_early_dram_usage(void) -{ - struct memmap_early_dram *e = cbmem_find(CBMEM_ID_CB_EARLY_DRAM); - - if (!e) - die("ERROR: Failed to read early dram usage!\n"); - - return e; -} diff --git a/src/soc/amd/picasso/romstage.c b/src/soc/amd/picasso/romstage.c index 1391536464..aa8da1ea69 100644 --- a/src/soc/amd/picasso/romstage.c +++ b/src/soc/amd/picasso/romstage.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/src/soc/amd/picasso/root_complex.c b/src/soc/amd/picasso/root_complex.c index 5166fe5ba7..8b348dccde 100644 --- a/src/soc/amd/picasso/root_complex.c +++ b/src/soc/amd/picasso/root_complex.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include #include #include "chip.h" -- cgit v1.2.3