arm64-common.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <fdtdec.h>
  8. #include <init.h>
  9. #include <asm/cache.h>
  10. #include <linux/libfdt.h>
  11. #include <linux/sizes.h>
  12. #include <pci.h>
  13. #include <asm/io.h>
  14. #include <asm/system.h>
  15. #include <asm/arch/cpu.h>
  16. #include <asm/arch/soc.h>
  17. #include <asm/armv8/mmu.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. /*
  20. * Not all memory is mapped in the MMU. So we need to restrict the
  21. * memory size so that U-Boot does not try to access it. Also, the
  22. * internal registers are located at 0xf000.0000 - 0xffff.ffff.
  23. * Currently only 2GiB are mapped for system memory. This is what
  24. * we pass to the U-Boot subsystem here.
  25. */
  26. #define USABLE_RAM_SIZE 0x80000000
  27. ulong board_get_usable_ram_top(ulong total_size)
  28. {
  29. if (gd->ram_size > USABLE_RAM_SIZE)
  30. return USABLE_RAM_SIZE;
  31. return gd->ram_size;
  32. }
  33. /*
  34. * On ARMv8, MBus is not configured in U-Boot. To enable compilation
  35. * of the already implemented drivers, lets add a dummy version of
  36. * this function so that linking does not fail.
  37. */
  38. const struct mbus_dram_target_info *mvebu_mbus_dram_info(void)
  39. {
  40. return NULL;
  41. }
  42. __weak int dram_init_banksize(void)
  43. {
  44. if (CONFIG_IS_ENABLED(ARMADA_8K))
  45. return a8k_dram_init_banksize();
  46. else if (CONFIG_IS_ENABLED(ARMADA_3700))
  47. return a3700_dram_init_banksize();
  48. else
  49. return fdtdec_setup_memory_banksize();
  50. }
  51. __weak int dram_init(void)
  52. {
  53. if (CONFIG_IS_ENABLED(ARMADA_8K)) {
  54. gd->ram_size = a8k_dram_scan_ap_sz();
  55. if (gd->ram_size != 0)
  56. return 0;
  57. }
  58. if (CONFIG_IS_ENABLED(ARMADA_3700))
  59. return a3700_dram_init();
  60. if (fdtdec_setup_mem_size_base() != 0)
  61. return -EINVAL;
  62. return 0;
  63. }
  64. int arch_cpu_init(void)
  65. {
  66. /* Nothing to do (yet) */
  67. return 0;
  68. }
  69. int arch_early_init_r(void)
  70. {
  71. struct udevice *dev;
  72. int ret;
  73. int i;
  74. /*
  75. * Loop over all MISC uclass drivers to call the comphy code
  76. * and init all CP110 devices enabled in the DT
  77. */
  78. i = 0;
  79. while (1) {
  80. /* Call the comphy code via the MISC uclass driver */
  81. ret = uclass_get_device(UCLASS_MISC, i++, &dev);
  82. /* We're done, once no further CP110 device is found */
  83. if (ret)
  84. break;
  85. }
  86. /* Cause the SATA device to do its early init */
  87. uclass_first_device(UCLASS_AHCI, &dev);
  88. #ifdef CONFIG_DM_PCI
  89. /* Trigger PCIe devices detection */
  90. pci_init();
  91. #endif
  92. return 0;
  93. }