ddr.c 640 B

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