2 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <linux/dma-mapping.h>
21 #include <linux/module.h>
22 #include <linux/platform_device.h>
23 #include <linux/serial.h>
24 #include <linux/gpio.h>
25 #include <mach/hardware.h>
26 #include <mach/irqs.h>
27 #include <mach/common.h>
28 #include <mach/imx-uart.h>
29 #include <mach/mx3_camera.h>
33 static struct resource uart0
[] = {
35 .start
= UART1_BASE_ADDR
,
36 .end
= UART1_BASE_ADDR
+ 0x0B5,
37 .flags
= IORESOURCE_MEM
,
39 .start
= MXC_INT_UART1
,
41 .flags
= IORESOURCE_IRQ
,
45 struct platform_device mxc_uart_device0
= {
49 .num_resources
= ARRAY_SIZE(uart0
),
52 static struct resource uart1
[] = {
54 .start
= UART2_BASE_ADDR
,
55 .end
= UART2_BASE_ADDR
+ 0x0B5,
56 .flags
= IORESOURCE_MEM
,
58 .start
= MXC_INT_UART2
,
60 .flags
= IORESOURCE_IRQ
,
64 struct platform_device mxc_uart_device1
= {
68 .num_resources
= ARRAY_SIZE(uart1
),
71 static struct resource uart2
[] = {
73 .start
= UART3_BASE_ADDR
,
74 .end
= UART3_BASE_ADDR
+ 0x0B5,
75 .flags
= IORESOURCE_MEM
,
77 .start
= MXC_INT_UART3
,
79 .flags
= IORESOURCE_IRQ
,
83 struct platform_device mxc_uart_device2
= {
87 .num_resources
= ARRAY_SIZE(uart2
),
90 #ifdef CONFIG_ARCH_MX31
91 static struct resource uart3
[] = {
93 .start
= UART4_BASE_ADDR
,
94 .end
= UART4_BASE_ADDR
+ 0x0B5,
95 .flags
= IORESOURCE_MEM
,
97 .start
= MXC_INT_UART4
,
99 .flags
= IORESOURCE_IRQ
,
103 struct platform_device mxc_uart_device3
= {
107 .num_resources
= ARRAY_SIZE(uart3
),
110 static struct resource uart4
[] = {
112 .start
= UART5_BASE_ADDR
,
113 .end
= UART5_BASE_ADDR
+ 0x0B5,
114 .flags
= IORESOURCE_MEM
,
116 .start
= MXC_INT_UART5
,
117 .end
= MXC_INT_UART5
,
118 .flags
= IORESOURCE_IRQ
,
122 struct platform_device mxc_uart_device4
= {
126 .num_resources
= ARRAY_SIZE(uart4
),
128 #endif /* CONFIG_ARCH_MX31 */
130 /* GPIO port description */
131 static struct mxc_gpio_port imx_gpio_ports
[] = {
133 .chip
.label
= "gpio-0",
134 .base
= IO_ADDRESS(GPIO1_BASE_ADDR
),
135 .irq
= MXC_INT_GPIO1
,
136 .virtual_irq_start
= MXC_GPIO_IRQ_START
,
138 .chip
.label
= "gpio-1",
139 .base
= IO_ADDRESS(GPIO2_BASE_ADDR
),
140 .irq
= MXC_INT_GPIO2
,
141 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 32,
143 .chip
.label
= "gpio-2",
144 .base
= IO_ADDRESS(GPIO3_BASE_ADDR
),
145 .irq
= MXC_INT_GPIO3
,
146 .virtual_irq_start
= MXC_GPIO_IRQ_START
+ 64,
150 int __init
imx3x_register_gpios(void)
152 return mxc_gpio_init(imx_gpio_ports
, ARRAY_SIZE(imx_gpio_ports
));
155 static struct resource mxc_w1_master_resources
[] = {
157 .start
= OWIRE_BASE_ADDR
,
158 .end
= OWIRE_BASE_ADDR
+ SZ_4K
- 1,
159 .flags
= IORESOURCE_MEM
,
163 struct platform_device mxc_w1_master_device
= {
166 .num_resources
= ARRAY_SIZE(mxc_w1_master_resources
),
167 .resource
= mxc_w1_master_resources
,
170 static struct resource mxc_i2c0_resources
[] = {
172 .start
= I2C_BASE_ADDR
,
173 .end
= I2C_BASE_ADDR
+ SZ_4K
- 1,
174 .flags
= IORESOURCE_MEM
,
176 .start
= MXC_INT_I2C
,
178 .flags
= IORESOURCE_IRQ
,
182 struct platform_device mxc_i2c_device0
= {
185 .num_resources
= ARRAY_SIZE(mxc_i2c0_resources
),
186 .resource
= mxc_i2c0_resources
,
189 static struct resource mxc_i2c1_resources
[] = {
191 .start
= I2C2_BASE_ADDR
,
192 .end
= I2C2_BASE_ADDR
+ SZ_4K
- 1,
193 .flags
= IORESOURCE_MEM
,
195 .start
= MXC_INT_I2C2
,
197 .flags
= IORESOURCE_IRQ
,
201 struct platform_device mxc_i2c_device1
= {
204 .num_resources
= ARRAY_SIZE(mxc_i2c1_resources
),
205 .resource
= mxc_i2c1_resources
,
208 static struct resource mxc_i2c2_resources
[] = {
210 .start
= I2C3_BASE_ADDR
,
211 .end
= I2C3_BASE_ADDR
+ SZ_4K
- 1,
212 .flags
= IORESOURCE_MEM
,
214 .start
= MXC_INT_I2C3
,
216 .flags
= IORESOURCE_IRQ
,
220 struct platform_device mxc_i2c_device2
= {
223 .num_resources
= ARRAY_SIZE(mxc_i2c2_resources
),
224 .resource
= mxc_i2c2_resources
,
227 #ifdef CONFIG_ARCH_MX31
228 static struct resource mxcsdhc0_resources
[] = {
230 .start
= MMC_SDHC1_BASE_ADDR
,
231 .end
= MMC_SDHC1_BASE_ADDR
+ SZ_16K
- 1,
232 .flags
= IORESOURCE_MEM
,
234 .start
= MXC_INT_MMC_SDHC1
,
235 .end
= MXC_INT_MMC_SDHC1
,
236 .flags
= IORESOURCE_IRQ
,
240 static struct resource mxcsdhc1_resources
[] = {
242 .start
= MMC_SDHC2_BASE_ADDR
,
243 .end
= MMC_SDHC2_BASE_ADDR
+ SZ_16K
- 1,
244 .flags
= IORESOURCE_MEM
,
246 .start
= MXC_INT_MMC_SDHC2
,
247 .end
= MXC_INT_MMC_SDHC2
,
248 .flags
= IORESOURCE_IRQ
,
252 struct platform_device mxcsdhc_device0
= {
255 .num_resources
= ARRAY_SIZE(mxcsdhc0_resources
),
256 .resource
= mxcsdhc0_resources
,
259 struct platform_device mxcsdhc_device1
= {
262 .num_resources
= ARRAY_SIZE(mxcsdhc1_resources
),
263 .resource
= mxcsdhc1_resources
,
266 static struct resource rnga_resources
[] = {
268 .start
= RNGA_BASE_ADDR
,
269 .end
= RNGA_BASE_ADDR
+ 0x28,
270 .flags
= IORESOURCE_MEM
,
274 struct platform_device mxc_rnga_device
= {
278 .resource
= rnga_resources
,
280 #endif /* CONFIG_ARCH_MX31 */
282 /* i.MX31 Image Processing Unit */
284 /* The resource order is important! */
285 static struct resource mx3_ipu_rsrc
[] = {
287 .start
= IPU_CTRL_BASE_ADDR
,
288 .end
= IPU_CTRL_BASE_ADDR
+ 0x5F,
289 .flags
= IORESOURCE_MEM
,
291 .start
= IPU_CTRL_BASE_ADDR
+ 0x88,
292 .end
= IPU_CTRL_BASE_ADDR
+ 0xB3,
293 .flags
= IORESOURCE_MEM
,
295 .start
= MXC_INT_IPU_SYN
,
296 .end
= MXC_INT_IPU_SYN
,
297 .flags
= IORESOURCE_IRQ
,
299 .start
= MXC_INT_IPU_ERR
,
300 .end
= MXC_INT_IPU_ERR
,
301 .flags
= IORESOURCE_IRQ
,
305 struct platform_device mx3_ipu
= {
308 .num_resources
= ARRAY_SIZE(mx3_ipu_rsrc
),
309 .resource
= mx3_ipu_rsrc
,
312 static struct resource fb_resources
[] = {
314 .start
= IPU_CTRL_BASE_ADDR
+ 0xB4,
315 .end
= IPU_CTRL_BASE_ADDR
+ 0x1BF,
316 .flags
= IORESOURCE_MEM
,
320 struct platform_device mx3_fb
= {
321 .name
= "mx3_sdc_fb",
323 .num_resources
= ARRAY_SIZE(fb_resources
),
324 .resource
= fb_resources
,
326 .coherent_dma_mask
= DMA_BIT_MASK(32),
330 static struct resource camera_resources
[] = {
332 .start
= IPU_CTRL_BASE_ADDR
+ 0x60,
333 .end
= IPU_CTRL_BASE_ADDR
+ 0x87,
334 .flags
= IORESOURCE_MEM
,
338 struct platform_device mx3_camera
= {
339 .name
= "mx3-camera",
341 .num_resources
= ARRAY_SIZE(camera_resources
),
342 .resource
= camera_resources
,
344 .coherent_dma_mask
= DMA_BIT_MASK(32),
348 static struct resource otg_resources
[] = {
350 .start
= MX31_OTG_BASE_ADDR
,
351 .end
= MX31_OTG_BASE_ADDR
+ 0x1ff,
352 .flags
= IORESOURCE_MEM
,
354 .start
= MXC_INT_USB3
,
356 .flags
= IORESOURCE_IRQ
,
360 static u64 otg_dmamask
= DMA_BIT_MASK(32);
362 /* OTG gadget device */
363 struct platform_device mxc_otg_udc_device
= {
364 .name
= "fsl-usb2-udc",
367 .dma_mask
= &otg_dmamask
,
368 .coherent_dma_mask
= DMA_BIT_MASK(32),
370 .resource
= otg_resources
,
371 .num_resources
= ARRAY_SIZE(otg_resources
),
375 struct platform_device mxc_otg_host
= {
379 .coherent_dma_mask
= 0xffffffff,
380 .dma_mask
= &otg_dmamask
,
382 .resource
= otg_resources
,
383 .num_resources
= ARRAY_SIZE(otg_resources
),
388 static u64 usbh1_dmamask
= ~(u32
)0;
390 static struct resource mxc_usbh1_resources
[] = {
392 .start
= MX31_OTG_BASE_ADDR
+ 0x200,
393 .end
= MX31_OTG_BASE_ADDR
+ 0x3ff,
394 .flags
= IORESOURCE_MEM
,
396 .start
= MXC_INT_USB1
,
398 .flags
= IORESOURCE_IRQ
,
402 struct platform_device mxc_usbh1
= {
406 .coherent_dma_mask
= 0xffffffff,
407 .dma_mask
= &usbh1_dmamask
,
409 .resource
= mxc_usbh1_resources
,
410 .num_resources
= ARRAY_SIZE(mxc_usbh1_resources
),
414 static u64 usbh2_dmamask
= ~(u32
)0;
416 static struct resource mxc_usbh2_resources
[] = {
418 .start
= MX31_OTG_BASE_ADDR
+ 0x400,
419 .end
= MX31_OTG_BASE_ADDR
+ 0x5ff,
420 .flags
= IORESOURCE_MEM
,
422 .start
= MXC_INT_USB2
,
424 .flags
= IORESOURCE_IRQ
,
428 struct platform_device mxc_usbh2
= {
432 .coherent_dma_mask
= 0xffffffff,
433 .dma_mask
= &usbh2_dmamask
,
435 .resource
= mxc_usbh2_resources
,
436 .num_resources
= ARRAY_SIZE(mxc_usbh2_resources
),
440 * SPI master controller
443 static struct resource mxc_spi_0_resources
[] = {
445 .start
= CSPI1_BASE_ADDR
,
446 .end
= CSPI1_BASE_ADDR
+ SZ_4K
- 1,
447 .flags
= IORESOURCE_MEM
,
449 .start
= MXC_INT_CSPI1
,
450 .end
= MXC_INT_CSPI1
,
451 .flags
= IORESOURCE_IRQ
,
455 static struct resource mxc_spi_1_resources
[] = {
457 .start
= CSPI2_BASE_ADDR
,
458 .end
= CSPI2_BASE_ADDR
+ SZ_4K
- 1,
459 .flags
= IORESOURCE_MEM
,
461 .start
= MXC_INT_CSPI2
,
462 .end
= MXC_INT_CSPI2
,
463 .flags
= IORESOURCE_IRQ
,
467 static struct resource mxc_spi_2_resources
[] = {
469 .start
= CSPI3_BASE_ADDR
,
470 .end
= CSPI3_BASE_ADDR
+ SZ_4K
- 1,
471 .flags
= IORESOURCE_MEM
,
473 .start
= MXC_INT_CSPI3
,
474 .end
= MXC_INT_CSPI3
,
475 .flags
= IORESOURCE_IRQ
,
479 struct platform_device mxc_spi_device0
= {
482 .num_resources
= ARRAY_SIZE(mxc_spi_0_resources
),
483 .resource
= mxc_spi_0_resources
,
486 struct platform_device mxc_spi_device1
= {
489 .num_resources
= ARRAY_SIZE(mxc_spi_1_resources
),
490 .resource
= mxc_spi_1_resources
,
493 struct platform_device mxc_spi_device2
= {
496 .num_resources
= ARRAY_SIZE(mxc_spi_2_resources
),
497 .resource
= mxc_spi_2_resources
,
500 #ifdef CONFIG_ARCH_MX35
501 static struct resource mxc_fec_resources
[] = {
503 .start
= MXC_FEC_BASE_ADDR
,
504 .end
= MXC_FEC_BASE_ADDR
+ 0xfff,
505 .flags
= IORESOURCE_MEM
,
507 .start
= MXC_INT_FEC
,
509 .flags
= IORESOURCE_IRQ
,
513 struct platform_device mxc_fec_device
= {
516 .num_resources
= ARRAY_SIZE(mxc_fec_resources
),
517 .resource
= mxc_fec_resources
,
521 static struct resource imx_ssi_resources0
[] = {
523 .start
= SSI1_BASE_ADDR
,
524 .end
= SSI1_BASE_ADDR
+ 0xfff,
525 .flags
= IORESOURCE_MEM
,
527 .start
= MX31_INT_SSI1
,
528 .end
= MX31_INT_SSI1
,
529 .flags
= IORESOURCE_IRQ
,
533 static struct resource imx_ssi_resources1
[] = {
535 .start
= SSI2_BASE_ADDR
,
536 .end
= SSI2_BASE_ADDR
+ 0xfff,
537 .flags
= IORESOURCE_MEM
539 .start
= MX31_INT_SSI2
,
540 .end
= MX31_INT_SSI2
,
541 .flags
= IORESOURCE_IRQ
,
545 struct platform_device imx_ssi_device0
= {
548 .num_resources
= ARRAY_SIZE(imx_ssi_resources0
),
549 .resource
= imx_ssi_resources0
,
552 struct platform_device imx_ssi_device1
= {
555 .num_resources
= ARRAY_SIZE(imx_ssi_resources1
),
556 .resource
= imx_ssi_resources1
,
559 static struct resource imx_wdt_resources
[] = {
561 .flags
= IORESOURCE_MEM
,
565 struct platform_device imx_wdt_device0
= {
568 .num_resources
= ARRAY_SIZE(imx_wdt_resources
),
569 .resource
= imx_wdt_resources
,
572 static struct resource imx_rtc_resources
[] = {
574 .start
= MX31_RTC_BASE_ADDR
,
575 .end
= MX31_RTC_BASE_ADDR
+ 0x3fff,
576 .flags
= IORESOURCE_MEM
,
579 .start
= MX31_INT_RTC
,
580 .flags
= IORESOURCE_IRQ
,
584 struct platform_device imx_rtc_device0
= {
587 .num_resources
= ARRAY_SIZE(imx_rtc_resources
),
588 .resource
= imx_rtc_resources
,
591 static struct resource imx_kpp_resources
[] = {
593 .start
= MX3x_KPP_BASE_ADDR
,
594 .end
= MX3x_KPP_BASE_ADDR
+ 0xf,
595 .flags
= IORESOURCE_MEM
597 .start
= MX3x_INT_KPP
,
599 .flags
= IORESOURCE_IRQ
,
603 struct platform_device imx_kpp_device
= {
604 .name
= "imx-keypad",
606 .num_resources
= ARRAY_SIZE(imx_kpp_resources
),
607 .resource
= imx_kpp_resources
,
610 static int __init
mx3_devices_init(void)
612 #if defined(CONFIG_ARCH_MX31)
614 imx_wdt_resources
[0].start
= MX31_WDOG_BASE_ADDR
;
615 imx_wdt_resources
[0].end
= MX31_WDOG_BASE_ADDR
+ 0x3fff;
616 mxc_register_device(&mxc_rnga_device
, NULL
);
619 #if defined(CONFIG_ARCH_MX35)
621 otg_resources
[0].start
= MX35_OTG_BASE_ADDR
;
622 otg_resources
[0].end
= MX35_OTG_BASE_ADDR
+ 0x1ff;
623 otg_resources
[1].start
= MXC_INT_USBOTG
;
624 otg_resources
[1].end
= MXC_INT_USBOTG
;
625 mxc_usbh1_resources
[0].start
= MX35_OTG_BASE_ADDR
+ 0x400;
626 mxc_usbh1_resources
[0].end
= MX35_OTG_BASE_ADDR
+ 0x5ff;
627 mxc_usbh1_resources
[1].start
= MXC_INT_USBHS
;
628 mxc_usbh1_resources
[1].end
= MXC_INT_USBHS
;
629 imx_ssi_resources0
[1].start
= MX35_INT_SSI1
;
630 imx_ssi_resources0
[1].end
= MX35_INT_SSI1
;
631 imx_ssi_resources1
[1].start
= MX35_INT_SSI2
;
632 imx_ssi_resources1
[1].end
= MX35_INT_SSI2
;
633 imx_wdt_resources
[0].start
= MX35_WDOG_BASE_ADDR
;
634 imx_wdt_resources
[0].end
= MX35_WDOG_BASE_ADDR
+ 0x3fff;
641 subsys_initcall(mx3_devices_init
);