Merge git://github.com/rustyrussell/linux
[pandora-kernel.git] / arch / arm / plat-mxc / devices / platform-mxc-ehci.c
1 /*
2  * Copyright (C) 2010 Pengutronix
3  * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 2 as published by the
7  * Free Software Foundation.
8  */
9 #include <linux/dma-mapping.h>
10 #include <mach/hardware.h>
11 #include <mach/devices-common.h>
12
13 #define imx_mxc_ehci_data_entry_single(soc, _id, hs)                    \
14         {                                                               \
15                 .id = _id,                                              \
16                 .iobase = soc ## _USB_ ## hs ## _BASE_ADDR,             \
17                 .irq = soc ## _INT_USB_ ## hs,                          \
18         }
19
20 #ifdef CONFIG_SOC_IMX25
21 const struct imx_mxc_ehci_data imx25_mxc_ehci_otg_data __initconst =
22         imx_mxc_ehci_data_entry_single(MX25, 0, OTG);
23 const struct imx_mxc_ehci_data imx25_mxc_ehci_hs_data __initconst =
24         imx_mxc_ehci_data_entry_single(MX25, 1, HS);
25 #endif /* ifdef CONFIG_SOC_IMX25 */
26
27 #ifdef CONFIG_SOC_IMX27
28 const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data __initconst =
29         imx_mxc_ehci_data_entry_single(MX27, 0, OTG);
30 const struct imx_mxc_ehci_data imx27_mxc_ehci_hs_data[] __initconst = {
31         imx_mxc_ehci_data_entry_single(MX27, 1, HS1),
32         imx_mxc_ehci_data_entry_single(MX27, 2, HS2),
33 };
34 #endif /* ifdef CONFIG_SOC_IMX27 */
35
36 #ifdef CONFIG_SOC_IMX31
37 const struct imx_mxc_ehci_data imx31_mxc_ehci_otg_data __initconst =
38         imx_mxc_ehci_data_entry_single(MX31, 0, OTG);
39 const struct imx_mxc_ehci_data imx31_mxc_ehci_hs_data[] __initconst = {
40         imx_mxc_ehci_data_entry_single(MX31, 1, HS1),
41         imx_mxc_ehci_data_entry_single(MX31, 2, HS2),
42 };
43 #endif /* ifdef CONFIG_SOC_IMX31 */
44
45 #ifdef CONFIG_SOC_IMX35
46 const struct imx_mxc_ehci_data imx35_mxc_ehci_otg_data __initconst =
47         imx_mxc_ehci_data_entry_single(MX35, 0, OTG);
48 const struct imx_mxc_ehci_data imx35_mxc_ehci_hs_data __initconst =
49         imx_mxc_ehci_data_entry_single(MX35, 1, HS);
50 #endif /* ifdef CONFIG_SOC_IMX35 */
51
52 #ifdef CONFIG_SOC_IMX51
53 const struct imx_mxc_ehci_data imx51_mxc_ehci_otg_data __initconst =
54         imx_mxc_ehci_data_entry_single(MX51, 0, OTG);
55 const struct imx_mxc_ehci_data imx51_mxc_ehci_hs_data[] __initconst = {
56         imx_mxc_ehci_data_entry_single(MX51, 1, HS1),
57         imx_mxc_ehci_data_entry_single(MX51, 2, HS2),
58 };
59 #endif /* ifdef CONFIG_SOC_IMX51 */
60
61 struct platform_device *__init imx_add_mxc_ehci(
62                 const struct imx_mxc_ehci_data *data,
63                 const struct mxc_usbh_platform_data *pdata)
64 {
65         struct resource res[] = {
66                 {
67                         .start = data->iobase,
68                         .end = data->iobase + SZ_512 - 1,
69                         .flags = IORESOURCE_MEM,
70                 }, {
71                         .start = data->irq,
72                         .end = data->irq,
73                         .flags = IORESOURCE_IRQ,
74                 },
75         };
76         return imx_add_platform_device_dmamask("mxc-ehci", data->id,
77                         res, ARRAY_SIZE(res),
78                         pdata, sizeof(*pdata), DMA_BIT_MASK(32));
79 }