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