fdt.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright 2014-2015 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 <phy.h>
  10. #ifdef CONFIG_FSL_LSCH3
  11. #include <asm/arch/fdt.h>
  12. #endif
  13. #ifdef CONFIG_FSL_ESDHC
  14. #include <fsl_esdhc.h>
  15. #endif
  16. #ifdef CONFIG_SYS_DPAA_FMAN
  17. #include <fsl_fman.h>
  18. #endif
  19. #ifdef CONFIG_MP
  20. #include <asm/arch/mp.h>
  21. #endif
  22. int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
  23. {
  24. return fdt_setprop_string(blob, offset, "phy-connection-type",
  25. phy_string_for_interface(phyc));
  26. }
  27. #ifdef CONFIG_MP
  28. void ft_fixup_cpu(void *blob)
  29. {
  30. int off;
  31. __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
  32. fdt32_t *reg;
  33. int addr_cells;
  34. u64 val, core_id;
  35. size_t *boot_code_size = &(__secondary_boot_code_size);
  36. off = fdt_path_offset(blob, "/cpus");
  37. if (off < 0) {
  38. puts("couldn't find /cpus node\n");
  39. return;
  40. }
  41. of_bus_default_count_cells(blob, off, &addr_cells, NULL);
  42. off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
  43. while (off != -FDT_ERR_NOTFOUND) {
  44. reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
  45. if (reg) {
  46. core_id = of_read_number(reg, addr_cells);
  47. if (core_id == 0 || (is_core_online(core_id))) {
  48. val = spin_tbl_addr;
  49. val += id_to_core(core_id) *
  50. SPIN_TABLE_ELEM_SIZE;
  51. val = cpu_to_fdt64(val);
  52. fdt_setprop_string(blob, off, "enable-method",
  53. "spin-table");
  54. fdt_setprop(blob, off, "cpu-release-addr",
  55. &val, sizeof(val));
  56. } else {
  57. debug("skipping offline core\n");
  58. }
  59. } else {
  60. puts("Warning: found cpu node without reg property\n");
  61. }
  62. off = fdt_node_offset_by_prop_value(blob, off, "device_type",
  63. "cpu", 4);
  64. }
  65. fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
  66. *boot_code_size);
  67. }
  68. #endif
  69. void ft_cpu_setup(void *blob, bd_t *bd)
  70. {
  71. #ifdef CONFIG_MP
  72. ft_fixup_cpu(blob);
  73. #endif
  74. #ifdef CONFIG_SYS_NS16550
  75. do_fixup_by_compat_u32(blob, "fsl,ns16550",
  76. "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
  77. #endif
  78. do_fixup_by_compat_u32(blob, "fixed-clock",
  79. "clock-frequency", CONFIG_SYS_CLK_FREQ, 1);
  80. #ifdef CONFIG_PCI
  81. ft_pci_setup(blob, bd);
  82. #endif
  83. #ifdef CONFIG_FSL_ESDHC
  84. fdt_fixup_esdhc(blob, bd);
  85. #endif
  86. #ifdef CONFIG_SYS_DPAA_FMAN
  87. fdt_fixup_fman_firmware(blob);
  88. #endif
  89. }