1 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
2 --- a/drivers/usb/host/Kconfig
3 +++ b/drivers/usb/host/Kconfig
4 @@ -96,6 +96,19 @@ config USB_EHCI_HCD_PPC_OF
5 Enables support for the USB controller present on the PowerPC
6 OpenFirmware platform bus.
8 +config USB_EHCI_HCD_SSB
9 + bool "EHCI support for Broadcom SSB EHCI core"
10 + depends on USB_EHCI_HCD && SSB && EXPERIMENTAL
13 + Support for the Sonics Silicon Backplane (SSB) attached
14 + Broadcom USB EHCI core.
16 + This device is present in some embedded devices with
17 + Broadcom based SSB bus.
21 config USB_ISP116X_HCD
22 tristate "ISP116X HCD support"
24 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
25 --- a/drivers/usb/host/ehci-hcd.c
26 +++ b/drivers/usb/host/ehci-hcd.c
27 @@ -1034,8 +1034,16 @@ MODULE_LICENSE ("GPL");
28 #define PLATFORM_DRIVER ixp4xx_ehci_driver
31 -#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
32 - !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
33 +#ifdef CONFIG_USB_EHCI_HCD_SSB
34 +#include "ehci-ssb.c"
35 +#define SSB_EHCI_DRIVER ssb_ehci_driver
38 +#if !defined(PCI_DRIVER) && \
39 + !defined(PLATFORM_DRIVER) && \
40 + !defined(PS3_SYSTEM_BUS_DRIVER) && \
41 + !defined(OF_PLATFORM_DRIVER) && \
42 + !defined(SSB_EHCI_DRIVER)
43 #error "missing bus glue for ehci-hcd"
46 diff --git a/drivers/usb/host/ehci-ssb.c b/drivers/usb/host/ehci-ssb.c
48 +++ b/drivers/usb/host/ehci-ssb.c
51 + * Sonics Silicon Backplane
52 + * Broadcom USB-core EHCI driver (SSB bus glue)
54 + * Copyright 2007 Steven Brown <sbrown@cortland.com>
56 + * Derived from the OHCI-SSB driver
57 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
59 + * Derived from the EHCI-PCI driver
60 + * Copyright (c) 2000-2004 by David Brownell
62 + * Derived from the OHCI-PCI driver
63 + * Copyright 1999 Roman Weissgaerber
64 + * Copyright 2000-2002 David Brownell
65 + * Copyright 1999 Linus Torvalds
66 + * Copyright 1999 Gregory P. Smith
68 + * Derived from the USBcore related parts of Broadcom-SB
69 + * Copyright 2005 Broadcom Corporation
71 + * Licensed under the GNU/GPL. See COPYING for details.
73 +#include <linux/ssb/ssb.h>
75 +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
77 +struct ssb_ehci_device {
78 + struct ehci_hcd ehci; /* _must_ be at the beginning. */
84 +struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd)
86 + return (struct ssb_ehci_device *)(hcd->hcd_priv);
90 +static int ssb_ehci_reset(struct usb_hcd *hcd)
92 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
95 + ehci->caps = hcd->regs;
96 + ehci->regs = hcd->regs +
97 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
99 + dbg_hcs_params(ehci, "reset");
100 + dbg_hcc_params(ehci, "reset");
102 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
104 + err = ehci_halt(ehci);
109 + err = ehci_init(hcd);
114 + ehci_port_power(ehci, 0);
119 +static int ssb_ehci_start(struct usb_hcd *hcd)
121 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
124 + err = ehci_run(hcd);
126 + ehci_err(ehci, "can't start\n");
134 +static int ssb_ehci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
136 + struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd);
137 + struct ehci_hcd *ehci = &ehcidev->ehci;
138 + unsigned long flags;
140 + spin_lock_irqsave(&ehci->lock, flags);
142 + ehci_writel(ehci, EHCI_INTR_MIE, &ehci->regs->intrdisable);
143 + ehci_readl(ehci, &ehci->regs->intrdisable); /* commit write */
145 + /* make sure snapshot being resumed re-enumerates everything */
146 + if (message.event == PM_EVENT_PRETHAW)
147 + ehci_usb_reset(ehci);
149 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
151 + spin_unlock_irqrestore(&ehci->lock, flags);
155 +static int ssb_ehci_hcd_resume(struct usb_hcd *hcd)
157 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
158 + usb_hcd_resume_root_hub(hcd);
161 +#endif /* CONFIG_PM */
163 +static const struct hc_driver ssb_ehci_hc_driver = {
164 + .description = "ssb-usb-ehci",
165 + .product_desc = "SSB EHCI Controller",
166 + .hcd_priv_size = sizeof(struct ssb_ehci_device),
169 + .flags = HCD_MEMORY | HCD_USB2,
171 + .reset = ssb_ehci_reset,
172 + .start = ssb_ehci_start,
174 + .shutdown = ehci_shutdown,
177 + .suspend = ssb_ehci_hcd_suspend,
178 + .resume = ssb_ehci_hcd_resume,
181 + .urb_enqueue = ehci_urb_enqueue,
182 + .urb_dequeue = ehci_urb_dequeue,
183 + .endpoint_disable = ehci_endpoint_disable,
185 + .get_frame_number = ehci_get_frame,
187 + .hub_status_data = ehci_hub_status_data,
188 + .hub_control = ehci_hub_control,
190 + .bus_suspend = ehci_bus_suspend,
191 + .bus_resume = ehci_bus_resume,
196 +static void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd)
199 + usb_remove_hcd(hcd);
200 + iounmap(hcd->regs);
203 +EXPORT_SYMBOL_GPL(ssb_ehci_detach);
205 +static int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **ehci_hcd)
207 + struct ssb_ehci_device *ehcidev;
208 + struct usb_hcd *hcd;
210 + u32 tmp, flags = 0;
212 + hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev,
215 + goto err_dev_disable;
217 + ehcidev = hcd_to_ssb_ehci(hcd);
218 + ehcidev->enable_flags = flags;
219 + tmp = ssb_read32(dev, SSB_ADMATCH0);
220 + hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */
221 + hcd->rsrc_len = 0x100; /* ehci reg block size */
223 + * start & size modified per sbutils.c
225 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
228 + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED | IRQF_DISABLED);
237 + iounmap(hcd->regs);
241 + ssb_device_disable(dev, flags);
244 +EXPORT_SYMBOL_GPL(ssb_ehci_attach);
246 +static const struct ssb_device_id ssb_ehci_table[] = {
247 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV),
250 +MODULE_DEVICE_TABLE(ssb, ssb_ehci_table);
251 diff --git a/drivers/usb/host/ohci-ssb.c b/drivers/usb/host/ohci-ssb.c
252 --- a/drivers/usb/host/ohci-ssb.c
253 +++ b/drivers/usb/host/ohci-ssb.c
256 #include <linux/ssb/ssb.h>
258 +extern int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **hcd);
259 +extern void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd);
261 #define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
263 @@ -24,6 +26,7 @@ struct ssb_ohci_device {
264 struct ohci_hcd ohci; /* _must_ be at the beginning. */
267 + struct usb_hcd *ehci_hcd;
271 @@ -92,13 +95,25 @@ static const struct hc_driver ssb_ohci_hc_driver = {
272 static void ssb_ohci_detach(struct ssb_device *dev)
274 struct usb_hcd *hcd = ssb_get_drvdata(dev);
275 +#ifdef CONFIG_USB_EHCI_HCD_SSB
276 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
283 +#ifdef CONFIG_USB_EHCI_HCD_SSB
285 + * Also detach ehci function
287 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
288 + ssb_ehci_detach(dev, ohcidev->ehci_hcd);
290 ssb_device_disable(dev, 0);
294 static int ssb_ohci_attach(struct ssb_device *dev)
296 struct ssb_ohci_device *ohcidev;
297 @@ -184,6 +199,14 @@ static int ssb_ohci_attach(struct ssb_device *dev)
299 ssb_set_drvdata(dev, hcd);
301 +#ifdef CONFIG_USB_EHCI_HCD_SSB
303 + * attach ehci function in this core
305 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
306 + err = ssb_ehci_attach(dev, &(ohcidev->ehci_hcd));