fdt.c 3.6 KB

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