ls2085a.c 2.8 KB

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