]> bbs.cooldavid.org Git - net-next-2.6.git/blob - arch/arm/mach-imx/devices.c
ARM: imx: dynamically register imx-i2c devices (imx1)
[net-next-2.6.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 #define DEFINE_IMX1_UART_DEVICE(n, baseaddr, irqrx, irqtx, irqrts)      \
74         static struct resource imx1_uart_resources ## n[] = {           \
75                 {                                                       \
76                         .start = baseaddr,                              \
77                         .end = baseaddr + 0xd0,                         \
78                         .flags = IORESOURCE_MEM,                        \
79                 }, {                                                    \
80                         .start = irqrx,                                 \
81                         .end = irqrx,                                   \
82                         .flags = IORESOURCE_IRQ,                        \
83                 }, {                                                    \
84                         .start = irqtx,                                 \
85                         .end = irqtx,                                   \
86                         .flags = IORESOURCE_IRQ,                        \
87                 }, {                                                    \
88                         .start = irqrts,                                \
89                         .end = irqrts,                                  \
90                         .flags = IORESOURCE_IRQ,                        \
91                 },                                                      \
92         };                                                              \
93                                                                         \
94         struct platform_device imx1_uart_device ## n = {                \
95                 .name = "imx-uart",                                     \
96                 .id = n,                                                \
97                 .num_resources = ARRAY_SIZE(imx1_uart_resources ## n),  \
98                 .resource = imx1_uart_resources ## n,                   \
99         }
100
101 DEFINE_IMX1_UART_DEVICE(0, MX1_UART1_BASE_ADDR, MX1_UART1_MINT_RX, MX1_UART1_MINT_TX, MX1_UART1_MINT_RTS);
102 DEFINE_IMX1_UART_DEVICE(1, MX1_UART2_BASE_ADDR, MX1_UART2_MINT_RX, MX1_UART2_MINT_TX, MX1_UART2_MINT_RTS);
103
104 static struct resource imx_rtc_resources[] = {
105         {
106                 .start  = 0x00204000,
107                 .end    = 0x00204024,
108                 .flags  = IORESOURCE_MEM,
109         }, {
110                 .start  = MX1_RTC_INT,
111                 .end    = MX1_RTC_INT,
112                 .flags  = IORESOURCE_IRQ,
113         }, {
114                 .start  = MX1_RTC_SAMINT,
115                 .end    = MX1_RTC_SAMINT,
116                 .flags  = IORESOURCE_IRQ,
117         },
118 };
119
120 struct platform_device imx_rtc_device = {
121         .name           = "rtc-imx",
122         .id             = 0,
123         .resource       = imx_rtc_resources,
124         .num_resources  = ARRAY_SIZE(imx_rtc_resources),
125 };
126
127 static struct resource imx_wdt_resources[] = {
128         {
129                 .start  = 0x00201000,
130                 .end    = 0x00201008,
131                 .flags  = IORESOURCE_MEM,
132         }, {
133                 .start  = MX1_WDT_INT,
134                 .end    = MX1_WDT_INT,
135                 .flags  = IORESOURCE_IRQ,
136         },
137 };
138
139 struct platform_device imx_wdt_device = {
140         .name           = "imx-wdt",
141         .id             = 0,
142         .resource       = imx_wdt_resources,
143         .num_resources  = ARRAY_SIZE(imx_wdt_resources),
144 };
145
146 static struct resource imx_usb_resources[] = {
147         {
148                 .start  = 0x00212000,
149                 .end    = 0x00212148,
150                 .flags  = IORESOURCE_MEM,
151         }, {
152                 .start  = MX1_USBD_INT0,
153                 .end    = MX1_USBD_INT0,
154                 .flags  = IORESOURCE_IRQ,
155         }, {
156                 .start  = MX1_USBD_INT1,
157                 .end    = MX1_USBD_INT1,
158                 .flags  = IORESOURCE_IRQ,
159         }, {
160                 .start  = MX1_USBD_INT2,
161                 .end    = MX1_USBD_INT2,
162                 .flags  = IORESOURCE_IRQ,
163         }, {
164                 .start  = MX1_USBD_INT3,
165                 .end    = MX1_USBD_INT3,
166                 .flags  = IORESOURCE_IRQ,
167         }, {
168                 .start  = MX1_USBD_INT4,
169                 .end    = MX1_USBD_INT4,
170                 .flags  = IORESOURCE_IRQ,
171         }, {
172                 .start  = MX1_USBD_INT5,
173                 .end    = MX1_USBD_INT5,
174                 .flags  = IORESOURCE_IRQ,
175         }, {
176                 .start  = MX1_USBD_INT6,
177                 .end    = MX1_USBD_INT6,
178                 .flags  = IORESOURCE_IRQ,
179         },
180 };
181
182 struct platform_device imx_usb_device = {
183         .name           = "imx_udc",
184         .id             = 0,
185         .num_resources  = ARRAY_SIZE(imx_usb_resources),
186         .resource       = imx_usb_resources,
187 };
188
189 /* GPIO port description */
190 static struct mxc_gpio_port imx_gpio_ports[] = {
191         {
192                 .chip.label = "gpio-0",
193                 .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
194                 .irq = MX1_GPIO_INT_PORTA,
195                 .virtual_irq_start = MXC_GPIO_IRQ_START,
196         }, {
197                 .chip.label = "gpio-1",
198                 .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
199                 .irq = MX1_GPIO_INT_PORTB,
200                 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
201         }, {
202                 .chip.label = "gpio-2",
203                 .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
204                 .irq = MX1_GPIO_INT_PORTC,
205                 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
206         }, {
207                 .chip.label = "gpio-3",
208                 .base = (void __iomem *)MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
209                 .irq = MX1_GPIO_INT_PORTD,
210                 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
211         }
212 };
213
214 int __init imx1_register_gpios(void)
215 {
216         return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
217 }
218 #endif
219
220 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
221 /*
222  * SPI master controller
223  *
224  * - i.MX1: 2 channel (slighly different register setting)
225  * - i.MX21: 2 channel
226  * - i.MX27: 3 channel
227  */
228 #define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq)                                 \
229         static struct resource mxc_spi_resources ## n[] = {                     \
230                 {                                                               \
231                         .start = baseaddr,                                      \
232                         .end = baseaddr + SZ_4K - 1,                            \
233                         .flags = IORESOURCE_MEM,                                \
234                 }, {                                                            \
235                         .start = irq,                                           \
236                         .end = irq,                                             \
237                         .flags = IORESOURCE_IRQ,                                \
238                 },                                                              \
239         };                                                                      \
240                                                                                 \
241         struct platform_device mxc_spi_device ## n = {                          \
242                 .name = "spi_imx",                                              \
243                 .id = n,                                                        \
244                 .num_resources = ARRAY_SIZE(mxc_spi_resources ## n),            \
245                 .resource = mxc_spi_resources ## n,                             \
246         }
247
248 DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1);
249 DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2);
250
251 #ifdef CONFIG_MACH_MX27
252 DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3);
253 #endif
254
255 /*
256  * General Purpose Timer
257  * - i.MX21: 3 timers
258  * - i.MX27: 6 timers
259  */
260 #define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq)                         \
261         static struct resource timer ## n ##_resources[] = {            \
262                 {                                                       \
263                         .start = baseaddr,                              \
264                         .end = baseaddr + SZ_4K - 1,                    \
265                         .flags = IORESOURCE_MEM,                        \
266                 }, {                                                    \
267                         .start = irq,                                   \
268                         .end = irq,                                     \
269                         .flags = IORESOURCE_IRQ,                        \
270                 }                                                       \
271         };                                                              \
272                                                                         \
273         struct platform_device mxc_gpt ## n = {                         \
274                 .name = "imx_gpt",                                      \
275                 .id = n,                                                \
276                 .num_resources = ARRAY_SIZE(timer ## n ## _resources),  \
277                 .resource = timer ## n ## _resources,                   \
278         }
279
280 /* We use gpt1 as system timer, so do not add a device for this one */
281 DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2);
282 DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3);
283
284 #ifdef CONFIG_MACH_MX27
285 DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4);
286 DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5);
287 DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6);
288 #endif
289
290 /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
291 static struct resource mxc_wdt_resources[] = {
292         {
293                 .start = MX2x_WDOG_BASE_ADDR,
294                 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
295                 .flags = IORESOURCE_MEM,
296         },
297 };
298
299 struct platform_device mxc_wdt = {
300         .name = "imx2-wdt",
301         .id = 0,
302         .num_resources = ARRAY_SIZE(mxc_wdt_resources),
303         .resource = mxc_wdt_resources,
304 };
305
306 static struct resource mxc_w1_master_resources[] = {
307         {
308                 .start = MX2x_OWIRE_BASE_ADDR,
309                 .end = MX2x_OWIRE_BASE_ADDR + SZ_4K - 1,
310                 .flags = IORESOURCE_MEM,
311         },
312 };
313
314 struct platform_device mxc_w1_master_device = {
315         .name = "mxc_w1",
316         .id = 0,
317         .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
318         .resource = mxc_w1_master_resources,
319 };
320
321 /*
322  * lcdc:
323  * - i.MX1: the basic controller
324  * - i.MX21: to be checked
325  * - i.MX27: like i.MX1, with slightly variations
326  */
327 static struct resource mxc_fb[] = {
328         {
329                 .start = MX2x_LCDC_BASE_ADDR,
330                 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
331                 .flags = IORESOURCE_MEM,
332         }, {
333                 .start = MX2x_INT_LCDC,
334                 .end = MX2x_INT_LCDC,
335                 .flags = IORESOURCE_IRQ,
336         }
337 };
338
339 /* mxc lcd driver */
340 struct platform_device mxc_fb_device = {
341         .name = "imx-fb",
342         .id = 0,
343         .num_resources = ARRAY_SIZE(mxc_fb),
344         .resource = mxc_fb,
345         .dev = {
346                 .coherent_dma_mask = DMA_BIT_MASK(32),
347         },
348 };
349
350 #ifdef CONFIG_MACH_MX27
351 static struct resource mxc_fec_resources[] = {
352         {
353                 .start = MX27_FEC_BASE_ADDR,
354                 .end = MX27_FEC_BASE_ADDR + SZ_4K - 1,
355                 .flags = IORESOURCE_MEM,
356         }, {
357                 .start = MX27_INT_FEC,
358                 .end = MX27_INT_FEC,
359                 .flags = IORESOURCE_IRQ,
360         },
361 };
362
363 struct platform_device mxc_fec_device = {
364         .name = "fec",
365         .id = 0,
366         .num_resources = ARRAY_SIZE(mxc_fec_resources),
367         .resource = mxc_fec_resources,
368 };
369 #endif
370
371 #define DEFINE_IMX_I2C_DEVICE(n, baseaddr, irq)                         \
372         static struct resource mxc_i2c_resources ## n[] = {             \
373                 {                                                       \
374                         .start = baseaddr,                              \
375                         .end = baseaddr + SZ_4K - 1,                    \
376                         .flags = IORESOURCE_MEM,                        \
377                 }, {                                                    \
378                         .start = irq,                                   \
379                         .end = irq,                                     \
380                         .flags = IORESOURCE_IRQ,                        \
381                 }                                                       \
382         };                                                              \
383                                                                         \
384         struct platform_device mxc_i2c_device ## n = {                  \
385                 .name = "imx-i2c",                                      \
386                 .id = n,                                                \
387                 .num_resources = ARRAY_SIZE(mxc_i2c_resources ## n),    \
388                 .resource = mxc_i2c_resources ## n,                     \
389         }
390
391 DEFINE_IMX_I2C_DEVICE(0, MX2x_I2C_BASE_ADDR, MX2x_INT_I2C);
392
393 #ifdef CONFIG_MACH_MX27
394 DEFINE_IMX_I2C_DEVICE(1, MX27_I2C2_BASE_ADDR, MX27_INT_I2C2);
395 #endif
396
397 static struct resource mxc_pwm_resources[] = {
398         {
399                 .start = MX2x_PWM_BASE_ADDR,
400                 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
401                 .flags = IORESOURCE_MEM,
402         }, {
403                 .start = MX2x_INT_PWM,
404                 .end = MX2x_INT_PWM,
405                 .flags = IORESOURCE_IRQ,
406         }
407 };
408
409 struct platform_device mxc_pwm_device = {
410         .name = "mxc_pwm",
411         .id = 0,
412         .num_resources = ARRAY_SIZE(mxc_pwm_resources),
413         .resource = mxc_pwm_resources,
414 };
415
416 #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq)                 \
417         static struct resource mxc_sdhc_resources ## n[] = {            \
418                 {                                                       \
419                         .start = baseaddr,                              \
420                         .end = baseaddr + SZ_4K - 1,                    \
421                         .flags = IORESOURCE_MEM,                        \
422                 }, {                                                    \
423                         .start = irq,                                   \
424                         .end = irq,                                     \
425                         .flags = IORESOURCE_IRQ,                        \
426                 }, {                                                    \
427                         .start = dmareq,                                \
428                         .end = dmareq,                                  \
429                         .flags = IORESOURCE_DMA,                        \
430                 },                                                      \
431         };                                                              \
432                                                                         \
433         static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32);        \
434                                                                         \
435         struct platform_device mxc_sdhc_device ## n = {                 \
436                 .name = "mxc-mmc",                                      \
437                 .id = n,                                                \
438                 .dev = {                                                \
439                         .dma_mask = &mxc_sdhc ## n ## _dmamask,         \
440                         .coherent_dma_mask = DMA_BIT_MASK(32),          \
441                 },                                                      \
442                 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n),   \
443                 .resource = mxc_sdhc_resources ## n,            \
444         }
445
446 DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
447 DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
448
449 #ifdef CONFIG_MACH_MX27
450 static struct resource otg_resources[] = {
451         {
452                 .start = MX27_USBOTG_BASE_ADDR,
453                 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
454                 .flags = IORESOURCE_MEM,
455         }, {
456                 .start = MX27_INT_USB3,
457                 .end = MX27_INT_USB3,
458                 .flags = IORESOURCE_IRQ,
459         },
460 };
461
462 static u64 otg_dmamask = DMA_BIT_MASK(32);
463
464 /* OTG gadget device */
465 struct platform_device mxc_otg_udc_device = {
466         .name           = "fsl-usb2-udc",
467         .id             = -1,
468         .dev            = {
469                 .dma_mask               = &otg_dmamask,
470                 .coherent_dma_mask      = DMA_BIT_MASK(32),
471         },
472         .resource       = otg_resources,
473         .num_resources  = ARRAY_SIZE(otg_resources),
474 };
475
476 /* OTG host */
477 struct platform_device mxc_otg_host = {
478         .name = "mxc-ehci",
479         .id = 0,
480         .dev = {
481                 .coherent_dma_mask = DMA_BIT_MASK(32),
482                 .dma_mask = &otg_dmamask,
483         },
484         .resource = otg_resources,
485         .num_resources = ARRAY_SIZE(otg_resources),
486 };
487
488 /* USB host 1 */
489
490 static u64 usbh1_dmamask = DMA_BIT_MASK(32);
491
492 static struct resource mxc_usbh1_resources[] = {
493         {
494                 .start = MX27_USBOTG_BASE_ADDR + 0x200,
495                 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
496                 .flags = IORESOURCE_MEM,
497         }, {
498                 .start = MX27_INT_USB1,
499                 .end = MX27_INT_USB1,
500                 .flags = IORESOURCE_IRQ,
501         },
502 };
503
504 struct platform_device mxc_usbh1 = {
505         .name = "mxc-ehci",
506         .id = 1,
507         .dev = {
508                 .coherent_dma_mask = DMA_BIT_MASK(32),
509                 .dma_mask = &usbh1_dmamask,
510         },
511         .resource = mxc_usbh1_resources,
512         .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
513 };
514
515 /* USB host 2 */
516 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
517
518 static struct resource mxc_usbh2_resources[] = {
519         {
520                 .start = MX27_USBOTG_BASE_ADDR + 0x400,
521                 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
522                 .flags = IORESOURCE_MEM,
523         }, {
524                 .start = MX27_INT_USB2,
525                 .end = MX27_INT_USB2,
526                 .flags = IORESOURCE_IRQ,
527         },
528 };
529
530 struct platform_device mxc_usbh2 = {
531         .name = "mxc-ehci",
532         .id = 2,
533         .dev = {
534                 .coherent_dma_mask = DMA_BIT_MASK(32),
535                 .dma_mask = &usbh2_dmamask,
536         },
537         .resource = mxc_usbh2_resources,
538         .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
539 };
540 #endif
541
542 #define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix)                      \
543         {                                                               \
544                 .name = _name,                                          \
545                 .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix,       \
546                 .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix,         \
547                 .flags = IORESOURCE_DMA,                                \
548         }
549
550 #define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq)                   \
551         static struct resource imx_ssi_resources ## n[] = {             \
552                 {                                                       \
553                         .start = MX2x_SSI ## ssin ## _BASE_ADDR,        \
554                         .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f,   \
555                         .flags = IORESOURCE_MEM,                        \
556                 }, {                                                    \
557                         .start = MX2x_INT_SSI1,                         \
558                         .end = MX2x_INT_SSI1,                           \
559                         .flags = IORESOURCE_IRQ,                        \
560                 },                                                      \
561                 DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0),                \
562                 DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0),                \
563                 DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1),                \
564                 DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1),                \
565         };                                                              \
566                                                                         \
567         struct platform_device imx_ssi_device ## n = {                  \
568                 .name = "imx-ssi",                                      \
569                 .id = n,                                                \
570                 .num_resources = ARRAY_SIZE(imx_ssi_resources ## n),    \
571                 .resource = imx_ssi_resources ## n,                     \
572         }
573
574 DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
575 DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
576
577 #define DEFINE_IMX2x_UART_DEVICE(n, baseaddr, irq)                      \
578         static struct resource imx2x_uart_resources ## n[] = {          \
579                 {                                                       \
580                         .start = baseaddr,                              \
581                         .end = baseaddr + 0xb5,                         \
582                         .flags = IORESOURCE_MEM,                        \
583                 }, {                                                    \
584                         .start = irq,                                   \
585                         .end = irq,                                     \
586                         .flags = IORESOURCE_IRQ,                        \
587                 },                                                      \
588         };                                                              \
589                                                                         \
590         struct platform_device imx2x_uart_device ## n = {               \
591                 .name = "imx-uart",                                     \
592                 .id = n,                                                \
593                 .num_resources = ARRAY_SIZE(imx2x_uart_resources ## n), \
594                 .resource = imx2x_uart_resources ## n,                  \
595         }
596
597 DEFINE_IMX2x_UART_DEVICE(0, MX2x_UART1_BASE_ADDR, MX2x_INT_UART1);
598 DEFINE_IMX2x_UART_DEVICE(1, MX2x_UART2_BASE_ADDR, MX2x_INT_UART2);
599 DEFINE_IMX2x_UART_DEVICE(2, MX2x_UART3_BASE_ADDR, MX2x_INT_UART3);
600 DEFINE_IMX2x_UART_DEVICE(3, MX2x_UART4_BASE_ADDR, MX2x_INT_UART4);
601
602 #ifdef CONFIG_MACH_MX27
603 DEFINE_IMX2x_UART_DEVICE(4, MX27_UART5_BASE_ADDR, MX27_INT_UART5);
604 DEFINE_IMX2x_UART_DEVICE(5, MX27_UART6_BASE_ADDR, MX27_INT_UART6);
605 #endif
606
607 /* GPIO port description */
608 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq)                          \
609         {                                                               \
610                 .chip.label = "gpio-" #n,                               \
611                 .irq = _irq,                                            \
612                 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR +        \
613                                 n * 0x100),                             \
614                 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,       \
615         }
616
617 #define DEFINE_MXC_GPIO_PORT(SOC, n)                                    \
618         {                                                               \
619                 .chip.label = "gpio-" #n,                               \
620                 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR +        \
621                                 n * 0x100),                             \
622                 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32,       \
623         }
624
625 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx)                                 \
626         static struct mxc_gpio_port pfx ## _gpio_ports[] = {            \
627                 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO),     \
628                 DEFINE_MXC_GPIO_PORT(SOC, 1),                           \
629                 DEFINE_MXC_GPIO_PORT(SOC, 2),                           \
630                 DEFINE_MXC_GPIO_PORT(SOC, 3),                           \
631                 DEFINE_MXC_GPIO_PORT(SOC, 4),                           \
632                 DEFINE_MXC_GPIO_PORT(SOC, 5),                           \
633         }
634
635 #ifdef CONFIG_MACH_MX21
636 DEFINE_MXC_GPIO_PORTS(MX21, imx21);
637
638 int __init imx21_register_gpios(void)
639 {
640         return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
641 }
642 #endif
643
644 #ifdef CONFIG_MACH_MX27
645 DEFINE_MXC_GPIO_PORTS(MX27, imx27);
646
647 int __init imx27_register_gpios(void)
648 {
649         return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
650 }
651 #endif
652
653 #ifdef CONFIG_MACH_MX21
654 static struct resource mx21_usbhc_resources[] = {
655         {
656                 .start  = MX21_USBOTG_BASE_ADDR,
657                 .end    = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
658                 .flags  = IORESOURCE_MEM,
659         },
660         {
661                 .start          = MX21_INT_USBHOST,
662                 .end            = MX21_INT_USBHOST,
663                 .flags          = IORESOURCE_IRQ,
664         },
665 };
666
667 struct platform_device mx21_usbhc_device = {
668         .name           = "imx21-hcd",
669         .id             = 0,
670         .dev            = {
671                 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
672                 .coherent_dma_mask = DMA_BIT_MASK(32),
673         },
674         .num_resources  = ARRAY_SIZE(mx21_usbhc_resources),
675         .resource       = mx21_usbhc_resources,
676 };
677 #endif
678 #endif