ls2080a.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2014 Freescale Semiconductor
  4. */
  5. #include <common.h>
  6. #include <malloc.h>
  7. #include <errno.h>
  8. #include <netdev.h>
  9. #include <fsl_ifc.h>
  10. #include <fsl_ddr.h>
  11. #include <asm/io.h>
  12. #include <fdt_support.h>
  13. #include <linux/libfdt.h>
  14. #include <fsl-mc/fsl_mc.h>
  15. #include <environment.h>
  16. #include <asm/arch/soc.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int board_init(void)
  19. {
  20. init_final_memctl_regs();
  21. #ifdef CONFIG_ENV_IS_NOWHERE
  22. gd->env_addr = (ulong)&default_environment[0];
  23. #endif
  24. return 0;
  25. }
  26. int board_early_init_f(void)
  27. {
  28. fsl_lsch3_early_init_f();
  29. return 0;
  30. }
  31. void detail_board_ddr_info(void)
  32. {
  33. puts("\nDDR ");
  34. print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
  35. print_ddr_info(0);
  36. #ifdef CONFIG_SYS_FSL_HAS_DP_DDR
  37. if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
  38. puts("\nDP-DDR ");
  39. print_size(gd->bd->bi_dram[2].size, "");
  40. print_ddr_info(CONFIG_DP_DDR_CTRL);
  41. }
  42. #endif
  43. }
  44. #if defined(CONFIG_ARCH_MISC_INIT)
  45. int arch_misc_init(void)
  46. {
  47. return 0;
  48. }
  49. #endif
  50. int board_eth_init(bd_t *bis)
  51. {
  52. int error = 0;
  53. #ifdef CONFIG_SMC91111
  54. error = smc91111_initialize(0, CONFIG_SMC91111_BASE);
  55. #endif
  56. #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
  57. error = cpu_eth_init(bis);
  58. #endif
  59. return error;
  60. }
  61. #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
  62. void fdt_fixup_board_enet(void *fdt)
  63. {
  64. int offset;
  65. offset = fdt_path_offset(fdt, "/soc/fsl-mc");
  66. /*
  67. * TODO: Remove this when backward compatibility
  68. * with old DT node (/fsl-mc) is no longer needed.
  69. */
  70. if (offset < 0)
  71. offset = fdt_path_offset(fdt, "/fsl-mc");
  72. if (offset < 0) {
  73. printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
  74. __func__, offset);
  75. return;
  76. }
  77. if ((get_mc_boot_status() == 0) && (get_dpl_apply_status() == 0))
  78. fdt_status_okay(fdt, offset);
  79. else
  80. fdt_status_fail(fdt, offset);
  81. }
  82. void board_quiesce_devices(void)
  83. {
  84. fsl_mc_ldpaa_exit(gd->bd);
  85. }
  86. #endif
  87. #ifdef CONFIG_OF_BOARD_SETUP
  88. int ft_board_setup(void *blob, bd_t *bd)
  89. {
  90. u64 base[CONFIG_NR_DRAM_BANKS];
  91. u64 size[CONFIG_NR_DRAM_BANKS];
  92. ft_cpu_setup(blob, bd);
  93. /* fixup DT for the two GPP DDR banks */
  94. base[0] = gd->bd->bi_dram[0].start;
  95. size[0] = gd->bd->bi_dram[0].size;
  96. base[1] = gd->bd->bi_dram[1].start;
  97. size[1] = gd->bd->bi_dram[1].size;
  98. #ifdef CONFIG_RESV_RAM
  99. /* reduce size if reserved memory is within this bank */
  100. if (gd->arch.resv_ram >= base[0] &&
  101. gd->arch.resv_ram < base[0] + size[0])
  102. size[0] = gd->arch.resv_ram - base[0];
  103. else if (gd->arch.resv_ram >= base[1] &&
  104. gd->arch.resv_ram < base[1] + size[1])
  105. size[1] = gd->arch.resv_ram - base[1];
  106. #endif
  107. fdt_fixup_memory_banks(blob, base, size, 2);
  108. #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
  109. fdt_fixup_board_enet(blob);
  110. #endif
  111. return 0;
  112. }
  113. #endif
  114. #if defined(CONFIG_RESET_PHY_R)
  115. void reset_phy(void)
  116. {
  117. }
  118. #endif