blob: 96de7927f06ae23be30649b7e363ed96dca7b4e3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jagan Teki532cb7f2017-09-27 23:03:12 +05302/*
3 * Copyright (C) 2017 Amarula Solutions
Jagan Teki532cb7f2017-09-27 23:03:12 +05304 */
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>
Philipp Tomsichdd320e12019-04-30 00:00:38 +020013#include <asm/arch-rockchip/bootrom.h>
Kever Yang15f09a12019-03-28 11:01:23 +080014#include <asm/arch-rockchip/clock.h>
Kever Yangae5a3652019-07-09 22:00:26 +080015
16#define TIMER_LOAD_COUNT_L 0x00
17#define TIMER_LOAD_COUNT_H 0x04
18#define TIMER_CONTROL_REG 0x10
19#define TIMER_EN 0x1
20#define TIMER_FMODE BIT(0)
21#define TIMER_RMODE BIT(1)
22
23void rockchip_stimer_init(void)
24{
25 asm volatile("mcr p15, 0, %0, c14, c0, 0"
26 : : "r"(COUNTER_FREQUENCY));
27
28 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
29 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
30 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
31 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
32 TIMER_CONTROL_REG);
33}
Jagan Teki532cb7f2017-09-27 23:03:12 +053034
Jagan Teki532cb7f2017-09-27 23:03:12 +053035void board_init_f(ulong dummy)
36{
37 struct udevice *dev;
38 int ret;
39
Kever Yange83e8852019-03-29 09:09:04 +080040#ifdef CONFIG_DEBUG_UART
Jagan Teki532cb7f2017-09-27 23:03:12 +053041 /*
42 * Debug UART can be used from here if required:
43 *
44 * debug_uart_init();
45 * printch('a');
46 * printhex8(0x1234);
47 * printascii("string");
48 */
49 debug_uart_init();
Kever Yange83e8852019-03-29 09:09:04 +080050#endif
Jagan Teki532cb7f2017-09-27 23:03:12 +053051 ret = spl_early_init();
52 if (ret) {
53 debug("spl_early_init() failed: %d\n", ret);
54 hang();
55 }
56
Kever Yangae5a3652019-07-09 22:00:26 +080057 /* Init secure timer */
58 rockchip_stimer_init();
59 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
60 timer_init();
Jagan Teki532cb7f2017-09-27 23:03:12 +053061
62 ret = rockchip_get_clk(&dev);
63 if (ret) {
64 debug("CLK init failed: %d\n", ret);
65 return;
66 }
67
68 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
69 if (ret) {
70 debug("DRAM init failed: %d\n", ret);
71 return;
72 }
73}
74
75void board_return_to_bootrom(void)
76{
Philipp Tomsichb82bd1f2017-10-10 16:21:16 +020077 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
Jagan Teki532cb7f2017-09-27 23:03:12 +053078}
79
80u32 spl_boot_device(void)
81{
82 return BOOT_DEVICE_BOOTROM;
83}
84
85void spl_board_init(void)
86{
87 puts("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
88 U_BOOT_TIME ")\n");
89}