blob: 7a0b10a27d6f6e4eee5c2c722db1796d6d8a7602 [file] [log] [blame]
Kever Yang0a2a5e12019-03-29 09:09:01 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4 */
5#include <common.h>
6#include <asm/io.h>
7#include <asm/arch-rockchip/grf_rk3188.h>
8#include <asm/arch-rockchip/hardware.h>
9
Kever Yang8fd60192019-07-22 19:59:14 +080010#define GRF_BASE 0x20008000
11
Kever Yang0a2a5e12019-03-29 09:09:01 +080012#ifdef CONFIG_DEBUG_UART_BOARD_INIT
13void board_debug_uart_init(void)
14{
15 /* Enable early UART on the RK3188 */
Kever Yang0a2a5e12019-03-29 09:09:01 +080016 struct rk3188_grf * const grf = (void *)GRF_BASE;
17 enum {
18 GPIO1B1_SHIFT = 2,
19 GPIO1B1_MASK = 3,
20 GPIO1B1_GPIO = 0,
21 GPIO1B1_UART2_SOUT,
22 GPIO1B1_JTAG_TDO,
23
24 GPIO1B0_SHIFT = 0,
25 GPIO1B0_MASK = 3,
26 GPIO1B0_GPIO = 0,
27 GPIO1B0_UART2_SIN,
28 GPIO1B0_JTAG_TDI,
29 };
30
31 rk_clrsetreg(&grf->gpio1b_iomux,
32 GPIO1B1_MASK << GPIO1B1_SHIFT |
33 GPIO1B0_MASK << GPIO1B0_SHIFT,
34 GPIO1B1_UART2_SOUT << GPIO1B1_SHIFT |
35 GPIO1B0_UART2_SIN << GPIO1B0_SHIFT);
36}
37#endif
Kever Yang8fd60192019-07-22 19:59:14 +080038
39int arch_cpu_init(void)
40{
41#ifdef CONFIG_ROCKCHIP_USB_UART
42 struct rk3188_grf * const grf = (void *)GRF_BASE;
43
44 rk_clrsetreg(&grf->uoc0_con[0],
45 SIDDQ_MASK | UOC_DISABLE_MASK | COMMON_ON_N_MASK,
46 1 << SIDDQ_SHIFT | 1 << UOC_DISABLE_SHIFT |
47 1 << COMMON_ON_N_SHIFT);
48 rk_clrsetreg(&grf->uoc0_con[2],
49 SOFT_CON_SEL_MASK, 1 << SOFT_CON_SEL_SHIFT);
50 rk_clrsetreg(&grf->uoc0_con[3],
51 OPMODE_MASK | XCVRSELECT_MASK |
52 TERMSEL_FULLSPEED_MASK | SUSPENDN_MASK,
53 OPMODE_NODRIVING << OPMODE_SHIFT |
54 XCVRSELECT_FSTRANSC << XCVRSELECT_SHIFT |
55 1 << TERMSEL_FULLSPEED_SHIFT |
56 1 << SUSPENDN_SHIFT);
57 rk_clrsetreg(&grf->uoc0_con[0],
58 BYPASSSEL_MASK | BYPASSDMEN_MASK,
59 1 << BYPASSSEL_SHIFT | 1 << BYPASSDMEN_SHIFT);
60#endif
61 return 0;
62}
Kever Yang96bf25a2019-07-22 19:59:16 +080063
64#ifdef CONFIG_SPL_BUILD
65static int setup_led(void)
66{
67#ifdef CONFIG_SPL_LED
68 struct udevice *dev;
69 char *led_name;
70 int ret;
71
72 led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
73 if (!led_name)
74 return 0;
75 ret = led_get_by_label(led_name, &dev);
76 if (ret) {
77 debug("%s: get=%d\n", __func__, ret);
78 return ret;
79 }
80 ret = led_set_on(dev, 1);
81 if (ret)
82 return ret;
83#endif
84
85 return 0;
86}
87
88void spl_board_init(void)
89{
90 int ret;
91
92 ret = setup_led();
93 if (ret) {
94 debug("LED ret=%d\n", ret);
95 hang();
96 }
97}
98#endif