1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
7 #include <debug_uart.h>
13 #include <asm/arch-rockchip/bootrom.h>
16 DECLARE_GLOBAL_DATA_PTR;
18 int board_return_to_bootrom(struct spl_image_info *spl_image,
19 struct spl_boot_device *bootdev)
21 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
26 __weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
29 const char *board_spl_was_booted_from(void)
31 u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
32 const char *bootdevice_ofpath = NULL;
34 if (bootdevice_brom_id < ARRAY_SIZE(boot_devices))
35 bootdevice_ofpath = boot_devices[bootdevice_brom_id];
37 if (bootdevice_ofpath)
38 debug("%s: brom_bootdevice_id %x maps to '%s'\n",
39 __func__, bootdevice_brom_id, bootdevice_ofpath);
41 debug("%s: failed to resolve brom_bootdevice_id %x\n",
42 __func__, bootdevice_brom_id);
44 return bootdevice_ofpath;
47 u32 spl_boot_device(void)
49 u32 boot_device = BOOT_DEVICE_MMC1;
51 #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
52 defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
53 defined(CONFIG_TARGET_CHROMEBOOK_MINNIE)
54 return BOOT_DEVICE_SPI;
56 if (CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM))
57 return BOOT_DEVICE_BOOTROM;
62 u32 spl_mmc_boot_mode(const u32 boot_device)
64 return MMCSD_MODE_RAW;
67 #if !defined(CONFIG_ROCKCHIP_RK3188)
68 #define TIMER_LOAD_COUNT_L 0x00
69 #define TIMER_LOAD_COUNT_H 0x04
70 #define TIMER_CONTROL_REG 0x10
72 #define TIMER_FMODE BIT(0)
73 #define TIMER_RMODE BIT(1)
75 __weak void rockchip_stimer_init(void)
77 /* If Timer already enabled, don't re-init it */
78 u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
83 asm volatile("mcr p15, 0, %0, c14, c0, 0"
84 : : "r"(COUNTER_FREQUENCY));
86 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
87 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
88 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
89 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
94 __weak int board_early_init_f(void)
99 __weak int arch_cpu_init(void)
104 void board_init_f(ulong dummy)
107 #if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
111 #ifdef CONFIG_DEBUG_UART
113 * Debug UART can be used from here if required:
118 * printascii("string");
121 debug("\nspl:debug uart enabled in %s\n", __func__);
124 board_early_init_f();
126 ret = spl_early_init();
128 printf("spl_early_init() failed: %d\n", ret);
132 #if !defined(CONFIG_ROCKCHIP_RK3188)
133 rockchip_stimer_init();
135 #ifdef CONFIG_SYS_ARCH_TIMER
136 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
139 #if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
140 debug("\nspl:init dram\n");
141 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
143 printf("DRAM init failed: %d\n", ret);
147 preloader_console_init();
150 #ifdef CONFIG_SPL_LOAD_FIT
151 int __weak board_fit_config_name_match(const char *name)
153 /* Just empty function now - can't decide what to choose */
154 debug("%s: %s\n", __func__, name);