aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/host/Kconfig4
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/xhci-plat.c205
-rw-r--r--drivers/usb/host/xhci.c9
-rw-r--r--drivers/usb/host/xhci.h11
5 files changed, 233 insertions, 0 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index dd045173ab79..b17995829514 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -27,6 +27,10 @@ config USB_XHCI_HCD
27 To compile this driver as a module, choose M here: the 27 To compile this driver as a module, choose M here: the
28 module will be called xhci-hcd. 28 module will be called xhci-hcd.
29 29
30config USB_XHCI_PLATFORM
31 tristate
32 depends on USB_XHCI_HCD
33
30config USB_XHCI_HCD_DEBUGGING 34config USB_XHCI_HCD_DEBUGGING
31 bool "Debugging for the xHCI host controller" 35 bool "Debugging for the xHCI host controller"
32 depends on USB_XHCI_HCD 36 depends on USB_XHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 7ca290fcb070..0982bcc140bd 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -15,6 +15,10 @@ xhci-hcd-y := xhci.o xhci-mem.o
15xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o 15xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
16xhci-hcd-$(CONFIG_PCI) += xhci-pci.o 16xhci-hcd-$(CONFIG_PCI) += xhci-pci.o
17 17
18ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
19 xhci-hcd-y += xhci-plat.o
20endif
21
18obj-$(CONFIG_USB_WHCI_HCD) += whci/ 22obj-$(CONFIG_USB_WHCI_HCD) += whci/
19 23
20obj-$(CONFIG_PCI) += pci-quirks.o 24obj-$(CONFIG_PCI) += pci-quirks.o
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
new file mode 100644
index 000000000000..689bc18b051d
--- /dev/null
+++ b/drivers/usb/host/xhci-plat.c
@@ -0,0 +1,205 @@
1/*
2 * xhci-plat.c - xHCI host controller driver platform Bus Glue.
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
5 * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
6 *
7 * A lot of code borrowed from the Linux xHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */
13
14#include <linux/platform_device.h>
15#include <linux/module.h>
16#include <linux/slab.h>
17
18#include "xhci.h"
19
20static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
21{
22 /*
23 * As of now platform drivers don't provide MSI support so we ensure
24 * here that the generic code does not try to make a pci_dev from our
25 * dev struct in order to setup MSI
26 */
27 xhci->quirks |= XHCI_BROKEN_MSI;
28}
29
30/* called during probe() after chip reset completes */
31static int xhci_plat_setup(struct usb_hcd *hcd)
32{
33 return xhci_gen_setup(hcd, xhci_plat_quirks);
34}
35
36static const struct hc_driver xhci_plat_xhci_driver = {
37 .description = "xhci-hcd",
38 .product_desc = "xHCI Host Controller",
39 .hcd_priv_size = sizeof(struct xhci_hcd *),
40
41 /*
42 * generic hardware linkage
43 */
44 .irq = xhci_irq,
45 .flags = HCD_MEMORY | HCD_USB3 | HCD_SHARED,
46
47 /*
48 * basic lifecycle operations
49 */
50 .reset = xhci_plat_setup,
51 .start = xhci_run,
52 .stop = xhci_stop,
53 .shutdown = xhci_shutdown,
54
55 /*
56 * managing i/o requests and associated device resources
57 */
58 .urb_enqueue = xhci_urb_enqueue,
59 .urb_dequeue = xhci_urb_dequeue,
60 .alloc_dev = xhci_alloc_dev,
61 .free_dev = xhci_free_dev,
62 .alloc_streams = xhci_alloc_streams,
63 .free_streams = xhci_free_streams,
64 .add_endpoint = xhci_add_endpoint,
65 .drop_endpoint = xhci_drop_endpoint,
66 .endpoint_reset = xhci_endpoint_reset,
67 .check_bandwidth = xhci_check_bandwidth,
68 .reset_bandwidth = xhci_reset_bandwidth,
69 .address_device = xhci_address_device,
70 .update_hub_device = xhci_update_hub_device,
71 .reset_device = xhci_discover_or_reset_device,
72
73 /*
74 * scheduling support
75 */
76 .get_frame_number = xhci_get_frame,
77
78 /* Root hub support */
79 .hub_control = xhci_hub_control,
80 .hub_status_data = xhci_hub_status_data,
81 .bus_suspend = xhci_bus_suspend,
82 .bus_resume = xhci_bus_resume,
83};
84
85static int xhci_plat_probe(struct platform_device *pdev)
86{
87 const struct hc_driver *driver;
88 struct xhci_hcd *xhci;
89 struct resource *res;
90 struct usb_hcd *hcd;
91 int ret;
92 int irq;
93
94 if (usb_disabled())
95 return -ENODEV;
96
97 driver = &xhci_plat_xhci_driver;
98
99 irq = platform_get_irq(pdev, 0);
100 if (irq < 0)
101 return -ENODEV;
102
103 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
104 if (!res)
105 return -ENODEV;
106
107 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
108 if (!hcd)
109 return -ENOMEM;
110
111 hcd->rsrc_start = res->start;
112 hcd->rsrc_len = resource_size(res);
113
114 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
115 driver->description)) {
116 dev_dbg(&pdev->dev, "controller already in use\n");
117 ret = -EBUSY;
118 goto put_hcd;
119 }
120
121 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
122 if (!hcd->regs) {
123 dev_dbg(&pdev->dev, "error mapping memory\n");
124 ret = -EFAULT;
125 goto release_mem_region;
126 }
127
128 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
129 if (ret)
130 goto unmap_registers;
131
132 /* USB 2.0 roothub is stored in the platform_device now. */
133 hcd = dev_get_drvdata(&pdev->dev);
134 xhci = hcd_to_xhci(hcd);
135 xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
136 dev_name(&pdev->dev), hcd);
137 if (!xhci->shared_hcd) {
138 ret = -ENOMEM;
139 goto dealloc_usb2_hcd;
140 }
141
142 /*
143 * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset)
144 * is called by usb_add_hcd().
145 */
146 *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;
147
148 ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
149 if (ret)
150 goto put_usb3_hcd;
151
152 return 0;
153
154put_usb3_hcd:
155 usb_put_hcd(xhci->shared_hcd);
156
157dealloc_usb2_hcd:
158 usb_remove_hcd(hcd);
159
160unmap_registers:
161 iounmap(hcd->regs);
162
163release_mem_region:
164 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
165
166put_hcd:
167 usb_put_hcd(hcd);
168
169 return ret;
170}
171
172static int xhci_plat_remove(struct platform_device *dev)
173{
174 struct usb_hcd *hcd = platform_get_drvdata(dev);
175 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
176
177 usb_remove_hcd(xhci->shared_hcd);
178 usb_put_hcd(xhci->shared_hcd);
179
180 usb_remove_hcd(hcd);
181 iounmap(hcd->regs);
182 usb_put_hcd(hcd);
183 kfree(xhci);
184
185 return 0;
186}
187
188static struct platform_driver usb_xhci_driver = {
189 .probe = xhci_plat_probe,
190 .remove = xhci_plat_remove,
191 .driver = {
192 .name = "xhci-hcd",
193 },
194};
195MODULE_ALIAS("platform:xhci-hcd");
196
197int xhci_register_plat(void)
198{
199 return platform_driver_register(&usb_xhci_driver);
200}
201
202void xhci_unregister_plat(void)
203{
204 platform_driver_unregister(&usb_xhci_driver);
205}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index f9f161fa66ad..e1963d4a430f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4064,6 +4064,11 @@ static int __init xhci_hcd_init(void)
4064 printk(KERN_DEBUG "Problem registering PCI driver."); 4064 printk(KERN_DEBUG "Problem registering PCI driver.");
4065 return retval; 4065 return retval;
4066 } 4066 }
4067 retval = xhci_register_plat();
4068 if (retval < 0) {
4069 printk(KERN_DEBUG "Problem registering platform driver.");
4070 goto unreg_pci;
4071 }
4067 /* 4072 /*
4068 * Check the compiler generated sizes of structures that must be laid 4073 * Check the compiler generated sizes of structures that must be laid
4069 * out in specific ways for hardware access. 4074 * out in specific ways for hardware access.
@@ -4083,11 +4088,15 @@ static int __init xhci_hcd_init(void)
4083 BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); 4088 BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
4084 BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8); 4089 BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8);
4085 return 0; 4090 return 0;
4091unreg_pci:
4092 xhci_unregister_pci();
4093 return retval;
4086} 4094}
4087module_init(xhci_hcd_init); 4095module_init(xhci_hcd_init);
4088 4096
4089static void __exit xhci_hcd_cleanup(void) 4097static void __exit xhci_hcd_cleanup(void)
4090{ 4098{
4091 xhci_unregister_pci(); 4099 xhci_unregister_pci();
4100 xhci_unregister_plat();
4092} 4101}
4093module_exit(xhci_hcd_cleanup); 4102module_exit(xhci_hcd_cleanup);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 57cd632064b4..91074fdab3eb 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1663,6 +1663,17 @@ static inline int xhci_register_pci(void) { return 0; }
1663static inline void xhci_unregister_pci(void) {} 1663static inline void xhci_unregister_pci(void) {}
1664#endif 1664#endif
1665 1665
1666#if defined(CONFIG_USB_XHCI_PLATFORM) \
1667 || defined(CONFIG_USB_XHCI_PLATFORM_MODULE)
1668int xhci_register_plat(void);
1669void xhci_unregister_plat(void);
1670#else
1671static inline int xhci_register_plat(void)
1672{ return 0; }
1673static inline void xhci_unregister_plat(void)
1674{ }
1675#endif
1676
1666/* xHCI host controller glue */ 1677/* xHCI host controller glue */
1667typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); 1678typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
1668void xhci_quiesce(struct xhci_hcd *xhci); 1679void xhci_quiesce(struct xhci_hcd *xhci);