1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2015 Google, Inc
8 #include <debug_uart.h>
18 #include <asm/arch-rockchip/bootrom.h>
19 #include <asm/arch-rockchip/clock.h>
20 #include <asm/arch-rockchip/grf_rk3188.h>
21 #include <asm/arch-rockchip/hardware.h>
22 #include <asm/arch-rockchip/periph.h>
23 #include <asm/arch-rockchip/pmu_rk3188.h>
24 #include <asm/arch-rockchip/sdram.h>
28 #include <power/regulator.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 u32 spl_boot_device(void)
34 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
35 const void *blob = gd->fdt_blob;
41 bootdev = fdtdec_get_config_string(blob, "u-boot,boot0");
42 debug("Boot device %s\n", bootdev);
46 node = fdt_path_offset(blob, bootdev);
48 debug("node=%d\n", node);
51 ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
53 debug("device at node %s/%d not found: %d\n", bootdev, node,
57 debug("Found device %s\n", dev->name);
58 switch (device_get_uclass_id(dev)) {
59 case UCLASS_SPI_FLASH:
60 return BOOT_DEVICE_SPI;
62 return BOOT_DEVICE_MMC1;
64 debug("Booting from device uclass '%s' not supported\n",
65 dev_get_uclass_name(dev));
70 return BOOT_DEVICE_MMC1;
73 static int setup_arm_clock(void)
79 ret = rockchip_get_clk(&dev);
84 ret = clk_request(dev, &clk);
88 ret = clk_set_rate(&clk, 600000000);
94 void board_init_f(ulong dummy)
99 #ifdef CONFIG_DEBUG_UART
101 * Debug UART can be used from here if required:
106 * printascii("string");
109 printascii("U-Boot SPL board init");
112 #ifdef CONFIG_ROCKCHIP_USB_UART
113 rk_clrsetreg(&grf->uoc0_con[0],
114 SIDDQ_MASK | UOC_DISABLE_MASK | COMMON_ON_N_MASK,
115 1 << SIDDQ_SHIFT | 1 << UOC_DISABLE_SHIFT |
116 1 << COMMON_ON_N_SHIFT);
117 rk_clrsetreg(&grf->uoc0_con[2],
118 SOFT_CON_SEL_MASK, 1 << SOFT_CON_SEL_SHIFT);
119 rk_clrsetreg(&grf->uoc0_con[3],
120 OPMODE_MASK | XCVRSELECT_MASK |
121 TERMSEL_FULLSPEED_MASK | SUSPENDN_MASK,
122 OPMODE_NODRIVING << OPMODE_SHIFT |
123 XCVRSELECT_FSTRANSC << XCVRSELECT_SHIFT |
124 1 << TERMSEL_FULLSPEED_SHIFT |
125 1 << SUSPENDN_SHIFT);
126 rk_clrsetreg(&grf->uoc0_con[0],
127 BYPASSSEL_MASK | BYPASSDMEN_MASK,
128 1 << BYPASSSEL_SHIFT | 1 << BYPASSDMEN_SHIFT);
131 ret = spl_early_init();
133 debug("spl_early_init() failed: %d\n", ret);
137 ret = rockchip_get_clk(&dev);
139 debug("CLK init failed: %d\n", ret);
143 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
145 debug("DRAM init failed: %d\n", ret);
150 #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
151 back_to_bootrom(BROM_BOOT_NEXTSTAGE);
155 static int setup_led(void)
157 #ifdef CONFIG_SPL_LED
162 led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
165 ret = led_get_by_label(led_name, &dev);
167 debug("%s: get=%d\n", __func__, ret);
170 ret = led_set_on(dev, 1);
178 void spl_board_init(void)
184 debug("LED ret=%d\n", ret);
188 preloader_console_init();
189 #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
190 back_to_bootrom(BROM_BOOT_NEXTSTAGE);