summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
authorPoonam Aggrwal <poonam.aggrwal@freescale.com>2009-09-02 19:40:36 +0530
committerKumar Gala <galak@kernel.crashing.org>2009-09-08 09:10:08 -0500
commitf8027f6b4789e3340f10620d8fb6113b95b88d9c (patch)
tree7a6cd3030bb8f18275c387c0953206d5757835fc /cpu
parent58442dc01e47cc8ce42af4f29486a34cad60b9d2 (diff)
downloadu-boot-imx-f8027f6b4789e3340f10620d8fb6113b95b88d9c.zip
u-boot-imx-f8027f6b4789e3340f10620d8fb6113b95b88d9c.tar.gz
u-boot-imx-f8027f6b4789e3340f10620d8fb6113b95b88d9c.tar.bz2
ppc/85xx/86xx: Device tree fixup for number of cores
Fixing the number of cores in the device tree based on the actual number of cores on the system. With this same device tree image can be used for dual core and single core members of otherwise exactly same SOC. For example: * P2020RDB and P2010RDB * P1020RDB and P1011RDB * MPC8641D and MPC8641 Signed-off-by: Poonam Aggrwal <poonam.aggrwal@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'cpu')
-rw-r--r--cpu/mpc85xx/fdt.c2
-rw-r--r--cpu/mpc86xx/fdt.c3
-rw-r--r--cpu/mpc8xxx/Makefile1
-rw-r--r--cpu/mpc8xxx/fdt.c55
4 files changed, 61 insertions, 0 deletions
diff --git a/cpu/mpc85xx/fdt.c b/cpu/mpc85xx/fdt.c
index 8366379..723f473 100644
--- a/cpu/mpc85xx/fdt.c
+++ b/cpu/mpc85xx/fdt.c
@@ -34,6 +34,7 @@
DECLARE_GLOBAL_DATA_PTR;
extern void ft_qe_setup(void *blob);
+extern void ft_fixup_num_cores(void *blob);
#ifdef CONFIG_MP
#include "mp.h"
@@ -327,6 +328,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
#ifdef CONFIG_MP
ft_fixup_cpu(blob, (u64)bd->bi_memstart + (u64)bd->bi_memsize);
#endif
+ ft_fixup_num_cores(blob);
ft_fixup_cache(blob);
diff --git a/cpu/mpc86xx/fdt.c b/cpu/mpc86xx/fdt.c
index a36ee30..51f3f4c 100644
--- a/cpu/mpc86xx/fdt.c
+++ b/cpu/mpc86xx/fdt.c
@@ -13,6 +13,8 @@
DECLARE_GLOBAL_DATA_PTR;
+extern void ft_fixup_num_cores(void *blob);
+
void ft_cpu_setup(void *blob, bd_t *bd)
{
#ifdef CONFIG_MP
@@ -54,4 +56,5 @@ void ft_cpu_setup(void *blob, bd_t *bd)
if (off < 0)
printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
#endif
+ ft_fixup_num_cores(blob);
}
diff --git a/cpu/mpc8xxx/Makefile b/cpu/mpc8xxx/Makefile
index 5cb6814..481f9e5 100644
--- a/cpu/mpc8xxx/Makefile
+++ b/cpu/mpc8xxx/Makefile
@@ -11,6 +11,7 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib8xxx.a
COBJS-y += cpu.o
+COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
COBJS-$(CONFIG_PCI) += pci_cfg.o
SRCS := $(START:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
diff --git a/cpu/mpc8xxx/fdt.c b/cpu/mpc8xxx/fdt.c
new file mode 100644
index 0000000..3a9b584
--- /dev/null
+++ b/cpu/mpc8xxx/fdt.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2009 Freescale Semiconductor, Inc.
+ *
+ * This file is derived from cpu/mpc85xx/cpu.c and cpu/mpc86xx/cpu.c.
+ * Basically this file contains cpu specific common code for 85xx/86xx
+ * processors.
+ * See file CREDITS for list of people who contributed to this
+ * 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; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+
+void ft_fixup_num_cores(void *blob) {
+ int off, num_cores, del_cores;
+
+ del_cores = 0;
+ num_cores = cpu_numcores();
+
+ off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
+ while (off != -FDT_ERR_NOTFOUND) {
+ u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
+
+ /* if we find a cpu node outside of what we expect delete it
+ * and reset the offset back to the start since we can't
+ * trust the offsets anymore
+ */
+ if (*reg > num_cores-1) {
+ fdt_del_node(blob, off);
+ del_cores++;
+ off = -1;
+ }
+ off = fdt_node_offset_by_prop_value(blob, off,
+ "device_type", "cpu", 4);
+ }
+ debug ("%x core system found\n", num_cores);
+ debug ("deleted %d extra core entry entries from device tree\n",
+ del_cores);
+}