fdt.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  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. #include <common.h>
  26. #include <libfdt.h>
  27. #include <fdt_support.h>
  28. void ft_fixup_num_cores(void *blob) {
  29. int off, num_cores, del_cores;
  30. del_cores = 0;
  31. num_cores = cpu_numcores();
  32. off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
  33. while (off != -FDT_ERR_NOTFOUND) {
  34. u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
  35. /* if we find a cpu node outside of what we expect delete it
  36. * and reset the offset back to the start since we can't
  37. * trust the offsets anymore
  38. */
  39. if (*reg > num_cores-1) {
  40. fdt_del_node(blob, off);
  41. del_cores++;
  42. off = -1;
  43. }
  44. off = fdt_node_offset_by_prop_value(blob, off,
  45. "device_type", "cpu", 4);
  46. }
  47. debug ("%x core system found\n", num_cores);
  48. debug ("deleted %d extra core entry entries from device tree\n",
  49. del_cores);
  50. }