2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-06-23 09:17:52 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2017 Rockchip Electronics Co., Ltd
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <spl.h>
|
|
|
|
#include <asm/io.h>
|
2019-03-28 03:01:23 +00:00
|
|
|
#include <asm/arch-rockchip/hardware.h>
|
2017-06-23 09:17:52 +00:00
|
|
|
|
|
|
|
u32 spl_boot_device(void)
|
|
|
|
{
|
|
|
|
return BOOT_DEVICE_MMC1;
|
|
|
|
}
|
2017-07-27 04:53:59 +00:00
|
|
|
|
2019-04-02 12:41:24 +00:00
|
|
|
u32 spl_boot_mode(const u32 boot_device)
|
|
|
|
{
|
|
|
|
return MMCSD_MODE_RAW;
|
|
|
|
}
|
|
|
|
|
2019-07-09 14:00:23 +00:00
|
|
|
#define TIMER_LOAD_COUNT_L 0x00
|
|
|
|
#define TIMER_LOAD_COUNT_H 0x04
|
|
|
|
#define TIMER_CONTROL_REG 0x10
|
|
|
|
#define TIMER_EN 0x1
|
|
|
|
#define TIMER_FMODE BIT(0)
|
|
|
|
#define TIMER_RMODE BIT(1)
|
|
|
|
|
|
|
|
void rockchip_stimer_init(void)
|
|
|
|
{
|
|
|
|
/* If Timer already enabled, don't re-init it */
|
|
|
|
u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
|
|
|
|
|
|
|
|
if (reg & TIMER_EN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
asm volatile("mcr p15, 0, %0, c14, c0, 0"
|
|
|
|
: : "r"(COUNTER_FREQUENCY));
|
|
|
|
|
|
|
|
writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
|
|
|
|
writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
|
|
|
|
writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
|
|
|
|
writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
|
|
|
|
TIMER_CONTROL_REG);
|
|
|
|
}
|
|
|
|
|
2017-07-27 04:53:59 +00:00
|
|
|
#define SGRF_DDR_CON0 0x10150000
|
2017-06-23 09:17:52 +00:00
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = spl_early_init();
|
|
|
|
if (ret) {
|
2019-04-02 12:41:24 +00:00
|
|
|
printf("spl_early_init() failed: %d\n", ret);
|
2017-06-23 09:17:52 +00:00
|
|
|
hang();
|
|
|
|
}
|
2019-04-02 12:41:24 +00:00
|
|
|
preloader_console_init();
|
2017-06-23 09:17:52 +00:00
|
|
|
|
2019-07-09 14:00:23 +00:00
|
|
|
/* Init secure timer */
|
|
|
|
rockchip_stimer_init();
|
|
|
|
/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
|
|
|
|
timer_init();
|
|
|
|
|
2017-07-27 04:53:59 +00:00
|
|
|
/* Disable the ddr secure region setting to make it non-secure */
|
|
|
|
rk_clrreg(SGRF_DDR_CON0, 0x4000);
|
2017-06-23 09:17:52 +00:00
|
|
|
}
|
2019-04-02 12:41:24 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_LOAD_FIT
|
|
|
|
int board_fit_config_name_match(const char *name)
|
|
|
|
{
|
|
|
|
/* Just empty function now - can't decide what to choose */
|
|
|
|
debug("%s: %s\n", __func__, name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|