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 | |
Quentin Schulz | 66eb36c | 2024-11-06 12:29:43 +0100 | [diff] [blame] | 24 | __weak void tpl_board_init(void) |
| 25 | { |
| 26 | } |
| 27 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 28 | void board_init_f(ulong dummy) |
| 29 | { |
| 30 | struct udevice *dev; |
| 31 | int ret; |
| 32 | |
Simon Glass | f4d6039 | 2021-08-08 12:20:12 -0600 | [diff] [blame] | 33 | #if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL) |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 34 | /* |
| 35 | * Debug UART can be used from here if required: |
| 36 | * |
| 37 | * debug_uart_init(); |
| 38 | * printch('a'); |
| 39 | * printhex8(0x1234); |
| 40 | * printascii("string"); |
| 41 | */ |
| 42 | debug_uart_init(); |
Chris Webb | 45dd801 | 2019-07-19 14:23:55 +0100 | [diff] [blame] | 43 | #ifdef CONFIG_TPL_BANNER_PRINT |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 44 | printascii("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ |
| 45 | U_BOOT_TIME ")\n"); |
| 46 | #endif |
Chris Webb | 45dd801 | 2019-07-19 14:23:55 +0100 | [diff] [blame] | 47 | #endif |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 48 | /* Init secure timer */ |
| 49 | rockchip_stimer_init(); |
| 50 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 51 | ret = spl_early_init(); |
| 52 | if (ret) { |
| 53 | debug("spl_early_init() failed: %d\n", ret); |
| 54 | hang(); |
| 55 | } |
| 56 | |
Johan Jonker | febb969 | 2022-04-09 18:55:05 +0200 | [diff] [blame] | 57 | /* Init ARM arch timer */ |
| 58 | if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER)) |
| 59 | timer_init(); |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 60 | |
Quentin Schulz | 66eb36c | 2024-11-06 12:29:43 +0100 | [diff] [blame] | 61 | tpl_board_init(); |
| 62 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 63 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 64 | if (ret) { |
| 65 | printf("DRAM init failed: %d\n", ret); |
| 66 | return; |
| 67 | } |
| 68 | } |
| 69 | |
Peng Fan | aa050c5 | 2019-08-07 06:40:53 +0000 | [diff] [blame] | 70 | int board_return_to_bootrom(struct spl_image_info *spl_image, |
| 71 | struct spl_boot_device *bootdev) |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 72 | { |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 73 | int ret; |
| 74 | |
| 75 | bootstage_mark_name(BOOTSTAGE_ID_END_TPL, "end tpl"); |
Tom Rini | d78c9bd | 2024-07-15 12:42:00 +0100 | [diff] [blame] | 76 | ret = bootstage_stash_default(); |
Simon Glass | 91eaa7c | 2023-01-07 14:57:30 -0700 | [diff] [blame] | 77 | if (ret) |
| 78 | debug("Failed to stash bootstage: err=%d\n", ret); |
Tom Rini | d78c9bd | 2024-07-15 12:42:00 +0100 | [diff] [blame] | 79 | |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 80 | back_to_bootrom(BROM_BOOT_NEXTSTAGE); |
Peng Fan | aa050c5 | 2019-08-07 06:40:53 +0000 | [diff] [blame] | 81 | |
| 82 | return 0; |
Kever Yang | 34ead0f | 2019-07-09 22:05:55 +0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | u32 spl_boot_device(void) |
| 86 | { |
| 87 | return BOOT_DEVICE_BOOTROM; |
| 88 | } |