39 #include <linux/module.h>
40 #include <linux/kernel.h>
41 #include <linux/slab.h>
48 #include <linux/list.h>
54 #include <linux/usb/ch9.h>
63 static char *maximum_speed =
"super";
69 #define DWC3_DEVS_POSSIBLE 32
86 pr_err(
"dwc3: no space for new device\n");
102 WARN(!ret,
"dwc3: ID %d not in use\n",
id);
122 static void dwc3_core_soft_reset(
struct dwc3 *dwc)
168 static void dwc3_free_one_event_buffer(
struct dwc3 *dwc,
184 dwc3_alloc_one_event_buffer(
struct dwc3 *dwc,
unsigned length)
208 static void dwc3_free_event_buffers(
struct dwc3 *dwc)
216 dwc3_free_one_event_buffer(dwc, evt);
230 static int __devinit dwc3_alloc_event_buffers(
struct dwc3 *dwc,
unsigned length)
240 dev_err(dwc->
dev,
"can't allocate event buffers array\n");
244 for (i = 0; i < num; i++) {
247 evt = dwc3_alloc_one_event_buffer(dwc, length);
249 dev_err(dwc->
dev,
"can't allocate event buffer\n");
264 static int dwc3_event_buffers_setup(
struct dwc3 *dwc)
271 dev_dbg(dwc->
dev,
"Event buf %p dma %08llx length %d\n",
272 evt->
buf, (
unsigned long long) evt->
dma,
289 static void dwc3_event_buffers_cleanup(
struct dwc3 *dwc)
336 dev_err(dwc->
dev,
"this is not a DesignWare USB3 DRD Core\n");
359 dwc3_core_soft_reset(dwc);
361 dwc3_cache_hwparams(dwc);
372 dev_dbg(dwc->
dev,
"No power optimization available\n");
388 dev_err(dwc->
dev,
"failed to allocate event buffers\n");
393 ret = dwc3_event_buffers_setup(dwc);
395 dev_err(dwc->
dev,
"failed to setup event buffers\n");
402 dwc3_free_event_buffers(dwc);
408 static void dwc3_core_exit(
struct dwc3 *dwc)
410 dwc3_event_buffers_cleanup(dwc);
411 dwc3_free_event_buffers(dwc);
418 #define DWC3_ALIGN_MASK (16 - 1)
436 dev_err(dev,
"not enough memory\n");
454 dev_err(dev,
"missing memory resource\n");
471 dev_err(dev,
"can't request mem region\n");
477 dev_err(dev,
"ioremap failed\n");
482 if (IS_ERR_OR_NULL(dwc->
usb2_phy)) {
483 dev_err(dev,
"no usb2 phy configured\n");
488 if (IS_ERR_OR_NULL(dwc->
usb3_phy)) {
489 dev_err(dev,
"no usb3 phy configured\n");
494 platform_set_drvdata(pdev, dwc);
500 if (!
strncmp(
"super", maximum_speed, 5))
502 else if (!
strncmp(
"high", maximum_speed, 4))
504 else if (!
strncmp(
"full", maximum_speed, 4))
506 else if (!
strncmp(
"low", maximum_speed, 3))
515 pm_runtime_get_sync(dev);
518 ret = dwc3_core_init(dwc);
520 dev_err(dev,
"failed to initialize core\n");
531 dev_err(dev,
"failed to initialize gadget\n");
539 dev_err(dev,
"failed to initialize host\n");
547 dev_err(dev,
"failed to initialize host\n");
553 dev_err(dev,
"failed to initialize gadget\n");
558 dev_err(dev,
"Unsupported mode of operation %d\n", mode);
565 dev_err(dev,
"failed to initialize debugfs\n");
598 struct dwc3 *dwc = platform_get_drvdata(pdev);
603 pm_runtime_put(&pdev->
dev);
604 pm_runtime_disable(&pdev->
dev);