2 +++ b/drivers/usb/host/ehci-cns21xx.c
5 + * Copyright (c) 2008 Cavium Networks
6 + * Copyright (c) 2010-2013 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/kernel.h>
14 +#include <linux/module.h>
15 +#include <linux/io.h>
16 +#include <linux/platform_device.h>
17 +#include <linux/irq.h>
18 +#include <linux/usb.h>
19 +#include <linux/usb/hcd.h>
21 +#include <mach/cns21xx.h>
25 +#define DRIVER_NAME "cns21xx-ehci"
27 +static const char hcd_name[] = "ehci-cns21xx";
28 +static struct hc_driver __read_mostly ehci_cns21xx_hc_driver;
30 +static void ehci_cns21xx_init_hc(void)
32 + void __iomem *base = (void __iomem *) CNS21XX_EHCI_CONFIG_BASE_VIRT;
34 + __raw_writel(0x106, base + 0x04);
35 + __raw_writel((3 << 5) | 0x2000, base + 0x40);
39 +static int ehci_cns21xx_probe(struct platform_device *pdev)
41 + struct usb_hcd *hcd;
42 + struct ehci_hcd *ehci;
43 + struct resource *res;
47 + irq = platform_get_irq(pdev, 0);
49 + dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
50 + dev_name(&pdev->dev));
54 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
56 + dev_dbg(&pdev->dev, "no base address specified for %s\n",
57 + dev_name(&pdev->dev));
61 + hcd = usb_create_hcd(&ehci_cns21xx_hc_driver, &pdev->dev,
62 + dev_name(&pdev->dev));
66 + hcd->rsrc_start = res->start;
67 + hcd->rsrc_len = res->end - res->start + 1;
69 + hcd->regs = devm_ioremap_resource(&pdev->dev, res);
70 + if (IS_ERR(hcd->regs)) {
71 + ret = PTR_ERR(hcd->regs);
75 + ehci_cns21xx_init_hc();
77 + ehci = hcd_to_ehci(hcd);
78 + ehci->caps = hcd->regs;
80 + ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
84 + platform_set_drvdata(pdev, hcd);
94 +static int ehci_cns21xx_remove(struct platform_device *pdev)
96 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
98 + usb_remove_hcd(hcd);
104 +static struct platform_driver ehci_cns21xx_driver = {
105 + .probe = ehci_cns21xx_probe,
106 + .remove = ehci_cns21xx_remove,
107 + .shutdown = usb_hcd_platform_shutdown,
109 + .owner = THIS_MODULE,
110 + .name = DRIVER_NAME,
114 +static int __init ehci_cns21xx_init(void)
116 + if (usb_disabled())
119 + ehci_init_driver(&ehci_cns21xx_hc_driver, NULL);
121 + return platform_driver_register(&ehci_cns21xx_driver);
123 +module_init(ehci_cns21xx_init);
125 +static void __exit ehci_cns21xx_exit(void)
127 + platform_driver_unregister(&ehci_cns21xx_driver);
129 +module_exit(ehci_cns21xx_exit);
131 +MODULE_DESCRIPTION("Cavium Networks CNS21xx built-in EHCI controller driver");
132 +MODULE_ALIAS("platform:" DRIVER_NAME);
133 +MODULE_LICENSE("GPL v2");
134 --- a/arch/arm/Kconfig
135 +++ b/arch/arm/Kconfig
136 @@ -375,6 +375,7 @@ config ARCH_CNS21XX
137 select ARCH_REQUIRE_GPIOLIB
138 select ARM_L1_CACHE_SHIFT_4
139 select USB_ARCH_HAS_OHCI
140 + select USB_ARCH_HAS_EHCI
142 Support for Cavium Networks CNS21xx family.
144 --- a/drivers/usb/host/Kconfig
145 +++ b/drivers/usb/host/Kconfig
146 @@ -249,6 +249,14 @@ config USB_W90X900_EHCI
148 Enables support for the W90X900 USB controller
150 +config USB_EHCI_CNS21XX
151 + tristate "EHCI support for the Cavium CNS21XX SoCs"
152 + depends on ARCH_CNS21XX
155 + Enables support for the built-in EHCI controller of the
156 + Cavium CNS21xx SoCs.
158 config USB_CNS3XXX_EHCI
159 bool "Cavium CNS3XXX EHCI Module (DEPRECATED)"
160 depends on ARCH_CNS3XXX
161 --- a/drivers/usb/host/Makefile
162 +++ b/drivers/usb/host/Makefile
163 @@ -33,6 +33,7 @@ obj-$(CONFIG_USB_EHCI_HCD_SPEAR) += ehci
164 obj-$(CONFIG_USB_EHCI_S5P) += ehci-s5p.o
165 obj-$(CONFIG_USB_EHCI_HCD_AT91) += ehci-atmel.o
166 obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
167 +obj-$(CONFIG_USB_EHCI_CNS21XX) += ehci-cns21xx.o
169 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
170 obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o