blob: bbb9329e725af79ea4c4049aa7890a4a143e7df5 [file] [log] [blame]
Kever Yang34ead0f2019-07-09 22:05:55 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4 */
5
Simon Glass91eaa7c2023-01-07 14:57:30 -07006#include <bootstage.h>
Kever Yang34ead0f2019-07-09 22:05:55 +08007#include <debug_uart.h>
8#include <dm.h>
Simon Glassf11478f2019-12-28 10:45:07 -07009#include <hang.h>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Kever Yang34ead0f2019-07-09 22:05:55 +080012#include <ram.h>
13#include <spl.h>
14#include <version.h>
15#include <asm/io.h>
16#include <asm/arch-rockchip/bootrom.h>
Simon Glassbac075b2024-08-22 07:54:50 -060017#include <asm/arch-rockchip/timer.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060018#include <linux/bitops.h>
Kever Yang34ead0f2019-07-09 22:05:55 +080019
Pali Rohár6e1f0852021-08-02 15:18:38 +020020#if CONFIG_IS_ENABLED(BANNER_PRINT)
21#include <timestamp.h>
22#endif
23
Kever Yang34ead0f2019-07-09 22:05:55 +080024void board_init_f(ulong dummy)
25{
26 struct udevice *dev;
27 int ret;
28
Simon Glassf4d60392021-08-08 12:20:12 -060029#if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL)
Kever Yang34ead0f2019-07-09 22:05:55 +080030 /*
31 * Debug UART can be used from here if required:
32 *
33 * debug_uart_init();
34 * printch('a');
35 * printhex8(0x1234);
36 * printascii("string");
37 */
38 debug_uart_init();
Chris Webb45dd8012019-07-19 14:23:55 +010039#ifdef CONFIG_TPL_BANNER_PRINT
Kever Yang34ead0f2019-07-09 22:05:55 +080040 printascii("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
41 U_BOOT_TIME ")\n");
42#endif
Chris Webb45dd8012019-07-19 14:23:55 +010043#endif
Simon Glass91eaa7c2023-01-07 14:57:30 -070044 /* Init secure timer */
45 rockchip_stimer_init();
46
Kever Yang34ead0f2019-07-09 22:05:55 +080047 ret = spl_early_init();
48 if (ret) {
49 debug("spl_early_init() failed: %d\n", ret);
50 hang();
51 }
52
Johan Jonkerfebb9692022-04-09 18:55:05 +020053 /* Init ARM arch timer */
54 if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER))
55 timer_init();
Kever Yang34ead0f2019-07-09 22:05:55 +080056
57 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
58 if (ret) {
59 printf("DRAM init failed: %d\n", ret);
60 return;
61 }
62}
63
Peng Fanaa050c52019-08-07 06:40:53 +000064int board_return_to_bootrom(struct spl_image_info *spl_image,
65 struct spl_boot_device *bootdev)
Kever Yang34ead0f2019-07-09 22:05:55 +080066{
Simon Glass91eaa7c2023-01-07 14:57:30 -070067 int ret;
68
69 bootstage_mark_name(BOOTSTAGE_ID_END_TPL, "end tpl");
Tom Rinid78c9bd2024-07-15 12:42:00 +010070 ret = bootstage_stash_default();
Simon Glass91eaa7c2023-01-07 14:57:30 -070071 if (ret)
72 debug("Failed to stash bootstage: err=%d\n", ret);
Tom Rinid78c9bd2024-07-15 12:42:00 +010073
Kever Yang34ead0f2019-07-09 22:05:55 +080074 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
Peng Fanaa050c52019-08-07 06:40:53 +000075
76 return 0;
Kever Yang34ead0f2019-07-09 22:05:55 +080077}
78
79u32 spl_boot_device(void)
80{
81 return BOOT_DEVICE_BOOTROM;
82}