fdt.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2014 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <libfdt.h>
  8. #include <fdt_support.h>
  9. #include "mp.h"
  10. #ifdef CONFIG_MP
  11. void ft_fixup_cpu(void *blob)
  12. {
  13. int off;
  14. __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
  15. fdt32_t *reg;
  16. int addr_cells;
  17. u64 val;
  18. size_t *boot_code_size = &(__secondary_boot_code_size);
  19. off = fdt_path_offset(blob, "/cpus");
  20. if (off < 0) {
  21. puts("couldn't find /cpus node\n");
  22. return;
  23. }
  24. of_bus_default_count_cells(blob, off, &addr_cells, NULL);
  25. off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
  26. while (off != -FDT_ERR_NOTFOUND) {
  27. reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
  28. if (reg) {
  29. val = spin_tbl_addr;
  30. val += id_to_core(of_read_number(reg, addr_cells))
  31. * SPIN_TABLE_ELEM_SIZE;
  32. val = cpu_to_fdt64(val);
  33. fdt_setprop_string(blob, off, "enable-method",
  34. "spin-table");
  35. fdt_setprop(blob, off, "cpu-release-addr",
  36. &val, sizeof(val));
  37. } else {
  38. puts("Warning: found cpu node without reg property\n");
  39. }
  40. off = fdt_node_offset_by_prop_value(blob, off, "device_type",
  41. "cpu", 4);
  42. }
  43. fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
  44. *boot_code_size);
  45. }
  46. #endif
  47. void ft_cpu_setup(void *blob, bd_t *bd)
  48. {
  49. #ifdef CONFIG_MP
  50. ft_fixup_cpu(blob);
  51. #endif
  52. }