blob: 53c8a15bf9c8400cde3722eb7e5cc36b39756038 [file] [log] [blame]
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +08001// 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 Wang28263592022-06-01 16:43:52 +080010#include <linux/err.h>
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080011#include <asm/io.h>
12#include <asm/arch/scu_ast2600.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060013#include <asm/global_data.h>
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080014
15DECLARE_GLOBAL_DATA_PTR;
16
17void board_init_f(ulong dummy)
18{
19 spl_early_init();
20 preloader_console_init();
21 timer_init();
22 dram_init();
23}
24
Chia-Wei Wang28263592022-06-01 16:43:52 +080025/*
26 * Try to detect the boot mode. Fallback to the default,
27 * memory mapped SPI XIP booting if detection failed.
28 */
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080029u32 spl_boot_device(void)
30{
Chia-Wei Wang28263592022-06-01 16:43:52 +080031 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
55out:
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080056 return BOOT_DEVICE_RAM;
57}
58
59struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
60{
Chia-Wei Wange7897742021-10-27 14:17:32 +080061 return (struct image_header *)(CONFIG_SYS_LOAD_ADDR);
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080062}
63
64#ifdef CONFIG_SPL_OS_BOOT
65int spl_start_uboot(void)
66{
67 /* boot linux */
68 return 0;
69}
70#endif
71
72#ifdef CONFIG_SPL_LOAD_FIT
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