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