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 void lowlevel_init(void)
88 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
90 #include <usb/dwc2_udc.h>
92 static struct dwc2_plat_otg_data rk3288_otg_data = {
98 int board_usb_init(int index, enum usb_init_type init)
102 bool matched = false;
103 const void *blob = gd->fdt_blob;
106 /* find the usb_otg node */
107 node = fdt_node_offset_by_compatible(blob, -1,
108 "rockchip,rk3288-usb");
111 mode = fdt_getprop(blob, node, "dr_mode", NULL);
112 if (mode && strcmp(mode, "otg") == 0) {
117 node = fdt_node_offset_by_compatible(blob, node,
118 "rockchip,rk3288-usb");
121 debug("Not found usb_otg device\n");
124 rk3288_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
126 node = fdtdec_lookup_phandle(blob, node, "phys");
128 debug("Not found usb phy device\n");
132 phy_node = fdt_parent_offset(blob, node);
134 debug("Not found usb phy device\n");
138 rk3288_otg_data.phy_of_node = phy_node;
139 grf_phy_offset = fdtdec_get_addr(blob, node, "reg");
141 /* find the grf node */
142 node = fdt_node_offset_by_compatible(blob, -1,
143 "rockchip,rk3288-grf");
145 debug("Not found grf device\n");
148 rk3288_otg_data.regs_phy = grf_phy_offset +
149 fdtdec_get_addr(blob, node, "reg");
151 return dwc2_udc_probe(&rk3288_otg_data);
154 int board_usb_cleanup(int index, enum usb_init_type init)
160 static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
163 static const struct {
170 { "cpll", CLK_CODEC },
171 { "gpll", CLK_GENERAL },
172 #ifdef CONFIG_ROCKCHIP_RK3036
181 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
183 printf("clk-uclass not found\n");
187 for (i = 0; i < ARRAY_SIZE(clks); i++) {
192 ret = clk_request(dev, &clk);
196 rate = clk_get_rate(&clk);
197 printf("%s: %lu\n", clks[i].name, rate);
206 clock, 2, 1, do_clock,
207 "display information about clocks",