2019-07-22 11:59:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2019 Rockchip Electronics Co., Ltd
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <debug_uart.h>
|
|
|
|
#include <dm.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-07-22 11:59:12 +00:00
|
|
|
#include <ram.h>
|
|
|
|
#include <spl.h>
|
|
|
|
#include <asm/arch-rockchip/bootrom.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2019-07-22 11:59:12 +00:00
|
|
|
#include <asm/io.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2019-07-22 11:59:12 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2019-08-07 06:40:53 +00:00
|
|
|
int board_return_to_bootrom(struct spl_image_info *spl_image,
|
|
|
|
struct spl_boot_device *bootdev)
|
2019-07-22 11:59:12 +00:00
|
|
|
{
|
|
|
|
back_to_bootrom(BROM_BOOT_NEXTSTAGE);
|
2019-08-07 06:40:53 +00:00
|
|
|
|
|
|
|
return 0;
|
2019-07-22 11:59:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *board_spl_was_booted_from(void)
|
|
|
|
{
|
|
|
|
u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
|
|
|
|
const char *bootdevice_ofpath = NULL;
|
|
|
|
|
|
|
|
if (bootdevice_brom_id < ARRAY_SIZE(boot_devices))
|
|
|
|
bootdevice_ofpath = boot_devices[bootdevice_brom_id];
|
|
|
|
|
|
|
|
if (bootdevice_ofpath)
|
|
|
|
debug("%s: brom_bootdevice_id %x maps to '%s'\n",
|
|
|
|
__func__, bootdevice_brom_id, bootdevice_ofpath);
|
|
|
|
else
|
|
|
|
debug("%s: failed to resolve brom_bootdevice_id %x\n",
|
|
|
|
__func__, bootdevice_brom_id);
|
|
|
|
|
|
|
|
return bootdevice_ofpath;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 spl_boot_device(void)
|
|
|
|
{
|
|
|
|
u32 boot_device = BOOT_DEVICE_MMC1;
|
|
|
|
|
|
|
|
#if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
|
|
|
|
defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
|
2020-05-13 19:15:20 +00:00
|
|
|
defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
|
2020-07-19 19:55:53 +00:00
|
|
|
defined(CONFIG_TARGET_CHROMEBOOK_SPEEDY) || \
|
rockchip: rk3399: Add support for chromebook_kevin
Add support for Kevin, an RK3399-based convertible chromebook that is
very similar to Bob. This patch is mostly based on existing support for
Bob, with only minor changes for Kevin-specific things.
Unlike other Gru boards, coreboot sets Kevin's center logic to 925 mV,
so adjust it here in the dts as well. The rk3399-gru-kevin devicetree
has an unknown event code reference which has to be defined, set it
to the Linux counterpart. The new defconfig is copied from Bob with the
diffconfig:
DEFAULT_DEVICE_TREE "rk3399-gru-bob" -> "rk3399-gru-kevin"
DEFAULT_FDT_FILE "rockchip/rk3399-gru-bob.dtb" -> "rockchip/rk3399-gru-kevin.dtb"
VIDEO_ROCKCHIP_MAX_XRES 1280 -> 2400
VIDEO_ROCKCHIP_MAX_YRES 800 -> 1600
+TARGET_CHROMEBOOK_KEVIN y
With this Kevin can boot from SPI flash to a usable U-Boot prompt on the
display with the keyboard working, but cannot boot into Linux for
unknown reasons.
eMMC starts in a working state but fails to re-init, microSD card works
but at a lower-than-expected speed, USB works but causes a hang on
de-init. There are known workarounds to solve eMMC and USB issues.
Cc: Marty E. Plummer <hanetzer@startmail.com>
Cc: Simon Glass <sjg@chromium.org>
[Alper: commit message, resync config with Bob, update MAINTAINERS,
add to Rockchip doc, add Kconfig help message, set regulator]
Co-developed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
2021-12-24 13:43:46 +00:00
|
|
|
defined(CONFIG_TARGET_CHROMEBOOK_BOB) || \
|
|
|
|
defined(CONFIG_TARGET_CHROMEBOOK_KEVIN)
|
2019-07-22 11:59:12 +00:00
|
|
|
return BOOT_DEVICE_SPI;
|
|
|
|
#endif
|
|
|
|
if (CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM))
|
|
|
|
return BOOT_DEVICE_BOOTROM;
|
|
|
|
|
|
|
|
return boot_device;
|
|
|
|
}
|
|
|
|
|
2021-07-12 10:06:49 +00:00
|
|
|
u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
|
2019-07-22 11:59:12 +00:00
|
|
|
{
|
|
|
|
return MMCSD_MODE_RAW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
|
|
|
__weak void rockchip_stimer_init(void)
|
|
|
|
{
|
2022-04-09 16:55:03 +00:00
|
|
|
#if defined(CONFIG_ROCKCHIP_STIMER_BASE)
|
2019-07-22 11:59:12 +00:00
|
|
|
/* If Timer already enabled, don't re-init it */
|
|
|
|
u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
|
|
|
|
|
|
|
|
if (reg & TIMER_EN)
|
|
|
|
return;
|
|
|
|
#ifndef CONFIG_ARM64
|
|
|
|
asm volatile("mcr p15, 0, %0, c14, c0, 0"
|
2022-04-13 09:47:22 +00:00
|
|
|
: : "r"(CONFIG_COUNTER_FREQUENCY));
|
2019-07-22 11:59:12 +00:00
|
|
|
#endif
|
|
|
|
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);
|
|
|
|
#endif
|
2022-04-09 16:55:03 +00:00
|
|
|
}
|
2019-07-22 11:59:12 +00:00
|
|
|
|
|
|
|
__weak int board_early_init_f(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
__weak int arch_cpu_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
board_early_init_f();
|
|
|
|
|
|
|
|
ret = spl_early_init();
|
|
|
|
if (ret) {
|
|
|
|
printf("spl_early_init() failed: %d\n", ret);
|
|
|
|
hang();
|
|
|
|
}
|
|
|
|
arch_cpu_init();
|
2022-04-09 16:55:03 +00:00
|
|
|
|
2019-11-15 16:48:55 +00:00
|
|
|
rockchip_stimer_init();
|
2022-04-09 16:55:03 +00:00
|
|
|
|
2019-11-15 16:48:55 +00:00
|
|
|
#ifdef CONFIG_SYS_ARCH_TIMER
|
|
|
|
/* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
|
|
|
|
timer_init();
|
|
|
|
#endif
|
2020-05-25 17:57:24 +00:00
|
|
|
#if !defined(CONFIG_TPL) || defined(CONFIG_SPL_RAM)
|
2019-07-22 11:59:12 +00:00
|
|
|
debug("\nspl:init dram\n");
|
2020-05-25 17:57:24 +00:00
|
|
|
ret = dram_init();
|
2019-07-22 11:59:12 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("DRAM init failed: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
2020-05-25 17:57:24 +00:00
|
|
|
gd->ram_top = gd->ram_base + get_effective_memsize();
|
|
|
|
gd->ram_top = board_get_usable_ram_top(gd->ram_size);
|
2019-07-22 11:59:12 +00:00
|
|
|
#endif
|
|
|
|
preloader_console_init();
|
|
|
|
}
|