]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/rockchip/evb_rk3328/evb-rk3328.c
rockchip: evb-rk3328: enable boot on regulator
[people/ms/u-boot.git] / board / rockchip / evb_rk3328 / evb-rk3328.c
1 /*
2 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7 #include <common.h>
8 #include <asm/armv8/mmu.h>
9 #include <dwc3-uboot.h>
10 #include <power/regulator.h>
11 #include <usb.h>
12
13 DECLARE_GLOBAL_DATA_PTR;
14
15 int board_init(void)
16 {
17 int ret;
18
19 ret = regulators_enable_boot_on(false);
20 if (ret)
21 debug("%s: Cannot enable boot on regulator\n", __func__);
22
23 return ret;
24 }
25
26 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
27 #include <usb.h>
28 #include <usb/dwc2_udc.h>
29
30 static struct dwc2_plat_otg_data rk3328_otg_data = {
31 .rx_fifo_sz = 512,
32 .np_tx_fifo_sz = 16,
33 .tx_fifo_sz = 128,
34 };
35
36 int board_usb_init(int index, enum usb_init_type init)
37 {
38 int node;
39 const char *mode;
40 bool matched = false;
41 const void *blob = gd->fdt_blob;
42
43 /* find the usb_otg node */
44 node = fdt_node_offset_by_compatible(blob, -1,
45 "rockchip,rk3328-usb");
46
47 while (node > 0) {
48 mode = fdt_getprop(blob, node, "dr_mode", NULL);
49 if (mode && strcmp(mode, "otg") == 0) {
50 matched = true;
51 break;
52 }
53
54 node = fdt_node_offset_by_compatible(blob, node,
55 "rockchip,rk3328-usb");
56 }
57 if (!matched) {
58 debug("Not found usb_otg device\n");
59 return -ENODEV;
60 }
61
62 rk3328_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
63
64 return dwc2_udc_probe(&rk3328_otg_data);
65 }
66
67 int board_usb_cleanup(int index, enum usb_init_type init)
68 {
69 return 0;
70 }
71 #endif