rockchip: elgin-rv1108: use board_early_init_f for per-boar init
[oweals/u-boot.git] / arch / arm / mach-rockchip / rv1108-board.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2015 Google, Inc
4  */
5
6 #include <common.h>
7
8 DECLARE_GLOBAL_DATA_PTR;
9
10 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
11 #include <usb.h>
12 #include <usb/dwc2_udc.h>
13
14 static struct dwc2_plat_otg_data otg_data = {
15         .rx_fifo_sz     = 512,
16         .np_tx_fifo_sz  = 16,
17         .tx_fifo_sz     = 128,
18 };
19
20 int board_usb_init(int index, enum usb_init_type init)
21 {
22         int node;
23         const char *mode;
24         bool matched = false;
25         const void *blob = gd->fdt_blob;
26
27         /* find the usb_otg node */
28         node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc2");
29
30         while (node > 0) {
31                 mode = fdt_getprop(blob, node, "dr_mode", NULL);
32                 if (mode && strcmp(mode, "otg") == 0) {
33                         matched = true;
34                         break;
35                 }
36
37                 node = fdt_node_offset_by_compatible(blob, node, "snps,dwc2");
38         }
39         if (!matched) {
40                 debug("Not found usb_otg device\n");
41                 return -ENODEV;
42         }
43         otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
44
45         return dwc2_udc_probe(&otg_data);
46 }
47
48 int board_usb_cleanup(int index, enum usb_init_type init)
49 {
50         return 0;
51 }
52 #endif