dram.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/post.h>
  8. #include <asm/arch/qemu.h>
  9. DECLARE_GLOBAL_DATA_PTR;
  10. int dram_init(void)
  11. {
  12. u32 ram;
  13. outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT);
  14. ram = ((u32)inb(CMOS_DATA_PORT)) << 14;
  15. outb(LOW_RAM_ADDR, CMOS_ADDR_PORT);
  16. ram |= ((u32)inb(CMOS_DATA_PORT)) << 6;
  17. ram += 16 * 1024;
  18. gd->ram_size = ram * 1024;
  19. post_code(POST_DRAM);
  20. return 0;
  21. }
  22. void dram_init_banksize(void)
  23. {
  24. gd->bd->bi_dram[0].start = 0;
  25. gd->bd->bi_dram[0].size = gd->ram_size;
  26. }
  27. /*
  28. * This function looks for the highest region of memory lower than 4GB which
  29. * has enough space for U-Boot where U-Boot is aligned on a page boundary.
  30. * It overrides the default implementation found elsewhere which simply
  31. * picks the end of ram, wherever that may be. The location of the stack,
  32. * the relocation address, and how far U-Boot is moved by relocation are
  33. * set in the global data structure.
  34. */
  35. ulong board_get_usable_ram_top(ulong total_size)
  36. {
  37. return gd->ram_size;
  38. }