init.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <ram.h>
  14. #include <wdt.h>
  15. #include <asm/arch/misc.h>
  16. #include <asm/armv8/mmu.h>
  17. #include <asm/cache.h>
  18. #include <asm/sections.h>
  19. #include <dm/uclass.h>
  20. #include <dt-bindings/clock/mt8512-clk.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. int dram_init(void)
  23. {
  24. return fdtdec_setup_mem_size_base();
  25. }
  26. phys_size_t get_effective_memsize(void)
  27. {
  28. /* limit stack below tee reserve memory */
  29. return gd->ram_size - 6 * SZ_1M;
  30. }
  31. int dram_init_banksize(void)
  32. {
  33. gd->bd->bi_dram[0].start = gd->ram_base;
  34. gd->bd->bi_dram[0].size = get_effective_memsize();
  35. return 0;
  36. }
  37. void reset_cpu(ulong addr)
  38. {
  39. struct udevice *watchdog_dev = NULL;
  40. if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev))
  41. if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev))
  42. psci_system_reset();
  43. wdt_expire_now(watchdog_dev, 0);
  44. }
  45. int print_cpuinfo(void)
  46. {
  47. debug("CPU: MediaTek MT8512\n");
  48. return 0;
  49. }
  50. static struct mm_region mt8512_mem_map[] = {
  51. {
  52. /* DDR */
  53. .virt = 0x40000000UL,
  54. .phys = 0x40000000UL,
  55. .size = 0x40000000UL,
  56. .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
  57. }, {
  58. .virt = 0x00000000UL,
  59. .phys = 0x00000000UL,
  60. .size = 0x40000000UL,
  61. .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
  62. PTE_BLOCK_NON_SHARE |
  63. PTE_BLOCK_PXN | PTE_BLOCK_UXN
  64. }, {
  65. 0,
  66. }
  67. };
  68. struct mm_region *mem_map = mt8512_mem_map;