fdt.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 <clock_legacy.h>
  10. #include <linux/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_ARCH_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, struct bd_info *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. #ifdef CONFIG_ARCH_MPC8313
  48. /*
  49. * mpc8313e erratum IPIC1 swapped TSEC interrupt ID numbers on rev. 1
  50. * h/w (see AN3545). The base device tree in use has rev. 1 ID numbers,
  51. * so if on Rev. 2 (and higher) h/w, we fix them up here
  52. */
  53. if (REVID_MAJOR(immr->sysconf.spridr) >= 2) {
  54. int nodeoffset, path;
  55. const char *prop;
  56. nodeoffset = fdt_path_offset(blob, "/aliases");
  57. if (nodeoffset >= 0) {
  58. #if defined(CONFIG_HAS_ETH0)
  59. prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
  60. if (prop) {
  61. u32 tmp[] = { 32, 0x8, 33, 0x8, 34, 0x8 };
  62. path = fdt_path_offset(blob, prop);
  63. prop = fdt_getprop(blob, path, "interrupts",
  64. NULL);
  65. if (prop)
  66. fdt_setprop(blob, path, "interrupts",
  67. &tmp, sizeof(tmp));
  68. }
  69. #endif
  70. #if defined(CONFIG_HAS_ETH1)
  71. prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
  72. if (prop) {
  73. u32 tmp[] = { 35, 0x8, 36, 0x8, 37, 0x8 };
  74. path = fdt_path_offset(blob, prop);
  75. prop = fdt_getprop(blob, path, "interrupts",
  76. NULL);
  77. if (prop)
  78. fdt_setprop(blob, path, "interrupts",
  79. &tmp, sizeof(tmp));
  80. }
  81. #endif
  82. }
  83. }
  84. #endif
  85. #endif
  86. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  87. "timebase-frequency", (bd->bi_busfreq / 4), 1);
  88. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  89. "bus-frequency", bd->bi_busfreq, 1);
  90. do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
  91. "clock-frequency", gd->arch.core_clk, 1);
  92. do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
  93. "bus-frequency", bd->bi_busfreq, 1);
  94. do_fixup_by_compat_u32(blob, "fsl,soc",
  95. "bus-frequency", bd->bi_busfreq, 1);
  96. do_fixup_by_compat_u32(blob, "fsl,soc",
  97. "clock-frequency", bd->bi_busfreq, 1);
  98. do_fixup_by_compat_u32(blob, "fsl,immr",
  99. "bus-frequency", bd->bi_busfreq, 1);
  100. do_fixup_by_compat_u32(blob, "fsl,immr",
  101. "clock-frequency", bd->bi_busfreq, 1);
  102. #ifdef CONFIG_QE
  103. ft_qe_setup(blob);
  104. #endif
  105. #ifdef CONFIG_SYS_NS16550
  106. do_fixup_by_compat_u32(blob, "ns16550",
  107. "clock-frequency", get_serial_clock(), 1);
  108. #endif
  109. fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
  110. #if defined(CONFIG_BOOTCOUNT_LIMIT) && \
  111. (defined(CONFIG_QE) && !defined(CONFIG_ARCH_MPC831X))
  112. fdt_fixup_muram (blob);
  113. #endif
  114. }