blob: 99a73dacf168b63f22ddb1c8c10e95b7a79c3a32 [file] [log] [blame]
Kever Yang975a2ab2017-02-23 15:37:55 +08001/*
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>
Kever Yang0d5967d2017-06-08 15:32:05 +080010#include <power/regulator.h>
Kever Yang975a2ab2017-02-23 15:37:55 +080011#include <usb.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15int board_init(void)
16{
Kever Yang0d5967d2017-06-08 15:32:05 +080017 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;
Kever Yang975a2ab2017-02-23 15:37:55 +080024}
25
Meng Dongyangf8ef72c2017-06-28 19:22:44 +080026#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
27#include <usb.h>
28#include <usb/dwc2_udc.h>
29
30static 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
Kever Yang975a2ab2017-02-23 15:37:55 +080036int board_usb_init(int index, enum usb_init_type init)
37{
Meng Dongyangf8ef72c2017-06-28 19:22:44 +080038 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
67int board_usb_cleanup(int index, enum usb_init_type init)
68{
Kever Yang975a2ab2017-02-23 15:37:55 +080069 return 0;
70}
Meng Dongyangf8ef72c2017-06-28 19:22:44 +080071#endif