[coreboot-gerrit] Change in coreboot[master]: [WIP, UNTESTED]cpu/amdk8: Depreciate LATE_CBMEM_INIT
Arthur Heymans (Code Review)
gerrit at coreboot.org
Tue Aug 22 18:52:56 CEST 2017
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/21151
Change subject: [WIP,UNTESTED]cpu/amdk8: Depreciate LATE_CBMEM_INIT
......................................................................
[WIP,UNTESTED]cpu/amdk8: Depreciate LATE_CBMEM_INIT
Change-Id: Ief7dd6d6f450fb8ed9dd4d36b099f3c0072b6b2e
Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
M src/cpu/amd/model_fxx/Makefile.inc
A src/cpu/amd/model_fxx/ram_calc.c
A src/cpu/amd/model_fxx/ram_calc.h
M src/northbridge/amd/amdk8/Kconfig
M src/northbridge/amd/amdk8/northbridge.c
5 files changed, 104 insertions(+), 44 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/21151/1
diff --git a/src/cpu/amd/model_fxx/Makefile.inc b/src/cpu/amd/model_fxx/Makefile.inc
index 4d8153a..31eeeb7 100644
--- a/src/cpu/amd/model_fxx/Makefile.inc
+++ b/src/cpu/amd/model_fxx/Makefile.inc
@@ -5,5 +5,7 @@
ramstage-y += model_fxx_update_microcode.c
ramstage-y += processor_name.c
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += powernow_acpi.c
+romstage-y += ram_calc.c
+ramstage-y += ram_calc.c
cpu_microcode_bins += 3rdparty/blobs/cpu/amd/model_fxx/microcode.bin
diff --git a/src/cpu/amd/model_fxx/ram_calc.c b/src/cpu/amd/model_fxx/ram_calc.c
new file mode 100644
index 0000000..34f1ebb
--- /dev/null
+++ b/src/cpu/amd/model_fxx/ram_calc.c
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Timothy Pearson <tpearson at raptorengineeringinc.com>, Raptor Engineering
+ * Copyright (C) 2007 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.
+ */
+
+#include <cpu/cpu.h>
+#include <cpu/x86/msr.h>
+#include <cpu/amd/mtrr.h>
+
+#include <arch/io.h>
+#include <device/device.h>
+#include <device/pci.h>
+
+#include <cbmem.h>
+
+#include "ram_calc.h"
+
+uint64_t get_uma_memory_size(uint64_t topmem)
+{
+ uint64_t uma_size = 0;
+
+#if IS_ENABLED(CONFIG_GFXUMA)
+#if !IS_ENABLED(CONFIG_BOARD_ASROCK_939A785GMH) && \
+ !IS_ENABLED(CONFIG_BOARD_AMD_MAHOGANY)
+
+ switch (topmem) {
+ case 0x10000000: /* 256M system memory */
+ uma_memory_size = 0x2000000; /* 32M recommended UMA */
+ break;
+
+ case 0x18000000: /* 384M system memory */
+ uma_memory_size = 0x4000000; /* 64M recommended UMA */
+ break;
+
+ case 0x20000000: /* 512M system memory */
+ uma_memory_size = 0x4000000; /* 64M recommended UMA */
+ break;
+
+ default: /* 1GB and above system memory */
+ uma_memory_size = 0x8000000; /* 128M recommended UMA */
+ break;
+ }
+#else
+ /* refer to UMA Size Consideration in 780 BDG. */
+ switch (topmem) {
+ case 0x10000000: /* 256M system memory */
+ uma_memory_size = 0x4000000; /* 64M recommended UMA */
+ break;
+
+ case 0x20000000: /* 512M system memory */
+ uma_memory_size = 0x8000000; /* 128M recommended UMA */
+ break;
+
+ default: /* 1GB and above system memory */
+ uma_memory_size = 0x10000000; /* 256M recommended UMA */
+ break;
+ }
+#endif
+#endif
+ return uma_size;
+}
+
+void *cbmem_top(void)
+{
+ uint32_t topmem = rdmsr(TOP_MEM).lo;
+
+ return (void *) topmem - get_uma_memory_size(topmem);
+}
diff --git a/src/cpu/amd/model_fxx/ram_calc.h b/src/cpu/amd/model_fxx/ram_calc.h
new file mode 100644
index 0000000..b780fe2
--- /dev/null
+++ b/src/cpu/amd/model_fxx/ram_calc.h
@@ -0,0 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Timothy Pearson <tpearson at raptorengineeringinc.com>, Raptor Engineering
+ *
+ * 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_MODEL_FXX_RAM_CALC_H_
+#define _AMD_MODEL_FXX_RAM_CALC_H_
+
+uint64_t get_uma_memory_size(uint64_t topmem);
+
+#endif
diff --git a/src/northbridge/amd/amdk8/Kconfig b/src/northbridge/amd/amdk8/Kconfig
index 83f70c9..0acd5d7 100644
--- a/src/northbridge/amd/amdk8/Kconfig
+++ b/src/northbridge/amd/amdk8/Kconfig
@@ -19,7 +19,6 @@
select HAVE_DEBUG_SMBUS
select HAVE_DEBUG_CAR
select HYPERTRANSPORT_PLUGIN_SUPPORT
- select LATE_CBMEM_INIT
if NORTHBRIDGE_AMD_AMDK8
diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c
index 2a92ca2..140c53d 100644
--- a/src/northbridge/amd/amdk8/northbridge.c
+++ b/src/northbridge/amd/amdk8/northbridge.c
@@ -36,6 +36,7 @@
#include <cpu/amd/model_fxx_rev.h>
#include <cpu/amd/amdk8_sysconf.h>
+#include <cpu/amd/model_fxx/ram_calc.h>
struct amdk8_sysconf_t sysconf;
@@ -807,51 +808,12 @@
}
#endif
-#include <cbmem.h>
-
static void setup_uma_memory(void)
{
#if IS_ENABLED(CONFIG_GFXUMA)
uint32_t topmem = (uint32_t) bsp_topmem();
-#if !IS_ENABLED(CONFIG_BOARD_ASROCK_939A785GMH) && \
- !IS_ENABLED(CONFIG_BOARD_AMD_MAHOGANY)
-
- switch (topmem) {
- case 0x10000000: /* 256M system memory */
- uma_memory_size = 0x2000000; /* 32M recommended UMA */
- break;
-
- case 0x18000000: /* 384M system memory */
- uma_memory_size = 0x4000000; /* 64M recommended UMA */
- break;
-
- case 0x20000000: /* 512M system memory */
- uma_memory_size = 0x4000000; /* 64M recommended UMA */
- break;
-
- default: /* 1GB and above system memory */
- uma_memory_size = 0x8000000; /* 128M recommended UMA */
- break;
- }
-#else
- /* refer to UMA Size Consideration in 780 BDG. */
- switch (topmem) {
- case 0x10000000: /* 256M system memory */
- uma_memory_size = 0x4000000; /* 64M recommended UMA */
- break;
-
- case 0x20000000: /* 512M system memory */
- uma_memory_size = 0x8000000; /* 128M recommended UMA */
- break;
-
- default: /* 1GB and above system memory */
- uma_memory_size = 0x10000000; /* 256M recommended UMA */
- break;
- }
-#endif
-
- uma_memory_base = topmem - uma_memory_size; /* TOP_MEM1 */
+ uma_memory_base = topmem - get_uma_memory_size(topmem); /* TOP_MEM1 */
printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
__func__, uma_memory_size, uma_memory_base);
#endif
@@ -1000,10 +962,7 @@
}
#if IS_ENABLED(CONFIG_GFXUMA)
- set_late_cbmem_top(uma_memory_base);
uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
-#else
- set_late_cbmem_top(ramtop);
#endif
assign_resources(dev->link_list);
--
To view, visit https://review.coreboot.org/21151
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief7dd6d6f450fb8ed9dd4d36b099f3c0072b6b2e
Gerrit-Change-Number: 21151
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur at aheymans.xyz>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20170822/d2e22a41/attachment.html>
More information about the coreboot-gerrit
mailing list