2 * (C) Copyright 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/clock.h>
14 #include <asm/arch/periph.h>
15 #include <asm/arch/pmu_rk3288.h>
16 #include <asm/arch/boot_mode.h>
18 #include <dm/pinctrl.h>
20 DECLARE_GLOBAL_DATA_PTR;
22 #define PMU_BASE 0xff730000
24 static void setup_boot_mode(void)
26 struct rk3288_pmu *const pmu = (void *)PMU_BASE;
27 int boot_mode = readl(&pmu->sys_reg[0]);
29 debug("boot mode %x.\n", boot_mode);
32 writel(BOOT_NORMAL, &pmu->sys_reg[0]);
36 printf("enter fastboot!\n");
37 setenv("preboot", "setenv preboot; fastboot usb0");
40 printf("enter UMS!\n");
41 setenv("preboot", "setenv preboot; if mmc dev 0;"
42 "then ums mmc 0; else ums mmc 1;fi");
47 __weak int rk_board_late_init(void)
52 int board_late_init(void)
56 return rk_board_late_init();
61 #ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
62 struct udevice *pinctrl;
66 * We need to implement sdcard iomux here for the further
67 * initlization, otherwise, it'll hit sdcard command sending
70 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
72 debug("%s: Cannot find pinctrl device\n", __func__);
75 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
77 debug("%s: Failed to set up SD card\n", __func__);
83 printf("board_init: Error %d\n", ret);
85 /* No way to report error here */
100 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
102 debug("DRAM init failed: %d\n", ret);
105 ret = ram_get_info(dev, &ram);
107 debug("Cannot get DRAM size: %d\n", ret);
110 debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
111 gd->ram_size = ram.size;
116 #ifndef CONFIG_SYS_DCACHE_OFF
117 void enable_caches(void)
119 /* Enable D-cache. I-cache is already enabled in start.S */
124 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
126 #include <usb/dwc2_udc.h>
128 static struct dwc2_plat_otg_data rk3288_otg_data = {
134 int board_usb_init(int index, enum usb_init_type init)
138 bool matched = false;
139 const void *blob = gd->fdt_blob;
142 /* find the usb_otg node */
143 node = fdt_node_offset_by_compatible(blob, -1,
144 "rockchip,rk3288-usb");
147 mode = fdt_getprop(blob, node, "dr_mode", NULL);
148 if (mode && strcmp(mode, "otg") == 0) {
153 node = fdt_node_offset_by_compatible(blob, node,
154 "rockchip,rk3288-usb");
157 debug("Not found usb_otg device\n");
160 rk3288_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
162 node = fdtdec_lookup_phandle(blob, node, "phys");
164 debug("Not found usb phy device\n");
168 phy_node = fdt_parent_offset(blob, node);
170 debug("Not found usb phy device\n");
174 rk3288_otg_data.phy_of_node = phy_node;
175 grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
177 /* find the grf node */
178 node = fdt_node_offset_by_compatible(blob, -1,
179 "rockchip,rk3288-grf");
181 debug("Not found grf device\n");
184 rk3288_otg_data.regs_phy = grf_phy_offset +
185 fdtdec_get_addr(blob, node, "reg");
187 return dwc2_udc_probe(&rk3288_otg_data);
190 int board_usb_cleanup(int index, enum usb_init_type init)
196 static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
199 static const struct {
206 { "cpll", CLK_CODEC },
207 { "gpll", CLK_GENERAL },
208 #ifdef CONFIG_ROCKCHIP_RK3036
217 ret = rockchip_get_clk(&dev);
219 printf("clk-uclass not found\n");
223 for (i = 0; i < ARRAY_SIZE(clks); i++) {
228 ret = clk_request(dev, &clk);
232 rate = clk_get_rate(&clk);
233 printf("%s: %lu\n", clks[i].name, rate);
242 clock, 2, 1, do_clock,
243 "display information about clocks",