rockchip: rk3128: use ARM arch timer instead of rk_timer
[oweals/u-boot.git] / arch / arm / mach-rockchip / rk322x-board-spl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <spl.h>
9 #include <asm/io.h>
10 #include <asm/arch-rockchip/hardware.h>
11
12 u32 spl_boot_device(void)
13 {
14         return BOOT_DEVICE_MMC1;
15 }
16
17 u32 spl_boot_mode(const u32 boot_device)
18 {
19         return MMCSD_MODE_RAW;
20 }
21
22 #define TIMER_LOAD_COUNT_L      0x00
23 #define TIMER_LOAD_COUNT_H      0x04
24 #define TIMER_CONTROL_REG       0x10
25 #define TIMER_EN        0x1
26 #define TIMER_FMODE     BIT(0)
27 #define TIMER_RMODE     BIT(1)
28
29 void rockchip_stimer_init(void)
30 {
31         /* If Timer already enabled, don't re-init it */
32         u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
33
34         if (reg & TIMER_EN)
35                 return;
36
37         asm volatile("mcr p15, 0, %0, c14, c0, 0"
38                      : : "r"(COUNTER_FREQUENCY));
39
40         writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
41         writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
42         writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
43         writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
44                TIMER_CONTROL_REG);
45 }
46
47 #define SGRF_DDR_CON0 0x10150000
48 void board_init_f(ulong dummy)
49 {
50         int ret;
51
52         ret = spl_early_init();
53         if (ret) {
54                 printf("spl_early_init() failed: %d\n", ret);
55                 hang();
56         }
57         preloader_console_init();
58
59         /* Init secure timer */
60         rockchip_stimer_init();
61         /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
62         timer_init();
63
64         /* Disable the ddr secure region setting to make it non-secure */
65         rk_clrreg(SGRF_DDR_CON0, 0x4000);
66 }
67
68 #ifdef CONFIG_SPL_LOAD_FIT
69 int board_fit_config_name_match(const char *name)
70 {
71         /* Just empty function now - can't decide what to choose */
72         debug("%s: %s\n", __func__, name);
73
74         return 0;
75 }
76 #endif