Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2019 Rockchip Electronics Co., Ltd |
| 4 | */ |
| 5 | |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 6 | #include <bootstage.h> |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 7 | #include <debug_uart.h> |
| 8 | #include <dm.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 9 | #include <hang.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 12 | #include <ram.h> |
| 13 | #include <spl.h> |
| 14 | #include <version.h> |
| 15 | #include <asm/io.h> |
| 16 | #include <asm/arch-rockchip/bootrom.h> |
Simon Glass | bac075b | 2024-08-22 07:54:50 -0600 | [diff] [blame] | 17 | #include <asm/arch-rockchip/timer.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 18 | #include <linux/bitops.h> |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 19 | |
Pali Rohár | 6e1f085 | 2021-08-02 15:18:38 +0200 | [diff] [blame] | 20 | #if CONFIG_IS_ENABLED(BANNER_PRINT) |
| 21 | #include <timestamp.h> |
| 22 | #endif |
| 23 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 24 | void board_init_f(ulong dummy) |
| 25 | { |
| 26 | struct udevice *dev; |
| 27 | int ret; |
| 28 | |
Simon Glass | f4d6039 | 2021-08-08 12:20:12 -0600 | [diff] [blame] | 29 | #if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL) |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 30 | /* |
| 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 Webb | 45dd801 | 2019-07-19 14:23:55 +0100 | [diff] [blame] | 39 | #ifdef CONFIG_TPL_BANNER_PRINT |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 40 | printascii("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ |
| 41 | U_BOOT_TIME ")\n"); |
| 42 | #endif |
Chris Webb | 45dd801 | 2019-07-19 14:23:55 +0100 | [diff] [blame] | 43 | #endif |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 44 | /* Init secure timer */ |
| 45 | rockchip_stimer_init(); |
| 46 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 47 | ret = spl_early_init(); |
| 48 | if (ret) { |
| 49 | debug("spl_early_init() failed: %d\n", ret); |
| 50 | hang(); |
| 51 | } |
| 52 | |
Johan Jonker | febb969 | 2022-04-09 18:55:05 +0200 | [diff] [blame] | 53 | /* Init ARM arch timer */ |
| 54 | if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER)) |
| 55 | timer_init(); |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 56 | |
| 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 Fan | aa050c5 | 2019-08-07 06:40:53 +0000 | [diff] [blame] | 64 | int board_return_to_bootrom(struct spl_image_info *spl_image, |
| 65 | struct spl_boot_device *bootdev) |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 66 | { |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 67 | int ret; |
| 68 | |
| 69 | bootstage_mark_name(BOOTSTAGE_ID_END_TPL, "end tpl"); |
Tom Rini | d78c9bd | 2024-07-15 12:42:00 +0100 | [diff] [blame] | 70 | ret = bootstage_stash_default(); |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 71 | if (ret) |
| 72 | debug("Failed to stash bootstage: err=%d\n", ret); |
Tom Rini | d78c9bd | 2024-07-15 12:42:00 +0100 | [diff] [blame] | 73 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 74 | back_to_bootrom(BROM_BOOT_NEXTSTAGE); |
Peng Fan | aa050c5 | 2019-08-07 06:40:53 +0000 | [diff] [blame] | 75 | |
| 76 | return 0; |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | u32 spl_boot_device(void) |
| 80 | { |
| 81 | return BOOT_DEVICE_BOOTROM; |
| 82 | } |