Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <debug_uart.h> |
| 8 | #include <dm.h> |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 9 | #include <ram.h> |
| 10 | #include <spl.h> |
| 11 | #include <asm/io.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 12 | #include <asm/arch-rockchip/periph.h> |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 13 | |
Kever Yang | 1f6b599 | 2019-07-09 22:00:30 +0800 | [diff] [blame] | 14 | __weak int arch_cpu_init(void) |
| 15 | { |
| 16 | return 0; |
| 17 | } |
| 18 | |
Kever Yang | 192445b | 2019-07-09 22:00:31 +0800 | [diff] [blame] | 19 | #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 | |
| 26 | void 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 Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 41 | void board_init_f(ulong dummy) |
| 42 | { |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 43 | 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 Yang | 192445b | 2019-07-09 22:00:31 +0800 | [diff] [blame] | 52 | /* 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 Yang | 1f6b599 | 2019-07-09 22:00:30 +0800 | [diff] [blame] | 57 | arch_cpu_init(); |
Philipp Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 58 | 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 Tomsich | fbbd380 | 2017-06-12 10:33:20 +0200 | [diff] [blame] | 67 | u32 spl_boot_device(void) |
| 68 | { |
| 69 | return BOOT_DEVICE_MMC1; |
| 70 | } |
| 71 | |
| 72 | #ifdef CONFIG_SPL_LOAD_FIT |
| 73 | int 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 |