1 --- a/drivers/usb/host/Kconfig
2 +++ b/drivers/usb/host/Kconfig
3 @@ -215,6 +215,19 @@ config USB_OXU210HP_HCD
4 To compile this driver as a module, choose M here: the
5 module will be called oxu210hp-hcd.
7 +config USB_EHCI_HCD_SSB
8 + bool "EHCI support for Broadcom SSB EHCI core"
9 + depends on USB_EHCI_HCD && (SSB = y || SSB = USB_EHCI_HCD) && EXPERIMENTAL
12 + Support for the Sonics Silicon Backplane (SSB) attached
13 + Broadcom USB EHCI core.
15 + This device is present in some embedded devices with
16 + Broadcom based SSB bus.
20 config USB_ISP116X_HCD
21 tristate "ISP116X HCD support"
23 --- a/drivers/usb/host/ehci-hcd.c
24 +++ b/drivers/usb/host/ehci-hcd.c
25 @@ -1267,9 +1267,14 @@ MODULE_LICENSE ("GPL");
26 #define PLATFORM_DRIVER tegra_ehci_driver
29 +#ifdef CONFIG_USB_EHCI_HCD_SSB
30 +#include "ehci-ssb.c"
31 +#define SSB_EHCI_DRIVER ssb_ehci_driver
34 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
35 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
36 - !defined(XILINX_OF_PLATFORM_DRIVER)
37 + !defined(XILINX_OF_PLATFORM_DRIVER) && !defined(SSB_EHCI_DRIVER)
38 #error "missing bus glue for ehci-hcd"
41 @@ -1329,10 +1334,20 @@ static int __init ehci_hcd_init(void)
46 +#ifdef SSB_EHCI_DRIVER
47 + retval = ssb_driver_register(&SSB_EHCI_DRIVER);
53 +#ifdef SSB_EHCI_DRIVER
54 + /* ssb_driver_unregister(&SSB_EHCI_DRIVER); */
57 #ifdef XILINX_OF_PLATFORM_DRIVER
58 - /* platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER); */
59 + platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER);
62 #ifdef OF_PLATFORM_DRIVER
63 @@ -1363,6 +1378,9 @@ module_init(ehci_hcd_init);
65 static void __exit ehci_hcd_cleanup(void)
67 +#ifdef SSB_EHCI_DRIVER
68 + ssb_driver_unregister(&SSB_EHCI_DRIVER);
70 #ifdef XILINX_OF_PLATFORM_DRIVER
71 platform_driver_unregister(&XILINX_OF_PLATFORM_DRIVER);
74 +++ b/drivers/usb/host/ehci-ssb.c
77 + * Sonics Silicon Backplane
78 + * Broadcom USB-core EHCI driver (SSB bus glue)
80 + * Copyright 2007 Steven Brown <sbrown@cortland.com>
81 + * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
83 + * Derived from the OHCI-SSB driver
84 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
86 + * Derived from the EHCI-PCI driver
87 + * Copyright (c) 2000-2004 by David Brownell
89 + * Derived from the OHCI-PCI driver
90 + * Copyright 1999 Roman Weissgaerber
91 + * Copyright 2000-2002 David Brownell
92 + * Copyright 1999 Linus Torvalds
93 + * Copyright 1999 Gregory P. Smith
95 + * Derived from the USBcore related parts of Broadcom-SB
96 + * Copyright 2005 Broadcom Corporation
98 + * Licensed under the GNU/GPL. See COPYING for details.
100 +#include <linux/ssb/ssb.h>
103 +struct ssb_ehci_device {
104 + struct ehci_hcd ehci; /* _must_ be at the beginning. */
108 +struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd)
110 + return (struct ssb_ehci_device *)(hcd->hcd_priv);
113 +static int ssb_ehci_reset(struct usb_hcd *hcd)
115 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
118 + ehci->caps = hcd->regs;
119 + ehci->regs = hcd->regs +
120 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
122 + dbg_hcs_params(ehci, "reset");
123 + dbg_hcc_params(ehci, "reset");
125 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
127 + err = ehci_halt(ehci);
132 + err = ehci_init(hcd);
142 +static const struct hc_driver ssb_ehci_hc_driver = {
143 + .description = "ssb-usb-ehci",
144 + .product_desc = "SSB EHCI Controller",
145 + .hcd_priv_size = sizeof(struct ssb_ehci_device),
148 + .flags = HCD_MEMORY | HCD_USB2,
150 + .reset = ssb_ehci_reset,
153 + .shutdown = ehci_shutdown,
155 + .urb_enqueue = ehci_urb_enqueue,
156 + .urb_dequeue = ehci_urb_dequeue,
157 + .endpoint_disable = ehci_endpoint_disable,
158 + .endpoint_reset = ehci_endpoint_reset,
160 + .get_frame_number = ehci_get_frame,
162 + .hub_status_data = ehci_hub_status_data,
163 + .hub_control = ehci_hub_control,
164 +#if defined(CONFIG_PM)
165 + .bus_suspend = ehci_bus_suspend,
166 + .bus_resume = ehci_bus_resume,
168 + .relinquish_port = ehci_relinquish_port,
169 + .port_handed_over = ehci_port_handed_over,
171 + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
174 +static void ssb_ehci_detach(struct ssb_device *dev)
176 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
178 + if (hcd->driver->shutdown)
179 + hcd->driver->shutdown(hcd);
180 + usb_remove_hcd(hcd);
181 + iounmap(hcd->regs);
182 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
184 + ssb_device_disable(dev, 0);
187 +static int ssb_ehci_attach(struct ssb_device *dev)
189 + struct ssb_ehci_device *ehcidev;
190 + struct usb_hcd *hcd;
194 + if (dma_set_mask(dev->dma_dev, DMA_BIT_MASK(32)) ||
195 + dma_set_coherent_mask(dev->dma_dev, DMA_BIT_MASK(32)))
196 + return -EOPNOTSUPP;
199 + * USB 2.0 special considerations:
201 + * In addition to the standard SSB reset sequence, the Host Control
202 + * Register must be programmed to bring the USB core and various phy
203 + * components out of reset.
205 + ssb_device_enable(dev, 0);
206 + ssb_write32(dev, 0x200, 0x7ff);
208 + /* Change Flush control reg */
209 + tmp = ssb_read32(dev, 0x400);
211 + ssb_write32(dev, 0x400, tmp);
212 + tmp = ssb_read32(dev, 0x400);
214 + /* Change Shim control reg */
215 + tmp = ssb_read32(dev, 0x304);
217 + ssb_write32(dev, 0x304, tmp);
218 + tmp = ssb_read32(dev, 0x304);
222 + /* Work around for 5354 failures */
223 + if (dev->id.revision == 2 && dev->bus->chip_id == 0x5354) {
224 + /* Change syn01 reg */
226 + ssb_write32(dev, 0x894, tmp);
228 + /* Change syn03 reg */
229 + tmp = ssb_read32(dev, 0x89c);
231 + ssb_write32(dev, 0x89c, tmp);
234 + hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev,
235 + dev_name(dev->dev));
237 + goto err_dev_disable;
239 + ehcidev = hcd_to_ssb_ehci(hcd);
240 + tmp = ssb_read32(dev, SSB_ADMATCH0);
241 + hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */
242 + hcd->rsrc_len = 0x100; /* ehci reg block size */
244 + * start & size modified per sbutils.c
246 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
249 + err = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED);
253 + ssb_set_drvdata(dev, hcd);
258 + iounmap(hcd->regs);
262 + ssb_device_disable(dev, 0);
266 +static int ssb_ehci_probe(struct ssb_device *dev,
267 + const struct ssb_device_id *id)
272 + /* USBcores are only connected on embedded devices. */
273 + chipid_top = (dev->bus->chip_id & 0xFF00);
274 + if (chipid_top != 0x4700 && chipid_top != 0x5300)
277 + /* TODO: Probably need checks here; is the core connected? */
279 + if (usb_disabled())
282 + err = ssb_ehci_attach(dev);
287 +static void ssb_ehci_remove(struct ssb_device *dev)
289 + ssb_ehci_detach(dev);
294 +static int ssb_ehci_suspend(struct ssb_device *dev, pm_message_t state)
296 + ssb_device_disable(dev, 0);
301 +static int ssb_ehci_resume(struct ssb_device *dev)
303 + struct usb_hcd *hcd = ssb_get_drvdata(dev);
304 + struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd);
306 + ssb_device_enable(dev, 0);
308 + ehci_finish_controller_resume(hcd);
312 +#else /* !CONFIG_PM */
313 +#define ssb_ehci_suspend NULL
314 +#define ssb_ehci_resume NULL
315 +#endif /* CONFIG_PM */
317 +static const struct ssb_device_id ssb_ehci_table[] = {
318 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV),
321 +MODULE_DEVICE_TABLE(ssb, ssb_ehci_table);
323 +static struct ssb_driver ssb_ehci_driver = {
324 + .name = KBUILD_MODNAME,
325 + .id_table = ssb_ehci_table,
326 + .probe = ssb_ehci_probe,
327 + .remove = ssb_ehci_remove,
328 + .suspend = ssb_ehci_suspend,
329 + .resume = ssb_ehci_resume,