Merge tag 'efi-2019-07-rc2' of git://git.denx.de/u-boot-efi
[oweals/u-boot.git] / arch / arm / mach-rockchip / rk322x-board-spl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2017 Rockchip Electronics Co., Ltd
4  */
5
6 #include <common.h>
7 #include <debug_uart.h>
8 #include <dm.h>
9 #include <ram.h>
10 #include <spl.h>
11 #include <asm/io.h>
12 #include <asm/arch-rockchip/bootrom.h>
13 #include <asm/arch-rockchip/hardware.h>
14 #include <asm/arch-rockchip/timer.h>
15
16 u32 spl_boot_device(void)
17 {
18         return BOOT_DEVICE_MMC1;
19 }
20
21 #define SGRF_DDR_CON0 0x10150000
22 void board_init_f(ulong dummy)
23 {
24         struct udevice *dev;
25         int ret;
26
27 #ifdef CONFIG_DEBUG_UART
28         /*
29          * Debug UART can be used from here if required:
30          *
31          * debug_uart_init();
32          * printch('a');
33          * printhex8(0x1234);
34          * printascii("string");
35          */
36         debug_uart_init();
37         printascii("SPL Init");
38 #endif
39         ret = spl_early_init();
40         if (ret) {
41                 debug("spl_early_init() failed: %d\n", ret);
42                 hang();
43         }
44
45         rockchip_timer_init();
46         printf("timer init done\n");
47         ret = uclass_get_device(UCLASS_RAM, 0, &dev);
48         if (ret) {
49                 printf("DRAM init failed: %d\n", ret);
50                 return;
51         }
52
53         /* Disable the ddr secure region setting to make it non-secure */
54         rk_clrreg(SGRF_DDR_CON0, 0x4000);
55 #if defined(CONFIG_SPL_ROCKCHIP_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
56         back_to_bootrom(BROM_BOOT_NEXTSTAGE);
57 #endif
58 }