blob: 3a9b5841b6956e5e3bc89c564fdec5ae5d382c84 [file] [log] [blame]
Poonam Aggrwalf8027f62009-09-02 19:40:36 +05301/*
2 * Copyright 2009 Freescale Semiconductor, Inc.
3 *
4 * This file is derived from cpu/mpc85xx/cpu.c and cpu/mpc86xx/cpu.c.
5 * Basically this file contains cpu specific common code for 85xx/86xx
6 * processors.
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <libfdt.h>
28#include <fdt_support.h>
29
30void ft_fixup_num_cores(void *blob) {
31 int off, num_cores, del_cores;
32
33 del_cores = 0;
34 num_cores = cpu_numcores();
35
36 off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
37 while (off != -FDT_ERR_NOTFOUND) {
38 u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
39
40 /* if we find a cpu node outside of what we expect delete it
41 * and reset the offset back to the start since we can't
42 * trust the offsets anymore
43 */
44 if (*reg > num_cores-1) {
45 fdt_del_node(blob, off);
46 del_cores++;
47 off = -1;
48 }
49 off = fdt_node_offset_by_prop_value(blob, off,
50 "device_type", "cpu", 4);
51 }
52 debug ("%x core system found\n", num_cores);
53 debug ("deleted %d extra core entry entries from device tree\n",
54 del_cores);
55}