xref: /openbmc/u-boot/board/rockchip/evb_rk3328/evb-rk3328.c (revision c93bef9323f5a9ede9a4d140d030afb22330b550)
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 <usb.h>
11 
12 DECLARE_GLOBAL_DATA_PTR;
13 
14 int board_init(void)
15 {
16 	return 0;
17 }
18 
19 #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
20 #include <usb.h>
21 #include <usb/dwc2_udc.h>
22 
23 static struct dwc2_plat_otg_data rk3328_otg_data = {
24 	.rx_fifo_sz	= 512,
25 	.np_tx_fifo_sz	= 16,
26 	.tx_fifo_sz	= 128,
27 };
28 
29 int board_usb_init(int index, enum usb_init_type init)
30 {
31 	int node;
32 	const char *mode;
33 	bool matched = false;
34 	const void *blob = gd->fdt_blob;
35 
36 	/* find the usb_otg node */
37 	node = fdt_node_offset_by_compatible(blob, -1,
38 					"rockchip,rk3328-usb");
39 
40 	while (node > 0) {
41 		mode = fdt_getprop(blob, node, "dr_mode", NULL);
42 		if (mode && strcmp(mode, "otg") == 0) {
43 			matched = true;
44 			break;
45 		}
46 
47 		node = fdt_node_offset_by_compatible(blob, node,
48 					"rockchip,rk3328-usb");
49 	}
50 	if (!matched) {
51 		debug("Not found usb_otg device\n");
52 		return -ENODEV;
53 	}
54 
55 	rk3328_otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
56 
57 	return dwc2_udc_probe(&rk3328_otg_data);
58 }
59 
60 int board_usb_cleanup(int index, enum usb_init_type init)
61 {
62 	return 0;
63 }
64 #endif
65