1 // SPDX-License-Identifier: GPL-2.0+ 2 #include <common.h> 3 #include <dm.h> 4 #include <ram.h> 5 #include <timer.h> 6 #include <asm/io.h> 7 #include <asm/arch/timer.h> 8 #include <linux/err.h> 9 #include <dm/uclass.h> 10 11 DECLARE_GLOBAL_DATA_PTR; 12 13 __weak int board_init(void) 14 { 15 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; 16 17 return 0; 18 } 19 20 #define SDMC_CONFIG_VRAM_GET(x) ((x >> 2) & 0x3) 21 #define SDMC_CONFIG_MEM_GET(x) (x & 0x3) 22 23 static const u32 ast2400_dram_table[] = { 24 0x04000000, //64MB 25 0x08000000, //128MB 26 0x10000000, //256MB 27 0x20000000, //512MB 28 }; 29 30 u32 31 ast_sdmc_get_mem_size(void) 32 { 33 u32 size = 0; 34 u32 size_conf = SDMC_CONFIG_MEM_GET(readl(0x1e6e0004)); 35 36 size = ast2400_dram_table[size_conf]; 37 38 return size; 39 } 40 41 42 static const u32 aspeed_vram_table[] = { 43 0x00800000, //8MB 44 0x01000000, //16MB 45 0x02000000, //32MB 46 0x04000000, //64MB 47 }; 48 49 u32 50 ast_sdmc_get_vram_size(void) 51 { 52 u32 size_conf = SDMC_CONFIG_VRAM_GET(readl(0x1e6e0004)); 53 return aspeed_vram_table[size_conf]; 54 } 55 56 __weak int dram_init(void) 57 { 58 #if 0 59 struct udevice *dev; 60 struct ram_info ram; 61 int ret; 62 63 ret = uclass_get_device(UCLASS_RAM, 0, &dev); 64 if (ret) { 65 debug("DRAM FAIL1\r\n"); 66 return ret; 67 } 68 69 ret = ram_get_info(dev, &ram); 70 if (ret) { 71 debug("DRAM FAIL2\r\n"); 72 return ret; 73 } 74 75 gd->ram_size = ram.size; 76 #else 77 u32 vga = ast_sdmc_get_vram_size(); 78 u32 dram = ast_sdmc_get_mem_size(); 79 gd->ram_size = (dram - vga); 80 #endif 81 return 0; 82 } 83