1 --- a/drivers/usb/host/ehci-hcd.c
2 +++ b/drivers/usb/host/ehci-hcd.c
3 @@ -1342,6 +1342,11 @@ MODULE_LICENSE ("GPL");
4 #define PLATFORM_DRIVER ehci_hcd_sead3_driver
7 +#ifdef CONFIG_ARCH_CNS21XX
8 +#include "ehci-cns21xx.c"
9 +#define PLATFORM_DRIVER ehci_cns21xx_driver
12 #if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
13 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
14 !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \
16 +++ b/drivers/usb/host/ehci-cns21xx.c
19 + * Copyright (c) 2008 Cavium Networks
20 + * Copyright (c) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
22 + * This file is free software; you can redistribute it and/or modify
23 + * it under the terms of the GNU General Public License, Version 2, as
24 + * published by the Free Software Foundation.
27 +#include <linux/platform_device.h>
28 +#include <linux/irq.h>
30 +#include <mach/cns21xx.h>
32 +#define DRIVER_NAME "cns21xx-ehci"
34 +static int cns21xx_ehci_reset(struct usb_hcd *hcd)
36 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
39 + ret = ehci_halt(ehci);
43 + ret = ehci_init(hcd);
52 +static const struct hc_driver ehci_cns21xx_hc_driver = {
53 + .description = hcd_name,
54 + .product_desc = DRIVER_NAME,
55 + .hcd_priv_size = sizeof(struct ehci_hcd),
58 + * generic hardware linkage
61 + .flags = HCD_MEMORY | HCD_USB2,
64 + * basic lifecycle operations
66 + .reset = cns21xx_ehci_reset,
69 + .shutdown = ehci_shutdown,
72 + * managing i/o requests and associated device resources
74 + .urb_enqueue = ehci_urb_enqueue,
75 + .urb_dequeue = ehci_urb_dequeue,
76 + .endpoint_disable = ehci_endpoint_disable,
77 + .endpoint_reset = ehci_endpoint_reset,
80 + * scheduling support
82 + .get_frame_number = ehci_get_frame,
87 + .hub_status_data = ehci_hub_status_data,
88 + .hub_control = ehci_hub_control,
89 + .relinquish_port = ehci_relinquish_port,
90 + .port_handed_over = ehci_port_handed_over,
92 + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
95 +static void cns21xx_ehci_init_hc(void)
97 + void __iomem *base = (void __iomem *) CNS21XX_EHCI_CONFIG_BASE_VIRT;
99 + __raw_writel(0x106, base + 0x04);
100 + __raw_writel((3 << 5) | 0x2000, base + 0x40);
104 +static int ehci_cns21xx_probe(struct platform_device *pdev)
106 + struct usb_hcd *hcd;
107 + struct ehci_hcd *ehci;
108 + struct resource *res;
112 + if (usb_disabled())
115 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
117 + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
118 + dev_name(&pdev->dev));
123 + hcd = usb_create_hcd(&ehci_cns21xx_hc_driver, &pdev->dev,
124 + dev_name(&pdev->dev));
128 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
130 + dev_dbg(&pdev->dev, "no base address specified for %s\n",
131 + dev_name(&pdev->dev));
135 + hcd->rsrc_start = res->start;
136 + hcd->rsrc_len = res->end - res->start + 1;
138 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
139 + dev_dbg(&pdev->dev, "controller already in use\n");
144 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
146 + dev_dbg(&pdev->dev, "error mapping memory\n");
148 + goto err_release_region;
151 + cns21xx_ehci_init_hc();
153 + ehci = hcd_to_ehci(hcd);
155 + ehci->caps = hcd->regs;
156 + ehci->regs = hcd->regs +
157 + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
158 + dbg_hcs_params(ehci, "reset");
159 + dbg_hcc_params(ehci, "reset");
161 + /* cache this readonly data; minimize chip reads */
162 + ehci->hcs_params = readl(&ehci->caps->hcs_params);
165 + ret = usb_add_hcd(hcd, CNS21XX_IRQ_EHCI, IRQF_DISABLED);
169 + platform_set_drvdata(pdev, hcd);
173 + iounmap(hcd->regs);
175 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
181 +static int ehci_cns21xx_remove(struct platform_device *pdev)
183 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
185 + usb_remove_hcd(hcd);
186 + iounmap(hcd->regs);
187 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
189 + platform_set_drvdata(pdev, NULL);
194 +static struct platform_driver ehci_cns21xx_driver = {
195 + .probe = ehci_cns21xx_probe,
196 + .remove = ehci_cns21xx_remove,
197 + .shutdown = usb_hcd_platform_shutdown,
199 + .owner = THIS_MODULE,
200 + .name = DRIVER_NAME,
204 +MODULE_ALIAS("platform:" DRIVER_NAME);
205 --- a/arch/arm/Kconfig
206 +++ b/arch/arm/Kconfig
207 @@ -382,6 +382,7 @@ config ARCH_CNS21XX
208 select ARCH_REQUIRE_GPIOLIB
209 select ARM_L1_CACHE_SHIFT_4
210 select USB_ARCH_HAS_OHCI
211 + select USB_ARCH_HAS_EHCI
213 Support for Cavium Networks CNS21xx family.