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