generate package for the new IXP4xx crpyto driver
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-2.6.24 / 402-ixp4xx_ehci_backport.patch
1 Index: linux-2.6.24.7/drivers/usb/host/ehci.h
2 ===================================================================
3 --- linux-2.6.24.7.orig/drivers/usb/host/ehci.h
4 +++ linux-2.6.24.7/drivers/usb/host/ehci.h
5 @@ -730,6 +730,11 @@ ehci_port_speed(struct ehci_hcd *ehci, u
6 #define writel_be(val, addr) out_be32((__force unsigned *)addr, val)
7 #endif
8
9 +#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX)
10 +#define readl_be(addr) __raw_readl((__force unsigned *)addr)
11 +#define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr)
12 +#endif
13 +
14 static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
15 __u32 __iomem * regs)
16 {
17 Index: linux-2.6.24.7/drivers/usb/host/ehci-hcd.c
18 ===================================================================
19 --- linux-2.6.24.7.orig/drivers/usb/host/ehci-hcd.c
20 +++ linux-2.6.24.7/drivers/usb/host/ehci-hcd.c
21 @@ -964,6 +964,11 @@ MODULE_LICENSE ("GPL");
22 #define PLATFORM_DRIVER ehci_ppc_soc_driver
23 #endif
24
25 +#ifdef CONFIG_ARCH_IXP4XX
26 +#include "ehci-ixp4xx.c"
27 +#define PLATFORM_DRIVER ixp4xx_ehci_driver
28 +#endif
29 +
30 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
31 !defined(PS3_SYSTEM_BUS_DRIVER)
32 #error "missing bus glue for ehci-hcd"
33 Index: linux-2.6.24.7/drivers/usb/host/ehci-ixp4xx.c
34 ===================================================================
35 --- /dev/null
36 +++ linux-2.6.24.7/drivers/usb/host/ehci-ixp4xx.c
37 @@ -0,0 +1,152 @@
38 +/*
39 + * IXP4XX EHCI Host Controller Driver
40 + *
41 + * Author: Vladimir Barinov <vbarinov@ru.mvista.com>
42 + *
43 + * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
44 + *
45 + * 2007 (c) MontaVista Software, Inc. This file is licensed under
46 + * the terms of the GNU General Public License version 2. This program
47 + * is licensed "as is" without any warranty of any kind, whether express
48 + * or implied.
49 + */
50 +
51 +#include <linux/platform_device.h>
52 +
53 +static int ixp4xx_ehci_init(struct usb_hcd *hcd)
54 +{
55 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
56 + int retval = 0;
57 +
58 + ehci->big_endian_desc = 1;
59 + ehci->big_endian_mmio = 1;
60 +
61 + ehci->caps = hcd->regs + 0x100;
62 + ehci->regs = hcd->regs + 0x100
63 + + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
64 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
65 +
66 + ehci->is_tdi_rh_tt = 1;
67 + ehci_reset(ehci);
68 +
69 + retval = ehci_init(hcd);
70 + if (retval)
71 + return retval;
72 +
73 + ehci_port_power(ehci, 0);
74 +
75 + return retval;
76 +}
77 +
78 +static const struct hc_driver ixp4xx_ehci_hc_driver = {
79 + .description = hcd_name,
80 + .product_desc = "IXP4XX EHCI Host Controller",
81 + .hcd_priv_size = sizeof(struct ehci_hcd),
82 + .irq = ehci_irq,
83 + .flags = HCD_MEMORY | HCD_USB2,
84 + .reset = ixp4xx_ehci_init,
85 + .start = ehci_run,
86 + .stop = ehci_stop,
87 + .shutdown = ehci_shutdown,
88 + .urb_enqueue = ehci_urb_enqueue,
89 + .urb_dequeue = ehci_urb_dequeue,
90 + .endpoint_disable = ehci_endpoint_disable,
91 + .get_frame_number = ehci_get_frame,
92 + .hub_status_data = ehci_hub_status_data,
93 + .hub_control = ehci_hub_control,
94 +#if defined(CONFIG_PM)
95 + .bus_suspend = ehci_bus_suspend,
96 + .bus_resume = ehci_bus_resume,
97 +#endif
98 +};
99 +
100 +static int ixp4xx_ehci_probe(struct platform_device *pdev)
101 +{
102 + struct usb_hcd *hcd;
103 + const struct hc_driver *driver = &ixp4xx_ehci_hc_driver;
104 + struct resource *res;
105 + int irq;
106 + int retval;
107 +
108 + if (usb_disabled())
109 + return -ENODEV;
110 +
111 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
112 + if (!res) {
113 + dev_err(&pdev->dev,
114 + "Found HC with no IRQ. Check %s setup!\n",
115 + pdev->dev.bus_id);
116 + return -ENODEV;
117 + }
118 + irq = res->start;
119 +
120 + hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id);
121 + if (!hcd) {
122 + retval = -ENOMEM;
123 + goto fail_create_hcd;
124 + }
125 +
126 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
127 + if (!res) {
128 + dev_err(&pdev->dev,
129 + "Found HC with no register addr. Check %s setup!\n",
130 + pdev->dev.bus_id);
131 + retval = -ENODEV;
132 + goto fail_request_resource;
133 + }
134 + hcd->rsrc_start = res->start;
135 + hcd->rsrc_len = res->end - res->start + 1;
136 +
137 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
138 + driver->description)) {
139 + dev_dbg(&pdev->dev, "controller already in use\n");
140 + retval = -EBUSY;
141 + goto fail_request_resource;
142 + }
143 +
144 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
145 + if (hcd->regs == NULL) {
146 + dev_dbg(&pdev->dev, "error mapping memory\n");
147 + retval = -EFAULT;
148 + goto fail_ioremap;
149 + }
150 +
151 + retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
152 + if (retval)
153 + goto fail_add_hcd;
154 +
155 + return retval;
156 +
157 +fail_add_hcd:
158 + iounmap(hcd->regs);
159 +fail_ioremap:
160 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
161 +fail_request_resource:
162 + usb_put_hcd(hcd);
163 +fail_create_hcd:
164 + dev_err(&pdev->dev, "init %s fail, %d\n", pdev->dev.bus_id, retval);
165 + return retval;
166 +}
167 +
168 +static int ixp4xx_ehci_remove(struct platform_device *pdev)
169 +{
170 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
171 +
172 + usb_remove_hcd(hcd);
173 + iounmap(hcd->regs);
174 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
175 + usb_put_hcd(hcd);
176 +
177 + return 0;
178 +}
179 +
180 +MODULE_ALIAS("platform:ixp4xx-ehci");
181 +
182 +static struct platform_driver ixp4xx_ehci_driver = {
183 + .probe = ixp4xx_ehci_probe,
184 + .remove = ixp4xx_ehci_remove,
185 + .driver = {
186 + .name = "ixp4xx-ehci",
187 +// .bus = &platform_bus_type
188 + },
189 +};
190 Index: linux-2.6.24.7/drivers/usb/host/Kconfig
191 ===================================================================
192 --- linux-2.6.24.7.orig/drivers/usb/host/Kconfig
193 +++ linux-2.6.24.7/drivers/usb/host/Kconfig
194 @@ -69,12 +69,12 @@ config USB_EHCI_TT_NEWSCHED
195
196 config USB_EHCI_BIG_ENDIAN_MMIO
197 bool
198 - depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX)
199 + depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX)
200 default y
201
202 config USB_EHCI_BIG_ENDIAN_DESC
203 bool
204 - depends on USB_EHCI_HCD && 440EPX
205 + depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX)
206 default y
207
208 config USB_EHCI_FSL
209 Index: linux-2.6.24.7/drivers/usb/Kconfig
210 ===================================================================
211 --- linux-2.6.24.7.orig/drivers/usb/Kconfig
212 +++ linux-2.6.24.7/drivers/usb/Kconfig
213 @@ -49,6 +49,7 @@ config USB_ARCH_HAS_EHCI
214 boolean
215 default y if PPC_83xx
216 default y if SOC_AU1200
217 + default y if ARCH_IXP4XX
218 default PCI
219
220 # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.