1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
7 #include <debug_uart.h>
14 #include <asm/arch-rockchip/bootrom.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 int board_return_to_bootrom(struct spl_image_info *spl_image,
20 struct spl_boot_device *bootdev)
22 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
27 __weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
30 const char *board_spl_was_booted_from(void)
32 u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
33 const char *bootdevice_ofpath = NULL;
35 if (bootdevice_brom_id < ARRAY_SIZE(boot_devices))
36 bootdevice_ofpath = boot_devices[bootdevice_brom_id];
38 if (bootdevice_ofpath)
39 debug("%s: brom_bootdevice_id %x maps to '%s'\n",
40 __func__, bootdevice_brom_id, bootdevice_ofpath);
42 debug("%s: failed to resolve brom_bootdevice_id %x\n",
43 __func__, bootdevice_brom_id);
45 return bootdevice_ofpath;
48 u32 spl_boot_device(void)
50 u32 boot_device = BOOT_DEVICE_MMC1;
52 #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
53 defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
54 defined(CONFIG_TARGET_CHROMEBOOK_MINNIE)
55 return BOOT_DEVICE_SPI;
57 if (CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM))
58 return BOOT_DEVICE_BOOTROM;
63 u32 spl_mmc_boot_mode(const u32 boot_device)
65 return MMCSD_MODE_RAW;
68 #if !defined(CONFIG_ROCKCHIP_RK3188)
69 #define TIMER_LOAD_COUNT_L 0x00
70 #define TIMER_LOAD_COUNT_H 0x04
71 #define TIMER_CONTROL_REG 0x10
73 #define TIMER_FMODE BIT(0)
74 #define TIMER_RMODE BIT(1)
76 __weak void rockchip_stimer_init(void)
78 /* If Timer already enabled, don't re-init it */
79 u32 reg = readl(CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
84 asm volatile("mcr p15, 0, %0, c14, c0, 0"
85 : : "r"(COUNTER_FREQUENCY));
87 writel(0, CONFIG_ROCKCHIP_STIMER_BASE + TIMER_CONTROL_REG);
88 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE);
89 writel(0xffffffff, CONFIG_ROCKCHIP_STIMER_BASE + 4);
90 writel(TIMER_EN | TIMER_FMODE, CONFIG_ROCKCHIP_STIMER_BASE +
95 __weak int board_early_init_f(void)
100 __weak int arch_cpu_init(void)
105 void board_init_f(ulong dummy)
108 #if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
112 #ifdef CONFIG_DEBUG_UART
114 * Debug UART can be used from here if required:
119 * printascii("string");
122 debug("\nspl:debug uart enabled in %s\n", __func__);
125 board_early_init_f();
127 ret = spl_early_init();
129 printf("spl_early_init() failed: %d\n", ret);
133 #if !defined(CONFIG_ROCKCHIP_RK3188)
134 rockchip_stimer_init();
136 #ifdef CONFIG_SYS_ARCH_TIMER
137 /* Init ARM arch timer in arch/arm/cpu/armv7/arch_timer.c */
140 #if !defined(CONFIG_TPL) || defined(CONFIG_SPL_OS_BOOT)
141 debug("\nspl:init dram\n");
142 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
144 printf("DRAM init failed: %d\n", ret);
148 preloader_console_init();
151 #ifdef CONFIG_SPL_LOAD_FIT
152 int __weak board_fit_config_name_match(const char *name)
154 /* Just empty function now - can't decide what to choose */
155 debug("%s: %s\n", __func__, name);