blob: 6ba106c63bd88ebf633370c792c3f17650fb0588 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Philipp Tomsichfbbd3802017-06-12 10:33:20 +02002/*
3 * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
Philipp Tomsichfbbd3802017-06-12 10:33:20 +02004 */
5
6#include <common.h>
7#include <debug_uart.h>
8#include <dm.h>
Philipp Tomsichfbbd3802017-06-12 10:33:20 +02009#include <ram.h>
10#include <spl.h>
11#include <asm/io.h>
Kever Yang15f09a12019-03-28 11:01:23 +080012#include <asm/arch-rockchip/periph.h>
Philipp Tomsichfbbd3802017-06-12 10:33:20 +020013
Kever Yang1f6b5992019-07-09 22:00:30 +080014__weak int arch_cpu_init(void)
15{
16 return 0;
17}
18
Kever Yang192445b2019-07-09 22:00:31 +080019#define TIMER_LOAD_COUNT_L 0x00
20#define TIMER_LOAD_COUNT_H 0x04
21#define TIMER_CONTROL_REG 0x10
22#define TIMER_EN 0x1
23#define TIMER_FMODE BIT(0)
24#define TIMER_RMODE BIT(1)
25
26void rockchip_stimer_init(void)
27{
28 /* If Timer already enabled, don't re-init it */
29 u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
30
31 if (reg & TIMER_EN)
32 return;
33
34 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
35 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
36 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
37 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
38 TIMER_CONTROL_REG);
39}
40
Philipp Tomsichfbbd3802017-06-12 10:33:20 +020041void board_init_f(ulong dummy)
42{
Philipp Tomsichfbbd3802017-06-12 10:33:20 +020043 struct udevice *dev;
44 int ret;
45
46 ret = spl_early_init();
47 if (ret) {
48 debug("spl_early_init() failed: %d\n", ret);
49 hang();
50 }
51
Kever Yang192445b2019-07-09 22:00:31 +080052 /* Init secure timer */
53 rockchip_stimer_init();
54 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
55 timer_init();
56
Kever Yang1f6b5992019-07-09 22:00:30 +080057 arch_cpu_init();
Philipp Tomsichfbbd3802017-06-12 10:33:20 +020058 preloader_console_init();
59
60 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
61 if (ret) {
62 debug("DRAM init failed: %d\n", ret);
63 return;
64 }
65}
66
Philipp Tomsichfbbd3802017-06-12 10:33:20 +020067u32 spl_boot_device(void)
68{
69 return BOOT_DEVICE_MMC1;
70}
71
72#ifdef CONFIG_SPL_LOAD_FIT
73int board_fit_config_name_match(const char *name)
74{
75 /* Just empty function now - can't decide what to choose */
76 debug("%s: %s\n", __func__, name);
77
78 return 0;
79}
80#endif