2 * (C) Copyright 2015 Rockchip Electronics Co., Ltd
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/clock.h>
13 #include <asm/arch/periph.h>
14 #include <asm/arch/grf_rk3036.h>
15 #include <asm/arch/boot_mode.h>
16 #include <asm/arch/sdram_rk3036.h>
18 #include <dm/pinctrl.h>
20 DECLARE_GLOBAL_DATA_PTR
;
22 #define GRF_BASE 0x20008000
24 static void setup_boot_mode(void)
26 struct rk3036_grf
*const grf
= (void *)GRF_BASE
;
27 int boot_mode
= readl(&grf
->os_reg
[4]);
29 debug("boot mode %x.\n", boot_mode
);
32 writel(BOOT_NORMAL
, &grf
->os_reg
[4]);
36 printf("enter fastboot!\n");
37 env_set("preboot", "setenv preboot; fastboot usb0");
40 printf("enter UMS!\n");
41 env_set("preboot", "setenv preboot; ums mmc 0");
46 __weak
int rk_board_late_init(void)
51 int board_late_init(void)
55 return rk_board_late_init();
63 #if !CONFIG_IS_ENABLED(RAM)
65 * When CONFIG_RAM is enabled, the dram_init() function is implemented
70 gd
->ram_size
= sdram_size();
76 #ifndef CONFIG_SYS_DCACHE_OFF
77 void enable_caches(void)
79 /* Enable D-cache. I-cache is already enabled in start.S */
84 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
86 #include <usb/dwc2_udc.h>
88 static struct dwc2_plat_otg_data rk3036_otg_data
= {
94 int board_usb_init(int index
, enum usb_init_type init
)
99 const void *blob
= gd
->fdt_blob
;
101 /* find the usb_otg node */
102 node
= fdt_node_offset_by_compatible(blob
, -1,
103 "rockchip,rk3288-usb");
106 mode
= fdt_getprop(blob
, node
, "dr_mode", NULL
);
107 if (mode
&& strcmp(mode
, "otg") == 0) {
112 node
= fdt_node_offset_by_compatible(blob
, node
,
113 "rockchip,rk3288-usb");
116 debug("Not found usb_otg device\n");
119 rk3036_otg_data
.regs_otg
= fdtdec_get_addr(blob
, node
, "reg");
121 return dwc2_udc_probe(&rk3036_otg_data
);
124 int board_usb_cleanup(int index
, enum usb_init_type init
)