fdt.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright 2007 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  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. extern void ft_qe_setup(void *blob);
  29. #ifdef CONFIG_MP
  30. #include "mp.h"
  31. DECLARE_GLOBAL_DATA_PTR;
  32. void ft_fixup_cpu(void *blob, u64 memory_limit)
  33. {
  34. int off;
  35. ulong spin_tbl_addr = get_spin_addr();
  36. u32 bootpg, id = get_my_id();
  37. /* if we have 4G or more of memory, put the boot page at 4Gb-4k */
  38. if ((u64)gd->ram_size > 0xfffff000)
  39. bootpg = 0xfffff000;
  40. else
  41. bootpg = gd->ram_size - 4096;
  42. off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
  43. while (off != -FDT_ERR_NOTFOUND) {
  44. u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
  45. if (reg) {
  46. if (*reg == id) {
  47. fdt_setprop_string(blob, off, "status", "okay");
  48. } else {
  49. u32 val = *reg * SIZE_BOOT_ENTRY + spin_tbl_addr;
  50. val = cpu_to_fdt32(val);
  51. fdt_setprop_string(blob, off, "status",
  52. "disabled");
  53. fdt_setprop_string(blob, off, "enable-method",
  54. "spin-table");
  55. fdt_setprop(blob, off, "cpu-release-addr",
  56. &val, sizeof(val));
  57. }
  58. } else {
  59. printf ("cpu NULL\n");
  60. }
  61. off = fdt_node_offset_by_prop_value(blob, off,
  62. "device_type", "cpu", 4);
  63. }
  64. /* Reserve the boot page so OSes dont use it */
  65. if ((u64)bootpg < memory_limit) {
  66. off = fdt_add_mem_rsv(blob, bootpg, (u64)4096);
  67. if (off < 0)
  68. printf("%s: %s\n", __FUNCTION__, fdt_strerror(off));
  69. }
  70. }
  71. #endif
  72. void ft_cpu_setup(void *blob, bd_t *bd)
  73. {
  74. #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
  75. defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
  76. fdt_fixup_ethernet(blob, bd);
  77. #endif
  78. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  79. "timebase-frequency", bd->bi_busfreq / 8, 1);
  80. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  81. "bus-frequency", bd->bi_busfreq, 1);
  82. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  83. "clock-frequency", bd->bi_intfreq, 1);
  84. do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
  85. "bus-frequency", bd->bi_busfreq, 1);
  86. #ifdef CONFIG_QE
  87. ft_qe_setup(blob);
  88. #endif
  89. #ifdef CFG_NS16550
  90. do_fixup_by_compat_u32(blob, "ns16550",
  91. "clock-frequency", bd->bi_busfreq, 1);
  92. #endif
  93. #ifdef CONFIG_CPM2
  94. do_fixup_by_compat_u32(blob, "fsl,cpm2-scc-uart",
  95. "current-speed", bd->bi_baudrate, 1);
  96. do_fixup_by_compat_u32(blob, "fsl,cpm2-brg",
  97. "clock-frequency", bd->bi_brgfreq, 1);
  98. #endif
  99. fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
  100. #ifdef CONFIG_MP
  101. ft_fixup_cpu(blob, (u64)bd->bi_memstart + (u64)bd->bi_memsize);
  102. #endif
  103. }