2 * (C) Copyright 2015 Rockchip Electronics Co., Ltd
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/uart.h>
11 #include <asm/arch-rockchip/grf_rk3036.h>
12 #include <asm/arch/sdram_rk3036.h>
15 DECLARE_GLOBAL_DATA_PTR;
17 #define GRF_BASE 0x20008000
19 void get_ddr_config(struct rk3036_ddr_config *config)
21 /* K4B4G1646Q config */
35 #define FASTBOOT_KEY_GPIO 93
37 int fastboot_key_pressed(void)
39 gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key");
40 gpio_direction_input(FASTBOOT_KEY_GPIO);
41 return !gpio_get_value(FASTBOOT_KEY_GPIO);
44 #define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309
46 int board_late_init(void)
48 struct rk3036_grf * const grf = (void *)GRF_BASE;
49 int boot_mode = readl(&grf->os_reg[4]);
52 writel(0, &grf->os_reg[4]);
54 if (boot_mode == ROCKCHIP_BOOT_MODE_FASTBOOT ||
55 fastboot_key_pressed()) {
56 printf("enter fastboot!\n");
57 setenv("preboot", "setenv preboot; fastboot usb0");
70 gd->ram_size = sdram_size();
75 #ifndef CONFIG_SYS_DCACHE_OFF
76 void enable_caches(void)
78 /* Enable D-cache. I-cache is already enabled in start.S */
83 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
85 #include <usb/dwc2_udc.h>
87 static struct dwc2_plat_otg_data rk3036_otg_data = {
93 int board_usb_init(int index, enum usb_init_type init)
98 const void *blob = gd->fdt_blob;
100 /* find the usb_otg node */
101 node = fdt_node_offset_by_compatible(blob, -1,
102 "rockchip,rk3288-usb");
105 mode = fdt_getprop(blob, node, "dr_mode", NULL);
106 if (mode && strcmp(mode, "otg") == 0) {
111 node = fdt_node_offset_by_compatible(blob, node,
112 "rockchip,rk3288-usb");
115 debug("Not found usb_otg device\n");
118 rk3036_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
120 return dwc2_udc_probe(&rk3036_otg_data);
123 int board_usb_cleanup(int index, enum usb_init_type init)