rockchip: rk3399: tpl: Add spl_board_init
[project/bcm63xx/u-boot.git] / arch / arm / mach-rockchip / rk3399-board-tpl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4 */
5
6 #include <common.h>
7 #include <debug_uart.h>
8 #include <dm.h>
9 #include <ram.h>
10 #include <spl.h>
11 #include <version.h>
12 #include <asm/io.h>
13 #include <asm/arch-rockchip/bootrom.h>
14
15 #define TIMER_CHN10_BASE 0xff8680a0
16 #define TIMER_END_COUNT_L 0x00
17 #define TIMER_END_COUNT_H 0x04
18 #define TIMER_INIT_COUNT_L 0x10
19 #define TIMER_INIT_COUNT_H 0x14
20 #define TIMER_CONTROL_REG 0x1c
21
22 #define TIMER_EN 0x1
23 #define TIMER_FMODE (0 << 1)
24 #define TIMER_RMODE (1 << 1)
25
26 void secure_timer_init(void)
27 {
28 writel(0xffffffff, TIMER_CHN10_BASE + TIMER_END_COUNT_L);
29 writel(0xffffffff, TIMER_CHN10_BASE + TIMER_END_COUNT_H);
30 writel(0, TIMER_CHN10_BASE + TIMER_INIT_COUNT_L);
31 writel(0, TIMER_CHN10_BASE + TIMER_INIT_COUNT_H);
32 writel(TIMER_EN | TIMER_FMODE, TIMER_CHN10_BASE + TIMER_CONTROL_REG);
33 }
34
35 void board_init_f(ulong dummy)
36 {
37 struct udevice *dev;
38 int ret;
39
40 #ifdef CONFIG_DEBUG_UART
41 debug_uart_init();
42 /*
43 * Debug UART can be used from here if required:
44 *
45 * debug_uart_init();
46 * printch('a');
47 * printhex8(0x1234);
48 * printascii("string");
49 */
50 printascii("U-Boot TPL board init\n");
51 #endif
52 ret = spl_early_init();
53 if (ret) {
54 debug("spl_early_init() failed: %d\n", ret);
55 hang();
56 }
57
58 secure_timer_init();
59
60 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
61 if (ret) {
62 pr_err("DRAM init failed: %d\n", ret);
63 return;
64 }
65 }
66
67 void board_return_to_bootrom(void)
68 {
69 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
70 }
71
72 u32 spl_boot_device(void)
73 {
74 return BOOT_DEVICE_BOOTROM;
75 }
76
77 void spl_board_init(void)
78 {
79 puts("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - "
80 U_BOOT_TIME " " U_BOOT_TZ ")\n");
81 }
82
83 #ifdef CONFIG_SPL_LOAD_FIT
84 int board_fit_config_name_match(const char *name)
85 {
86 /* Just empty function now - can't decide what to choose */
87 debug("%s: %s\n", __func__, name);
88
89 return 0;
90 }
91 #endif