1 --- a/drivers/usb/host/Kconfig
2 +++ b/drivers/usb/host/Kconfig
3 @@ -96,6 +96,19 @@ config USB_EHCI_HCD_PPC_OF
4 Enables support for the USB controller present on the PowerPC
5 OpenFirmware platform bus.
7 +config USB_EHCI_HCD_SSB
8 + bool "EHCI support for Broadcom SSB EHCI core"
9 + depends on USB_EHCI_HCD && SSB && 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 @@ -1036,8 +1036,16 @@ MODULE_LICENSE ("GPL");
26 #define PLATFORM_DRIVER ixp4xx_ehci_driver
29 -#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
30 - !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
31 +#ifdef CONFIG_USB_EHCI_HCD_SSB
32 +#include "ehci-ssb.c"
33 +#define SSB_EHCI_DRIVER ssb_ehci_driver
36 +#if !defined(PCI_DRIVER) && \
37 + !defined(PLATFORM_DRIVER) && \
38 + !defined(PS3_SYSTEM_BUS_DRIVER) && \
39 + !defined(OF_PLATFORM_DRIVER) && \
40 + !defined(SSB_EHCI_DRIVER)
41 #error "missing bus glue for ehci-hcd"
45 +++ b/drivers/usb/host/ehci-ssb.c
48 + * Sonics Silicon Backplane
49 + * Broadcom USB-core EHCI driver (SSB bus glue)
51 + * Copyright 2007 Steven Brown <sbrown@cortland.com>
53 + * Derived from the OHCI-SSB driver
54 + * Copyright 2007 Michael Buesch <mb@bu3sch.de>
56 + * Derived from the EHCI-PCI driver
57 + * Copyright (c) 2000-2004 by David Brownell
59 + * Derived from the OHCI-PCI driver
60 + * Copyright 1999 Roman Weissgaerber
61 + * Copyright 2000-2002 David Brownell
62 + * Copyright 1999 Linus Torvalds
63 + * Copyright 1999 Gregory P. Smith
65 + * Derived from the USBcore related parts of Broadcom-SB
66 + * Copyright 2005 Broadcom Corporation
68 + * Licensed under the GNU/GPL. See COPYING for details.
70 +#include <linux/ssb/ssb.h>
72 +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
74 +struct ssb_ehci_device {
75 + struct ehci_hcd ehci; /* _must_ be at the beginning. */
81 +struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd)
83 + return (struct ssb_ehci_device *)(hcd->hcd_priv);
87 +static int ssb_ehci_reset(struct usb_hcd *hcd)
89 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
92 + ehci->caps = hcd->regs;
93 + ehci->regs = hcd->regs +
94 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
96 + dbg_hcs_params(ehci, "reset");
97 + dbg_hcc_params(ehci, "reset");
99 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
101 + err = ehci_halt(ehci);
106 + err = ehci_init(hcd);
111 + ehci_port_power(ehci, 0);
116 +static int ssb_ehci_start(struct usb_hcd *hcd)
118 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
121 + err = ehci_run(hcd);
123 + ehci_err(ehci, "can't start\n");
131 +static int ssb_ehci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
133 + struct ssb_ehci_device *ehcidev = hcd_to_ssb_ehci(hcd);
134 + struct ehci_hcd *ehci = &ehcidev->ehci;
135 + unsigned long flags;
137 + spin_lock_irqsave(&ehci->lock, flags);
139 + ehci_writel(ehci, EHCI_INTR_MIE, &ehci->regs->intrdisable);
140 + ehci_readl(ehci, &ehci->regs->intrdisable); /* commit write */
142 + /* make sure snapshot being resumed re-enumerates everything */
143 + if (message.event == PM_EVENT_PRETHAW)
144 + ehci_usb_reset(ehci);
146 + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
148 + spin_unlock_irqrestore(&ehci->lock, flags);
152 +static int ssb_ehci_hcd_resume(struct usb_hcd *hcd)
154 + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
155 + usb_hcd_resume_root_hub(hcd);
158 +#endif /* CONFIG_PM */
160 +static const struct hc_driver ssb_ehci_hc_driver = {
161 + .description = "ssb-usb-ehci",
162 + .product_desc = "SSB EHCI Controller",
163 + .hcd_priv_size = sizeof(struct ssb_ehci_device),
166 + .flags = HCD_MEMORY | HCD_USB2,
168 + .reset = ssb_ehci_reset,
169 + .start = ssb_ehci_start,
171 + .shutdown = ehci_shutdown,
174 + .suspend = ssb_ehci_hcd_suspend,
175 + .resume = ssb_ehci_hcd_resume,
178 + .urb_enqueue = ehci_urb_enqueue,
179 + .urb_dequeue = ehci_urb_dequeue,
180 + .endpoint_disable = ehci_endpoint_disable,
182 + .get_frame_number = ehci_get_frame,
184 + .hub_status_data = ehci_hub_status_data,
185 + .hub_control = ehci_hub_control,
187 + .bus_suspend = ehci_bus_suspend,
188 + .bus_resume = ehci_bus_resume,
193 +static void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd)
196 + usb_remove_hcd(hcd);
197 + iounmap(hcd->regs);
200 +EXPORT_SYMBOL_GPL(ssb_ehci_detach);
202 +static int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **ehci_hcd)
204 + struct ssb_ehci_device *ehcidev;
205 + struct usb_hcd *hcd;
207 + u32 tmp, flags = 0;
209 + hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev,
212 + goto err_dev_disable;
214 + ehcidev = hcd_to_ssb_ehci(hcd);
215 + ehcidev->enable_flags = flags;
216 + tmp = ssb_read32(dev, SSB_ADMATCH0);
217 + hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */
218 + hcd->rsrc_len = 0x100; /* ehci reg block size */
220 + * start & size modified per sbutils.c
222 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
225 + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED | IRQF_DISABLED);
234 + iounmap(hcd->regs);
238 + ssb_device_disable(dev, flags);
241 +EXPORT_SYMBOL_GPL(ssb_ehci_attach);
243 +static const struct ssb_device_id ssb_ehci_table[] = {
244 + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV),
247 +MODULE_DEVICE_TABLE(ssb, ssb_ehci_table);
248 --- a/drivers/usb/host/ohci-ssb.c
249 +++ b/drivers/usb/host/ohci-ssb.c
252 #include <linux/ssb/ssb.h>
254 +extern int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **hcd);
255 +extern void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd);
257 #define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29)
259 @@ -24,6 +26,7 @@ struct ssb_ohci_device {
260 struct ohci_hcd ohci; /* _must_ be at the beginning. */
263 + struct usb_hcd *ehci_hcd;
267 @@ -92,13 +95,25 @@ static const struct hc_driver ssb_ohci_h
268 static void ssb_ohci_detach(struct ssb_device *dev)
270 struct usb_hcd *hcd = ssb_get_drvdata(dev);
271 +#ifdef CONFIG_USB_EHCI_HCD_SSB
272 + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd);
279 +#ifdef CONFIG_USB_EHCI_HCD_SSB
281 + * Also detach ehci function
283 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
284 + ssb_ehci_detach(dev, ohcidev->ehci_hcd);
286 ssb_device_disable(dev, 0);
290 static int ssb_ohci_attach(struct ssb_device *dev)
292 struct ssb_ohci_device *ohcidev;
293 @@ -184,6 +199,14 @@ static int ssb_ohci_attach(struct ssb_de
295 ssb_set_drvdata(dev, hcd);
297 +#ifdef CONFIG_USB_EHCI_HCD_SSB
299 + * attach ehci function in this core
301 + if (dev->id.coreid == SSB_DEV_USB20_HOST)
302 + err = ssb_ehci_attach(dev, &(ohcidev->ehci_hcd));