blob: aef142a881c3f382bc5a9da6adc395db040f52ef [file] [log] [blame]
Jim Liu4359b332022-04-19 13:32:19 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 *
4 * Copyright (c) 2021 Nuvoton Technology Corp.
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <asm/io.h>
10#include <asm/arch/gcr.h>
11#include <asm/mach-types.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15int board_init(void)
16{
17 return 0;
18}
19
20int dram_init(void)
21{
22 struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
23
24 int ramsize = (readl(&gcr->intcr3) >> 8) & 0x7;
25
26 switch (ramsize) {
27 case 0:
28 gd->ram_size = 0x08000000; /* 128 MB. */
29 break;
30 case 1:
31 gd->ram_size = 0x10000000; /* 256 MB. */
32 break;
33 case 2:
34 gd->ram_size = 0x20000000; /* 512 MB. */
35 break;
36 case 3:
37 gd->ram_size = 0x40000000; /* 1024 MB. */
38 break;
39 case 4:
40 gd->ram_size = 0x80000000; /* 2048 MB. */
41 break;
42
43 default:
44 break;
45 }
46
47 return 0;
48}