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 | |
Tom Rini | d216155 | 2024-04-30 07:35:46 -0600 | [diff] [blame] | 6 | #include <config.h> |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 8 | #include <asm/global_data.h> |
developer | ed71a40 | 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 | |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 28 | if (((size_t)preloader_param >= CFG_SYS_SDRAM_BASE) && |
developer | ed71a40 | 2018-11-15 10:07:53 +0800 | [diff] [blame] | 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 { |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 38 | gd->ram_size = get_ram_size((long *)CFG_SYS_SDRAM_BASE, |
developer | ed71a40 | 2018-11-15 10:07:53 +0800 | [diff] [blame] | 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 | } |