board.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * (C) Copyright 2016 Beniamino Galvani <b.galvani@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <libfdt.h>
  8. #include <linux/err.h>
  9. #include <asm/arch/gxbb.h>
  10. #include <asm/arch/sm.h>
  11. #include <asm/armv8/mmu.h>
  12. #include <asm/unaligned.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  14. int dram_init(void)
  15. {
  16. const fdt64_t *val;
  17. int offset;
  18. int len;
  19. offset = fdt_path_offset(gd->fdt_blob, "/memory");
  20. if (offset < 0)
  21. return -EINVAL;
  22. val = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
  23. if (len < sizeof(*val) * 2)
  24. return -EINVAL;
  25. /* Use unaligned access since cache is still disabled */
  26. gd->ram_size = get_unaligned_be64(&val[1]);
  27. return 0;
  28. }
  29. void dram_init_banksize(void)
  30. {
  31. /* Reserve first 16 MiB of RAM for firmware */
  32. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE + (16 * 1024 * 1024);
  33. gd->bd->bi_dram[0].size = gd->ram_size - (16 * 1024 * 1024);
  34. }
  35. void reset_cpu(ulong addr)
  36. {
  37. psci_system_reset();
  38. }
  39. static struct mm_region gxbb_mem_map[] = {
  40. {
  41. .virt = 0x0UL,
  42. .phys = 0x0UL,
  43. .size = 0x80000000UL,
  44. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
  45. PTE_BLOCK_INNER_SHARE
  46. }, {
  47. .virt = 0x80000000UL,
  48. .phys = 0x80000000UL,
  49. .size = 0x80000000UL,
  50. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  51. PTE_BLOCK_NON_SHARE |
  52. PTE_BLOCK_PXN | PTE_BLOCK_UXN
  53. }, {
  54. /* List terminator */
  55. 0,
  56. }
  57. };
  58. struct mm_region *mem_map = gxbb_mem_map;