Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2022 Nuvoton Technology Corp. */ #include <dm.h> #include <event.h> #include <asm/io.h> #include <asm/arch/gcr.h> #include "../common/uart.h" #define SR_MII_CTRL_SWR_BIT15 15 #define DRAM_512MB_ECC_SIZE 0x1C000000ULL #define DRAM_512MB_SIZE 0x20000000ULL #define DRAM_1GB_ECC_SIZE 0x38000000ULL #define DRAM_1GB_SIZE 0x40000000ULL #define DRAM_2GB_ECC_SIZE 0x70000000ULL #define DRAM_2GB_SIZE 0x80000000ULL #define DRAM_4GB_ECC_SIZE 0xE0000000ULL #define DRAM_4GB_SIZE 0x100000000ULL DECLARE_GLOBAL_DATA_PTR; phys_size_t get_effective_memsize(void) { /* Use bank0 only */ if (gd->ram_size > DRAM_2GB_SIZE) return DRAM_2GB_SIZE; return gd->ram_size; } int dram_init(void) { struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA; /* * get dram active size value from bootblock. * Value sent using scrpad_03 register. * feature available in bootblock 0.0.6 and above. */ gd->ram_size = readl(&gcr->scrpad_c); if (gd->ram_size == 0) gd->ram_size = readl(&gcr->scrpad_b); else gd->ram_size *= 0x100000ULL; debug("ram_size: %llx ", gd->ram_size); return 0; } int dram_init_banksize(void) { phys_size_t ram_size = gd->ram_size; gd->bd->bi_dram[0].start = 0; #if defined(CONFIG_SYS_MEM_TOP_HIDE) ram_size += CONFIG_SYS_MEM_TOP_HIDE; #endif switch (ram_size) { case DRAM_512MB_ECC_SIZE: case DRAM_512MB_SIZE: case DRAM_1GB_ECC_SIZE: case DRAM_1GB_SIZE: case DRAM_2GB_ECC_SIZE: case DRAM_2GB_SIZE: gd->bd->bi_dram[0].size = ram_size; gd->bd->bi_dram[1].start = 0; gd->bd->bi_dram[1].size = 0; break; case DRAM_4GB_ECC_SIZE: gd->bd->bi_dram[0].size = DRAM_2GB_SIZE; gd->bd->bi_dram[1].start = DRAM_4GB_SIZE; gd->bd->bi_dram[1].size = DRAM_2GB_SIZE - (DRAM_4GB_SIZE - DRAM_4GB_ECC_SIZE); break; case DRAM_4GB_SIZE: gd->bd->bi_dram[0].size = DRAM_2GB_SIZE; gd->bd->bi_dram[1].start = DRAM_4GB_SIZE; gd->bd->bi_dram[1].size = DRAM_2GB_SIZE; break; default: gd->bd->bi_dram[0].size = DRAM_1GB_SIZE; gd->bd->bi_dram[1].start = 0; gd->bd->bi_dram[1].size = 0; break; } return 0; } static int last_stage_init(void) { #ifdef CONFIG_SYS_SKIP_UART_INIT return board_set_console(); #endif return 0; } EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init); |