blob: 7421911a416beb13d6a96cf8c9d2bf8c73325b68 [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>
Jim Liuc4ab55c2023-06-13 15:45:54 +08009#include <env.h>
Jim Liu4359b332022-04-19 13:32:19 +080010#include <asm/io.h>
11#include <asm/arch/gcr.h>
12#include <asm/mach-types.h>
Jim Liuc32c95c2023-11-14 16:51:59 +080013#include "../common/uart.h"
Jim Liu4359b332022-04-19 13:32:19 +080014
15DECLARE_GLOBAL_DATA_PTR;
16
17int board_init(void)
18{
19 return 0;
20}
21
22int dram_init(void)
23{
Jim Liuc4ab55c2023-06-13 15:45:54 +080024 char value[32];
Jim Liu4359b332022-04-19 13:32:19 +080025 struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
26
27 int ramsize = (readl(&gcr->intcr3) >> 8) & 0x7;
28
29 switch (ramsize) {
30 case 0:
31 gd->ram_size = 0x08000000; /* 128 MB. */
32 break;
33 case 1:
34 gd->ram_size = 0x10000000; /* 256 MB. */
35 break;
36 case 2:
37 gd->ram_size = 0x20000000; /* 512 MB. */
38 break;
39 case 3:
40 gd->ram_size = 0x40000000; /* 1024 MB. */
41 break;
42 case 4:
43 gd->ram_size = 0x80000000; /* 2048 MB. */
44 break;
45
46 default:
47 break;
48 }
49
Jim Liuc4ab55c2023-06-13 15:45:54 +080050 if (gd->ram_size > 0) {
51 sprintf(value, "%ldM", (gd->ram_size / 0x100000));
52 env_set("mem", value);
53 }
54
Jim Liu4359b332022-04-19 13:32:19 +080055 return 0;
56}
Jim Liuc32c95c2023-11-14 16:51:59 +080057
58int last_stage_init(void)
59{
60 board_set_console();
61
62 return 0;
63}