1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (c) 2016 Google, Inc 4 */ 5 #include <common.h> 6 #include <dm.h> 7 #include <ram.h> 8 #include <timer.h> 9 #include <asm/io.h> 10 #include <asm/arch/timer.h> 11 #include <linux/err.h> 12 #include <dm/uclass.h> 13 14 DECLARE_GLOBAL_DATA_PTR; 15 16 __weak int board_init(void) 17 { 18 struct udevice *dev; 19 int i; 20 int ret; 21 22 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; 23 24 /* 25 * Loop over all MISC uclass drivers to call the comphy code 26 * and init all CP110 devices enabled in the DT 27 */ 28 i = 0; 29 while (1) { 30 /* Call the comphy code via the MISC uclass driver */ 31 ret = uclass_get_device(UCLASS_MISC, i++, &dev); 32 33 /* We're done, once no further CP110 device is found */ 34 if (ret) 35 break; 36 } 37 38 return 0; 39 } 40 41 __weak int dram_init(void) 42 { 43 struct udevice *dev; 44 struct ram_info ram; 45 int ret; 46 47 ret = uclass_get_device(UCLASS_RAM, 0, &dev); 48 if (ret) { 49 debug("DRAM FAIL1\r\n"); 50 return ret; 51 } 52 53 ret = ram_get_info(dev, &ram); 54 if (ret) { 55 debug("DRAM FAIL2\r\n"); 56 return ret; 57 } 58 59 gd->ram_size = ram.size; 60 return 0; 61 } 62 63 int arch_early_init_r(void) 64 { 65 #ifdef CONFIG_DM_PCI 66 /* Trigger PCIe devices detection */ 67 pci_init(); 68 #endif 69 70 return 0; 71 } 72 73