Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Amarula Solutions |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 4 | */ |
| 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 Tomsich | dd320e1 | 2019-04-30 00:00:38 +0200 | [diff] [blame] | 13 | #include <asm/arch-rockchip/bootrom.h> |
Kever Yang | 15f09a1 | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 14 | #include <asm/arch-rockchip/clock.h> |
Kever Yang | ae5a365 | 2019-07-09 22:00:26 +0800 | [diff] [blame^] | 15 | |
| 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 | |
| 23 | void 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 Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 34 | |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 35 | void board_init_f(ulong dummy) |
| 36 | { |
| 37 | struct udevice *dev; |
| 38 | int ret; |
| 39 | |
Kever Yang | e83e885 | 2019-03-29 09:09:04 +0800 | [diff] [blame] | 40 | #ifdef CONFIG_DEBUG_UART |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 41 | /* |
| 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 Yang | e83e885 | 2019-03-29 09:09:04 +0800 | [diff] [blame] | 50 | #endif |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 51 | ret = spl_early_init(); |
| 52 | if (ret) { |
| 53 | debug("spl_early_init() failed: %d\n", ret); |
| 54 | hang(); |
| 55 | } |
| 56 | |
Kever Yang | ae5a365 | 2019-07-09 22:00:26 +0800 | [diff] [blame^] | 57 | /* Init secure timer */ |
| 58 | rockchip_stimer_init(); |
| 59 | /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */ |
| 60 | timer_init(); |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 61 | |
| 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 | |
| 75 | void board_return_to_bootrom(void) |
| 76 | { |
Philipp Tomsich | b82bd1f | 2017-10-10 16:21:16 +0200 | [diff] [blame] | 77 | back_to_bootrom(BROM_BOOT_NEXTSTAGE); |
Jagan Teki | 532cb7f | 2017-09-27 23:03:12 +0530 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | u32 spl_boot_device(void) |
| 81 | { |
| 82 | return BOOT_DEVICE_BOOTROM; |
| 83 | } |
| 84 | |
| 85 | void spl_board_init(void) |
| 86 | { |
| 87 | puts("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \ |
| 88 | U_BOOT_TIME ")\n"); |
| 89 | } |