1 --- a/drivers/usb/host/ohci-hcd.c
2 +++ b/drivers/usb/host/ohci-hcd.c
3 @@ -697,6 +697,9 @@ retry:
5 periodic_reinit (ohci);
7 + if (ohci->flags & OHCI_QUIRK_INIT_FMINTERVAL)
8 + ohci_writel (ohci, ohci->fminterval, &ohci->regs->fminterval);
10 /* some OHCI implementations are finicky about how they init.
11 * bogus values here mean not even enumeration could work.
13 @@ -1191,6 +1194,11 @@ MODULE_LICENSE ("GPL");
14 #define PLATFORM_DRIVER ohci_hcd_tilegx_driver
17 +#ifdef CONFIG_ARCH_CNS21XX
18 +#include "ohci-cns21xx.c"
19 +#define CNS21XX_PLATFORM_DRIVER ohci_cns21xx_driver
22 #ifdef CONFIG_USB_OHCI_HCD_PLATFORM
23 #include "ohci-platform.c"
24 #define PLATFORM_DRIVER ohci_platform_driver
25 @@ -1211,7 +1219,8 @@ MODULE_LICENSE ("GPL");
26 !defined(AT91_PLATFORM_DRIVER) && \
27 !defined(NXP_PLATFORM_DRIVER) && \
28 !defined(DAVINCI_PLATFORM_DRIVER) && \
29 - !defined(SPEAR_PLATFORM_DRIVER)
30 + !defined(SPEAR_PLATFORM_DRIVER) && \
31 + !defined(CNS21XX_PLATFORM_DRIVER)
32 #error "missing bus glue for ohci-hcd"
35 @@ -1331,9 +1340,19 @@ static int __init ohci_hcd_mod_init(void
39 +#ifdef CNS21XX_PLATFORM_DRIVER
40 + retval = platform_driver_register(&CNS21XX_PLATFORM_DRIVER);
48 +#ifdef CNS21XX_PLATFORM_DRIVER
49 + platform_driver_unregister(&CNS21XX_PLATFORM_DRIVER);
52 #ifdef SPEAR_PLATFORM_DRIVER
53 platform_driver_unregister(&SPEAR_PLATFORM_DRIVER);
55 @@ -1411,6 +1430,9 @@ module_init(ohci_hcd_mod_init);
57 static void __exit ohci_hcd_mod_exit(void)
59 +#ifdef CNS21XX_PLATFORM_DRIVER
60 + platform_driver_unregister(&CNS21XX_PLATFORM_DRIVER);
62 #ifdef SPEAR_PLATFORM_DRIVER
63 platform_driver_unregister(&SPEAR_PLATFORM_DRIVER);
66 +++ b/drivers/usb/host/ohci-cns21xx.c
69 + * Copyright (c) 2008 Cavium Networks
70 + * Copyright (c) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
72 + * This file is free software; you can redistribute it and/or modify
73 + * it under the terms of the GNU General Public License, Version 2, as
74 + * published by the Free Software Foundation.
77 +#include <linux/platform_device.h>
79 +#include <mach/cns21xx.h>
81 +#define DRIVER_NAME "cns21xx-ohci"
83 +static int cns21xx_ohci_start(struct usb_hcd *hcd)
85 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
88 + ret = ohci_init(ohci);
92 + ret = ohci_run(ohci);
94 + ohci_err(ohci, "can't start %s",
95 + ohci_to_hcd(ohci)->self.bus_name);
106 +static const struct hc_driver ohci_cns21xx_hc_driver = {
107 + .description = hcd_name,
108 + .product_desc = "cns21xx-ohci",
109 + .hcd_priv_size = sizeof(struct ohci_hcd),
112 + * generic hardware linkage
115 + .flags = HCD_USB11 | HCD_MEMORY,
118 + * basic lifecycle operations
120 + .start = cns21xx_ohci_start,
122 + .shutdown = ohci_shutdown,
125 + * managing i/o requests and associated device resources
127 + .urb_enqueue = ohci_urb_enqueue,
128 + .urb_dequeue = ohci_urb_dequeue,
129 + .endpoint_disable = ohci_endpoint_disable,
132 + * scheduling support
134 + .get_frame_number = ohci_get_frame,
139 + .hub_status_data = ohci_hub_status_data,
140 + .hub_control = ohci_hub_control,
141 + .start_port_reset = ohci_start_port_reset,
144 +static void cns21xx_ohci_init_hc(void)
146 + void __iomem *base = (void __iomem *) CNS21XX_OHCI_CONFIG_BASE_VIRT;
148 + __raw_writel(0x146, base + 0x04);
149 + __raw_writel(0x200, base + 0x44);
153 +static int ohci_cns21xx_probe(struct platform_device *pdev)
155 + struct usb_hcd *hcd;
156 + struct resource *res;
157 + struct ohci_hcd *ohci;
161 + if (usb_disabled())
164 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
166 + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
167 + dev_name(&pdev->dev));
172 + hcd = usb_create_hcd(&ohci_cns21xx_hc_driver, &pdev->dev,
173 + dev_name(&pdev->dev));
177 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
179 + dev_dbg(&pdev->dev, "no base address specified for %s\n",
180 + dev_name(&pdev->dev));
184 + hcd->rsrc_start = res->start;
185 + hcd->rsrc_len = res->end - res->start + 1;
187 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
188 + dev_dbg(&pdev->dev, "controller already in use\n");
193 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
195 + dev_dbg(&pdev->dev, "error mapping memory\n");
197 + goto err_release_region;
200 + cns21xx_ohci_init_hc();
202 + ohci = hcd_to_ohci(hcd);
203 + ohci->flags |= OHCI_QUIRK_INIT_FMINTERVAL;
204 + ohci_hcd_init(ohci);
206 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
210 + platform_set_drvdata(pdev, hcd);
214 + iounmap(hcd->regs);
216 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
222 +static int ohci_cns21xx_remove(struct platform_device *pdev)
224 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
226 + usb_remove_hcd(hcd);
227 + iounmap(hcd->regs);
228 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
230 + platform_set_drvdata(pdev, NULL);
235 +static struct platform_driver ohci_cns21xx_driver = {
236 + .probe = ohci_cns21xx_probe,
237 + .remove = ohci_cns21xx_remove,
238 + .shutdown = usb_hcd_platform_shutdown,
240 + .owner = THIS_MODULE,
241 + .name = DRIVER_NAME,
245 +MODULE_ALIAS("platform:" DRIVER_NAME);
246 --- a/drivers/usb/host/ohci.h
247 +++ b/drivers/usb/host/ohci.h
248 @@ -406,6 +406,7 @@ struct ohci_hcd {
249 #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/
250 #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
251 #define OHCI_QUIRK_GLOBAL_SUSPEND 0x800 /* must suspend ports */
252 +#define OHCI_QUIRK_INIT_FMINTERVAL 0x1000 /* fminterval must be initialized */
254 // there are also chip quirks/bugs in init logic
256 --- a/arch/arm/Kconfig
257 +++ b/arch/arm/Kconfig
258 @@ -374,6 +374,7 @@ config ARCH_CNS21XX
260 select ARCH_REQUIRE_GPIOLIB
261 select ARM_L1_CACHE_SHIFT_4
262 + select USB_ARCH_HAS_OHCI
264 Support for Cavium Networks CNS21xx family.