[coreboot-gerrit] Patch set updated for coreboot: 13d7426 cpu/amd/model_10xxx: Add support for early cbmem

Timothy Pearson (tpearson@raptorengineeringinc.com) gerrit at coreboot.org
Sat Feb 28 22:08:28 CET 2015


Timothy Pearson (tpearson at raptorengineeringinc.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8488

-gerrit

commit 13d74267d7335b9dae160266e7567f916d6dba75
Author: Timothy Pearson <tpearson at raptorengineeringinc.com>
Date:   Wed Feb 18 18:26:31 2015 -0600

    cpu/amd/model_10xxx: Add support for early cbmem
    
    Change-Id: I80622b1998ad77c8e2f5ae94bf28bdb704a41eb9
    Signed-off-by: Timothy Pearson <tpearson at raptorengineeringinc.com>
---
 src/cpu/amd/model_10xxx/Makefile.inc       |  2 +
 src/cpu/amd/model_10xxx/ram_calc.c         | 59 ++++++++++++++++++++++++++++++
 src/cpu/amd/model_10xxx/ram_calc.h         | 25 +++++++++++++
 src/northbridge/amd/amdfam10/Kconfig       |  1 -
 src/northbridge/amd/amdfam10/northbridge.c | 20 +---------
 src/southbridge/amd/sb700/early_setup.c    |  5 +++
 src/southbridge/amd/sb700/lpc.c            |  5 +++
 src/southbridge/amd/sb800/early_setup.c    |  5 +++
 8 files changed, 103 insertions(+), 19 deletions(-)

diff --git a/src/cpu/amd/model_10xxx/Makefile.inc b/src/cpu/amd/model_10xxx/Makefile.inc
index ba12dcd..c17e66c 100644
--- a/src/cpu/amd/model_10xxx/Makefile.inc
+++ b/src/cpu/amd/model_10xxx/Makefile.inc
@@ -3,6 +3,8 @@ ramstage-y += model_10xxx_init.c
 ramstage-y += processor_name.c
 
 romstage-y += update_microcode.c
+romstage-y += ram_calc.c
+ramstage-y += ram_calc.c
 ramstage-y += monotonic_timer.c
 ramstage-$(CONFIG_HAVE_ACPI_TABLES) += powernow_acpi.c
 
diff --git a/src/cpu/amd/model_10xxx/ram_calc.c b/src/cpu/amd/model_10xxx/ram_calc.c
new file mode 100644
index 0000000..1b1d2c6
--- /dev/null
+++ b/src/cpu/amd/model_10xxx/ram_calc.c
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <cpu/cpu.h>
+#include <cpu/x86/msr.h>
+#include <cpu/amd/mtrr.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)) {
+		/* refer to UMA Size Consideration in 780 BDG. */
+		switch (topmem) {
+		case 0x10000000:		/* 256M system memory */
+			uma_size = 0x4000000;	/* 64M recommended UMA */
+			break;
+
+		case 0x20000000:		/* 512M system memory */
+			uma_size = 0x8000000;	/* 128M recommended UMA */
+			break;
+
+		default:			/* 1GB and above system memory */
+			uma_size = 0x10000000;	/* 256M recommended UMA */
+			break;
+		}
+	}
+
+	return uma_size;
+}
+
+void *cbmem_top(void)
+{
+	uint32_t topmem = (uint32_t) rdmsr(TOP_MEM).lo;
+
+	topmem = topmem - get_uma_memory_size(topmem);
+
+	return (void *) topmem;
+}
diff --git a/src/cpu/amd/model_10xxx/ram_calc.h b/src/cpu/amd/model_10xxx/ram_calc.h
new file mode 100644
index 0000000..7ece338
--- /dev/null
+++ b/src/cpu/amd/model_10xxx/ram_calc.h
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _AMD_MODEL_10XXX_MEM_CALC_H_
+#define _AMD_MODEL_10XXX_MEM_CALC_H_
+
+uint64_t get_uma_memory_size(uint64_t topmem);
+
+#endif
diff --git a/src/northbridge/amd/amdfam10/Kconfig b/src/northbridge/amd/amdfam10/Kconfig
index 8e1c4f8..96d2904 100644
--- a/src/northbridge/amd/amdfam10/Kconfig
+++ b/src/northbridge/amd/amdfam10/Kconfig
@@ -26,7 +26,6 @@ config NORTHBRIDGE_AMD_AMDFAM10
 	select HYPERTRANSPORT_PLUGIN_SUPPORT
 	select MMCONF_SUPPORT
 	select PER_DEVICE_ACPI_TABLES
-	select LATE_CBMEM_INIT
 
 if NORTHBRIDGE_AMD_AMDFAM10
 config AGP_APERTURE_SIZE
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c
index f28c726..60296dd 100644
--- a/src/northbridge/amd/amdfam10/northbridge.c
+++ b/src/northbridge/amd/amdfam10/northbridge.c
@@ -32,6 +32,7 @@
 
 #include <cpu/x86/lapic.h>
 #include <cpu/amd/mtrr.h>
+#include <cpu/amd/model_10xxx/ram_calc.h>
 
 #if CONFIG_LOGICAL_CPUS
 #include <cpu/amd/multicore.h>
@@ -828,21 +829,7 @@ static void setup_uma_memory(void)
 {
 #if CONFIG_GFXUMA
 	uint32_t topmem = (uint32_t) bsp_topmem();
-	/* 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;
-	}
-
+	uma_memory_size = get_uma_memory_size(topmem);
 	uma_memory_base = topmem - uma_memory_size;	/* TOP_MEM1 */
 	printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
 		    __func__, uma_memory_size, uma_memory_base);
@@ -1052,10 +1039,7 @@ static void amdfam10_domain_set_resources(device_t dev)
 	}
 
 #if CONFIG_GFXUMA
-	set_top_of_ram(uma_memory_base);
 	uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
-#else
-	set_top_of_ram(ramtop);
 #endif
 
 	for(link = dev->link_list; link; link = link->next) {
diff --git a/src/southbridge/amd/sb700/early_setup.c b/src/southbridge/amd/sb700/early_setup.c
index 94f33b7..0c37840 100644
--- a/src/southbridge/amd/sb700/early_setup.c
+++ b/src/southbridge/amd/sb700/early_setup.c
@@ -728,6 +728,10 @@ int acpi_get_sleep_type(void)
 	return ((tmp & (7 << 10)) >> 10);
 }
 
+/* FIXME
+ * Remove this block when all processors support early CBMEM init
+ */
+#if CONFIG_LATE_CBMEM_INIT
 unsigned long get_top_of_ram(void)
 {
 	uint32_t xdata = 0;
@@ -742,5 +746,6 @@ unsigned long get_top_of_ram(void)
 	}
 	return (unsigned long) xdata;
 }
+#endif
 
 #endif
diff --git a/src/southbridge/amd/sb700/lpc.c b/src/southbridge/amd/sb700/lpc.c
index 658e954..a5f11a6 100644
--- a/src/southbridge/amd/sb700/lpc.c
+++ b/src/southbridge/amd/sb700/lpc.c
@@ -88,6 +88,10 @@ int acpi_get_sleep_type(void)
 	return ((tmp & (7 << 10)) >> 10);
 }
 
+/* FIXME
+ * Remove this block when all processors support early CBMEM init
+ */
+#if CONFIG_LATE_CBMEM_INIT
 void backup_top_of_ram(uint64_t ramtop)
 {
 	u32 dword = (u32) ramtop;
@@ -98,6 +102,7 @@ void backup_top_of_ram(uint64_t ramtop)
 		nvram_pos++;
 	}
 }
+#endif
 
 static void sb700_lpc_read_resources(device_t dev)
 {
diff --git a/src/southbridge/amd/sb800/early_setup.c b/src/southbridge/amd/sb800/early_setup.c
index 69bc3bd..300b54e 100644
--- a/src/southbridge/amd/sb800/early_setup.c
+++ b/src/southbridge/amd/sb800/early_setup.c
@@ -673,6 +673,10 @@ int acpi_get_sleep_type(void)
 	return ((tmp & (7 << 10)) >> 10);
 }
 
+/* FIXME
+ * Remove this block when all processors support early CBMEM init
+ */
+#if CONFIG_LATE_CBMEM_INIT
 unsigned long get_top_of_ram(void)
 {
 	uint32_t xdata = 0;
@@ -687,5 +691,6 @@ unsigned long get_top_of_ram(void)
 	}
 	return (unsigned long) xdata;
 }
+#endif
 
 #endif



More information about the coreboot-gerrit mailing list