blob: 2778e260e024cf9d040fac598df8439eea84bafe [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>
Simon Glass8e16b1e2019-12-28 10:45:05 -07007#include <init.h>
developered71a402018-11-15 10:07:53 +08008#include <linux/io.h>
9#include <linux/sizes.h>
10#include <asm/arch/misc.h>
11
12#include "preloader.h"
13
14DECLARE_GLOBAL_DATA_PTR;
15
16struct boot_argument *preloader_param;
17
18int mtk_soc_early_init(void)
19{
20 return 0;
21}
22
23int 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
44int 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}