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>
18 #include <linux/kconfig.h>
20 #if CONFIG_IS_ENABLED(BANNER_PRINT)
21 #include <timestamp.h>
24 #define TIMER_LOAD_COUNT_L 0x00
25 #define TIMER_LOAD_COUNT_H 0x04
26 #define TIMER_CONTROL_REG 0x10
28 #define TIMER_FMODE BIT(0)
29 #define TIMER_RMODE BIT(1)
31 __weak void rockchip_stimer_init(void)
33 #if defined(CONFIG_ROCKCHIP_STIMER_BASE)
34 /* If Timer already enabled, don't re-init it */
35 u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
41 asm volatile("mcr p15, 0, %0, c14, c0, 0"
42 : : "r"(COUNTER_FREQUENCY));
45 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
46 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
47 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
48 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
53 void board_init_f(ulong dummy)
58 #if defined(CONFIG_DEBUG_UART) && defined(CONFIG_TPL_SERIAL)
60 * Debug UART can be used from here if required:
65 * printascii("string");
68 #ifdef CONFIG_TPL_BANNER_PRINT
69 printascii("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
73 ret = spl_early_init();
75 debug("spl_early_init() failed: %d\n", ret);
79 /* Init secure timer */
80 rockchip_stimer_init();
82 /* Init ARM arch timer */
83 if (IS_ENABLED(CONFIG_SYS_ARCH_TIMER))
86 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
88 printf("DRAM init failed: %d\n", ret);
93 int board_return_to_bootrom(struct spl_image_info *spl_image,
94 struct spl_boot_device *bootdev)
96 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
101 u32 spl_boot_device(void)
103 return BOOT_DEVICE_BOOTROM;