blob: a430bb43adc00a0acf18a1629604938dc91f95b0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jagan Teki387fd4b2017-09-27 23:03:12 +05302/*
3 * Copyright (C) 2017 Amarula Solutions
Jagan Teki387fd4b2017-09-27 23:03:12 +05304 */
5
6#include <common.h>
7#include <debug_uart.h>
8#include <dm.h>
9#include <ram.h>
10#include <spl.h>
11#include <version.h>
12#include <asm/io.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080013#include <asm/arch-rockchip/bootrom.h>
14#include <asm/arch-rockchip/clock.h>
15#include <asm/arch-rockchip/grf_rk3288.h>
16#include <asm/arch-rockchip/periph.h>
17#include <asm/arch-rockchip/pmu_rk3288.h>
18#include <asm/arch-rockchip/sys_proto.h>
19#include <asm/arch-rockchip/timer.h>
Jagan Teki387fd4b2017-09-27 23:03:12 +053020
Jagan Teki387fd4b2017-09-27 23:03:12 +053021#define GRF_BASE 0xff770000
22void board_init_f(ulong dummy)
23{
24 struct udevice *dev;
25 int ret;
26
27 /* Example code showing how to enable the debug UART on RK3288 */
28 /* Enable early UART on the RK3288 */
29 struct rk3288_grf * const grf = (void *)GRF_BASE;
30
31 rk_clrsetreg(&grf->gpio7ch_iomux, GPIO7C7_MASK << GPIO7C7_SHIFT |
32 GPIO7C6_MASK << GPIO7C6_SHIFT,
33 GPIO7C7_UART2DBG_SOUT << GPIO7C7_SHIFT |
34 GPIO7C6_UART2DBG_SIN << GPIO7C6_SHIFT);
35 /*
36 * Debug UART can be used from here if required:
37 *
38 * debug_uart_init();
39 * printch('a');
40 * printhex8(0x1234);
41 * printascii("string");
42 */
43 debug_uart_init();
44
45 ret = spl_early_init();
46 if (ret) {
47 debug("spl_early_init() failed: %d\n", ret);
48 hang();
49 }
50
51 rockchip_timer_init();
52 configure_l2ctlr();
53
54 ret = rockchip_get_clk(&dev);
55 if (ret) {
56 debug("CLK init failed: %d\n", ret);
57 return;
58 }
59
60 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
61 if (ret) {
62 debug("DRAM init failed: %d\n", ret);
63 return;
64 }
65}
66
67void board_return_to_bootrom(void)
68{
Philipp Tomsich7234c732017-10-10 16:21:16 +020069 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
Jagan Teki387fd4b2017-09-27 23:03:12 +053070}
71
72u32 spl_boot_device(void)
73{
74 return BOOT_DEVICE_BOOTROM;
75}
76
77void spl_board_init(void)
78{
79 puts("\nU-Boot TPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
80 U_BOOT_TIME ")\n");
81}