dram.c 747 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <fdtdec.h>
  7. #include <init.h>
  8. #include <asm/global_data.h>
  9. #include <linux/sizes.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. int dram_init(void)
  12. {
  13. return fdtdec_setup_mem_size_base();
  14. }
  15. int dram_init_banksize(void)
  16. {
  17. return fdtdec_setup_memory_banksize();
  18. }
  19. ulong board_get_usable_ram_top(ulong total_size)
  20. {
  21. /*
  22. * Ensure that we run from first 4GB so that all
  23. * addresses used by U-Boot are 32bit addresses.
  24. *
  25. * This in-turn ensures that 32bit DMA capable
  26. * devices work fine because DMA mapping APIs will
  27. * provide 32bit DMA addresses only.
  28. */
  29. if (gd->ram_top >= SZ_4G)
  30. return SZ_4G - 1;
  31. return gd->ram_top;
  32. }