board.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. int 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. return 0;
  35. }
  36. void reset_cpu(ulong addr)
  37. {
  38. psci_system_reset();
  39. }
  40. static struct mm_region gxbb_mem_map[] = {
  41. {
  42. .virt = 0x0UL,
  43. .phys = 0x0UL,
  44. .size = 0x80000000UL,
  45. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
  46. PTE_BLOCK_INNER_SHARE
  47. }, {
  48. .virt = 0x80000000UL,
  49. .phys = 0x80000000UL,
  50. .size = 0x80000000UL,
  51. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  52. PTE_BLOCK_NON_SHARE |
  53. PTE_BLOCK_PXN | PTE_BLOCK_UXN
  54. }, {
  55. /* List terminator */
  56. 0,
  57. }
  58. };
  59. struct mm_region *mem_map = gxbb_mem_map;