ARM: imx: remove unused devices
[pandora-kernel.git] / arch / arm / mach-imx / devices.c
1 /*
2  * Author: MontaVista Software, Inc.
3  *       <source@mvista.com>
4  *
5  * Based on the OMAP devices.c
6  *
7  * 2005 (c) MontaVista Software, Inc. This file is licensed under the
8  * terms of the GNU General Public License version 2. This program is
9  * licensed "as is" without any warranty of any kind, whether express
10  * or implied.
11  *
12  * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
13  * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
14  * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
15  * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
16  * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
30  * MA 02110-1301, USA.
31  */
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/init.h>
35 #include <linux/platform_device.h>
36 #include <linux/gpio.h>
37 #include <linux/dma-mapping.h>
38 #include <linux/serial.h>
39
40 #include <mach/irqs.h>
41 #include <mach/hardware.h>
42 #include <mach/common.h>
43 #include <mach/mmc.h>
44
45 #include "devices.h"
46
47 #if defined(CONFIG_ARCH_MX1)
48 static struct resource imx1_camera_resources[] = {
49         {
50                 .start  = 0x00224000,
51                 .end    = 0x00224010,
52                 .flags  = IORESOURCE_MEM,
53         }, {
54                 .start  = MX1_CSI_INT,
55                 .end    = MX1_CSI_INT,
56                 .flags  = IORESOURCE_IRQ,
57         },
58 };
59
60 static u64 imx1_camera_dmamask = DMA_BIT_MASK(32);
61
62 struct platform_device imx1_camera_device = {
63         .name           = "mx1-camera",
64         .id             = 0, /* This is used to put cameras on this interface */
65         .dev            = {
66                 .dma_mask = &imx1_camera_dmamask,
67                 .coherent_dma_mask = DMA_BIT_MASK(32),
68         },
69         .resource       = imx1_camera_resources,
70         .num_resources  = ARRAY_SIZE(imx1_camera_resources),
71 };
72
73 static struct resource imx_usb_resources[] = {
74         {
75                 .start  = 0x00212000,
76                 .end    = 0x00212148,
77                 .flags  = IORESOURCE_MEM,
78         }, {
79                 .start  = MX1_USBD_INT0,
80                 .end    = MX1_USBD_INT0,
81                 .flags  = IORESOURCE_IRQ,
82         }, {
83                 .start  = MX1_USBD_INT1,
84                 .end    = MX1_USBD_INT1,
85                 .flags  = IORESOURCE_IRQ,
86         }, {
87                 .start  = MX1_USBD_INT2,
88                 .end    = MX1_USBD_INT2,
89                 .flags  = IORESOURCE_IRQ,
90         }, {
91                 .start  = MX1_USBD_INT3,
92                 .end    = MX1_USBD_INT3,
93                 .flags  = IORESOURCE_IRQ,
94         }, {
95                 .start  = MX1_USBD_INT4,
96                 .end    = MX1_USBD_INT4,
97                 .flags  = IORESOURCE_IRQ,
98         }, {
99                 .start  = MX1_USBD_INT5,
100                 .end    = MX1_USBD_INT5,
101                 .flags  = IORESOURCE_IRQ,
102         }, {
103                 .start  = MX1_USBD_INT6,
104                 .end    = MX1_USBD_INT6,
105                 .flags  = IORESOURCE_IRQ,
106         },
107 };
108
109 struct platform_device imx_usb_device = {
110         .name           = "imx_udc",
111         .id             = 0,
112         .num_resources  = ARRAY_SIZE(imx_usb_resources),
113         .resource       = imx_usb_resources,
114 };
115
116 /* GPIO port description */
117 static struct mxc_gpio_port imx_gpio_ports[] = {
118         {
119                 .chip.label = "gpio-0",
120                 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
121                 .irq = MX1_GPIO_INT_PORTA,
122                 .virtual_irq_start = MXC_GPIO_IRQ_START,
123         }, {
124                 .chip.label = "gpio-1",
125                 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
126                 .irq = MX1_GPIO_INT_PORTB,
127                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
128         }, {
129                 .chip.label = "gpio-2",
130                 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
131                 .irq = MX1_GPIO_INT_PORTC,
132                 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
133         }, {
134                 .chip.label = "gpio-3",
135                 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
136                 .irq = MX1_GPIO_INT_PORTD,
137                 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
138         }
139 };
140
141 int __init imx1_register_gpios(void)
142 {
143         return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
144 }
145 #endif
146
147 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
148
149 #ifdef CONFIG_MACH_MX27
150 static struct resource mx27_camera_resources[] = {
151         {
152                .start = MX27_CSI_BASE_ADDR,
153                .end = MX27_CSI_BASE_ADDR + 0x1f,
154                .flags = IORESOURCE_MEM,
155         }, {
156                .start = MX27_EMMA_PRP_BASE_ADDR,
157                .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
158                .flags = IORESOURCE_MEM,
159         }, {
160                .start = MX27_INT_CSI,
161                .end = MX27_INT_CSI,
162                .flags = IORESOURCE_IRQ,
163         },{
164                .start = MX27_INT_EMMAPRP,
165                .end = MX27_INT_EMMAPRP,
166                .flags = IORESOURCE_IRQ,
167         },
168 };
169 struct platform_device mx27_camera_device = {
170         .name = "mx2-camera",
171         .id = 0,
172         .num_resources = ARRAY_SIZE(mx27_camera_resources),
173         .resource = mx27_camera_resources,
174         .dev = {
175                 .coherent_dma_mask = 0xffffffff,
176         },
177 };
178 #endif
179
180 /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
181 static struct resource mxc_wdt_resources[] = {
182         {
183                 .start = MX2x_WDOG_BASE_ADDR,
184                 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
185                 .flags = IORESOURCE_MEM,
186         },
187 };
188
189 struct platform_device mxc_wdt = {
190         .name = "imx2-wdt",
191         .id = 0,
192         .num_resources = ARRAY_SIZE(mxc_wdt_resources),
193         .resource = mxc_wdt_resources,
194 };
195
196 /*
197  * lcdc:
198  * - i.MX1: the basic controller
199  * - i.MX21: to be checked
200  * - i.MX27: like i.MX1, with slightly variations
201  */
202 static struct resource mxc_fb[] = {
203         {
204                 .start = MX2x_LCDC_BASE_ADDR,
205                 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
206                 .flags = IORESOURCE_MEM,
207         }, {
208                 .start = MX2x_INT_LCDC,
209                 .end = MX2x_INT_LCDC,
210                 .flags = IORESOURCE_IRQ,
211         }
212 };
213
214 /* mxc lcd driver */
215 struct platform_device mxc_fb_device = {
216         .name = "imx-fb",
217         .id = 0,
218         .num_resources = ARRAY_SIZE(mxc_fb),
219         .resource = mxc_fb,
220         .dev = {
221                 .coherent_dma_mask = DMA_BIT_MASK(32),
222         },
223 };
224
225 static struct resource mxc_pwm_resources[] = {
226         {
227                 .start = MX2x_PWM_BASE_ADDR,
228                 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
229                 .flags = IORESOURCE_MEM,
230         }, {
231                 .start = MX2x_INT_PWM,
232                 .end = MX2x_INT_PWM,
233                 .flags = IORESOURCE_IRQ,
234         }
235 };
236
237 struct platform_device mxc_pwm_device = {
238         .name = "mxc_pwm",
239         .id = 0,
240         .num_resources = ARRAY_SIZE(mxc_pwm_resources),
241         .resource = mxc_pwm_resources,
242 };
243
244 #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq)                 \
245         static struct resource mxc_sdhc_resources ## n[] = {            \
246                 {                                                       \
247                         .start = baseaddr,                              \
248                         .end = baseaddr + SZ_4K - 1,                    \
249                         .flags = IORESOURCE_MEM,                        \
250                 }, {                                                    \
251                         .start = irq,                                   \
252                         .end = irq,                                     \
253                         .flags = IORESOURCE_IRQ,                        \
254                 }, {                                                    \
255                         .start = dmareq,                                \
256                         .end = dmareq,                                  \
257                         .flags = IORESOURCE_DMA,                        \
258                 },                                                      \
259         };                                                              \
260                                                                         \
261         static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32);        \
262                                                                         \
263         struct platform_device mxc_sdhc_device ## n = {                 \
264                 .name = "mxc-mmc",                                      \
265                 .id = n,                                                \
266                 .dev = {                                                \
267                         .dma_mask = &mxc_sdhc ## n ## _dmamask,         \
268                         .coherent_dma_mask = DMA_BIT_MASK(32),          \
269                 },                                                      \
270                 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n),   \
271                 .resource = mxc_sdhc_resources ## n,            \
272         }
273
274 DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
275 DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
276
277 #ifdef CONFIG_MACH_MX27
278 static struct resource otg_resources[] = {
279         {
280                 .start = MX27_USBOTG_BASE_ADDR,
281                 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
282                 .flags = IORESOURCE_MEM,
283         }, {
284                 .start = MX27_INT_USB3,
285                 .end = MX27_INT_USB3,
286                 .flags = IORESOURCE_IRQ,
287         },
288 };
289
290 static u64 otg_dmamask = DMA_BIT_MASK(32);
291
292 /* OTG gadget device */
293 struct platform_device mxc_otg_udc_device = {
294         .name           = "fsl-usb2-udc",
295         .id             = -1,
296         .dev            = {
297                 .dma_mask               = &otg_dmamask,
298                 .coherent_dma_mask      = DMA_BIT_MASK(32),
299         },
300         .resource       = otg_resources,
301         .num_resources  = ARRAY_SIZE(otg_resources),
302 };
303
304 /* OTG host */
305 struct platform_device mxc_otg_host = {
306         .name = "mxc-ehci",
307         .id = 0,
308         .dev = {
309                 .coherent_dma_mask = DMA_BIT_MASK(32),
310                 .dma_mask = &otg_dmamask,
311         },
312         .resource = otg_resources,
313         .num_resources = ARRAY_SIZE(otg_resources),
314 };
315
316 /* USB host 1 */
317
318 static u64 usbh1_dmamask = DMA_BIT_MASK(32);
319
320 static struct resource mxc_usbh1_resources[] = {
321         {
322                 .start = MX27_USBOTG_BASE_ADDR + 0x200,
323                 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
324                 .flags = IORESOURCE_MEM,
325         }, {
326                 .start = MX27_INT_USB1,
327                 .end = MX27_INT_USB1,
328                 .flags = IORESOURCE_IRQ,
329         },
330 };
331
332 struct platform_device mxc_usbh1 = {
333         .name = "mxc-ehci",
334         .id = 1,
335         .dev = {
336                 .coherent_dma_mask = DMA_BIT_MASK(32),
337                 .dma_mask = &usbh1_dmamask,
338         },
339         .resource = mxc_usbh1_resources,
340         .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
341 };
342
343 /* USB host 2 */
344 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
345
346 static struct resource mxc_usbh2_resources[] = {
347         {
348                 .start = MX27_USBOTG_BASE_ADDR + 0x400,
349                 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
350                 .flags = IORESOURCE_MEM,
351         }, {
352                 .start = MX27_INT_USB2,
353                 .end = MX27_INT_USB2,
354                 .flags = IORESOURCE_IRQ,
355         },
356 };
357
358 struct platform_device mxc_usbh2 = {
359         .name = "mxc-ehci",
360         .id = 2,
361         .dev = {
362                 .coherent_dma_mask = DMA_BIT_MASK(32),
363                 .dma_mask = &usbh2_dmamask,
364         },
365         .resource = mxc_usbh2_resources,
366         .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
367 };
368 #endif
369
370 /* GPIO port description */
371 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq)                          \
372         {                                                               \
373                 .chip.label = "gpio-" #n,                               \
374                 .irq = _irq,                                            \
375                 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR +        \
376                                 n * 0x100),                             \
377                 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,       \
378         }
379
380 #define DEFINE_MXC_GPIO_PORT(SOC, n)                                    \
381         {                                                               \
382                 .chip.label = "gpio-" #n,                               \
383                 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR +        \
384                                 n * 0x100),                             \
385                 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,       \
386         }
387
388 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx)                                 \
389         static struct mxc_gpio_port pfx ## _gpio_ports[] = {            \
390                 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO),     \
391                 DEFINE_MXC_GPIO_PORT(SOC, 1),                           \
392                 DEFINE_MXC_GPIO_PORT(SOC, 2),                           \
393                 DEFINE_MXC_GPIO_PORT(SOC, 3),                           \
394                 DEFINE_MXC_GPIO_PORT(SOC, 4),                           \
395                 DEFINE_MXC_GPIO_PORT(SOC, 5),                           \
396         }
397
398 #ifdef CONFIG_MACH_MX21
399 DEFINE_MXC_GPIO_PORTS(MX21, imx21);
400
401 int __init imx21_register_gpios(void)
402 {
403         return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
404 }
405 #endif
406
407 #ifdef CONFIG_MACH_MX27
408 DEFINE_MXC_GPIO_PORTS(MX27, imx27);
409
410 int __init imx27_register_gpios(void)
411 {
412         return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
413 }
414 #endif
415
416 #ifdef CONFIG_MACH_MX21
417 static struct resource mx21_usbhc_resources[] = {
418         {
419                 .start  = MX21_USBOTG_BASE_ADDR,
420                 .end    = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
421                 .flags  = IORESOURCE_MEM,
422         },
423         {
424                 .start          = MX21_INT_USBHOST,
425                 .end            = MX21_INT_USBHOST,
426                 .flags          = IORESOURCE_IRQ,
427         },
428 };
429
430 struct platform_device mx21_usbhc_device = {
431         .name           = "imx21-hcd",
432         .id             = 0,
433         .dev            = {
434                 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
435                 .coherent_dma_mask = DMA_BIT_MASK(32),
436         },
437         .num_resources  = ARRAY_SIZE(mx21_usbhc_resources),
438         .resource       = mx21_usbhc_resources,
439 };
440 #endif
441
442 static struct resource imx_kpp_resources[] = {
443         {
444                 .start  = MX2x_KPP_BASE_ADDR,
445                 .end    = MX2x_KPP_BASE_ADDR + 0xf,
446                 .flags  = IORESOURCE_MEM
447         }, {
448                 .start  = MX2x_INT_KPP,
449                 .end    = MX2x_INT_KPP,
450                 .flags  = IORESOURCE_IRQ,
451         },
452 };
453
454 struct platform_device imx_kpp_device = {
455         .name = "imx-keypad",
456         .id = -1,
457         .num_resources = ARRAY_SIZE(imx_kpp_resources),
458         .resource = imx_kpp_resources,
459 };
460
461 #endif