2022-04-19 05:32:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Nuvoton Technology Corp.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2023-06-13 07:45:54 +00:00
|
|
|
#include <env.h>
|
2022-04-19 05:32:19 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/gcr.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
2023-06-13 07:45:54 +00:00
|
|
|
char value[32];
|
2022-04-19 05:32:19 +00:00
|
|
|
struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
|
|
|
|
|
|
|
|
int ramsize = (readl(&gcr->intcr3) >> 8) & 0x7;
|
|
|
|
|
|
|
|
switch (ramsize) {
|
|
|
|
case 0:
|
|
|
|
gd->ram_size = 0x08000000; /* 128 MB. */
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gd->ram_size = 0x10000000; /* 256 MB. */
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gd->ram_size = 0x20000000; /* 512 MB. */
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
gd->ram_size = 0x40000000; /* 1024 MB. */
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
gd->ram_size = 0x80000000; /* 2048 MB. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-06-13 07:45:54 +00:00
|
|
|
if (gd->ram_size > 0) {
|
|
|
|
sprintf(value, "%ldM", (gd->ram_size / 0x100000));
|
|
|
|
env_set("mem", value);
|
|
|
|
}
|
|
|
|
|
2022-04-19 05:32:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|