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 --- a/drivers/usb/host/Kconfig
17 +++ b/drivers/usb/host/Kconfig
19 Enables support for PCI-bus plug-in USB controller cards.
22 +config USB_OHCI_HCD_SSB
23 + bool "OHCI support for Broadcom SSB OHCI core"
24 + depends on USB_OHCI_HCD && SSB && EXPERIMENTAL
27 + Support for the Sonics Silicon Backplane (SSB) attached
28 + Broadcom USB OHCI core.
30 + This device is present in some embedded devices with
31 + Broadcom based SSB bus.
35 config USB_OHCI_BIG_ENDIAN_DESC
37 depends on USB_OHCI_HCD
38 --- a/drivers/usb/host/ohci-hcd.c
39 +++ b/drivers/usb/host/ohci-hcd.c
41 #define PS3_SYSTEM_BUS_DRIVER ps3_ohci_driver
44 +#ifdef CONFIG_USB_OHCI_HCD_SSB
45 +#include "ohci-ssb.c"
46 +#define SSB_OHCI_DRIVER ssb_ohci_driver
49 #if !defined(PCI_DRIVER) && \
50 !defined(PLATFORM_DRIVER) && \
51 !defined(OF_PLATFORM_DRIVER) && \
52 !defined(SA1111_DRIVER) && \
53 - !defined(PS3_SYSTEM_BUS_DRIVER)
54 + !defined(PS3_SYSTEM_BUS_DRIVER) && \
55 + !defined(SSB_OHCI_DRIVER)
56 #error "missing bus glue for ohci-hcd"
63 +#ifdef SSB_OHCI_DRIVER
64 + retval = ssb_driver_register(&SSB_OHCI_DRIVER);
72 +#ifdef SSB_OHCI_DRIVER
76 + pci_unregister_driver(&PCI_DRIVER);
82 static void __exit ohci_hcd_mod_exit(void)
84 +#ifdef SSB_OHCI_DRIVER
85 + ssb_driver_unregister(&SSB_OHCI_DRIVER);
88 pci_unregister_driver(&PCI_DRIVER);
91 +++ b/drivers/usb/host/ohci-ssb.c
94 + * Sonics Silicon Backplane
95 + * Broadcom USB-core OHCI driver
97 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
99 + * Derived from the OHCI-PCI driver
100 + * Copyright 1999 Roman Weissgaerber
101 + * Copyright 2000-2002 David Brownell
102 + * Copyright 1999 Linus Torvalds
103 + * Copyright 1999 Gregory P. Smith
105 + * Derived from the USBcore related parts of Broadcom-SB
106 + * Copyright 2005 Broadcom Corporation
108 + * Licensed under the GNU/GPL. See COPYING for details.
110 +#include <linux/ssb/ssb.h>
113 +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
115 +struct ssb_ohci_device {
116 + struct ohci_hcd ohci; /* _must_ be at the beginning. */
122 +struct ssb_ohci_device *hcd_to_ssb_ohci(struct usb_hcd *hcd)
124 + return (struct ssb_ohci_device *)(hcd->hcd_priv);
128 +static int ssb_ohci_reset(struct usb_hcd *hcd)
130 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
131 + struct ohci_hcd *ohci = &ohcidev->ohci;
134 + ohci_hcd_init(ohci);
135 + err = ohci_init(ohci);
140 +static int ssb_ohci_start(struct usb_hcd *hcd)
142 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
143 + struct ohci_hcd *ohci = &ohcidev->ohci;
146 + err = ohci_run(ohci);
148 + ohci_err(ohci, "can't start\n");
156 +static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
158 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
159 + struct ohci_hcd *ohci = &ohcidev->ohci;
160 + unsigned long flags;
162 + spin_lock_irqsave(&ohci->lock, flags);
164 + ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
165 + ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */
167 + /* make sure snapshot being resumed re-enumerates everything */
168 + if (message.event == PM_EVENT_PRETHAW)
169 + ohci_usb_reset(ohci);
171 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
173 + spin_unlock_irqrestore(&ohci->lock, flags);
177 +static int ssb_ohci_hcd_resume(struct usb_hcd *hcd)
179 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
180 + usb_hcd_resume_root_hub(hcd);
183 +#endif /* CONFIG_PM */
185 +static const struct hc_driver ssb_ohci_hc_driver = {
186 + .description = "ssb-usb-ohci",
187 + .product_desc = "SSB OHCI Controller",
188 + .hcd_priv_size = sizeof(struct ssb_ohci_device),
191 + .flags = HCD_MEMORY | HCD_USB11,
193 + .reset = ssb_ohci_reset,
194 + .start = ssb_ohci_start,
196 + .shutdown = ohci_shutdown,
199 + .suspend = ssb_ohci_hcd_suspend,
200 + .resume = ssb_ohci_hcd_resume,
203 + .urb_enqueue = ohci_urb_enqueue,
204 + .urb_dequeue = ohci_urb_dequeue,
205 + .endpoint_disable = ohci_endpoint_disable,
207 + .get_frame_number = ohci_get_frame,
209 + .hub_status_data = ohci_hub_status_data,
210 + .hub_control = ohci_hub_control,
211 + .hub_irq_enable = ohci_rhsc_enable,
212 + .bus_suspend = ohci_bus_suspend,
213 + .bus_resume = ohci_bus_resume,
215 + .start_port_reset = ohci_start_port_reset,
218 +static void ssb_ohci_detach(struct ssb_device *dev)
220 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
222 + usb_remove_hcd(hcd);
223 + iounmap(hcd->regs);
225 + ssb_device_disable(dev, 0);
228 +static int ssb_ohci_attach(struct ssb_device *dev)
230 + struct ssb_ohci_device *ohcidev;
231 + struct usb_hcd *hcd;
233 + u32 tmp, flags = 0;
235 + if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV)
236 + flags |= SSB_OHCI_TMSLOW_HOSTMODE;
238 + ssb_device_enable(dev, flags);
240 + hcd = usb_create_hcd(&ssb_ohci_hc_driver, dev->dev,
243 + goto err_dev_disable;
244 + ohcidev = hcd_to_ssb_ohci(hcd);
245 + ohcidev->enable_flags = flags;
247 + tmp = ssb_read32(dev, SSB_ADMATCH0);
248 + hcd->rsrc_start = ssb_admatch_base(tmp);
249 + hcd->rsrc_len = ssb_admatch_size(tmp);
250 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
253 + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED);
257 + ssb_set_drvdata(dev, hcd);
262 + iounmap(hcd->regs);
266 + ssb_device_disable(dev, flags);
270 +static int ssb_ohci_probe(struct ssb_device *dev,
271 + const struct ssb_device_id *id)
276 + /* USBcores are only connected on embedded devices. */
277 + chipid_top = (dev->bus->chip_id & 0xFF00);
278 + if (chipid_top != 0x4700 && chipid_top != 0x5300)
281 + /* TODO: Probably need checks here; is the core connected? */
283 + if (usb_disabled())
286 + /* We currently always attach SSB_DEV_USB11_HOSTDEV
287 + * as HOST OHCI. If we want to attach it as Client device,
288 + * we must branch here and call into the (yet to
289 + * be written) Client mode driver. Same for remove(). */
291 + err = ssb_ohci_attach(dev);
296 +static void ssb_ohci_remove(struct ssb_device *dev)
298 + ssb_ohci_detach(dev);
303 +static int ssb_ohci_suspend(struct ssb_device *dev, pm_message_t state)
305 + ssb_device_disable(dev, 0);
310 +static int ssb_ohci_resume(struct ssb_device *dev)
312 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
313 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
315 + ssb_device_enable(dev, ohcidev->enable_flags);
320 +#else /* !CONFIG_PM */
321 +#define ssb_ohci_suspend NULL
322 +#define ssb_ohci_resume NULL
323 +#endif /* CONFIG_PM */
325 +static const struct ssb_device_id ssb_ohci_table[] = {
326 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV),
327 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV),
330 +MODULE_DEVICE_TABLE(ssb, ssb_ohci_table);
332 +static struct ssb_driver ssb_ohci_driver = {
333 + .name = KBUILD_MODNAME,
334 + .id_table = ssb_ohci_table,
335 + .probe = ssb_ohci_probe,
336 + .remove = ssb_ohci_remove,
337 + .suspend = ssb_ohci_suspend,
338 + .resume = ssb_ohci_resume,