Jim Liu | 4359b33 | 2022-04-19 13:32:19 +0800 | [diff] [blame] | 1 | // 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 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | int board_init(void) |
| 16 | { |
| 17 | return 0; |
| 18 | } |
| 19 | |
| 20 | int 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 | } |