1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (c) Aspeed Technology Inc. 4 */ 5 #include <common.h> 6 #include <debug_uart.h> 7 #include <dm.h> 8 #include <spl.h> 9 #include <init.h> 10 #include <linux/err.h> 11 #include <asm/io.h> 12 #include <asm/arch/scu_ast2600.h> 13 #include <asm/global_data.h> 14 15 DECLARE_GLOBAL_DATA_PTR; 16 board_init_f(ulong dummy)17void board_init_f(ulong dummy) 18 { 19 spl_early_init(); 20 preloader_console_init(); 21 timer_init(); 22 dram_init(); 23 } 24 25 /* 26 * Try to detect the boot mode. Fallback to the default, 27 * memory mapped SPI XIP booting if detection failed. 28 */ spl_boot_device(void)29u32 spl_boot_device(void) 30 { 31 int rc; 32 struct udevice *scu_dev; 33 struct ast2600_scu *scu; 34 35 rc = uclass_get_device_by_driver(UCLASS_CLK, 36 DM_DRIVER_GET(aspeed_ast2600_scu), &scu_dev); 37 if (rc) { 38 debug("%s: failed to get SCU driver\n", __func__); 39 goto out; 40 } 41 42 scu = devfdt_get_addr_ptr(scu_dev); 43 if (IS_ERR_OR_NULL(scu)) { 44 debug("%s: failed to get SCU base\n", __func__); 45 goto out; 46 } 47 48 /* boot from UART has higher priority */ 49 if (scu->hwstrap2 & SCU_HWSTRAP2_BOOT_UART) 50 return BOOT_DEVICE_UART; 51 52 if (scu->hwstrap1 & SCU_HWSTRAP1_BOOT_EMMC) 53 return BOOT_DEVICE_MMC1; 54 55 out: 56 return BOOT_DEVICE_RAM; 57 } 58 spl_get_load_buffer(ssize_t offset,size_t size)59struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size) 60 { 61 return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR); 62 } 63 64 #ifdef CONFIG_SPL_OS_BOOT spl_start_uboot(void)65int spl_start_uboot(void) 66 { 67 /* boot linux */ 68 return 0; 69 } 70 #endif 71 72 #ifdef CONFIG_SPL_LOAD_FIT board_fit_config_name_match(const char * name)73int board_fit_config_name_match(const char *name) 74 { 75 /* just empty function now - can't decide what to choose */ 76 debug("%s: %s\n", __func__, name); 77 return 0; 78 } 79 #endif 80