Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 2 | /* |
Kever Yang | 002d897 | 2019-07-09 22:00:25 +0800 | [diff] [blame] | 3 | * (C) Copyright 2015-2019 Rockchip Electronics Co., Ltd |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9b20519 | 2015-12-13 21:37:00 -0700 | [diff] [blame] | 7 | #include <debug_uart.h> |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 8 | #include <asm/io.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 9 | #include <asm/arch-rockchip/bootrom.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 10 | #include <asm/arch-rockchip/sdram_rk3036.h> |
Kever Yang | 002d897 | 2019-07-09 22:00:25 +0800 | [diff] [blame] | 11 | |
| 12 | #define TIMER_LOAD_COUNT_L 0x00 |
| 13 | #define TIMER_LOAD_COUNT_H 0x04 |
| 14 | #define TIMER_CONTROL_REG 0x10 |
| 15 | #define TIMER_EN 0x1 |
| 16 | #define TIMER_FMODE (0 << 1) |
| 17 | #define TIMER_RMODE (1 << 1) |
| 18 | |
| 19 | void rockchip_stimer_init(void) |
| 20 | { |
| 21 | asm volatile("mcr p15, 0, %0, c14, c0, 0" |
| 22 | : : "r"(COUNTER_FREQUENCY)); |
| 23 | |
| 24 | writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG); |
| 25 | writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE); |
| 26 | writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4); |
| 27 | writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE + |
| 28 | TIMER_CONTROL_REG); |
| 29 | } |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 30 | |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 31 | void board_init_f(ulong dummy) |
| 32 | { |
Kever Yang | 7f3eec0 | 2019-03-29 09:09:00 +0800 | [diff] [blame] | 33 | #ifdef CONFIG_DEBUG_UART |
Simon Glass | 9b20519 | 2015-12-13 21:37:00 -0700 | [diff] [blame] | 34 | debug_uart_init(); |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 35 | #endif |
Kever Yang | 002d897 | 2019-07-09 22:00:25 +0800 | [diff] [blame] | 36 | |
| 37 | /* Init secure timer */ |
| 38 | rockchip_stimer_init(); |
| 39 | /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ |
| 40 | timer_init(); |
| 41 | |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 42 | sdram_init(); |
| 43 | |
| 44 | /* return to maskrom */ |
Philipp Tomsich | b82bd1f | 2017-10-10 16:21:16 +0200 | [diff] [blame] | 45 | back_to_bootrom(BROM_BOOT_NEXTSTAGE); |
huang lin | be1d5e0 | 2015-11-17 14:20:27 +0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /* Place Holders */ |
| 49 | void board_init_r(gd_t *id, ulong dest_addr) |
| 50 | { |
| 51 | /* |
| 52 | * Function attribute is no-return |
| 53 | * This Function never executes |
| 54 | */ |
| 55 | while (1) |
| 56 | ; |
| 57 | } |