init.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Configuration for MediaTek MT8512 SoC
  4. *
  5. * Copyright (C) 2019 MediaTek Inc.
  6. * Author: Mingming Lee <mingming.lee@mediatek.com>
  7. */
  8. #include <clk.h>
  9. #include <common.h>
  10. #include <dm.h>
  11. #include <fdtdec.h>
  12. #include <init.h>
  13. #include <log.h>
  14. #include <ram.h>
  15. #include <wdt.h>
  16. #include <asm/arch/misc.h>
  17. #include <asm/armv8/mmu.h>
  18. #include <asm/cache.h>
  19. #include <asm/sections.h>
  20. #include <dm/uclass.h>
  21. #include <dt-bindings/clock/mt8512-clk.h>
  22. DECLARE_GLOBAL_DATA_PTR;
  23. int dram_init(void)
  24. {
  25. return fdtdec_setup_mem_size_base();
  26. }
  27. phys_size_t get_effective_memsize(void)
  28. {
  29. /* limit stack below tee reserve memory */
  30. return gd->ram_size - 6 * SZ_1M;
  31. }
  32. int dram_init_banksize(void)
  33. {
  34. gd->bd->bi_dram[0].start = gd->ram_base;
  35. gd->bd->bi_dram[0].size = get_effective_memsize();
  36. return 0;
  37. }
  38. void reset_cpu(ulong addr)
  39. {
  40. struct udevice *watchdog_dev = NULL;
  41. if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev))
  42. if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev))
  43. psci_system_reset();
  44. wdt_expire_now(watchdog_dev, 0);
  45. }
  46. int print_cpuinfo(void)
  47. {
  48. debug("CPU: MediaTek MT8512\n");
  49. return 0;
  50. }
  51. static struct mm_region mt8512_mem_map[] = {
  52. {
  53. /* DDR */
  54. .virt = 0x40000000UL,
  55. .phys = 0x40000000UL,
  56. .size = 0x40000000UL,
  57. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
  58. }, {
  59. .virt = 0x00000000UL,
  60. .phys = 0x00000000UL,
  61. .size = 0x40000000UL,
  62. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  63. PTE_BLOCK_NON_SHARE |
  64. PTE_BLOCK_PXN | PTE_BLOCK_UXN
  65. }, {
  66. 0,
  67. }
  68. };
  69. struct mm_region *mem_map = mt8512_mem_map;