developer | ed71a40 | 2018-11-15 10:07:53 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2018 MediaTek Inc. |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 7 | #include <init.h> |
developer | ed71a40 | 2018-11-15 10:07:53 +0800 | [diff] [blame] | 8 | #include <linux/io.h> |
| 9 | #include <linux/sizes.h> |
| 10 | #include <asm/arch/misc.h> |
| 11 | |
| 12 | #include "preloader.h" |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | struct boot_argument *preloader_param; |
| 17 | |
| 18 | int mtk_soc_early_init(void) |
| 19 | { |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int dram_init(void) |
| 24 | { |
| 25 | u32 i; |
| 26 | |
| 27 | if (((size_t)preloader_param >= CONFIG_SYS_SDRAM_BASE) && |
| 28 | ((size_t)preloader_param % sizeof(size_t) == 0) && |
| 29 | preloader_param->magic == BOOT_ARGUMENT_MAGIC && |
| 30 | preloader_param->dram_rank_num <= |
| 31 | ARRAY_SIZE(preloader_param->dram_rank_size)) { |
| 32 | gd->ram_size = 0; |
| 33 | |
| 34 | for (i = 0; i < preloader_param->dram_rank_num; i++) |
| 35 | gd->ram_size += preloader_param->dram_rank_size[i]; |
| 36 | } else { |
| 37 | gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, |
| 38 | SZ_2G); |
| 39 | } |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | int print_cpuinfo(void) |
| 45 | { |
| 46 | void __iomem *chipid; |
| 47 | u32 swver; |
| 48 | |
| 49 | chipid = ioremap(VER_BASE, VER_SIZE); |
| 50 | swver = readl(chipid + APSW_VER); |
| 51 | |
| 52 | printf("CPU: MediaTek MT7623 E%d\n", (swver & 0xf) + 1); |
| 53 | |
| 54 | return 0; |
| 55 | } |