// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2016 Google, Inc */ #include #include #include #include #include #include #include #include DECLARE_GLOBAL_DATA_PTR; __weak int board_init(void) { struct udevice *dev; int i; int ret; gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; /* * Loop over all MISC uclass drivers to call the comphy code * and init all CP110 devices enabled in the DT */ i = 0; while (1) { /* Call the comphy code via the MISC uclass driver */ ret = uclass_get_device(UCLASS_MISC, i++, &dev); /* We're done, once no further CP110 device is found */ if (ret) break; } return 0; } #ifndef CONFIG_RAM #define SDMC_CONFIG_VRAM_GET(x) ((x >> 2) & 0x3) #define SDMC_CONFIG_MEM_GET(x) (x & 0x3) static const u32 ast2500_dram_table[] = { 0x08000000, //128MB 0x10000000, //256MB 0x20000000, //512MB 0x40000000, //1024MB }; u32 ast_sdmc_get_mem_size(void) { u32 size = 0; u32 size_conf = SDMC_CONFIG_MEM_GET(readl(0x1e6e0004)); size = ast2500_dram_table[size_conf]; return size; } static const u32 aspeed_vram_table[] = { 0x00800000, //8MB 0x01000000, //16MB 0x02000000, //32MB 0x04000000, //64MB }; static u32 ast_sdmc_get_vram_size(void) { u32 size_conf = SDMC_CONFIG_VRAM_GET(readl(0x1e6e0004)); return aspeed_vram_table[size_conf]; } #endif __weak int dram_init(void) { #ifdef CONFIG_RAM struct udevice *dev; struct ram_info ram; int ret; ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) { debug("DRAM FAIL1\r\n"); return ret; } ret = ram_get_info(dev, &ram); if (ret) { debug("DRAM FAIL2\r\n"); return ret; } gd->ram_size = ram.size; #else u32 vga = ast_sdmc_get_vram_size(); u32 dram = ast_sdmc_get_mem_size(); gd->ram_size = (dram - vga); #endif return 0; } int arch_early_init_r(void) { #ifdef CONFIG_DM_PCI /* Trigger PCIe devices detection */ pci_init(); #endif return 0; }