common: Drop init.h from common header
[pandora-u-boot.git] / arch / arm / mach-mediatek / mt8512 / init.c
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
9 #include <clk.h>
10 #include <common.h>
11 #include <dm.h>
12 #include <fdtdec.h>
13 #include <init.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
23 DECLARE_GLOBAL_DATA_PTR;
24
25 int dram_init(void)
26 {
27         return fdtdec_setup_mem_size_base();
28 }
29
30 phys_size_t  get_effective_memsize(void)
31 {
32         /* limit stack below tee reserve memory */
33         return gd->ram_size - 6 * SZ_1M;
34 }
35
36 int dram_init_banksize(void)
37 {
38         gd->bd->bi_dram[0].start = gd->ram_base;
39         gd->bd->bi_dram[0].size = get_effective_memsize();
40
41         return 0;
42 }
43
44 void reset_cpu(ulong addr)
45 {
46         struct udevice *watchdog_dev = NULL;
47
48         if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev))
49                 if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev))
50                         psci_system_reset();
51
52         wdt_expire_now(watchdog_dev, 0);
53 }
54
55 int print_cpuinfo(void)
56 {
57         debug("CPU:   MediaTek MT8512\n");
58         return 0;
59 }
60
61 static struct mm_region mt8512_mem_map[] = {
62         {
63                 /* DDR */
64                 .virt = 0x40000000UL,
65                 .phys = 0x40000000UL,
66                 .size = 0x40000000UL,
67                 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_OUTER_SHARE,
68         }, {
69                 .virt = 0x00000000UL,
70                 .phys = 0x00000000UL,
71                 .size = 0x40000000UL,
72                 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
73                          PTE_BLOCK_NON_SHARE |
74                          PTE_BLOCK_PXN | PTE_BLOCK_UXN
75         }, {
76                 0,
77         }
78 };
79
80 struct mm_region *mem_map = mt8512_mem_map;