1 --- a/drivers/usb/host/ohci-hcd.c
2 +++ b/drivers/usb/host/ohci-hcd.c
3 @@ -579,7 +579,6 @@ static int ohci_run (struct ohci_hcd *oh
5 /* boot firmware should have set this up (5.1.1.3.1) */
8 val = ohci_readl (ohci, &ohci->regs->fminterval);
9 ohci->fminterval = val & 0x3fff;
10 if (ohci->fminterval != FI)
11 @@ -663,6 +662,9 @@ retry:
13 periodic_reinit (ohci);
15 + if (ohci->flags & OHCI_QUIRK_INIT_FMINTERVAL)
16 + ohci_writel (ohci, ohci->fminterval, &ohci->regs->fminterval);
18 /* some OHCI implementations are finicky about how they init.
19 * bogus values here mean not even enumeration could work.
21 @@ -1105,6 +1107,11 @@ MODULE_LICENSE ("GPL");
22 #define PLATFORM_DRIVER ohci_hcd_tilegx_driver
25 +#ifdef CONFIG_ARCH_CNS21XX
26 +#include "ohci-cns21xx.c"
27 +#define PLATFORM_DRIVER ohci_cns21xx_driver
30 #ifdef CONFIG_USB_CNS3XXX_OHCI
31 #include "ohci-cns3xxx.c"
32 #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver
33 @@ -1117,7 +1124,7 @@ MODULE_LICENSE ("GPL");
35 #ifdef CONFIG_USB_OHCI_HCD_PLATFORM
36 #include "ohci-platform.c"
37 -#define PLATFORM_DRIVER ohci_platform_driver
38 +#define OHCI_PLATFORM_DRIVER ohci_platform_driver
41 #if !defined(PCI_DRIVER) && \
42 @@ -1128,7 +1135,8 @@ MODULE_LICENSE ("GPL");
43 !defined(SA1111_DRIVER) && \
44 !defined(PS3_SYSTEM_BUS_DRIVER) && \
45 !defined(SM501_OHCI_DRIVER) && \
46 - !defined(TMIO_OHCI_DRIVER)
47 + !defined(TMIO_OHCI_DRIVER) && \
48 + !defined(OHCI_PLATFORM_DRIVER)
49 #error "missing bus glue for ohci-hcd"
52 @@ -1206,9 +1214,19 @@ static int __init ohci_hcd_mod_init(void
56 +#ifdef OHCI_PLATFORM_DRIVER
57 + retval = platform_driver_register(&OHCI_PLATFORM_DRIVER);
65 +#ifdef OHCI_PLATFORM_DRIVER
66 + platform_driver_unregister(&OHCI_PLATFORM_DRIVER);
69 #ifdef TMIO_OHCI_DRIVER
70 platform_driver_unregister(&TMIO_OHCI_DRIVER);
72 @@ -1258,6 +1276,9 @@ module_init(ohci_hcd_mod_init);
74 static void __exit ohci_hcd_mod_exit(void)
76 +#ifdef OHCI_PLATFORM_DRIVER
77 + platform_driver_unregister(&OHCI_PLATFORM_DRIVER);
79 #ifdef TMIO_OHCI_DRIVER
80 platform_driver_unregister(&TMIO_OHCI_DRIVER);
83 +++ b/drivers/usb/host/ohci-cns21xx.c
86 + * Copyright (c) 2008 Cavium Networks
87 + * Copyright (c) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
89 + * This file is free software; you can redistribute it and/or modify
90 + * it under the terms of the GNU General Public License, Version 2, as
91 + * published by the Free Software Foundation.
94 +#include <linux/platform_device.h>
96 +#include <mach/cns21xx.h>
98 +#define DRIVER_NAME "cns21xx-ohci"
100 +static int __devinit cns21xx_ohci_start(struct usb_hcd *hcd)
102 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
105 + ret = ohci_init(ohci);
109 + ret = ohci_run(ohci);
111 + ohci_err(ohci, "can't start %s",
112 + ohci_to_hcd(ohci)->self.bus_name);
123 +static const struct hc_driver ohci_cns21xx_hc_driver = {
124 + .description = hcd_name,
125 + .product_desc = "cns21xx-ohci",
126 + .hcd_priv_size = sizeof(struct ohci_hcd),
129 + * generic hardware linkage
132 + .flags = HCD_USB11 | HCD_MEMORY,
135 + * basic lifecycle operations
137 + .start = cns21xx_ohci_start,
139 + .shutdown = ohci_shutdown,
142 + * managing i/o requests and associated device resources
144 + .urb_enqueue = ohci_urb_enqueue,
145 + .urb_dequeue = ohci_urb_dequeue,
146 + .endpoint_disable = ohci_endpoint_disable,
149 + * scheduling support
151 + .get_frame_number = ohci_get_frame,
156 + .hub_status_data = ohci_hub_status_data,
157 + .hub_control = ohci_hub_control,
158 + .start_port_reset = ohci_start_port_reset,
161 +static void cns21xx_ohci_init_hc(void)
163 + __raw_writel(0x146, CNS21XX_OHCI_CONFIG_BASE_VIRT + 0x04);
164 + __raw_writel(0x200, CNS21XX_OHCI_CONFIG_BASE_VIRT + 0x44);
168 +static int ohci_cns21xx_probe(struct platform_device *pdev)
170 + struct usb_hcd *hcd;
171 + struct resource *res;
172 + struct ohci_hcd *ohci;
176 + if (usb_disabled())
179 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
181 + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
182 + dev_name(&pdev->dev));
187 + hcd = usb_create_hcd(&ohci_cns21xx_hc_driver, &pdev->dev,
188 + dev_name(&pdev->dev));
192 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
194 + dev_dbg(&pdev->dev, "no base address specified for %s\n",
195 + dev_name(&pdev->dev));
199 + hcd->rsrc_start = res->start;
200 + hcd->rsrc_len = res->end - res->start + 1;
202 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
203 + dev_dbg(&pdev->dev, "controller already in use\n");
208 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
210 + dev_dbg(&pdev->dev, "error mapping memory\n");
212 + goto err_release_region;
215 + cns21xx_ohci_init_hc();
217 + ohci = hcd_to_ohci(hcd);
218 + ohci->flags |= OHCI_QUIRK_INIT_FMINTERVAL;
219 + ohci_hcd_init(ohci);
221 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
225 + platform_set_drvdata(pdev, hcd);
229 + iounmap(hcd->regs);
231 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
237 +static int ohci_cns21xx_remove(struct platform_device *pdev)
239 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
241 + usb_remove_hcd(hcd);
242 + iounmap(hcd->regs);
243 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
245 + platform_set_drvdata(pdev, NULL);
250 +static struct platform_driver ohci_cns21xx_driver = {
251 + .probe = ohci_cns21xx_probe,
252 + .remove = ohci_cns21xx_remove,
253 + .shutdown = usb_hcd_platform_shutdown,
255 + .owner = THIS_MODULE,
256 + .name = DRIVER_NAME,
260 +MODULE_ALIAS("platform:" DRIVER_NAME);
261 --- a/drivers/usb/host/ohci.h
262 +++ b/drivers/usb/host/ohci.h
263 @@ -405,6 +405,7 @@ struct ohci_hcd {
264 #define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */
265 #define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/
266 #define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
267 +#define OHCI_QUIRK_INIT_FMINTERVAL 0x1000 /* fminterval must be initialized */
268 // there are also chip quirks/bugs in init logic
270 struct work_struct nec_work; /* Worker for NEC quirk */
271 --- a/arch/arm/Kconfig
272 +++ b/arch/arm/Kconfig
273 @@ -393,6 +393,7 @@ config ARCH_CNS21XX
275 select ARCH_REQUIRE_GPIOLIB
276 select ARM_L1_CACHE_SHIFT_4
277 + select USB_ARCH_HAS_OHCI
279 Support for Cavium Networks CNS21xx family.