blob: 4a301249b499691f3660756ea37812032e7cc25a [file] [log] [blame]
Kever Yang6bbf5e12018-11-09 11:18:15 +08001// 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>
Jagan Tekic997c0f2019-06-21 00:25:04 +053011#include <version.h>
Kever Yang6bbf5e12018-11-09 11:18:15 +080012#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
26void 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
35void 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 */
Jagan Teki97d98e62019-06-21 00:25:05 +053050 debug("U-Boot TPL board init\n");
Kever Yang6bbf5e12018-11-09 11:18:15 +080051#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
67void board_return_to_bootrom(void)
68{
69 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
70}
71
72u32 spl_boot_device(void)
73{
74 return BOOT_DEVICE_BOOTROM;
75}
76
Jagan Tekic997c0f2019-06-21 00:25:04 +053077void 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
Kever Yang6bbf5e12018-11-09 11:18:15 +080083#ifdef CONFIG_SPL_LOAD_FIT
84int 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