aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/host.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-10-12 07:08:26 -0400
committerFelipe Balbi <balbi@ti.com>2011-12-12 04:48:12 -0500
commitd07e8819a03dc2d1f03f725194ae56544e6c680b (patch)
tree0715634a05d360ef7939fd0c23befaf11c40919a /drivers/usb/dwc3/host.c
parent0949e99b05736946cf0ac78e37194be0807e497e (diff)
usb: dwc3: add xHCI Host support
The Designware USB3 IP can be configured with an internal xHCI. If we're running on such a version, let's start the xHCI stack. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/host.c')
-rw-r--r--drivers/usb/dwc3/host.c116
1 files changed, 116 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
new file mode 100644
index 000000000000..9b300a26fceb
--- /dev/null
+++ b/drivers/usb/dwc3/host.c
@@ -0,0 +1,116 @@
1/**
2 * host.c - DesignWare USB3 DRD Controller Host Glue
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions, and the following disclaimer,
13 * without modification.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The names of the above-listed copyright holders may not be used
18 * to endorse or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * ALTERNATIVELY, this software may be distributed under the terms of the
22 * GNU General Public License ("GPL") version 2, as published by the Free
23 * Software Foundation.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
26 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <linux/module.h>
39#include <linux/kernel.h>
40#include <linux/slab.h>
41#include <linux/spinlock.h>
42#include <linux/platform_device.h>
43#include <linux/pm_runtime.h>
44#include <linux/interrupt.h>
45#include <linux/ioport.h>
46#include <linux/io.h>
47#include <linux/list.h>
48#include <linux/delay.h>
49#include <linux/dma-mapping.h>
50
51#include "core.h"
52#include "io.h"
53
54#include "debug.h"
55
56static struct resource generic_resources[] = {
57 {
58 .flags = IORESOURCE_IRQ,
59 },
60 {
61 .flags = IORESOURCE_MEM,
62 },
63};
64
65int dwc3_host_init(struct dwc3 *dwc)
66{
67 struct platform_device *xhci;
68 int ret;
69
70 xhci = platform_device_alloc("xhci", -1);
71 if (!xhci) {
72 dev_err(dwc->dev, "couldn't allocate xHCI device\n");
73 ret = -ENOMEM;
74 goto err0;
75 }
76
77 dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask);
78
79 xhci->dev.parent = dwc->dev;
80 xhci->dev.dma_mask = dwc->dev->dma_mask;
81 xhci->dev.dma_parms = dwc->dev->dma_parms;
82
83 dwc->xhci = xhci;
84
85 /* setup resources */
86 generic_resources[0].start = dwc->irq;
87
88 generic_resources[1].start = dwc->res->start;
89 generic_resources[1].end = dwc->res->start + 0x7fff;
90
91 ret = platform_device_add_resources(xhci, generic_resources,
92 ARRAY_SIZE(generic_resources));
93 if (ret) {
94 dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
95 goto err1;
96 }
97
98 ret = platform_device_add(xhci);
99 if (ret) {
100 dev_err(dwc->dev, "failed to register xHCI device\n");
101 goto err1;
102 }
103
104 return 0;
105
106err1:
107 platform_device_put(xhci);
108
109err0:
110 return ret;
111}
112
113void dwc3_host_exit(struct dwc3 *dwc)
114{
115 platform_device_unregister(dwc->xhci);
116}