arm64-common.c 1.9 KB

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