2018-11-30 22:34:15 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2015 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG)
|
|
|
|
#include <usb.h>
|
|
|
|
#include <usb/dwc2_udc.h>
|
|
|
|
|
2019-07-22 21:02:00 +09:00
|
|
|
static struct dwc2_plat_otg_data otg_data = {
|
2018-11-30 22:34:15 +09:00
|
|
|
.rx_fifo_sz = 512,
|
|
|
|
.np_tx_fifo_sz = 16,
|
|
|
|
.tx_fifo_sz = 128,
|
|
|
|
};
|
|
|
|
|
|
|
|
int board_usb_init(int index, enum usb_init_type init)
|
|
|
|
{
|
2019-07-22 21:02:00 +09:00
|
|
|
int node;
|
2018-11-30 22:34:15 +09:00
|
|
|
const char *mode;
|
2019-07-22 21:02:00 +09:00
|
|
|
bool matched = false;
|
|
|
|
const void *blob = gd->fdt_blob;
|
2018-11-30 22:34:15 +09:00
|
|
|
|
|
|
|
/* find the usb_otg node */
|
2019-07-22 21:02:00 +09:00
|
|
|
node = fdt_node_offset_by_compatible(blob, -1, "snps,dwc2");
|
|
|
|
|
2018-11-30 22:34:15 +09:00
|
|
|
while (node > 0) {
|
|
|
|
mode = fdt_getprop(blob, node, "dr_mode", NULL);
|
|
|
|
if (mode && strcmp(mode, "otg") == 0) {
|
|
|
|
matched = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-07-22 21:02:00 +09:00
|
|
|
node = fdt_node_offset_by_compatible(blob, node, "snps,dwc2");
|
2018-11-30 22:34:15 +09:00
|
|
|
}
|
|
|
|
if (!matched) {
|
2019-07-22 21:02:00 +09:00
|
|
|
debug("Not found usb_otg device\n");
|
2018-11-30 22:34:15 +09:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
2019-07-22 21:02:00 +09:00
|
|
|
otg_data.regs_otg = fdtdec_get_addr(blob, node, "reg");
|
2018-11-30 22:34:15 +09:00
|
|
|
|
2019-07-22 21:02:00 +09:00
|
|
|
return dwc2_udc_probe(&otg_data);
|
2018-11-30 22:34:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
int board_usb_cleanup(int index, enum usb_init_type init)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|