blob: 05390c16f3aff42c388c7de453b5899beac61546 [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 */
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +08005#include <debug_uart.h>
6#include <dm.h>
7#include <spl.h>
8#include <init.h>
Chia-Wei Wang28263592022-06-01 16:43:52 +08009#include <linux/err.h>
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080010#include <asm/io.h>
11#include <asm/arch/scu_ast2600.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060012#include <asm/global_data.h>
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080013
14DECLARE_GLOBAL_DATA_PTR;
15
16void board_init_f(ulong dummy)
17{
18 spl_early_init();
19 preloader_console_init();
20 timer_init();
21 dram_init();
22}
23
Chia-Wei Wang28263592022-06-01 16:43:52 +080024/*
25 * Try to detect the boot mode. Fallback to the default,
26 * memory mapped SPI XIP booting if detection failed.
27 */
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080028u32 spl_boot_device(void)
29{
Chia-Wei Wang28263592022-06-01 16:43:52 +080030 int rc;
31 struct udevice *scu_dev;
32 struct ast2600_scu *scu;
33
34 rc = uclass_get_device_by_driver(UCLASS_CLK,
35 DM_DRIVER_GET(aspeed_ast2600_scu), &scu_dev);
36 if (rc) {
37 debug("%s: failed to get SCU driver\n", __func__);
38 goto out;
39 }
40
41 scu = devfdt_get_addr_ptr(scu_dev);
42 if (IS_ERR_OR_NULL(scu)) {
43 debug("%s: failed to get SCU base\n", __func__);
44 goto out;
45 }
46
47 /* boot from UART has higher priority */
48 if (scu->hwstrap2 & SCU_HWSTRAP2_BOOT_UART)
49 return BOOT_DEVICE_UART;
50
51 if (scu->hwstrap1 & SCU_HWSTRAP1_BOOT_EMMC)
52 return BOOT_DEVICE_MMC1;
53
54out:
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080055 return BOOT_DEVICE_RAM;
56}
57
Simon Glassbb7d3bb2022-09-06 20:26:52 -060058struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080059{
Simon Glassbb7d3bb2022-09-06 20:26:52 -060060 return (struct legacy_img_hdr *)(CONFIG_SYS_LOAD_ADDR);
Chia-Wei, Wang8f7f4902020-12-14 13:54:28 +080061}
62
63#ifdef CONFIG_SPL_OS_BOOT
64int spl_start_uboot(void)
65{
66 /* boot linux */
67 return 0;
68}
69#endif
70
71#ifdef CONFIG_SPL_LOAD_FIT
72int board_fit_config_name_match(const char *name)
73{
74 /* just empty function now - can't decide what to choose */
75 debug("%s: %s\n", __func__, name);
76 return 0;
77}
78#endif