1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2017 Rockchip Electronics Co., Ltd.
11 #include <asm/arch-rockchip/clock.h>
12 #include <asm/arch-rockchip/periph.h>
13 #include <asm/arch-rockchip/grf_rk3128.h>
14 #include <asm/arch-rockchip/boot_mode.h>
15 #include <power/regulator.h>
17 DECLARE_GLOBAL_DATA_PTR
;
19 __weak
int rk_board_late_init(void)
24 int board_late_init(void)
28 return rk_board_late_init();
35 ret
= regulators_enable_boot_on(false);
37 debug("%s: Cannot enable boot on regulator\n", __func__
);
44 int dram_init_banksize(void)
46 gd
->bd
->bi_dram
[0].start
= CONFIG_SYS_SDRAM_BASE
;
47 gd
->bd
->bi_dram
[0].size
= 0x8400000;
48 /* Reserve 0xe00000(14MB) for OPTEE with TA enabled, otherwise 2MB */
49 gd
->bd
->bi_dram
[1].start
= CONFIG_SYS_SDRAM_BASE
50 + gd
->bd
->bi_dram
[0].size
+ 0xe00000;
51 gd
->bd
->bi_dram
[1].size
= gd
->bd
->bi_dram
[0].start
52 + gd
->ram_size
- gd
->bd
->bi_dram
[1].start
;
57 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
58 void enable_caches(void)
60 /* Enable D-cache. I-cache is already enabled in start.S */
65 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
67 #include <usb/dwc2_udc.h>
69 static struct dwc2_plat_otg_data rk3128_otg_data
= {
75 int board_usb_init(int index
, enum usb_init_type init
)
80 const void *blob
= gd
->fdt_blob
;
82 /* find the usb_otg node */
83 node
= fdt_node_offset_by_compatible(blob
, -1,
84 "rockchip,rk3128-usb");
87 mode
= fdt_getprop(blob
, node
, "dr_mode", NULL
);
88 if (mode
&& strcmp(mode
, "otg") == 0) {
93 node
= fdt_node_offset_by_compatible(blob
, node
,
94 "rockchip,rk3128-usb");
97 debug("Not found usb_otg device\n");
100 rk3128_otg_data
.regs_otg
= fdtdec_get_addr(blob
, node
, "reg");
102 return dwc2_udc_probe(&rk3128_otg_data
);
105 int board_usb_cleanup(int index
, enum usb_init_type init
)
111 #if CONFIG_IS_ENABLED(FASTBOOT)
112 int fastboot_set_reboot_flag(void)
114 printf("Setting reboot to fastboot flag ...\n");
115 /* Set boot mode to fastboot */
116 writel(BOOT_FASTBOOT
, CONFIG_ROCKCHIP_BOOT_MODE_REG
);