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