2 +++ b/drivers/usb/host/ehci-cns21xx.c
5 + * Copyright (c) 2008 Cavium Networks
6 + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
8 + * This file is free software; you can redistribute it and/or modify
9 + * it under the terms of the GNU General Public License, Version 2, as
10 + * published by the Free Software Foundation.
13 +#include <linux/platform_device.h>
14 +#include <linux/irq.h>
16 +#include <mach/cns21xx.h>
18 +#define DRIVER_NAME "cns21xx-ehci"
20 +static int cns21xx_ehci_reset(struct usb_hcd *hcd)
22 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
25 + ret = ehci_halt(ehci);
29 + ret = ehci_init(hcd);
34 + ehci_port_power(ehci, 0);
39 +static const struct hc_driver ehci_cns21xx_hc_driver = {
40 + .description = hcd_name,
41 + .product_desc = DRIVER_NAME,
42 + .hcd_priv_size = sizeof(struct ehci_hcd),
45 + * generic hardware linkage
48 + .flags = HCD_MEMORY | HCD_USB2,
51 + * basic lifecycle operations
53 + .reset = cns21xx_ehci_reset,
56 + .shutdown = ehci_shutdown,
59 + * managing i/o requests and associated device resources
61 + .urb_enqueue = ehci_urb_enqueue,
62 + .urb_dequeue = ehci_urb_dequeue,
63 + .endpoint_disable = ehci_endpoint_disable,
64 + .endpoint_reset = ehci_endpoint_reset,
67 + * scheduling support
69 + .get_frame_number = ehci_get_frame,
74 + .hub_status_data = ehci_hub_status_data,
75 + .hub_control = ehci_hub_control,
76 + .relinquish_port = ehci_relinquish_port,
77 + .port_handed_over = ehci_port_handed_over,
79 + .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
82 +static void cns21xx_ehci_init_hc(void)
84 + __raw_writel(0x106, CNS21XX_EHCI_CONFIG_BASE_VIRT + 0x04);
85 + __raw_writel((3 << 5) | 0x2000, CNS21XX_EHCI_CONFIG_BASE_VIRT + 0x40);
89 +static int ehci_cns21xx_probe(struct platform_device *pdev)
91 + struct usb_hcd *hcd;
92 + struct ehci_hcd *ehci;
93 + struct resource *res;
100 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
102 + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
103 + dev_name(&pdev->dev));
108 + hcd = usb_create_hcd(&ehci_cns21xx_hc_driver, &pdev->dev,
109 + dev_name(&pdev->dev));
113 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
115 + dev_dbg(&pdev->dev, "no base address specified for %s\n",
116 + dev_name(&pdev->dev));
120 + hcd->rsrc_start = res->start;
121 + hcd->rsrc_len = res->end - res->start + 1;
123 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
124 + dev_dbg(&pdev->dev, "controller already in use\n");
129 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
131 + dev_dbg(&pdev->dev, "error mapping memory\n");
133 + goto err_release_region;
136 + cns21xx_ehci_init_hc();
138 + ehci = hcd_to_ehci(hcd);
140 + ehci->caps = hcd->regs;
141 + ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
142 + dbg_hcs_params(ehci, "reset");
143 + dbg_hcc_params(ehci, "reset");
145 + /* cache this readonly data; minimize chip reads */
146 + ehci->hcs_params = readl(&ehci->caps->hcs_params);
149 + ret = usb_add_hcd(hcd, CNS21XX_IRQ_EHCI, IRQF_DISABLED);
153 + platform_set_drvdata(pdev, hcd);
157 + iounmap(hcd->regs);
159 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
165 +static int ehci_cns21xx_remove(struct platform_device *pdev)
167 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
169 + usb_remove_hcd(hcd);
170 + iounmap(hcd->regs);
171 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
173 + platform_set_drvdata(pdev, NULL);
178 +static struct platform_driver ehci_cns21xx_driver = {
179 + .probe = ehci_cns21xx_probe,
180 + .remove = ehci_cns21xx_remove,
182 + .owner = THIS_MODULE,
183 + .name = DRIVER_NAME,
187 +MODULE_ALIAS("platform:" DRIVER_NAME);
188 --- a/drivers/usb/host/ehci-hcd.c
189 +++ b/drivers/usb/host/ehci-hcd.c
190 @@ -1197,6 +1197,11 @@ MODULE_LICENSE ("GPL");
191 #define PLATFORM_DRIVER ehci_atmel_driver
194 +#ifdef CONFIG_ARCH_CNS21XX
195 +#include "ehci-cns21xx.c"
196 +#define PLATFORM_DRIVER ehci_cns21xx_driver
199 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
200 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
201 !defined(XILINX_OF_PLATFORM_DRIVER)
202 --- a/arch/arm/Kconfig
203 +++ b/arch/arm/Kconfig
204 @@ -300,6 +300,7 @@ config ARCH_CNS21XX
205 select ARCH_REQUIRE_GPIOLIB
206 select ARM_L1_CACHE_SHIFT_4
207 select USB_ARCH_HAS_OHCI
208 + select USB_ARCH_HAS_EHCI
210 Support for Cavium Networks CNS21xx family.