blob: 73f6d241a1cef1068f001ba7cdd00a5592aaed63 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
huang linbe1d5e02015-11-17 14:20:27 +08002/*
Kever Yang002d8972019-07-09 22:00:25 +08003 * (C) Copyright 2015-2019 Rockchip Electronics Co., Ltd
huang linbe1d5e02015-11-17 14:20:27 +08004 */
5
6#include <common.h>
Simon Glass9b205192015-12-13 21:37:00 -07007#include <debug_uart.h>
Simon Glass691d7192020-05-10 11:40:02 -06008#include <init.h>
huang linbe1d5e02015-11-17 14:20:27 +08009#include <asm/io.h>
Kever Yang15f09a12019-03-28 11:01:23 +080010#include <asm/arch-rockchip/bootrom.h>
Kever Yang15f09a12019-03-28 11:01:23 +080011#include <asm/arch-rockchip/sdram_rk3036.h>
Kever Yang002d8972019-07-09 22:00:25 +080012
13#define TIMER_LOAD_COUNT_L 0x00
14#define TIMER_LOAD_COUNT_H 0x04
15#define TIMER_CONTROL_REG 0x10
16#define TIMER_EN 0x1
17#define TIMER_FMODE (0 << 1)
18#define TIMER_RMODE (1 << 1)
19
20void rockchip_stimer_init(void)
21{
22 asm volatile("mcr p15, 0, %0, c14, c0, 0"
Peng Fan151a0302022-04-13 17:47:22 +080023 : : "r"(CONFIG_COUNTER_FREQUENCY));
Kever Yang002d8972019-07-09 22:00:25 +080024
25 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
26 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
27 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
28 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
29 TIMER_CONTROL_REG);
30}
huang linbe1d5e02015-11-17 14:20:27 +080031
huang linbe1d5e02015-11-17 14:20:27 +080032void board_init_f(ulong dummy)
33{
Kever Yang7f3eec02019-03-29 09:09:00 +080034#ifdef CONFIG_DEBUG_UART
Simon Glass9b205192015-12-13 21:37:00 -070035 debug_uart_init();
huang linbe1d5e02015-11-17 14:20:27 +080036#endif
Kever Yang002d8972019-07-09 22:00:25 +080037
38 /* Init secure timer */
39 rockchip_stimer_init();
40 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
41 timer_init();
42
huang linbe1d5e02015-11-17 14:20:27 +080043 sdram_init();
44
45 /* return to maskrom */
Philipp Tomsichb82bd1f2017-10-10 16:21:16 +020046 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
huang linbe1d5e02015-11-17 14:20:27 +080047}
48
49/* Place Holders */
50void board_init_r(gd_t *id, ulong dest_addr)
51{
52 /*
53 * Function attribute is no-return
54 * This Function never executes
55 */
56 while (1)
57 ;
58}