cns21xx: switch to 3.10
[librecmc/librecmc.git] / target / linux / cns21xx / patches-3.8 / 104-cns21xx-usb-ehci-support.patch
1 --- a/drivers/usb/host/ehci-hcd.c
2 +++ b/drivers/usb/host/ehci-hcd.c
3 @@ -1342,6 +1342,7 @@ MODULE_LICENSE ("GPL");
4         !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
5         !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \
6         !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \
7 +       !IS_ENABLED(CONFIG_USB_EHCI_CNS21XX) && \
8         !defined(PLATFORM_DRIVER) && \
9         !defined(PS3_SYSTEM_BUS_DRIVER) && \
10         !defined(OF_PLATFORM_DRIVER) && \
11 --- /dev/null
12 +++ b/drivers/usb/host/ehci-cns21xx.c
13 @@ -0,0 +1,130 @@
14 +/*
15 + *  Copyright (c) 2008 Cavium Networks
16 + *  Copyright (c) 2010-2013 Gabor Juhos <juhosg@openwrt.org>
17 + *
18 + *  This file is free software; you can redistribute it and/or modify
19 + *  it under the terms of the GNU General Public License, Version 2, as
20 + *  published by the Free Software Foundation.
21 + */
22 +
23 +#include <linux/kernel.h>
24 +#include <linux/module.h>
25 +#include <linux/io.h>
26 +#include <linux/platform_device.h>
27 +#include <linux/irq.h>
28 +#include <linux/usb.h>
29 +#include <linux/usb/hcd.h>
30 +
31 +#include <mach/cns21xx.h>
32 +
33 +#include "ehci.h"
34 +
35 +#define DRIVER_NAME    "cns21xx-ehci"
36 +
37 +static const char hcd_name[] = "ehci-cns21xx";
38 +static struct hc_driver __read_mostly ehci_cns21xx_hc_driver;
39 +
40 +static void ehci_cns21xx_init_hc(void)
41 +{
42 +       void __iomem *base = (void __iomem *) CNS21XX_EHCI_CONFIG_BASE_VIRT;
43 +
44 +       __raw_writel(0x106, base + 0x04);
45 +       __raw_writel((3 << 5) | 0x2000, base + 0x40);
46 +       msleep(100);
47 +}
48 +
49 +static int ehci_cns21xx_probe(struct platform_device *pdev)
50 +{
51 +       struct usb_hcd *hcd;
52 +       struct ehci_hcd *ehci;
53 +       struct resource *res;
54 +       int irq;
55 +       int ret;
56 +
57 +       irq = platform_get_irq(pdev, 0);
58 +       if (irq < 0) {
59 +               dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
60 +                       dev_name(&pdev->dev));
61 +               return -ENODEV;
62 +       }
63 +
64 +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
65 +       if (!res) {
66 +               dev_dbg(&pdev->dev, "no base address specified for %s\n",
67 +                       dev_name(&pdev->dev));
68 +               return -EINVAL;
69 +       }
70 +
71 +       hcd = usb_create_hcd(&ehci_cns21xx_hc_driver, &pdev->dev,
72 +                            dev_name(&pdev->dev));
73 +       if (!hcd)
74 +               return -ENOMEM;
75 +
76 +       hcd->rsrc_start = res->start;
77 +       hcd->rsrc_len   = res->end - res->start + 1;
78 +
79 +       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
80 +       if (IS_ERR(hcd->regs)) {
81 +               ret = PTR_ERR(hcd->regs);
82 +               goto err_put_hcd;
83 +       }
84 +
85 +       ehci_cns21xx_init_hc();
86 +
87 +       ehci = hcd_to_ehci(hcd);
88 +       ehci->caps = hcd->regs;
89 +
90 +       ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
91 +       if (ret)
92 +               goto err_put_hcd;
93 +
94 +       platform_set_drvdata(pdev, hcd);
95 +
96 +       return 0;
97 +
98 +err_put_hcd:
99 +       usb_put_hcd(hcd);
100 +
101 +       return ret;
102 +}
103 +
104 +static int ehci_cns21xx_remove(struct platform_device *pdev)
105 +{
106 +       struct usb_hcd *hcd = platform_get_drvdata(pdev);
107 +
108 +       usb_remove_hcd(hcd);
109 +       usb_put_hcd(hcd);
110 +
111 +       return 0;
112 +}
113 +
114 +static struct platform_driver ehci_cns21xx_driver = {
115 +       .probe          = ehci_cns21xx_probe,
116 +       .remove         = ehci_cns21xx_remove,
117 +       .shutdown       = usb_hcd_platform_shutdown,
118 +       .driver         = {
119 +               .owner  = THIS_MODULE,
120 +               .name   = DRIVER_NAME,
121 +       },
122 +};
123 +
124 +static int __init ehci_cns21xx_init(void)
125 +{
126 +       if (usb_disabled())
127 +               return -ENODEV;
128 +
129 +       ehci_init_driver(&ehci_cns21xx_hc_driver, NULL);
130 +
131 +       return platform_driver_register(&ehci_cns21xx_driver);
132 +}
133 +module_init(ehci_cns21xx_init);
134 +
135 +static void __exit ehci_cns21xx_exit(void)
136 +{
137 +       platform_driver_unregister(&ehci_cns21xx_driver);
138 +}
139 +module_exit(ehci_cns21xx_exit);
140 +
141 +MODULE_DESCRIPTION("Cavium Networks CNS21xx built-in EHCI controller driver");
142 +MODULE_ALIAS("platform:" DRIVER_NAME);
143 +MODULE_LICENSE("GPL v2");
144 --- a/arch/arm/Kconfig
145 +++ b/arch/arm/Kconfig
146 @@ -382,6 +382,7 @@ config ARCH_CNS21XX
147         select ARCH_REQUIRE_GPIOLIB
148         select ARM_L1_CACHE_SHIFT_4
149         select USB_ARCH_HAS_OHCI
150 +       select USB_ARCH_HAS_EHCI
151         help
152           Support for Cavium Networks CNS21xx family.
153  
154 --- a/drivers/usb/host/Kconfig
155 +++ b/drivers/usb/host/Kconfig
156 @@ -219,6 +219,14 @@ config USB_W90X900_EHCI
157         ---help---
158                 Enables support for the W90X900 USB controller
159  
160 +config USB_EHCI_CNS21XX
161 +       tristate "EHCI support for the Cavium CNS21XX SoCs"
162 +       depends on ARCH_CNS21XX
163 +       default y
164 +       help
165 +         Enables support for the built-in EHCI controller of the
166 +         Cavium CNS21xx SoCs.
167 +
168  config USB_CNS3XXX_EHCI
169         bool "Cavium CNS3XXX EHCI Module (DEPRECATED)"
170         depends on USB_EHCI_HCD && ARCH_CNS3XXX
171 --- a/drivers/usb/host/Makefile
172 +++ b/drivers/usb/host/Makefile
173 @@ -27,6 +27,7 @@ obj-$(CONFIG_USB_EHCI_HCD)    += ehci-hcd.o
174  obj-$(CONFIG_USB_EHCI_PCI)     += ehci-pci.o
175  obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)    += ehci-platform.o
176  obj-$(CONFIG_USB_EHCI_MXC)     += ehci-mxc.o
177 +obj-$(CONFIG_USB_EHCI_CNS21XX) += ehci-cns21xx.o
178  
179  obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
180  obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o