Merge commit 'v2.6.37-rc1' into for-2.6.37
[pandora-kernel.git] / arch / arm / mach-mx25 / devices.c
1 /*
2  * Copyright 2009 Sascha Hauer, <kernel@pengutronix.de>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA  02110-1301, USA.
17  */
18
19 #include <linux/platform_device.h>
20 #include <linux/dma-mapping.h>
21 #include <linux/gpio.h>
22 #include <mach/mx25.h>
23 #include <mach/irqs.h>
24
25 static u64 otg_dmamask = DMA_BIT_MASK(32);
26
27 static struct resource mxc_otg_resources[] = {
28         {
29                 .start = MX25_OTG_BASE_ADDR,
30                 .end = MX25_OTG_BASE_ADDR + 0x1ff,
31                 .flags = IORESOURCE_MEM,
32         }, {
33                 .start = 37,
34                 .end = 37,
35                 .flags = IORESOURCE_IRQ,
36         },
37 };
38
39 struct platform_device mxc_otg = {
40         .name = "mxc-ehci",
41         .id = 0,
42         .dev = {
43                 .coherent_dma_mask = 0xffffffff,
44                 .dma_mask = &otg_dmamask,
45         },
46         .resource = mxc_otg_resources,
47         .num_resources = ARRAY_SIZE(mxc_otg_resources),
48 };
49
50 /* OTG gadget device */
51 struct platform_device otg_udc_device = {
52         .name = "fsl-usb2-udc",
53         .id   = -1,
54         .dev  = {
55                 .dma_mask          = &otg_dmamask,
56                 .coherent_dma_mask = 0xffffffff,
57         },
58         .resource = mxc_otg_resources,
59         .num_resources = ARRAY_SIZE(mxc_otg_resources),
60 };
61
62 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
63
64 static struct resource mxc_usbh2_resources[] = {
65         {
66                 .start = MX25_OTG_BASE_ADDR + 0x400,
67                 .end = MX25_OTG_BASE_ADDR + 0x5ff,
68                 .flags = IORESOURCE_MEM,
69         }, {
70                 .start = 35,
71                 .end = 35,
72                 .flags = IORESOURCE_IRQ,
73         },
74 };
75
76 struct platform_device mxc_usbh2 = {
77         .name = "mxc-ehci",
78         .id = 1,
79         .dev = {
80                 .coherent_dma_mask = 0xffffffff,
81                 .dma_mask = &usbh2_dmamask,
82         },
83         .resource = mxc_usbh2_resources,
84         .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
85 };
86
87 static struct resource mxc_pwm_resources0[] = {
88         {
89                 .start  = 0x53fe0000,
90                 .end    = 0x53fe3fff,
91                 .flags  = IORESOURCE_MEM,
92         }, {
93                 .start   = 26,
94                 .end     = 26,
95                 .flags   = IORESOURCE_IRQ,
96         }
97 };
98
99 struct platform_device mxc_pwm_device0 = {
100         .name = "mxc_pwm",
101         .id = 0,
102         .num_resources = ARRAY_SIZE(mxc_pwm_resources0),
103         .resource = mxc_pwm_resources0,
104 };
105
106 static struct resource mxc_pwm_resources1[] = {
107         {
108                 .start  = 0x53fa0000,
109                 .end    = 0x53fa3fff,
110                 .flags  = IORESOURCE_MEM,
111         }, {
112                 .start   = 36,
113                 .end     = 36,
114                 .flags   = IORESOURCE_IRQ,
115         }
116 };
117
118 struct platform_device mxc_pwm_device1 = {
119         .name = "mxc_pwm",
120         .id = 1,
121         .num_resources = ARRAY_SIZE(mxc_pwm_resources1),
122         .resource = mxc_pwm_resources1,
123 };
124
125 static struct resource mxc_pwm_resources2[] = {
126         {
127                 .start  = 0x53fa8000,
128                 .end    = 0x53fabfff,
129                 .flags  = IORESOURCE_MEM,
130         }, {
131                 .start   = 41,
132                 .end     = 41,
133                 .flags   = IORESOURCE_IRQ,
134         }
135 };
136
137 struct platform_device mxc_pwm_device2 = {
138         .name = "mxc_pwm",
139         .id = 2,
140         .num_resources = ARRAY_SIZE(mxc_pwm_resources2),
141         .resource = mxc_pwm_resources2,
142 };
143
144 static struct resource mxc_keypad_resources[] = {
145         {
146                 .start  = 0x43fa8000,
147                 .end    = 0x43fabfff,
148                 .flags  = IORESOURCE_MEM,
149         }, {
150                 .start   = 24,
151                 .end     = 24,
152                 .flags   = IORESOURCE_IRQ,
153         }
154 };
155
156 struct platform_device mxc_keypad_device = {
157         .name = "mxc-keypad",
158         .id = -1,
159         .num_resources = ARRAY_SIZE(mxc_keypad_resources),
160         .resource = mxc_keypad_resources,
161 };
162
163 static struct resource mxc_pwm_resources3[] = {
164         {
165                 .start  = 0x53fc8000,
166                 .end    = 0x53fcbfff,
167                 .flags  = IORESOURCE_MEM,
168         }, {
169                 .start   = 42,
170                 .end     = 42,
171                 .flags   = IORESOURCE_IRQ,
172         }
173 };
174
175 struct platform_device mxc_pwm_device3 = {
176         .name = "mxc_pwm",
177         .id = 3,
178         .num_resources = ARRAY_SIZE(mxc_pwm_resources3),
179         .resource = mxc_pwm_resources3,
180 };
181
182 static struct mxc_gpio_port imx_gpio_ports[] = {
183         {
184                 .chip.label = "gpio-0",
185                 .base = (void __iomem *)MX25_GPIO1_BASE_ADDR_VIRT,
186                 .irq = 52,
187                 .virtual_irq_start = MXC_GPIO_IRQ_START,
188         }, {
189                 .chip.label = "gpio-1",
190                 .base = (void __iomem *)MX25_GPIO2_BASE_ADDR_VIRT,
191                 .irq = 51,
192                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
193         }, {
194                 .chip.label = "gpio-2",
195                 .base = (void __iomem *)MX25_GPIO3_BASE_ADDR_VIRT,
196                 .irq = 16,
197                 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
198         }, {
199                 .chip.label = "gpio-3",
200                 .base = (void __iomem *)MX25_GPIO4_BASE_ADDR_VIRT,
201                 .irq = 23,
202                 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
203         }
204 };
205
206 int __init imx25_register_gpios(void)
207 {
208         return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
209 }
210
211 static struct resource mx25_rtc_resources[] = {
212         {
213                 .start  = MX25_DRYICE_BASE_ADDR,
214                 .end    = MX25_DRYICE_BASE_ADDR + 0x40,
215                 .flags  = IORESOURCE_MEM,
216         },
217         {
218                 .start  = MX25_INT_DRYICE,
219                 .flags  = IORESOURCE_IRQ
220         },
221 };
222
223 struct platform_device mx25_rtc_device = {
224         .name   = "imxdi_rtc",
225         .id     = 0,
226         .num_resources  = ARRAY_SIZE(mx25_rtc_resources),
227         .resource       = mx25_rtc_resources,
228 };
229
230 static struct resource mx25_fb_resources[] = {
231         {
232                 .start  = MX25_LCDC_BASE_ADDR,
233                 .end    = MX25_LCDC_BASE_ADDR + 0xfff,
234                 .flags  = IORESOURCE_MEM,
235         },
236         {
237                 .start  = MX25_INT_LCDC,
238                 .end    = MX25_INT_LCDC,
239                 .flags  = IORESOURCE_IRQ,
240         },
241 };
242
243 struct platform_device mx25_fb_device = {
244         .name           = "imx-fb",
245         .id             = 0,
246         .resource       = mx25_fb_resources,
247         .num_resources  = ARRAY_SIZE(mx25_fb_resources),
248         .dev            = {
249                 .coherent_dma_mask = 0xFFFFFFFF,
250         },
251 };
252
253 static struct resource mxc_wdt_resources[] = {
254         {
255                 .start = MX25_WDOG_BASE_ADDR,
256                 .end = MX25_WDOG_BASE_ADDR + SZ_16K - 1,
257                 .flags = IORESOURCE_MEM,
258         },
259 };
260
261 struct platform_device mxc_wdt = {
262         .name = "imx2-wdt",
263         .id = 0,
264         .num_resources = ARRAY_SIZE(mxc_wdt_resources),
265         .resource = mxc_wdt_resources,
266 };
267
268 static struct resource mx25_kpp_resources[] = {
269         {
270                 .start  = MX25_KPP_BASE_ADDR,
271                 .end    = MX25_KPP_BASE_ADDR + 0xf,
272                 .flags  = IORESOURCE_MEM,
273         },
274         {
275                 .start  = MX25_INT_KPP,
276                 .end    = MX25_INT_KPP,
277                 .flags  = IORESOURCE_IRQ,
278         },
279 };
280
281 struct platform_device mx25_kpp_device = {
282         .name   = "imx-keypad",
283         .id     = -1,
284         .num_resources  = ARRAY_SIZE(mx25_kpp_resources),
285         .resource       = mx25_kpp_resources,
286 };
287
288 static struct resource mx25_csi_resources[] = {
289         {
290                 .start  = MX25_CSI_BASE_ADDR,
291                 .end    = MX25_CSI_BASE_ADDR + 0xfff,
292                 .flags  = IORESOURCE_MEM,
293         },
294         {
295                 .start  = MX25_INT_CSI,
296                 .flags  = IORESOURCE_IRQ
297         },
298 };
299
300 struct platform_device mx25_csi_device = {
301         .name   = "mx2-camera",
302         .id     = 0,
303         .num_resources  = ARRAY_SIZE(mx25_csi_resources),
304         .resource       = mx25_csi_resources,
305         .dev            = {
306                 .coherent_dma_mask = 0xffffffff,
307         },
308 };