Michał Żygowski has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37402 )
Change subject: soc/amd/common/blocks: introduce two new BIOSRAM based common blocks ......................................................................
soc/amd/common/blocks: introduce two new BIOSRAM based common blocks
All AMD CPU families supported in coreboot have BIOSRAM space. Looking at the source code, every family could have the same API to save and restore cbmem top or UMA base and size.
Create unified BIOSRAM layout, AMD UMA block and AMD RAMTOP block.
Signed-off-by: Michał Żygowski michal.zygowski@3mdeb.com Change-Id: I69a03e4f01d7fb2ffc9f8b5af73d7e4e7ec027da --- A src/soc/amd/common/block/include/amdblocks/biosram_layout.h A src/soc/amd/common/block/include/amdblocks/uma.h A src/soc/amd/common/block/ramtop/Kconfig A src/soc/amd/common/block/ramtop/Makefile.inc A src/soc/amd/common/block/ramtop/ramtop.c A src/soc/amd/common/block/uma/Kconfig A src/soc/amd/common/block/uma/Makefile.inc A src/soc/amd/common/block/uma/uma.c 8 files changed, 136 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/37402/1
diff --git a/src/soc/amd/common/block/include/amdblocks/biosram_layout.h b/src/soc/amd/common/block/include/amdblocks/biosram_layout.h new file mode 100644 index 0000000..2ca4f74 --- /dev/null +++ b/src/soc/amd/common/block/include/amdblocks/biosram_layout.h @@ -0,0 +1,22 @@ +/* + * This file is part of the coreboot project. + * + * 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 __AMDBLOCKS_BIOSRAM_H__ +#define __AMDBLOCKS_BIOSRAM_H__ + +/* BiosRam Ranges at 0xfed80500 or I/O 0xcd4/0xcd5 */ +#define BIOSRAM_CBMEM_TOP 0xf0 /* 4 bytes */ +#define BIOSRAM_UMA_SIZE 0xf4 /* 4 bytes */ +#define BIOSRAM_UMA_BASE 0xf8 /* 8 bytes */ + +#endif diff --git a/src/soc/amd/common/block/include/amdblocks/uma.h b/src/soc/amd/common/block/include/amdblocks/uma.h new file mode 100644 index 0000000..939713d --- /dev/null +++ b/src/soc/amd/common/block/include/amdblocks/uma.h @@ -0,0 +1,26 @@ +/* + * This file is part of the coreboot project. + * + * 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 __AMDBLOCKS_UMA_H__ +#define __AMDBLOCKS_UMA_H__ + +/* Saves the UMA size returned by AGESA */ +void save_uma_size(uint32_t size); +/* Saves the UMA base address returned by AGESA */ +void save_uma_base(uint64_t base); +/* Returns the saved UMA size */ +uint32_t get_uma_size(void); +/* Returns the saved UMA base */ +uint64_t get_uma_base(void); + +#endif diff --git a/src/soc/amd/common/block/ramtop/Kconfig b/src/soc/amd/common/block/ramtop/Kconfig new file mode 100644 index 0000000..36bf074 --- /dev/null +++ b/src/soc/amd/common/block/ramtop/Kconfig @@ -0,0 +1,7 @@ +config SOC_AMD_COMMON_BLOCK_RAMTOP + bool + default n + depends on SOC_AMD_COMMON_BLOCK_ACPIMMIO + help + Select this option to enable common cbmem top save and restore + functions usign BIOSRAM. diff --git a/src/soc/amd/common/block/ramtop/Makefile.inc b/src/soc/amd/common/block/ramtop/Makefile.inc new file mode 100644 index 0000000..bb2d290 --- /dev/null +++ b/src/soc/amd/common/block/ramtop/Makefile.inc @@ -0,0 +1,3 @@ +romstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_RAMTOP) += ramtop.c +postcar-$(CONFIG_SOC_AMD_COMMON_BLOCK_RAMTOP) += ramtop.c +ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_RAMTOP) += ramtop.c diff --git a/src/soc/amd/common/block/ramtop/ramtop.c b/src/soc/amd/common/block/ramtop/ramtop.c new file mode 100644 index 0000000..ae93537 --- /dev/null +++ b/src/soc/amd/common/block/ramtop/ramtop.c @@ -0,0 +1,27 @@ +/* + * This file is part of the coreboot project. + * + * 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 <stdint.h> +#include <cbmem.h> +#include <amdblocks/acpimmio.h> +#include <amdblocks/biosram_layout.h> + +void backup_top_of_low_cacheable(uintptr_t ramtop) +{ + biosram_write32(BIOSRAM_CBMEM_TOP, ramtop); +} + +uintptr_t restore_top_of_low_cacheable(void) +{ + return biosram_read32(BIOSRAM_CBMEM_TOP); +} diff --git a/src/soc/amd/common/block/uma/Kconfig b/src/soc/amd/common/block/uma/Kconfig new file mode 100644 index 0000000..8b0e18a --- /dev/null +++ b/src/soc/amd/common/block/uma/Kconfig @@ -0,0 +1,7 @@ +config SOC_AMD_COMMON_BLOCK_UMA + bool + default n + depends on SOC_AMD_COMMON_BLOCK_ACPIMMIO + help + Select this option to enable common UMA parameters save and + restore functions using BIOSRAM. diff --git a/src/soc/amd/common/block/uma/Makefile.inc b/src/soc/amd/common/block/uma/Makefile.inc new file mode 100644 index 0000000..b3bb8c6 --- /dev/null +++ b/src/soc/amd/common/block/uma/Makefile.inc @@ -0,0 +1,3 @@ +romstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_UMA) += uma.c +postcar-$(CONFIG_SOC_AMD_COMMON_BLOCK_UMA) += uma.c +ramstage-$(CONFIG_SOC_AMD_COMMON_BLOCK_UMA) += uma.c diff --git a/src/soc/amd/common/block/uma/uma.c b/src/soc/amd/common/block/uma/uma.c new file mode 100644 index 0000000..00b4642 --- /dev/null +++ b/src/soc/amd/common/block/uma/uma.c @@ -0,0 +1,41 @@ +/* + * This file is part of the coreboot project. + * + * 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 <stdint.h> +#include <amdblocks/acpimmio.h> +#include <amdblocks/biosram_layout.h> +#include <amdblocks/uma.h> + +void save_uma_size(uint32_t size) +{ + biosram_write32(BIOSRAM_UMA_SIZE, size); +} + +void save_uma_base(uint64_t base) +{ + biosram_write32(BIOSRAM_UMA_BASE, (uint32_t) base); + biosram_write32(BIOSRAM_UMA_BASE + 4, (uint32_t) (base >> 32)); +} + +uint32_t get_uma_size(void) +{ + return biosram_read32(BIOSRAM_UMA_SIZE); +} + +uint64_t get_uma_base(void) +{ + uint64_t base; + base = biosram_read32(BIOSRAM_UMA_BASE); + base |= ((uint64_t)(biosram_read32(BIOSRAM_UMA_BASE + 4)) << 32); + return base; +}