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 setenv("preboot", "setenv preboot; fastboot usb0");
40 printf("enter UMS!\n");
41 setenv("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();
65 gd->ram_size = sdram_size();
70 #ifndef CONFIG_SYS_DCACHE_OFF
71 void enable_caches(void)
73 /* Enable D-cache. I-cache is already enabled in start.S */
78 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
80 #include <usb/dwc2_udc.h>
82 static struct dwc2_plat_otg_data rk3036_otg_data = {
88 int board_usb_init(int index, enum usb_init_type init)
93 const void *blob = gd->fdt_blob;
95 /* find the usb_otg node */
96 node = fdt_node_offset_by_compatible(blob, -1,
97 "rockchip,rk3288-usb");
100 mode = fdt_getprop(blob, node, "dr_mode", NULL);
101 if (mode && strcmp(mode, "otg") == 0) {
106 node = fdt_node_offset_by_compatible(blob, node,
107 "rockchip,rk3288-usb");
110 debug("Not found usb_otg device\n");
113 rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
115 return dwc2_udc_probe(&rk3036_otg_data);
118 int board_usb_cleanup(int index, enum usb_init_type init)