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