ddr.c 622 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2016 Imagination Technologies
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include "boston-regs.h"
  8. DECLARE_GLOBAL_DATA_PTR;
  9. int dram_init(void)
  10. {
  11. u32 ddrconf0 = __raw_readl((uint32_t *)BOSTON_PLAT_DDRCONF0);
  12. gd->ram_size = (phys_size_t)(ddrconf0 & BOSTON_PLAT_DDRCONF0_SIZE) <<
  13. 30;
  14. return 0;
  15. }
  16. ulong board_get_usable_ram_top(ulong total_size)
  17. {
  18. DECLARE_GLOBAL_DATA_PTR;
  19. if (gd->ram_top < CONFIG_SYS_SDRAM_BASE) {
  20. /* 2GB wrapped around to 0 */
  21. return CKSEG0ADDR(256 << 20);
  22. }
  23. return min_t(unsigned long, gd->ram_top, CKSEG0ADDR(256 << 20));
  24. }