1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4 */
5
6 #include <common.h>
7 #include <init.h>
8 #include <asm/global_data.h>
9 #include <asm/io.h>
10 #include <asm/arch-rockchip/grf_rk3036.h>
11 #include <asm/arch-rockchip/hardware.h>
12 #include <asm/arch-rockchip/sdram_rk3036.h>
13
14 DECLARE_GLOBAL_DATA_PTR;
15
16 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
board_debug_uart_init(void)17 void board_debug_uart_init(void)
18 {
19 #define GRF_BASE 0x20008000
20 struct rk3036_grf * const grf = (void *)GRF_BASE;
21 enum {
22 GPIO1C3_SHIFT = 6,
23 GPIO1C3_MASK = 3 << GPIO1C3_SHIFT,
24 GPIO1C3_GPIO = 0,
25 GPIO1C3_MMC0_D1,
26 GPIO1C3_UART2_SOUT,
27
28 GPIO1C2_SHIFT = 4,
29 GPIO1C2_MASK = 3 << GPIO1C2_SHIFT,
30 GPIO1C2_GPIO = 0,
31 GPIO1C2_MMC0_D0,
32 GPIO1C2_UART2_SIN,
33 };
34 /*
35 * NOTE: sd card and debug uart use same iomux in rk3036,
36 * so if you enable uart,
37 * you can not boot from sdcard
38 */
39 rk_clrsetreg(&grf->gpio1c_iomux,
40 GPIO1C3_MASK << GPIO1C3_SHIFT |
41 GPIO1C2_MASK << GPIO1C2_SHIFT,
42 GPIO1C3_UART2_SOUT << GPIO1C3_SHIFT |
43 GPIO1C2_UART2_SIN << GPIO1C2_SHIFT);
44 }
45 #endif
46
47 #if !CONFIG_IS_ENABLED(RAM)
48 /*
49 * When CONFIG_RAM is enabled, the dram_init() function is implemented
50 * in sdram.c.
51 */
dram_init(void)52 int dram_init(void)
53 {
54 gd->ram_size = sdram_size();
55
56 return 0;
57 }
58 #endif
59