dram.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <asm/post.h>
  7. #include <asm/arch/qemu.h>
  8. DECLARE_GLOBAL_DATA_PTR;
  9. int dram_init(void)
  10. {
  11. u32 ram;
  12. outb(HIGH_RAM_ADDR, CMOS_ADDR_PORT);
  13. ram = ((u32)inb(CMOS_DATA_PORT)) << 14;
  14. outb(LOW_RAM_ADDR, CMOS_ADDR_PORT);
  15. ram |= ((u32)inb(CMOS_DATA_PORT)) << 6;
  16. ram += 16 * 1024;
  17. gd->ram_size = ram * 1024;
  18. post_code(POST_DRAM);
  19. return 0;
  20. }
  21. int dram_init_banksize(void)
  22. {
  23. gd->bd->bi_dram[0].start = 0;
  24. gd->bd->bi_dram[0].size = gd->ram_size;
  25. return 0;
  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. }