aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorJayachandran C <jayachandranc@netlogicmicro.com>2011-08-04 15:58:22 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-08-22 18:54:38 -0400
commit23106343db66171c94ae486d2035478ec575b228 (patch)
tree10d40f1a8e9148f23ab3cc58fc4d2dc3784bd542 /drivers/usb/host
parent3abd7f68b28dcf6394c71c998376fc7bc92342c4 (diff)
usb: OHCI/EHCI support for Netlogic XLS processor.
Add supprt for on-chip USB controller for Netlogic XLS MIPS64 SoC processor family. Changes are: - update ehci-hcd.c and ohci-hcd.c to add XLS hcds - add ehci-xls.c: EHCI support for Netlogic XLS. - add ohci-xls.c: OHCI support for Netlogic XLS. Signed-off-by: Jayachandran C <jayachandranc@netlogicmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/host/ehci-xls.c161
-rw-r--r--drivers/usb/host/ohci-hcd.c5
-rw-r--r--drivers/usb/host/ohci-xls.c151
4 files changed, 322 insertions, 0 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 750f60fe6a9f..2af3e2a89efc 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1296,6 +1296,11 @@ MODULE_LICENSE ("GPL");
1296#define PLATFORM_DRIVER ehci_pxa168_driver 1296#define PLATFORM_DRIVER ehci_pxa168_driver
1297#endif 1297#endif
1298 1298
1299#ifdef CONFIG_NLM_XLR
1300#include "ehci-xls.c"
1301#define PLATFORM_DRIVER ehci_xls_driver
1302#endif
1303
1299#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1304#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
1300 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ 1305 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
1301 !defined(XILINX_OF_PLATFORM_DRIVER) 1306 !defined(XILINX_OF_PLATFORM_DRIVER)
diff --git a/drivers/usb/host/ehci-xls.c b/drivers/usb/host/ehci-xls.c
new file mode 100644
index 000000000000..fe74bd676018
--- /dev/null
+++ b/drivers/usb/host/ehci-xls.c
@@ -0,0 +1,161 @@
1/*
2 * EHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on various ehci-*.c drivers
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14
15static int ehci_xls_setup(struct usb_hcd *hcd)
16{
17 int retval;
18 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
19
20 ehci->caps = hcd->regs;
21 ehci->regs = hcd->regs +
22 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
23 dbg_hcs_params(ehci, "reset");
24 dbg_hcc_params(ehci, "reset");
25
26 /* cache this readonly data; minimize chip reads */
27 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
28
29 retval = ehci_halt(ehci);
30 if (retval)
31 return retval;
32
33 /* data structure init */
34 retval = ehci_init(hcd);
35 if (retval)
36 return retval;
37
38 ehci_reset(ehci);
39
40 return retval;
41}
42
43int ehci_xls_probe_internal(const struct hc_driver *driver,
44 struct platform_device *pdev)
45{
46 struct usb_hcd *hcd;
47 struct resource *res;
48 int retval, irq;
49
50 /* Get our IRQ from an earlier registered Platform Resource */
51 irq = platform_get_irq(pdev, 0);
52 if (irq < 0) {
53 dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n",
54 dev_name(&pdev->dev));
55 return -ENODEV;
56 }
57
58 /* Get our Memory Handle */
59 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
60 if (!res) {
61 dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n",
62 dev_name(&pdev->dev));
63 return -ENODEV;
64 }
65 hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
66 if (!hcd) {
67 retval = -ENOMEM;
68 goto err1;
69 }
70
71 hcd->rsrc_start = res->start;
72 hcd->rsrc_len = res->end - res->start + 1;
73
74 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
75 driver->description)) {
76 dev_dbg(&pdev->dev, "controller already in use\n");
77 retval = -EBUSY;
78 goto err2;
79 }
80 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
81
82 if (hcd->regs == NULL) {
83 dev_dbg(&pdev->dev, "error mapping memory\n");
84 retval = -EFAULT;
85 goto err3;
86 }
87
88 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
89 if (retval != 0)
90 goto err4;
91 return retval;
92
93err4:
94 iounmap(hcd->regs);
95err3:
96 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
97err2:
98 usb_put_hcd(hcd);
99err1:
100 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev),
101 retval);
102 return retval;
103}
104
105static struct hc_driver ehci_xls_hc_driver = {
106 .description = hcd_name,
107 .product_desc = "XLS EHCI Host Controller",
108 .hcd_priv_size = sizeof(struct ehci_hcd),
109 .irq = ehci_irq,
110 .flags = HCD_USB2 | HCD_MEMORY,
111 .reset = ehci_xls_setup,
112 .start = ehci_run,
113 .stop = ehci_stop,
114 .shutdown = ehci_shutdown,
115
116 .urb_enqueue = ehci_urb_enqueue,
117 .urb_dequeue = ehci_urb_dequeue,
118 .endpoint_disable = ehci_endpoint_disable,
119 .endpoint_reset = ehci_endpoint_reset,
120
121 .get_frame_number = ehci_get_frame,
122
123 .hub_status_data = ehci_hub_status_data,
124 .hub_control = ehci_hub_control,
125 .bus_suspend = ehci_bus_suspend,
126 .bus_resume = ehci_bus_resume,
127 .relinquish_port = ehci_relinquish_port,
128 .port_handed_over = ehci_port_handed_over,
129
130 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
131};
132
133static int ehci_xls_probe(struct platform_device *pdev)
134{
135 if (usb_disabled())
136 return -ENODEV;
137
138 return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev);
139}
140
141static int ehci_xls_remove(struct platform_device *pdev)
142{
143 struct usb_hcd *hcd = platform_get_drvdata(pdev);
144
145 usb_remove_hcd(hcd);
146 iounmap(hcd->regs);
147 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
148 usb_put_hcd(hcd);
149 return 0;
150}
151
152MODULE_ALIAS("ehci-xls");
153
154static struct platform_driver ehci_xls_driver = {
155 .probe = ehci_xls_probe,
156 .remove = ehci_xls_remove,
157 .shutdown = usb_hcd_platform_shutdown,
158 .driver = {
159 .name = "ehci-xls",
160 },
161};
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index f9cf3f04b742..34efd479e068 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1114,6 +1114,11 @@ MODULE_LICENSE ("GPL");
1114#define PLATFORM_DRIVER ohci_hcd_ath79_driver 1114#define PLATFORM_DRIVER ohci_hcd_ath79_driver
1115#endif 1115#endif
1116 1116
1117#ifdef CONFIG_NLM_XLR
1118#include "ohci-xls.c"
1119#define PLATFORM_DRIVER ohci_xls_driver
1120#endif
1121
1117#if !defined(PCI_DRIVER) && \ 1122#if !defined(PCI_DRIVER) && \
1118 !defined(PLATFORM_DRIVER) && \ 1123 !defined(PLATFORM_DRIVER) && \
1119 !defined(OMAP1_PLATFORM_DRIVER) && \ 1124 !defined(OMAP1_PLATFORM_DRIVER) && \
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c
new file mode 100644
index 000000000000..a3a9c6f45b91
--- /dev/null
+++ b/drivers/usb/host/ohci-xls.c
@@ -0,0 +1,151 @@
1/*
2 * OHCI HCD for Netlogic XLS processors.
3 *
4 * (C) Copyright 2011 Netlogic Microsystems Inc.
5 *
6 * Based on ohci-au1xxx.c, and other Linux OHCI drivers.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive for
10 * more details.
11 */
12
13#include <linux/platform_device.h>
14#include <linux/signal.h>
15
16static int ohci_xls_probe_internal(const struct hc_driver *driver,
17 struct platform_device *dev)
18{
19 struct resource *res;
20 struct usb_hcd *hcd;
21 int retval, irq;
22
23 /* Get our IRQ from an earlier registered Platform Resource */
24 irq = platform_get_irq(dev, 0);
25 if (irq < 0) {
26 dev_err(&dev->dev, "Found HC with no IRQ\n");
27 return -ENODEV;
28 }
29
30 /* Get our Memory Handle */
31 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
32 if (!res) {
33 dev_err(&dev->dev, "MMIO Handle incorrect!\n");
34 return -ENODEV;
35 }
36
37 hcd = usb_create_hcd(driver, &dev->dev, "XLS");
38 if (!hcd) {
39 retval = -ENOMEM;
40 goto err1;
41 }
42 hcd->rsrc_start = res->start;
43 hcd->rsrc_len = res->end - res->start + 1;
44
45 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
46 driver->description)) {
47 dev_dbg(&dev->dev, "Controller already in use\n");
48 retval = -EBUSY;
49 goto err2;
50 }
51
52 hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
53 if (hcd->regs == NULL) {
54 dev_dbg(&dev->dev, "error mapping memory\n");
55 retval = -EFAULT;
56 goto err3;
57 }
58
59 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
60 if (retval != 0)
61 goto err4;
62 return retval;
63
64err4:
65 iounmap(hcd->regs);
66err3:
67 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
68err2:
69 usb_put_hcd(hcd);
70err1:
71 dev_err(&dev->dev, "init fail, %d\n", retval);
72 return retval;
73}
74
75static int ohci_xls_reset(struct usb_hcd *hcd)
76{
77 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
78
79 ohci_hcd_init(ohci);
80 return ohci_init(ohci);
81}
82
83static int __devinit ohci_xls_start(struct usb_hcd *hcd)
84{
85 struct ohci_hcd *ohci;
86 int ret;
87
88 ohci = hcd_to_ohci(hcd);
89 ret = ohci_run(ohci);
90 if (ret < 0) {
91 err("can't start %s", hcd->self.bus_name);
92 ohci_stop(hcd);
93 return ret;
94 }
95 return 0;
96}
97
98static struct hc_driver ohci_xls_hc_driver = {
99 .description = hcd_name,
100 .product_desc = "XLS OHCI Host Controller",
101 .hcd_priv_size = sizeof(struct ohci_hcd),
102 .irq = ohci_irq,
103 .flags = HCD_MEMORY | HCD_USB11,
104 .reset = ohci_xls_reset,
105 .start = ohci_xls_start,
106 .stop = ohci_stop,
107 .shutdown = ohci_shutdown,
108 .urb_enqueue = ohci_urb_enqueue,
109 .urb_dequeue = ohci_urb_dequeue,
110 .endpoint_disable = ohci_endpoint_disable,
111 .get_frame_number = ohci_get_frame,
112 .hub_status_data = ohci_hub_status_data,
113 .hub_control = ohci_hub_control,
114#ifdef CONFIG_PM
115 .bus_suspend = ohci_bus_suspend,
116 .bus_resume = ohci_bus_resume,
117#endif
118 .start_port_reset = ohci_start_port_reset,
119};
120
121static int ohci_xls_probe(struct platform_device *dev)
122{
123 int ret;
124
125 pr_debug("In ohci_xls_probe");
126 if (usb_disabled())
127 return -ENODEV;
128 ret = ohci_xls_probe_internal(&ohci_xls_hc_driver, dev);
129 return ret;
130}
131
132static int ohci_xls_remove(struct platform_device *dev)
133{
134 struct usb_hcd *hcd = platform_get_drvdata(dev);
135
136 usb_remove_hcd(hcd);
137 iounmap(hcd->regs);
138 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
139 usb_put_hcd(hcd);
140 return 0;
141}
142
143static struct platform_driver ohci_xls_driver = {
144 .probe = ohci_xls_probe,
145 .remove = ohci_xls_remove,
146 .shutdown = usb_hcd_platform_shutdown,
147 .driver = {
148 .name = "ohci-xls-0",
149 .owner = THIS_MODULE,
150 },
151};