2 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <debug_uart.h>
17 #include <asm/arch/clock.h>
18 #include <asm/arch/hardware.h>
19 #include <asm/arch/periph.h>
20 #include <asm/arch/sdram.h>
21 #include <asm/arch/timer.h>
22 #include <dm/pinctrl.h>
26 #include <power/regulator.h>
28 DECLARE_GLOBAL_DATA_PTR;
30 u32 spl_boot_device(void)
32 return BOOT_DEVICE_MMC1;
35 u32 spl_boot_mode(const u32 boot_device)
37 return MMCSD_MODE_RAW;
40 #define TIMER_CHN10_BASE 0xff8680a0
41 #define TIMER_END_COUNT_L 0x00
42 #define TIMER_END_COUNT_H 0x04
43 #define TIMER_INIT_COUNT_L 0x10
44 #define TIMER_INIT_COUNT_H 0x14
45 #define TIMER_CONTROL_REG 0x1c
48 #define TIMER_FMODE (0 << 1)
49 #define TIMER_RMODE (1 << 1)
51 void secure_timer_init(void)
53 writel(0xffffffff, TIMER_CHN10_BASE + TIMER_END_COUNT_L);
54 writel(0xffffffff, TIMER_CHN10_BASE + TIMER_END_COUNT_H);
55 writel(0, TIMER_CHN10_BASE + TIMER_INIT_COUNT_L);
56 writel(0, TIMER_CHN10_BASE + TIMER_INIT_COUNT_H);
57 writel(TIMER_EN | TIMER_FMODE, TIMER_CHN10_BASE + TIMER_CONTROL_REG);
60 #define GRF_EMMCCORE_CON11 0xff77f02c
61 void board_init_f(ulong dummy)
63 struct udevice *pinctrl;
67 /* Example code showing how to enable the debug UART on RK3288 */
68 #include <asm/arch/grf_rk3399.h>
69 /* Enable early UART2 channel C on the RK3399 */
70 #define GRF_BASE 0xff770000
71 struct rk3399_grf_regs * const grf = (void *)GRF_BASE;
73 rk_clrsetreg(&grf->gpio4c_iomux,
75 GRF_UART2DGBC_SIN << GRF_GPIO4C3_SEL_SHIFT);
76 rk_clrsetreg(&grf->gpio4c_iomux,
78 GRF_UART2DBGC_SOUT << GRF_GPIO4C4_SEL_SHIFT);
79 /* Set channel C as UART2 input */
80 rk_clrsetreg(&grf->soc_con7,
81 GRF_UART_DBG_SEL_MASK,
82 GRF_UART_DBG_SEL_C << GRF_UART_DBG_SEL_SHIFT);
86 * Debug UART can be used from here if required:
91 * printascii("string");
94 printascii("U-Boot SPL board init");
96 /* Emmc clock generator: disable the clock multipilier */
97 rk_clrreg(GRF_EMMCCORE_CON11, 0x0ff);
101 debug("spl_init() failed: %d\n", ret);
107 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
109 debug("Pinctrl init failed: %d\n", ret);
113 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
115 debug("DRAM init failed: %d\n", ret);
120 void spl_board_init(void)
122 struct udevice *pinctrl;
125 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
127 debug("%s: Cannot find pinctrl device\n", __func__);
131 /* Enable debug UART */
132 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG);
134 debug("%s: Failed to set up console UART\n", __func__);
138 preloader_console_init();
139 #ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
144 printf("spl_board_init: Error %d\n", ret);
146 /* No way to report error here */
150 #ifdef CONFIG_SPL_LOAD_FIT
151 int 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);