Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 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> |
Chia-Wei Wang | 2826359 | 2022-06-01 16:43:52 +0800 | [diff] [blame^] | 10 | #include <linux/err.h> |
Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 11 | #include <asm/io.h> |
| 12 | #include <asm/arch/scu_ast2600.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | void board_init_f(ulong dummy) |
| 18 | { |
| 19 | spl_early_init(); |
| 20 | preloader_console_init(); |
| 21 | timer_init(); |
| 22 | dram_init(); |
| 23 | } |
| 24 | |
Chia-Wei Wang | 2826359 | 2022-06-01 16:43:52 +0800 | [diff] [blame^] | 25 | /* |
| 26 | * Try to detect the boot mode. Fallback to the default, |
| 27 | * memory mapped SPI XIP booting if detection failed. |
| 28 | */ |
Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 29 | u32 spl_boot_device(void) |
| 30 | { |
Chia-Wei Wang | 2826359 | 2022-06-01 16:43:52 +0800 | [diff] [blame^] | 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: |
Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 56 | return BOOT_DEVICE_RAM; |
| 57 | } |
| 58 | |
| 59 | struct image_header *spl_get_load_buffer(ssize_t offset, size_t size) |
| 60 | { |
Chia-Wei Wang | e789774 | 2021-10-27 14:17:32 +0800 | [diff] [blame] | 61 | return (struct image_header *)(CONFIG_SYS_LOAD_ADDR); |
Chia-Wei, Wang | 8f7f490 | 2020-12-14 13:54:28 +0800 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | #ifdef CONFIG_SPL_OS_BOOT |
| 65 | int spl_start_uboot(void) |
| 66 | { |
| 67 | /* boot linux */ |
| 68 | return 0; |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | #ifdef CONFIG_SPL_LOAD_FIT |
| 73 | int 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 |