1 From: Michael Buesch <mb@bu3sch.de>
2 Date: Wed, 10 Oct 2007 06:47:17 +0000 (-0700)
3 Subject: USB: ohci SSB bus glue
4 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fralf%2Flinux.git;a=commitdiff_plain;h=c604e851486eabcbeb73e984279d436ce121fd5d
8 This adds SSB bus glue for the USB OHCI HCD.
10 Signed-off-by: Michael Buesch <mb@bu3sch.de>
11 Signed-off-by: John W. Linville <linville@tuxdriver.com>
12 Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16 Index: linux-2.6.23.16/drivers/usb/host/Kconfig
17 ===================================================================
18 --- linux-2.6.23.16.orig/drivers/usb/host/Kconfig 2008-02-19 00:47:29.000000000 +0100
19 +++ linux-2.6.23.16/drivers/usb/host/Kconfig 2008-02-19 00:47:51.000000000 +0100
20 @@ -154,6 +154,19 @@ config USB_OHCI_HCD_PCI
21 Enables support for PCI-bus plug-in USB controller cards.
24 +config USB_OHCI_HCD_SSB
25 + bool "OHCI support for Broadcom SSB OHCI core"
26 + depends on USB_OHCI_HCD && SSB && EXPERIMENTAL
29 + Support for the Sonics Silicon Backplane (SSB) attached
30 + Broadcom USB OHCI core.
32 + This device is present in some embedded devices with
33 + Broadcom based SSB bus.
37 config USB_OHCI_BIG_ENDIAN_DESC
39 depends on USB_OHCI_HCD
40 Index: linux-2.6.23.16/drivers/usb/host/ohci-hcd.c
41 ===================================================================
42 --- linux-2.6.23.16.orig/drivers/usb/host/ohci-hcd.c 2008-02-19 00:47:29.000000000 +0100
43 +++ linux-2.6.23.16/drivers/usb/host/ohci-hcd.c 2008-02-19 00:47:51.000000000 +0100
44 @@ -926,11 +926,17 @@ MODULE_LICENSE ("GPL");
45 #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver
48 +#ifdef CONFIG_USB_OHCI_HCD_SSB
49 +#include "ohci-ssb.c"
50 +#define SSB_OHCI_DRIVER ssb_ohci_driver
53 #if !defined(PCI_DRIVER) && \
54 !defined(PLATFORM_DRIVER) && \
55 !defined(OF_PLATFORM_DRIVER) && \
56 !defined(SA1111_DRIVER) && \
57 - !defined(PS3_SYSTEM_BUS_DRIVER)
58 + !defined(PS3_SYSTEM_BUS_DRIVER) && \
59 + !defined(SSB_OHCI_DRIVER)
60 #error "missing bus glue for ohci-hcd"
63 @@ -975,10 +981,20 @@ static int __init ohci_hcd_mod_init(void
67 +#ifdef SSB_OHCI_DRIVER
68 + retval = ssb_driver_register(&SSB_OHCI_DRIVER);
76 +#ifdef SSB_OHCI_DRIVER
80 + pci_unregister_driver(&PCI_DRIVER);
84 @@ -1003,6 +1019,9 @@ module_init(ohci_hcd_mod_init);
86 static void __exit ohci_hcd_mod_exit(void)
88 +#ifdef SSB_OHCI_DRIVER
89 + ssb_driver_unregister(&SSB_OHCI_DRIVER);
92 pci_unregister_driver(&PCI_DRIVER);
94 Index: linux-2.6.23.16/drivers/usb/host/ohci-ssb.c
95 ===================================================================
96 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
97 +++ linux-2.6.23.16/drivers/usb/host/ohci-ssb.c 2008-02-19 00:47:51.000000000 +0100
100 + * Sonics Silicon Backplane
101 + * Broadcom USB-core OHCI driver
103 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
105 + * Derived from the OHCI-PCI driver
106 + * Copyright 1999 Roman Weissgaerber
107 + * Copyright 2000-2002 David Brownell
108 + * Copyright 1999 Linus Torvalds
109 + * Copyright 1999 Gregory P. Smith
111 + * Derived from the USBcore related parts of Broadcom-SB
112 + * Copyright 2005 Broadcom Corporation
114 + * Licensed under the GNU/GPL. See COPYING for details.
116 +#include <linux/ssb/ssb.h>
119 +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
121 +struct ssb_ohci_device {
122 + struct ohci_hcd ohci; /* _must_ be at the beginning. */
128 +struct ssb_ohci_device *hcd_to_ssb_ohci(struct usb_hcd *hcd)
130 + return (struct ssb_ohci_device *)(hcd->hcd_priv);
134 +static int ssb_ohci_reset(struct usb_hcd *hcd)
136 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
137 + struct ohci_hcd *ohci = &ohcidev->ohci;
140 + ohci_hcd_init(ohci);
141 + err = ohci_init(ohci);
146 +static int ssb_ohci_start(struct usb_hcd *hcd)
148 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
149 + struct ohci_hcd *ohci = &ohcidev->ohci;
152 + err = ohci_run(ohci);
154 + ohci_err(ohci, "can't start\n");
162 +static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
164 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
165 + struct ohci_hcd *ohci = &ohcidev->ohci;
166 + unsigned long flags;
168 + spin_lock_irqsave(&ohci->lock, flags);
170 + ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
171 + ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */
173 + /* make sure snapshot being resumed re-enumerates everything */
174 + if (message.event == PM_EVENT_PRETHAW)
175 + ohci_usb_reset(ohci);
177 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
179 + spin_unlock_irqrestore(&ohci->lock, flags);
183 +static int ssb_ohci_hcd_resume(struct usb_hcd *hcd)
185 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
186 + usb_hcd_resume_root_hub(hcd);
189 +#endif /* CONFIG_PM */
191 +static const struct hc_driver ssb_ohci_hc_driver = {
192 + .description = "ssb-usb-ohci",
193 + .product_desc = "SSB OHCI Controller",
194 + .hcd_priv_size = sizeof(struct ssb_ohci_device),
197 + .flags = HCD_MEMORY | HCD_USB11,
199 + .reset = ssb_ohci_reset,
200 + .start = ssb_ohci_start,
202 + .shutdown = ohci_shutdown,
205 + .suspend = ssb_ohci_hcd_suspend,
206 + .resume = ssb_ohci_hcd_resume,
209 + .urb_enqueue = ohci_urb_enqueue,
210 + .urb_dequeue = ohci_urb_dequeue,
211 + .endpoint_disable = ohci_endpoint_disable,
213 + .get_frame_number = ohci_get_frame,
215 + .hub_status_data = ohci_hub_status_data,
216 + .hub_control = ohci_hub_control,
217 + .hub_irq_enable = ohci_rhsc_enable,
218 + .bus_suspend = ohci_bus_suspend,
219 + .bus_resume = ohci_bus_resume,
221 + .start_port_reset = ohci_start_port_reset,
224 +static void ssb_ohci_detach(struct ssb_device *dev)
226 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
228 + usb_remove_hcd(hcd);
229 + iounmap(hcd->regs);
231 + ssb_device_disable(dev, 0);
234 +static int ssb_ohci_attach(struct ssb_device *dev)
236 + struct ssb_ohci_device *ohcidev;
237 + struct usb_hcd *hcd;
239 + u32 tmp, flags = 0;
241 + if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV)
242 + flags |= SSB_OHCI_TMSLOW_HOSTMODE;
244 + ssb_device_enable(dev, flags);
246 + hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev,
249 + goto err_dev_disable;
250 + ohcidev = hcd_to_ssb_ohci(hcd);
251 + ohcidev->enable_flags = flags;
253 + tmp = ssb_read32(dev, SSB_ADMATCH0);
254 + hcd->rsrc_start = ssb_admatch_base(tmp);
255 + hcd->rsrc_len = ssb_admatch_size(tmp);
256 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
259 + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED);
263 + ssb_set_drvdata(dev, hcd);
268 + iounmap(hcd->regs);
272 + ssb_device_disable(dev, flags);
276 +static int ssb_ohci_probe(struct ssb_device *dev,
277 + const struct ssb_device_id *id)
282 + /* USBcores are only connected on embedded devices. */
283 + chipid_top = (dev->bus->chip_id & 0xFF00);
284 + if (chipid_top != 0x4700 && chipid_top != 0x5300)
287 + /* TODO: Probably need checks here; is the core connected? */
289 + if (usb_disabled())
292 + /* We currently always attach SSB_DEV_USB11_HOSTDEV
293 + * as HOST OHCI. If we want to attach it as Client device,
294 + * we must branch here and call into the (yet to
295 + * be written) Client mode driver. Same for remove(). */
297 + err = ssb_ohci_attach(dev);
302 +static void ssb_ohci_remove(struct ssb_device *dev)
304 + ssb_ohci_detach(dev);
309 +static int ssb_ohci_suspend(struct ssb_device *dev, pm_message_t state)
311 + ssb_device_disable(dev, 0);
316 +static int ssb_ohci_resume(struct ssb_device *dev)
318 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
319 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
321 + ssb_device_enable(dev, ohcidev->enable_flags);
326 +#else /* !CONFIG_PM */
327 +#define ssb_ohci_suspend NULL
328 +#define ssb_ohci_resume NULL
329 +#endif /* CONFIG_PM */
331 +static const struct ssb_device_id ssb_ohci_table[] = {
332 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV),
333 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV),
336 +MODULE_DEVICE_TABLE(ssb, ssb_ohci_table);
338 +static struct ssb_driver ssb_ohci_driver = {
339 + .name = KBUILD_MODNAME,
340 + .id_table = ssb_ohci_table,
341 + .probe = ssb_ohci_probe,
342 + .remove = ssb_ohci_remove,
343 + .suspend = ssb_ohci_suspend,
344 + .resume = ssb_ohci_resume,