[ar71xx] ag71xx driver: fix RX_STATUS_OF bitmask, and add DMA status register bit...
[openwrt.git] / target / linux / ar71xx / files / drivers / usb / host / ehci-ar71xx.c
1 /*
2 * Bus Glue for Atheros AR71xx built-in EHCI controller.
3 *
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * Parts of this file are based on Atheros' 2.6.15 BSP
8 * Copyright (C) 2007 Atheros Communications, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
17
18 extern int usb_disabled(void);
19
20 static void ehci_ar71xx_setup(void)
21 {
22 /*
23 * TODO: implement
24 */
25 }
26
27 static int ehci_ar71xx_probe(const struct hc_driver *driver,
28 struct usb_hcd **hcd_out,
29 struct platform_device *pdev)
30 {
31 struct usb_hcd *hcd;
32 struct ehci_hcd *ehci;
33 struct resource *res;
34 int irq;
35 int ret;
36
37 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
38 if (!res) {
39 dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
40 pdev->dev.bus_id);
41 return -ENODEV;
42 }
43 irq = res->start;
44
45 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
46 if (!res) {
47 dev_dbg(&pdev->dev, "no base address specified for %s\n",
48 pdev->dev.bus_id);
49 return -ENODEV;
50 }
51
52 hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id);
53 if (!hcd)
54 return -ENOMEM;
55
56 hcd->rsrc_start = res->start;
57 hcd->rsrc_len = res->end - res->start + 1;
58
59 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
60 dev_dbg(&pdev->dev, "controller already in use\n");
61 ret = -EBUSY;
62 goto err_put_hcd;
63 }
64
65 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
66 if (!hcd->regs) {
67 dev_dbg(&pdev->dev, "error mapping memory\n");
68 ret = -EFAULT;
69 goto err_release_region;
70 }
71
72 ehci = hcd_to_ehci(hcd);
73 ehci->caps = hcd->regs;
74 ehci->regs = hcd->regs +
75 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
76 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
77
78 ehci_ar71xx_setup();
79
80 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
81 if (ret)
82 goto err_iounmap;
83
84 return 0;
85
86 err_iounmap:
87 iounmap(hcd->regs);
88
89 err_release_region:
90 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
91 err_put_hcd:
92 usb_put_hcd(hcd);
93 return ret;
94 }
95
96 static void ehci_ar71xx_remove(struct usb_hcd *hcd,
97 struct platform_device *pdev)
98 {
99 usb_remove_hcd(hcd);
100 iounmap(hcd->regs);
101 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
102 usb_put_hcd(hcd);
103 }
104
105 static const struct hc_driver ehci_ar71xx_hc_driver = {
106 .description = hcd_name,
107 .product_desc = "Atheros AR71xx built-in EHCI controller",
108 .hcd_priv_size = sizeof(struct ehci_hcd),
109
110 /*
111 * generic hardware linkage
112 */
113 .irq = ehci_irq,
114 .flags = HCD_MEMORY | HCD_USB2,
115
116 /*
117 * basic lifecycle operations
118 */
119 .reset = ehci_init,
120 .start = ehci_run,
121 .stop = ehci_stop,
122 .shutdown = ehci_shutdown,
123
124 /*
125 * managing i/o requests and associated device resources
126 */
127 .urb_enqueue = ehci_urb_enqueue,
128 .urb_dequeue = ehci_urb_dequeue,
129 .endpoint_disable = ehci_endpoint_disable,
130
131 /*
132 * scheduling support
133 */
134 .get_frame_number = ehci_get_frame,
135
136 /*
137 * root hub support
138 */
139 .hub_status_data = ehci_hub_status_data,
140 .hub_control = ehci_hub_control,
141 #ifdef CONFIG_PM
142 .hub_suspend = ehci_hub_suspend,
143 .hub_resume = ehci_hub_resume,
144 #endif
145 };
146
147 static int ehci_ar71xx_driver_probe(struct platform_device *pdev)
148 {
149 struct usb_hcd *hcd = NULL;
150
151 if (usb_disabled())
152 return -ENODEV;
153
154 return ehci_ar71xx_probe(&ehci_ar71xx_hc_driver, &hcd, pdev);
155 }
156
157 static int ehci_ar71xx_driver_remove(struct platform_device *pdev)
158 {
159 struct usb_hcd *hcd = platform_get_drvdata(pdev);
160
161 ehci_ar71xx_remove(hcd, pdev);
162 return 0;
163 }
164
165 MODULE_ALIAS("platform:ar71xx-ehci");
166
167 static struct platform_driver ehci_ar71xx_driver = {
168 .probe = ehci_ar71xx_driver_probe,
169 .remove = ehci_ar71xx_driver_remove,
170 .driver = {
171 .name = "ar71xx-ehci",
172 }
173 };
This page took 0.063163 seconds and 5 git commands to generate.