| 1 | --- |
| 2 | drivers/usb/host/Kconfig | 13 ++ |
| 3 | drivers/usb/host/ehci-hcd.c | 12 ++ |
| 4 | drivers/usb/host/ehci-ssb.c | 201 ++++++++++++++++++++++++++++++++++++++++++++ |
| 5 | drivers/usb/host/ohci-ssb.c | 23 +++++ |
| 6 | 4 files changed, 247 insertions(+), 2 deletions(-) |
| 7 | |
| 8 | --- a/drivers/usb/host/Kconfig |
| 9 | +++ b/drivers/usb/host/Kconfig |
| 10 | @@ -132,6 +132,19 @@ config USB_OXU210HP_HCD |
| 11 | To compile this driver as a module, choose M here: the |
| 12 | module will be called oxu210hp-hcd. |
| 13 | |
| 14 | +config USB_EHCI_HCD_SSB |
| 15 | + bool "EHCI support for Broadcom SSB EHCI core" |
| 16 | + depends on USB_EHCI_HCD && SSB && EXPERIMENTAL |
| 17 | + default n |
| 18 | + ---help--- |
| 19 | + Support for the Sonics Silicon Backplane (SSB) attached |
| 20 | + Broadcom USB EHCI core. |
| 21 | + |
| 22 | + This device is present in some embedded devices with |
| 23 | + Broadcom based SSB bus. |
| 24 | + |
| 25 | + If unsure, say N. |
| 26 | + |
| 27 | config USB_ISP116X_HCD |
| 28 | tristate "ISP116X HCD support" |
| 29 | depends on USB |
| 30 | --- a/drivers/usb/host/ehci-hcd.c |
| 31 | +++ b/drivers/usb/host/ehci-hcd.c |
| 32 | @@ -1142,8 +1142,16 @@ MODULE_LICENSE ("GPL"); |
| 33 | #define PLATFORM_DRIVER ehci_atmel_driver |
| 34 | #endif |
| 35 | |
| 36 | -#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
| 37 | - !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) |
| 38 | +#ifdef CONFIG_USB_EHCI_HCD_SSB |
| 39 | +#include "ehci-ssb.c" |
| 40 | +#define SSB_EHCI_DRIVER ssb_ehci_driver |
| 41 | +#endif |
| 42 | + |
| 43 | +#if !defined(PCI_DRIVER) && \ |
| 44 | + !defined(PLATFORM_DRIVER) && \ |
| 45 | + !defined(PS3_SYSTEM_BUS_DRIVER) && \ |
| 46 | + !defined(OF_PLATFORM_DRIVER) && \ |
| 47 | + !defined(SSB_EHCI_DRIVER) |
| 48 | #error "missing bus glue for ehci-hcd" |
| 49 | #endif |
| 50 | |
| 51 | --- /dev/null |
| 52 | +++ b/drivers/usb/host/ehci-ssb.c |
| 53 | @@ -0,0 +1,158 @@ |
| 54 | +/* |
| 55 | + * Sonics Silicon Backplane |
| 56 | + * Broadcom USB-core EHCI driver (SSB bus glue) |
| 57 | + * |
| 58 | + * Copyright 2007 Steven Brown <sbrown@cortland.com> |
| 59 | + * |
| 60 | + * Derived from the OHCI-SSB driver |
| 61 | + * Copyright 2007 Michael Buesch <mb@bu3sch.de> |
| 62 | + * |
| 63 | + * Derived from the EHCI-PCI driver |
| 64 | + * Copyright (c) 2000-2004 by David Brownell |
| 65 | + * |
| 66 | + * Derived from the OHCI-PCI driver |
| 67 | + * Copyright 1999 Roman Weissgaerber |
| 68 | + * Copyright 2000-2002 David Brownell |
| 69 | + * Copyright 1999 Linus Torvalds |
| 70 | + * Copyright 1999 Gregory P. Smith |
| 71 | + * |
| 72 | + * Derived from the USBcore related parts of Broadcom-SB |
| 73 | + * Copyright 2005 Broadcom Corporation |
| 74 | + * |
| 75 | + * Licensed under the GNU/GPL. See COPYING for details. |
| 76 | + */ |
| 77 | +#include <linux/ssb/ssb.h> |
| 78 | + |
| 79 | +#define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29) |
| 80 | + |
| 81 | +struct ssb_ehci_device { |
| 82 | + struct ehci_hcd ehci; /* _must_ be at the beginning. */ |
| 83 | + |
| 84 | + u32 enable_flags; |
| 85 | +}; |
| 86 | + |
| 87 | +static inline |
| 88 | +struct ssb_ehci_device *hcd_to_ssb_ehci(struct usb_hcd *hcd) |
| 89 | +{ |
| 90 | + return (struct ssb_ehci_device *)(hcd->hcd_priv); |
| 91 | +} |
| 92 | + |
| 93 | +static int ssb_ehci_reset(struct usb_hcd *hcd) |
| 94 | +{ |
| 95 | + struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
| 96 | + int err; |
| 97 | + |
| 98 | + ehci->caps = hcd->regs; |
| 99 | + ehci->regs = hcd->regs + |
| 100 | + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase)); |
| 101 | + |
| 102 | + dbg_hcs_params(ehci, "reset"); |
| 103 | + dbg_hcc_params(ehci, "reset"); |
| 104 | + |
| 105 | + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); |
| 106 | + |
| 107 | + err = ehci_halt(ehci); |
| 108 | + |
| 109 | + if (err) |
| 110 | + return err; |
| 111 | + |
| 112 | + err = ehci_init(hcd); |
| 113 | + |
| 114 | + if (err) |
| 115 | + return err; |
| 116 | + |
| 117 | + ehci_reset(ehci); |
| 118 | + |
| 119 | + return err; |
| 120 | +} |
| 121 | + |
| 122 | +static const struct hc_driver ssb_ehci_hc_driver = { |
| 123 | + .description = "ssb-usb-ehci", |
| 124 | + .product_desc = "SSB EHCI Controller", |
| 125 | + .hcd_priv_size = sizeof(struct ssb_ehci_device), |
| 126 | + |
| 127 | + .irq = ehci_irq, |
| 128 | + .flags = HCD_MEMORY | HCD_USB2, |
| 129 | + |
| 130 | + .reset = ssb_ehci_reset, |
| 131 | + .start = ehci_run, |
| 132 | + .stop = ehci_stop, |
| 133 | + .shutdown = ehci_shutdown, |
| 134 | + |
| 135 | + .urb_enqueue = ehci_urb_enqueue, |
| 136 | + .urb_dequeue = ehci_urb_dequeue, |
| 137 | + .endpoint_disable = ehci_endpoint_disable, |
| 138 | + .endpoint_reset = ehci_endpoint_reset, |
| 139 | + |
| 140 | + .get_frame_number = ehci_get_frame, |
| 141 | + |
| 142 | + .hub_status_data = ehci_hub_status_data, |
| 143 | + .hub_control = ehci_hub_control, |
| 144 | + .bus_suspend = ehci_bus_suspend, |
| 145 | + .bus_resume = ehci_bus_resume, |
| 146 | + .relinquish_port = ehci_relinquish_port, |
| 147 | + .port_handed_over = ehci_port_handed_over, |
| 148 | + |
| 149 | + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
| 150 | +}; |
| 151 | + |
| 152 | +static void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd) |
| 153 | +{ |
| 154 | + if (hcd->driver->shutdown) |
| 155 | + hcd->driver->shutdown(hcd); |
| 156 | + |
| 157 | + usb_remove_hcd(hcd); |
| 158 | + |
| 159 | + iounmap(hcd->regs); |
| 160 | + release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
| 161 | + |
| 162 | + usb_put_hcd(hcd); |
| 163 | +} |
| 164 | +EXPORT_SYMBOL_GPL(ssb_ehci_detach); |
| 165 | + |
| 166 | +static int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **ehci_hcd) |
| 167 | +{ |
| 168 | + struct ssb_ehci_device *ehcidev; |
| 169 | + struct usb_hcd *hcd; |
| 170 | + int err = -ENOMEM; |
| 171 | + u32 tmp, flags = 0; |
| 172 | + |
| 173 | + hcd = usb_create_hcd(&ssb_ehci_hc_driver, dev->dev, |
| 174 | + dev_name(dev->dev)); |
| 175 | + if (!hcd) |
| 176 | + goto err_dev_disable; |
| 177 | + |
| 178 | + ehcidev = hcd_to_ssb_ehci(hcd); |
| 179 | + ehcidev->enable_flags = flags; |
| 180 | + tmp = ssb_read32(dev, SSB_ADMATCH0); |
| 181 | + hcd->rsrc_start = ssb_admatch_base(tmp) + 0x800; /* ehci core offset */ |
| 182 | + hcd->rsrc_len = 0x100; /* ehci reg block size */ |
| 183 | + /* |
| 184 | + * start & size modified per sbutils.c |
| 185 | + */ |
| 186 | + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); |
| 187 | + if (!hcd->regs) |
| 188 | + goto err_put_hcd; |
| 189 | + err = usb_add_hcd(hcd, dev->irq, IRQF_SHARED | IRQF_DISABLED); |
| 190 | + if (err) |
| 191 | + goto err_iounmap; |
| 192 | + |
| 193 | + *ehci_hcd = hcd; |
| 194 | + |
| 195 | + return err; |
| 196 | + |
| 197 | +err_iounmap: |
| 198 | + iounmap(hcd->regs); |
| 199 | +err_put_hcd: |
| 200 | + usb_put_hcd(hcd); |
| 201 | +err_dev_disable: |
| 202 | + ssb_device_disable(dev, flags); |
| 203 | + return err; |
| 204 | +} |
| 205 | +EXPORT_SYMBOL_GPL(ssb_ehci_attach); |
| 206 | + |
| 207 | +static const struct ssb_device_id ssb_ehci_table[] = { |
| 208 | + SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), |
| 209 | + SSB_DEVTABLE_END |
| 210 | +}; |
| 211 | +MODULE_DEVICE_TABLE(ssb, ssb_ehci_table); |
| 212 | --- a/drivers/usb/host/ohci-ssb.c |
| 213 | +++ b/drivers/usb/host/ohci-ssb.c |
| 214 | @@ -17,6 +17,8 @@ |
| 215 | */ |
| 216 | #include <linux/ssb/ssb.h> |
| 217 | |
| 218 | +extern int ssb_ehci_attach(struct ssb_device *dev, struct usb_hcd **hcd); |
| 219 | +extern void ssb_ehci_detach(struct ssb_device *dev, struct usb_hcd *hcd); |
| 220 | |
| 221 | #define SSB_OHCI_TMSLOW_HOSTMODE (1 << 29) |
| 222 | |
| 223 | @@ -24,6 +26,7 @@ struct ssb_ohci_device { |
| 224 | struct ohci_hcd ohci; /* _must_ be at the beginning. */ |
| 225 | |
| 226 | u32 enable_flags; |
| 227 | + struct usb_hcd *ehci_hcd; |
| 228 | }; |
| 229 | |
| 230 | static inline |
| 231 | @@ -92,13 +95,25 @@ static const struct hc_driver ssb_ohci_h |
| 232 | static void ssb_ohci_detach(struct ssb_device *dev) |
| 233 | { |
| 234 | struct usb_hcd *hcd = ssb_get_drvdata(dev); |
| 235 | +#ifdef CONFIG_USB_EHCI_HCD_SSB |
| 236 | + struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); |
| 237 | +#endif |
| 238 | |
| 239 | usb_remove_hcd(hcd); |
| 240 | iounmap(hcd->regs); |
| 241 | usb_put_hcd(hcd); |
| 242 | + |
| 243 | +#ifdef CONFIG_USB_EHCI_HCD_SSB |
| 244 | + /* |
| 245 | + * Also detach ehci function |
| 246 | + */ |
| 247 | + if (dev->id.coreid == SSB_DEV_USB20_HOST) |
| 248 | + ssb_ehci_detach(dev, ohcidev->ehci_hcd); |
| 249 | +#endif |
| 250 | ssb_device_disable(dev, 0); |
| 251 | } |
| 252 | |
| 253 | + |
| 254 | static int ssb_ohci_attach(struct ssb_device *dev) |
| 255 | { |
| 256 | struct ssb_ohci_device *ohcidev; |
| 257 | @@ -165,6 +180,14 @@ static int ssb_ohci_attach(struct ssb_de |
| 258 | |
| 259 | ssb_set_drvdata(dev, hcd); |
| 260 | |
| 261 | +#ifdef CONFIG_USB_EHCI_HCD_SSB |
| 262 | + /* |
| 263 | + * attach ehci function in this core |
| 264 | + */ |
| 265 | + if (dev->id.coreid == SSB_DEV_USB20_HOST) |
| 266 | + err = ssb_ehci_attach(dev, &(ohcidev->ehci_hcd)); |
| 267 | +#endif |
| 268 | + |
| 269 | return err; |
| 270 | |
| 271 | err_iounmap: |
| 272 | |