fdt.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright 2007 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <libfdt.h>
  11. #include <fdt_support.h>
  12. #include <asm/processor.h>
  13. extern void ft_qe_setup(void *blob);
  14. DECLARE_GLOBAL_DATA_PTR;
  15. #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
  16. (defined(CONFIG_QE) && !defined(CONFIG_MPC831x))
  17. #include <linux/immap_qe.h>
  18. void fdt_fixup_muram (void *blob)
  19. {
  20. ulong data[2];
  21. data[0] = 0;
  22. data[1] = QE_MURAM_SIZE - 2 * sizeof(unsigned long);
  23. do_fixup_by_compat(blob, "fsl,qe-muram-data", "reg",
  24. data, sizeof (data), 0);
  25. }
  26. #endif
  27. void ft_cpu_setup(void *blob, bd_t *bd)
  28. {
  29. immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  30. int spridr = immr->sysconf.spridr;
  31. /*
  32. * delete crypto node if not on an E-processor
  33. * initial revisions of the MPC834xE/6xE have the original SEC 2.0.
  34. * EA revisions got the SEC uprevved to 2.4 but since the default device
  35. * tree contains SEC 2.0 properties we uprev them here.
  36. */
  37. if (!IS_E_PROCESSOR(spridr))
  38. fdt_fixup_crypto_node(blob, 0);
  39. else if (IS_E_PROCESSOR(spridr) &&
  40. (SPR_FAMILY(spridr) == SPR_834X_FAMILY ||
  41. SPR_FAMILY(spridr) == SPR_836X_FAMILY) &&
  42. REVID_MAJOR(spridr) >= 2)
  43. fdt_fixup_crypto_node(blob, 0x0204);
  44. #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
  45. defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3) ||\
  46. defined(CONFIG_HAS_ETH4) || defined(CONFIG_HAS_ETH5)
  47. fdt_fixup_ethernet(blob);
  48. #ifdef CONFIG_MPC8313
  49. /*
  50. * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
  51. * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
  52. * so if on Rev. 2 (and higher) h/w, we fix them up here
  53. */
  54. if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
  55. int nodeoffset, path;
  56. const char *prop;
  57. nodeoffset = fdt_path_offset(blob, "/aliases");
  58. if (nodeoffset >= 0) {
  59. #if defined(CONFIG_HAS_ETH0)
  60. prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
  61. if (prop) {
  62. u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
  63. path = fdt_path_offset(blob, prop);
  64. prop = fdt_getprop(blob, path, "interrupts",
  65. NULL);
  66. if (prop)
  67. fdt_setprop(blob, path, "interrupts",
  68. &tmp, sizeof(tmp));
  69. }
  70. #endif
  71. #if defined(CONFIG_HAS_ETH1)
  72. prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
  73. if (prop) {
  74. u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
  75. path = fdt_path_offset(blob, prop);
  76. prop = fdt_getprop(blob, path, "interrupts",
  77. NULL);
  78. if (prop)
  79. fdt_setprop(blob, path, "interrupts",
  80. &tmp, sizeof(tmp));
  81. }
  82. #endif
  83. }
  84. }
  85. #endif
  86. #endif
  87. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  88. "timebase-frequency", (bd->bi_busfreq / 4), 1);
  89. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  90. "bus-frequency", bd->bi_busfreq, 1);
  91. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  92. "clock-frequency", gd->arch.core_clk, 1);
  93. do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
  94. "bus-frequency", bd->bi_busfreq, 1);
  95. do_fixup_by_compat_u32(blob, "fsl,soc",
  96. "bus-frequency", bd->bi_busfreq, 1);
  97. do_fixup_by_compat_u32(blob, "fsl,soc",
  98. "clock-frequency", bd->bi_busfreq, 1);
  99. do_fixup_by_compat_u32(blob, "fsl,immr",
  100. "bus-frequency", bd->bi_busfreq, 1);
  101. do_fixup_by_compat_u32(blob, "fsl,immr",
  102. "clock-frequency", bd->bi_busfreq, 1);
  103. #ifdef CONFIG_QE
  104. ft_qe_setup(blob);
  105. #endif
  106. #ifdef CONFIG_SYS_NS16550
  107. do_fixup_by_compat_u32(blob, "ns16550",
  108. "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
  109. #endif
  110. fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
  111. #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
  112. (defined(CONFIG_QE) && !defined(CONFIG_MPC831x))
  113. fdt_fixup_muram (blob);
  114. #endif
  115. }