1 /* 2 * (C) Copyright ASPEED Technology Inc. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 #include <common.h> 7 #include <debug_uart.h> 8 #include <spl.h> 9 #include <dm.h> 10 #include <mmc.h> 11 #include <xyzModem.h> 12 #include <asm/io.h> 13 #include <asm/arch/aspeed_verify.h> 14 15 DECLARE_GLOBAL_DATA_PTR; 16 17 #define AST_BOOTMODE_SPI 0 18 #define AST_BOOTMODE_EMMC 1 19 #define AST_BOOTMODE_UART 2 20 21 u32 aspeed_bootmode(void); 22 void aspeed_mmc_init(void); 23 24 void board_init_f(ulong dummy) 25 { 26 #ifndef CONFIG_SPL_TINY 27 struct udevice *dev; 28 spl_early_init(); 29 timer_init(); 30 uclass_get_device(UCLASS_PINCTRL, 0, &dev); 31 preloader_console_init(); 32 dram_init(); 33 aspeed_mmc_init(); 34 #endif 35 } 36 37 #ifdef CONFIG_SPL_BOARD_INIT 38 void spl_board_init(void) 39 { 40 struct udevice *dev; 41 42 if (uclass_get_device_by_driver(UCLASS_MISC, 43 DM_GET_DRIVER(aspeed_hace), 44 &dev)) { 45 debug("Warning: HACE initialization failure\n"); 46 } 47 48 if (uclass_get_device_by_driver(UCLASS_MISC, 49 DM_GET_DRIVER(aspeed_acry), 50 &dev)) { 51 debug("Warning: ACRY initialization failure\n"); 52 } 53 } 54 #endif 55 56 u32 spl_boot_device(void) 57 { 58 #ifdef CONFIG_ASPEED_LOADERS 59 switch (aspeed_bootmode()) { 60 case AST_BOOTMODE_EMMC: 61 return (IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT))? 62 ASPEED_SECBOOT_DEVICE_MMC : ASPEED_BOOT_DEVICE_MMC; 63 case AST_BOOTMODE_SPI: 64 return (IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT))? 65 ASPEED_SECBOOT_DEVICE_RAM : ASPEED_BOOT_DEVICE_RAM; 66 case AST_BOOTMODE_UART: 67 return (IS_ENABLED(CONFIG_ASPEED_SECURE_BOOT))? 68 ASPEED_SECBOOT_DEVICE_UART : ASPEED_BOOT_DEVICE_UART; 69 default: 70 break; 71 } 72 #else 73 switch (aspeed_bootmode()) { 74 case AST_BOOTMODE_EMMC: 75 return BOOT_DEVICE_MMC1; 76 case AST_BOOTMODE_SPI: 77 return BOOT_DEVICE_RAM; 78 case AST_BOOTMODE_UART: 79 return BOOT_DEVICE_UART; 80 default: 81 break; 82 } 83 #endif 84 85 return BOOT_DEVICE_NONE; 86 } 87 88 #ifdef CONFIG_SPL_OS_BOOT 89 int spl_start_uboot(void) 90 { 91 /* boot linux */ 92 return 0; 93 } 94 #endif 95 96 int board_fit_config_name_match(const char *name) 97 { 98 /* we always use the default configuration */ 99 debug("%s: %s\n", __func__, name); 100 return 0; 101 } 102 103 struct image_header *spl_get_load_buffer(ssize_t offset, size_t size) 104 { 105 return (struct image_header *)(CONFIG_SYS_LOAD_ADDR); 106 } 107