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