blob: c825e31c02dd00a2b5b3b2d67b607e7328537ce6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kever Yang57d4dbf2017-06-23 17:17:52 +08002/*
3 * (C) Copyright 2017 Rockchip Electronics Co., Ltd
Kever Yang57d4dbf2017-06-23 17:17:52 +08004 */
5
6#include <common.h>
Kever Yang57d4dbf2017-06-23 17:17:52 +08007#include <dm.h>
Kever Yang57d4dbf2017-06-23 17:17:52 +08008#include <spl.h>
9#include <asm/io.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080010#include <asm/arch-rockchip/hardware.h>
Kever Yang57d4dbf2017-06-23 17:17:52 +080011
12u32 spl_boot_device(void)
13{
14 return BOOT_DEVICE_MMC1;
15}
Kever Yanga65d5fa2017-07-27 12:53:59 +080016
Kever Yangaff40c62019-04-02 20:41:24 +080017u32 spl_boot_mode(const u32 boot_device)
18{
19 return MMCSD_MODE_RAW;
20}
21
Kever Yangc84ba5d2019-07-09 22:00:23 +080022#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
29void 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
Kever Yanga65d5fa2017-07-27 12:53:59 +080047#define SGRF_DDR_CON0 0x10150000
Kever Yang57d4dbf2017-06-23 17:17:52 +080048void board_init_f(ulong dummy)
49{
Kever Yang57d4dbf2017-06-23 17:17:52 +080050 int ret;
51
Kever Yang57d4dbf2017-06-23 17:17:52 +080052 ret = spl_early_init();
53 if (ret) {
Kever Yangaff40c62019-04-02 20:41:24 +080054 printf("spl_early_init() failed: %d\n", ret);
Kever Yang57d4dbf2017-06-23 17:17:52 +080055 hang();
56 }
Kever Yangaff40c62019-04-02 20:41:24 +080057 preloader_console_init();
Kever Yang57d4dbf2017-06-23 17:17:52 +080058
Kever Yangc84ba5d2019-07-09 22:00:23 +080059 /* Init secure timer */
60 rockchip_stimer_init();
61 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
62 timer_init();
63
Kever Yanga65d5fa2017-07-27 12:53:59 +080064 /* Disable the ddr secure region setting to make it non-secure */
65 rk_clrreg(SGRF_DDR_CON0, 0x4000);
Kever Yangaff40c62019-04-02 20:41:24 +080066}
67
68#ifdef CONFIG_SPL_LOAD_FIT
69int 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;
Kever Yang57d4dbf2017-06-23 17:17:52 +080075}
Kever Yangaff40c62019-04-02 20:41:24 +080076#endif