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