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