2 * (C) Copyright 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/clock.h>
13 #include <asm/arch/periph.h>
15 #include <dm/pinctrl.h>
17 DECLARE_GLOBAL_DATA_PTR;
21 #ifdef CONFIG_ROCKCHIP_SPL_BACK_TO_BROM
22 struct udevice *pinctrl;
26 * We need to implement sdcard iomux here for the further
27 * initlization, otherwise, it'll hit sdcard command sending
30 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
32 debug("%s: Cannot find pinctrl device\n", __func__);
35 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
37 debug("%s: Failed to set up SD card\n", __func__);
43 printf("board_init: Error %d\n", ret);
45 /* No way to report error here */
60 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
62 debug("DRAM init failed: %d\n", ret);
65 ret = ram_get_info(dev, &ram);
67 debug("Cannot get DRAM size: %d\n", ret);
70 debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
71 gd->ram_size = ram.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 rk3288_otg_data = {
94 int board_usb_init(int index, enum usb_init_type init)
99 const void *blob = gd->fdt_blob;
102 /* find the usb_otg node */
103 node = fdt_node_offset_by_compatible(blob, -1,
104 "rockchip,rk3288-usb");
107 mode = fdt_getprop(blob, node, "dr_mode", NULL);
108 if (mode && strcmp(mode, "otg") == 0) {
113 node = fdt_node_offset_by_compatible(blob, node,
114 "rockchip,rk3288-usb");
117 debug("Not found usb_otg device\n");
120 rk3288_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
122 node = fdtdec_lookup_phandle(blob, node, "phys");
124 debug("Not found usb phy device\n");
128 phy_node = fdt_parent_offset(blob, node);
130 debug("Not found usb phy device\n");
134 rk3288_otg_data.phy_of_node = phy_node;
135 grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
137 /* find the grf node */
138 node = fdt_node_offset_by_compatible(blob, -1,
139 "rockchip,rk3288-grf");
141 debug("Not found grf device\n");
144 rk3288_otg_data.regs_phy = grf_phy_offset +
145 fdtdec_get_addr(blob, node, "reg");
147 return dwc2_udc_probe(&rk3288_otg_data);
150 int board_usb_cleanup(int index, enum usb_init_type init)
156 static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
159 static const struct {
166 { "cpll", CLK_CODEC },
167 { "gpll", CLK_GENERAL },
168 #ifdef CONFIG_ROCKCHIP_RK3036
177 ret = rockchip_get_clk(&dev);
179 printf("clk-uclass not found\n");
183 for (i = 0; i < ARRAY_SIZE(clks); i++) {
188 ret = clk_request(dev, &clk);
192 rate = clk_get_rate(&clk);
193 printf("%s: %lu\n", clks[i].name, rate);
202 clock, 2, 1, do_clock,
203 "display information about clocks",