[ar71xx] sync kernel configs
[openwrt.git] / target / linux / brcm47xx / patches-2.6.28 / 270-ehci-ssb.patch
1 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
2 --- a/drivers/usb/host/Kconfig
3 +++ b/drivers/usb/host/Kconfig
4 @@ -96,6 +96,19 @@ config USB_EHCI_HCD_PPC_OF
5 Enables support for the USB controller present on the PowerPC
6 OpenFirmware platform bus.
7
8 +config USB_EHCI_HCD_SSB
9 + bool "EHCI support for Broadcom SSB EHCI core"
10 + depends on USB_EHCI_HCD && SSB && EXPERIMENTAL
11 + default n
12 + ---help---
13 + Support for the Sonics Silicon Backplane (SSB) attached
14 + Broadcom USB EHCI core.
15 +
16 + This device is present in some embedded devices with
17 + Broadcom based SSB bus.
18 +
19 + If unsure, say N.
20 +
21 config USB_ISP116X_HCD
22 tristate "ISP116X HCD support"
23 depends on USB
24 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
25 --- a/drivers/usb/host/ehci-hcd.c
26 +++ b/drivers/usb/host/ehci-hcd.c
27 @@ -1034,8 +1034,16 @@ MODULE_LICENSE ("GPL");
28 #define PLATFORM_DRIVER ixp4xx_ehci_driver
29 #endif
30
31 -#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
32 - !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
33 +#ifdef CONFIG_USB_EHCI_HCD_SSB
34 +#include "ehci-ssb.c"
35 +#define SSB_EHCI_DRIVER ssb_ehci_driver
36 +#endif
37 +
38 +#if !defined(PCI_DRIVER) && \
39 + !defined(PLATFORM_DRIVER) && \
40 + !defined(PS3_SYSTEM_BUS_DRIVER) && \
41 + !defined(OF_PLATFORM_DRIVER) && \
42 + !defined(SSB_EHCI_DRIVER)
43 #error "missing bus glue for ehci-hcd"
44 #endif
45
46 diff --git a/drivers/usb/host/ehci-ssb.c b/drivers/usb/host/ehci-ssb.c
47 --- /dev/null
48 +++ b/drivers/usb/host/ehci-ssb.c
49 @@ -0,0 +1,201 @@
50 +/*
51 + * Sonics Silicon Backplane
52 + * Broadcom USB-core EHCI driver (SSB bus glue)
53 + *
54 + * Copyright 2007 Steven Brown <sbrown@cortland.com>
55 + *
56 + * Derived from the OHCI-SSB driver
57 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
58 + *
59 + * Derived from the EHCI-PCI driver
60 + * Copyright (c) 2000-2004 by David Brownell
61 + *
62 + * Derived from the OHCI-PCI driver
63 + * Copyright 1999 Roman Weissgaerber
64 + * Copyright 2000-2002 David Brownell
65 + * Copyright 1999 Linus Torvalds
66 + * Copyright 1999 Gregory P. Smith
67 + *
68 + * Derived from the USBcore related parts of Broadcom-SB
69 + * Copyright 2005 Broadcom Corporation
70 + *
71 + * Licensed under the GNU/GPL. See COPYING for details.
72 + */
73 +#include <linux/ssb/ssb.h>
74 +
75 +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
76 +
77 +struct ssb_ehci_device {
78 + struct ehci_hcd ehci; /* _must_ be at the beginning. */
79 +
80 + u32 enable_flags;
81 +};
82 +
83 +static inline
84 +struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd)
85 +{
86 + return (struct ssb_ehci_device *)(hcd->hcd_priv);
87 +}
88 +
89 +
90 +static int ssb_ehci_reset(struct usb_hcd *hcd)
91 +{
92 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
93 + int err;
94 +
95 + ehci->caps = hcd->regs;
96 + ehci->regs = hcd->regs +
97 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
98 +
99 + dbg_hcs_params(ehci, "reset");
100 + dbg_hcc_params(ehci, "reset");
101 +
102 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
103 +
104 + err = ehci_halt(ehci);
105 +
106 + if (err)
107 + return err;
108 +
109 + err = ehci_init(hcd);
110 +
111 + if (err)
112 + return err;
113 +
114 + ehci_port_power(ehci, 0);
115 +
116 + return err;
117 +}
118 +
119 +static int ssb_ehci_start(struct usb_hcd *hcd)
120 +{
121 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
122 + int err;
123 +
124 + err = ehci_run(hcd);
125 + if (err < 0) {
126 + ehci_err(ehci, "can't start\n");
127 + ehci_stop(hcd);
128 + }
129 +
130 + return err;
131 +}
132 +
133 +#ifdef CONFIG_PM
134 +static int ssb_ehci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
135 +{
136 + struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd);
137 + struct ehci_hcd *ehci = &ehcidev->ehci;
138 + unsigned long flags;
139 +
140 + spin_lock_irqsave(&ehci->lock, flags);
141 +
142 + ehci_writel(ehci, EHCI_INTR_MIE, &ehci->regs->intrdisable);
143 + ehci_readl(ehci, &ehci->regs->intrdisable); /* commit write */
144 +
145 + /* make sure snapshot being resumed re-enumerates everything */
146 + if (message.event == PM_EVENT_PRETHAW)
147 + ehci_usb_reset(ehci);
148 +
149 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
150 +
151 + spin_unlock_irqrestore(&ehci->lock, flags);
152 + return 0;
153 +}
154 +
155 +static int ssb_ehci_hcd_resume(struct usb_hcd *hcd)
156 +{
157 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
158 + usb_hcd_resume_root_hub(hcd);
159 + return 0;
160 +}
161 +#endif /* CONFIG_PM */
162 +
163 +static const struct hc_driver ssb_ehci_hc_driver = {
164 + .description = "ssb-usb-ehci",
165 + .product_desc = "SSB EHCI Controller",
166 + .hcd_priv_size = sizeof(struct ssb_ehci_device),
167 +
168 + .irq = ehci_irq,
169 + .flags = HCD_MEMORY | HCD_USB2,
170 +
171 + .reset = ssb_ehci_reset,
172 + .start = ssb_ehci_start,
173 + .stop = ehci_stop,
174 + .shutdown = ehci_shutdown,
175 +
176 +#ifdef CONFIG_PM
177 + .suspend = ssb_ehci_hcd_suspend,
178 + .resume = ssb_ehci_hcd_resume,
179 +#endif
180 +
181 + .urb_enqueue = ehci_urb_enqueue,
182 + .urb_dequeue = ehci_urb_dequeue,
183 + .endpoint_disable = ehci_endpoint_disable,
184 +
185 + .get_frame_number = ehci_get_frame,
186 +
187 + .hub_status_data = ehci_hub_status_data,
188 + .hub_control = ehci_hub_control,
189 +#ifdef CONFIG_PM
190 + .bus_suspend = ehci_bus_suspend,
191 + .bus_resume = ehci_bus_resume,
192 +#endif
193 +
194 +};
195 +
196 +static void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd)
197 +{
198 +
199 + usb_remove_hcd(hcd);
200 + iounmap(hcd->regs);
201 + usb_put_hcd(hcd);
202 +}
203 +EXPORT_SYMBOL_GPL(ssb_ehci_detach);
204 +
205 +static int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **ehci_hcd)
206 +{
207 + struct ssb_ehci_device *ehcidev;
208 + struct usb_hcd *hcd;
209 + int err = -ENOMEM;
210 + u32 tmp, flags = 0;
211 +
212 + hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev,
213 + dev->dev->bus_id);
214 + if (!hcd)
215 + goto err_dev_disable;
216 +
217 + ehcidev = hcd_to_ssb_ehci(hcd);
218 + ehcidev->enable_flags = flags;
219 + tmp = ssb_read32(dev, SSB_ADMATCH0);
220 + hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */
221 + hcd->rsrc_len = 0x100; /* ehci reg block size */
222 + /*
223 + * start & size modified per sbutils.c
224 + */
225 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
226 + if (!hcd->regs)
227 + goto err_put_hcd;
228 + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED | IRQF_DISABLED);
229 + if (err)
230 + goto err_iounmap;
231 +
232 + *ehci_hcd = hcd;
233 +
234 + return err;
235 +
236 +err_iounmap:
237 + iounmap(hcd->regs);
238 +err_put_hcd:
239 + usb_put_hcd(hcd);
240 +err_dev_disable:
241 + ssb_device_disable(dev, flags);
242 + return err;
243 +}
244 +EXPORT_SYMBOL_GPL(ssb_ehci_attach);
245 +
246 +static const struct ssb_device_id ssb_ehci_table[] = {
247 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV),
248 + SSB_DEVTABLE_END
249 +};
250 +MODULE_DEVICE_TABLE(ssb, ssb_ehci_table);
251 diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c
252 --- a/drivers/usb/host/ohci-ssb.c
253 +++ b/drivers/usb/host/ohci-ssb.c
254 @@ -17,6 +17,8 @@
255 */
256 #include <linux/ssb/ssb.h>
257
258 +extern int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **hcd);
259 +extern void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd);
260
261 #define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
262
263 @@ -24,6 +26,7 @@ struct ssb_ohci_device {
264 struct ohci_hcd ohci; /* _must_ be at the beginning. */
265
266 u32 enable_flags;
267 + struct usb_hcd *ehci_hcd;
268 };
269
270 static inline
271 @@ -92,13 +95,25 @@ static const struct hc_driver ssb_ohci_hc_driver = {
272 static void ssb_ohci_detach(struct ssb_device *dev)
273 {
274 struct usb_hcd *hcd = ssb_get_drvdata(dev);
275 +#ifdef CONFIG_USB_EHCI_HCD_SSB
276 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
277 +#endif
278
279 usb_remove_hcd(hcd);
280 iounmap(hcd->regs);
281 usb_put_hcd(hcd);
282 +
283 +#ifdef CONFIG_USB_EHCI_HCD_SSB
284 + /*
285 + * Also detach ehci function
286 + */
287 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
288 + ssb_ehci_detach(dev, ohcidev->ehci_hcd);
289 +#endif
290 ssb_device_disable(dev, 0);
291 }
292
293 +
294 static int ssb_ohci_attach(struct ssb_device *dev)
295 {
296 struct ssb_ohci_device *ohcidev;
297 @@ -184,6 +199,14 @@ static int ssb_ohci_attach(struct ssb_device *dev)
298
299 ssb_set_drvdata(dev, hcd);
300
301 +#ifdef CONFIG_USB_EHCI_HCD_SSB
302 + /*
303 + * attach ehci function in this core
304 + */
305 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
306 + err = ssb_ehci_attach(dev, &(ohcidev->ehci_hcd));
307 +#endif
308 +
309 return err;
310
311 err_iounmap:
This page took 0.074936 seconds and 5 git commands to generate.