1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
7 #include <debug_uart.h>
16 #include <asm/arch-rockchip/bootrom.h>
17 #include <linux/bitops.h>
19 #if CONFIG_IS_ENABLED(BANNER_PRINT)
20 #include <timestamp.h>
23 #define TIMER_LOAD_COUNT_L 0x00
24 #define TIMER_LOAD_COUNT_H 0x04
25 #define TIMER_CONTROL_REG 0x10
27 #define TIMER_FMODE BIT(0)
28 #define TIMER_RMODE BIT(1)
30 __weak void rockchip_stimer_init(void)
32 #if defined(CONFIG_ROCKCHIP_STIMER_BASE)
33 /* If Timer already enabled, don't re-init it */
34 u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
40 asm volatile("mcr p15, 0, %0, c14, c0, 0"
41 : : "r"(CONFIG_COUNTER_FREQUENCY));
44 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
45 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
46 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
47 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
52 void board_init_f(ulong dummy)
57 #if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL)
59 * Debug UART can be used from here if required:
64 * printascii("string");
67 #ifdef CONFIG_TPL_BANNER_PRINT
68 printascii("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
72 /* Init secure timer */
73 rockchip_stimer_init();
75 ret = spl_early_init();
77 debug("spl_early_init() failed: %d\n", ret);
81 /* Init ARM arch timer */
82 if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER))
85 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
87 printf("DRAM init failed: %d\n", ret);
92 int board_return_to_bootrom(struct spl_image_info *spl_image,
93 struct spl_boot_device *bootdev)
95 #ifdef CONFIG_BOOTSTAGE_STASH
98 bootstage_mark_name(BOOTSTAGE_ID_END_TPL, "end tpl");
99 ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
100 CONFIG_BOOTSTAGE_STASH_SIZE);
102 debug("Failed to stash bootstage: err=%d\n", ret);
104 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
109 u32 spl_boot_device(void)
111 return BOOT_DEVICE_BOOTROM;