1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2017 Rockchip Electronics Co., Ltd.
11 #include <asm/arch-rockchip/boot_mode.h>
12 #include <asm/arch-rockchip/clock.h>
13 #include <asm/arch-rockchip/grf_rk322x.h>
14 #include <asm/arch-rockchip/periph.h>
16 DECLARE_GLOBAL_DATA_PTR
;
18 __weak
int rk_board_late_init(void)
23 int board_late_init(void)
27 return rk_board_late_init();
32 #include <asm/arch-rockchip/grf_rk322x.h>
33 /* Enable early UART2 channel 1 on the RK322x */
34 #define GRF_BASE 0x11000000
35 static struct rk322x_grf
* const grf
= (void *)GRF_BASE
;
38 * The integrated macphy is enabled by default, disable it
39 * for saving power consuming.
41 rk_clrsetreg(&grf
->macphy_con
[0],
42 MACPHY_CFG_ENABLE_MASK
,
43 0 << MACPHY_CFG_ENABLE_SHIFT
);
48 int dram_init_banksize(void)
50 gd
->bd
->bi_dram
[0].start
= CONFIG_SYS_SDRAM_BASE
;
51 gd
->bd
->bi_dram
[0].size
= 0x8400000;
52 /* Reserve 0x200000 for OPTEE */
53 gd
->bd
->bi_dram
[1].start
= CONFIG_SYS_SDRAM_BASE
54 + gd
->bd
->bi_dram
[0].size
+ 0x200000;
55 gd
->bd
->bi_dram
[1].size
= gd
->bd
->bi_dram
[0].start
56 + gd
->ram_size
- gd
->bd
->bi_dram
[1].start
;
61 #ifndef CONFIG_SYS_DCACHE_OFF
62 void enable_caches(void)
64 /* Enable D-cache. I-cache is already enabled in start.S */
69 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
71 #include <usb/dwc2_udc.h>
73 static struct dwc2_plat_otg_data rk322x_otg_data
= {
79 int board_usb_init(int index
, enum usb_init_type init
)
84 const void *blob
= gd
->fdt_blob
;
86 /* find the usb_otg node */
87 node
= fdt_node_offset_by_compatible(blob
, -1,
88 "rockchip,rk3288-usb");
91 mode
= fdt_getprop(blob
, node
, "dr_mode", NULL
);
92 if (mode
&& strcmp(mode
, "otg") == 0) {
97 node
= fdt_node_offset_by_compatible(blob
, node
,
98 "rockchip,rk3288-usb");
101 debug("Not found usb_otg device\n");
104 rk322x_otg_data
.regs_otg
= fdtdec_get_addr(blob
, node
, "reg");
106 return dwc2_udc_probe(&rk322x_otg_data
);
109 int board_usb_cleanup(int index
, enum usb_init_type init
)
115 #if CONFIG_IS_ENABLED(FASTBOOT)
116 int fastboot_set_reboot_flag(void)
118 struct rk322x_grf
*grf
;
120 printf("Setting reboot to fastboot flag ...\n");
121 grf
= syscon_get_first_range(ROCKCHIP_SYSCON_GRF
);
122 /* Set boot mode to fastboot */
123 writel(BOOT_FASTBOOT
, &grf
->os_reg
[0]);