1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2017 Rockchip Electronics Co., Ltd.
11 #include <asm/arch/clock.h>
12 #include <asm/arch/periph.h>
13 #include <asm/arch/grf_rk3128.h>
14 #include <asm/arch/boot_mode.h>
15 #include <asm/arch/timer.h>
16 #include <power/regulator.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 __weak int rk_board_late_init(void)
25 int board_late_init(void)
29 return rk_board_late_init();
36 rockchip_timer_init();
38 ret = regulators_enable_boot_on(false);
40 debug("%s: Cannot enable boot on regulator\n", __func__);
47 int dram_init_banksize(void)
49 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
50 gd->bd->bi_dram[0].size = 0x8400000;
51 /* Reserve 0xe00000(14MB) for OPTEE with TA enabled, otherwise 2MB */
52 gd->bd->bi_dram[1].start = CONFIG_SYS_SDRAM_BASE
53 + gd->bd->bi_dram[0].size + 0xe00000;
54 gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start
55 + gd->ram_size - gd->bd->bi_dram[1].start;
60 #ifndef CONFIG_SYS_DCACHE_OFF
61 void enable_caches(void)
63 /* Enable D-cache. I-cache is already enabled in start.S */
68 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
70 #include <usb/dwc2_udc.h>
72 static struct dwc2_plat_otg_data rk3128_otg_data = {
78 int board_usb_init(int index, enum usb_init_type init)
83 const void *blob = gd->fdt_blob;
85 /* find the usb_otg node */
86 node = fdt_node_offset_by_compatible(blob, -1,
87 "rockchip,rk3128-usb");
90 mode = fdt_getprop(blob, node, "dr_mode", NULL);
91 if (mode && strcmp(mode, "otg") == 0) {
96 node = fdt_node_offset_by_compatible(blob, node,
97 "rockchip,rk3128-usb");
100 debug("Not found usb_otg device\n");
103 rk3128_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
105 return dwc2_udc_probe(&rk3128_otg_data);
108 int board_usb_cleanup(int index, enum usb_init_type init)
114 #if CONFIG_IS_ENABLED(FASTBOOT)
115 int fastboot_set_reboot_flag(void)
117 struct rk3128_grf *grf;
119 printf("Setting reboot to fastboot flag ...\n");
120 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
121 /* Set boot mode to fastboot */
122 writel(BOOT_FASTBOOT, &grf->os_reg[0]);