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
mxc_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_nand_resources
[] = {
172 .start
= 0, /* runtime dependent */
174 .flags
= IORESOURCE_MEM
,
176 .start
= MXC_INT_NANDFC
,
177 .end
= MXC_INT_NANDFC
,
178 .flags
= IORESOURCE_IRQ
,
182 struct platform_device mxc_nand_device
= {
185 .num_resources
= ARRAY_SIZE(mxc_nand_resources
),
186 .resource
= mxc_nand_resources
,
189 static struct resource mxc_i2c0_resources
[] = {
191 .start
= I2C_BASE_ADDR
,
192 .end
= I2C_BASE_ADDR
+ SZ_4K
- 1,
193 .flags
= IORESOURCE_MEM
,
195 .start
= MXC_INT_I2C
,
197 .flags
= IORESOURCE_IRQ
,
201 struct platform_device mxc_i2c_device0
= {
204 .num_resources
= ARRAY_SIZE(mxc_i2c0_resources
),
205 .resource
= mxc_i2c0_resources
,
208 static struct resource mxc_i2c1_resources
[] = {
210 .start
= I2C2_BASE_ADDR
,
211 .end
= I2C2_BASE_ADDR
+ SZ_4K
- 1,
212 .flags
= IORESOURCE_MEM
,
214 .start
= MXC_INT_I2C2
,
216 .flags
= IORESOURCE_IRQ
,
220 struct platform_device mxc_i2c_device1
= {
223 .num_resources
= ARRAY_SIZE(mxc_i2c1_resources
),
224 .resource
= mxc_i2c1_resources
,
227 static struct resource mxc_i2c2_resources
[] = {
229 .start
= I2C3_BASE_ADDR
,
230 .end
= I2C3_BASE_ADDR
+ SZ_4K
- 1,
231 .flags
= IORESOURCE_MEM
,
233 .start
= MXC_INT_I2C3
,
235 .flags
= IORESOURCE_IRQ
,
239 struct platform_device mxc_i2c_device2
= {
242 .num_resources
= ARRAY_SIZE(mxc_i2c2_resources
),
243 .resource
= mxc_i2c2_resources
,
246 #ifdef CONFIG_ARCH_MX31
247 static struct resource mxcsdhc0_resources
[] = {
249 .start
= MMC_SDHC1_BASE_ADDR
,
250 .end
= MMC_SDHC1_BASE_ADDR
+ SZ_16K
- 1,
251 .flags
= IORESOURCE_MEM
,
253 .start
= MXC_INT_MMC_SDHC1
,
254 .end
= MXC_INT_MMC_SDHC1
,
255 .flags
= IORESOURCE_IRQ
,
259 static struct resource mxcsdhc1_resources
[] = {
261 .start
= MMC_SDHC2_BASE_ADDR
,
262 .end
= MMC_SDHC2_BASE_ADDR
+ SZ_16K
- 1,
263 .flags
= IORESOURCE_MEM
,
265 .start
= MXC_INT_MMC_SDHC2
,
266 .end
= MXC_INT_MMC_SDHC2
,
267 .flags
= IORESOURCE_IRQ
,
271 struct platform_device mxcsdhc_device0
= {
274 .num_resources
= ARRAY_SIZE(mxcsdhc0_resources
),
275 .resource
= mxcsdhc0_resources
,
278 struct platform_device mxcsdhc_device1
= {
281 .num_resources
= ARRAY_SIZE(mxcsdhc1_resources
),
282 .resource
= mxcsdhc1_resources
,
285 static struct resource rnga_resources
[] = {
287 .start
= RNGA_BASE_ADDR
,
288 .end
= RNGA_BASE_ADDR
+ 0x28,
289 .flags
= IORESOURCE_MEM
,
293 struct platform_device mxc_rnga_device
= {
297 .resource
= rnga_resources
,
299 #endif /* CONFIG_ARCH_MX31 */
301 /* i.MX31 Image Processing Unit */
303 /* The resource order is important! */
304 static struct resource mx3_ipu_rsrc
[] = {
306 .start
= IPU_CTRL_BASE_ADDR
,
307 .end
= IPU_CTRL_BASE_ADDR
+ 0x5F,
308 .flags
= IORESOURCE_MEM
,
310 .start
= IPU_CTRL_BASE_ADDR
+ 0x88,
311 .end
= IPU_CTRL_BASE_ADDR
+ 0xB3,
312 .flags
= IORESOURCE_MEM
,
314 .start
= MXC_INT_IPU_SYN
,
315 .end
= MXC_INT_IPU_SYN
,
316 .flags
= IORESOURCE_IRQ
,
318 .start
= MXC_INT_IPU_ERR
,
319 .end
= MXC_INT_IPU_ERR
,
320 .flags
= IORESOURCE_IRQ
,
324 struct platform_device mx3_ipu
= {
327 .num_resources
= ARRAY_SIZE(mx3_ipu_rsrc
),
328 .resource
= mx3_ipu_rsrc
,
331 static struct resource fb_resources
[] = {
333 .start
= IPU_CTRL_BASE_ADDR
+ 0xB4,
334 .end
= IPU_CTRL_BASE_ADDR
+ 0x1BF,
335 .flags
= IORESOURCE_MEM
,
339 struct platform_device mx3_fb
= {
340 .name
= "mx3_sdc_fb",
342 .num_resources
= ARRAY_SIZE(fb_resources
),
343 .resource
= fb_resources
,
345 .coherent_dma_mask
= DMA_BIT_MASK(32),
349 static struct resource camera_resources
[] = {
351 .start
= IPU_CTRL_BASE_ADDR
+ 0x60,
352 .end
= IPU_CTRL_BASE_ADDR
+ 0x87,
353 .flags
= IORESOURCE_MEM
,
357 struct platform_device mx3_camera
= {
358 .name
= "mx3-camera",
360 .num_resources
= ARRAY_SIZE(camera_resources
),
361 .resource
= camera_resources
,
363 .coherent_dma_mask
= DMA_BIT_MASK(32),
367 static struct resource otg_resources
[] = {
369 .start
= MX31_OTG_BASE_ADDR
,
370 .end
= MX31_OTG_BASE_ADDR
+ 0x1ff,
371 .flags
= IORESOURCE_MEM
,
373 .start
= MXC_INT_USB3
,
375 .flags
= IORESOURCE_IRQ
,
379 static u64 otg_dmamask
= DMA_BIT_MASK(32);
381 /* OTG gadget device */
382 struct platform_device mxc_otg_udc_device
= {
383 .name
= "fsl-usb2-udc",
386 .dma_mask
= &otg_dmamask
,
387 .coherent_dma_mask
= DMA_BIT_MASK(32),
389 .resource
= otg_resources
,
390 .num_resources
= ARRAY_SIZE(otg_resources
),
394 struct platform_device mxc_otg_host
= {
398 .coherent_dma_mask
= 0xffffffff,
399 .dma_mask
= &otg_dmamask
,
401 .resource
= otg_resources
,
402 .num_resources
= ARRAY_SIZE(otg_resources
),
407 static u64 usbh1_dmamask
= ~(u32
)0;
409 static struct resource mxc_usbh1_resources
[] = {
411 .start
= MX31_OTG_BASE_ADDR
+ 0x200,
412 .end
= MX31_OTG_BASE_ADDR
+ 0x3ff,
413 .flags
= IORESOURCE_MEM
,
415 .start
= MXC_INT_USB1
,
417 .flags
= IORESOURCE_IRQ
,
421 struct platform_device mxc_usbh1
= {
425 .coherent_dma_mask
= 0xffffffff,
426 .dma_mask
= &usbh1_dmamask
,
428 .resource
= mxc_usbh1_resources
,
429 .num_resources
= ARRAY_SIZE(mxc_usbh1_resources
),
433 static u64 usbh2_dmamask
= ~(u32
)0;
435 static struct resource mxc_usbh2_resources
[] = {
437 .start
= MX31_OTG_BASE_ADDR
+ 0x400,
438 .end
= MX31_OTG_BASE_ADDR
+ 0x5ff,
439 .flags
= IORESOURCE_MEM
,
441 .start
= MXC_INT_USB2
,
443 .flags
= IORESOURCE_IRQ
,
447 struct platform_device mxc_usbh2
= {
451 .coherent_dma_mask
= 0xffffffff,
452 .dma_mask
= &usbh2_dmamask
,
454 .resource
= mxc_usbh2_resources
,
455 .num_resources
= ARRAY_SIZE(mxc_usbh2_resources
),
459 * SPI master controller
462 static struct resource imx_spi_0_resources
[] = {
464 .start
= CSPI1_BASE_ADDR
,
465 .end
= CSPI1_BASE_ADDR
+ SZ_4K
- 1,
466 .flags
= IORESOURCE_MEM
,
468 .start
= MXC_INT_CSPI1
,
469 .end
= MXC_INT_CSPI1
,
470 .flags
= IORESOURCE_IRQ
,
474 static struct resource imx_spi_1_resources
[] = {
476 .start
= CSPI2_BASE_ADDR
,
477 .end
= CSPI2_BASE_ADDR
+ SZ_4K
- 1,
478 .flags
= IORESOURCE_MEM
,
480 .start
= MXC_INT_CSPI2
,
481 .end
= MXC_INT_CSPI2
,
482 .flags
= IORESOURCE_IRQ
,
486 static struct resource imx_spi_2_resources
[] = {
488 .start
= CSPI3_BASE_ADDR
,
489 .end
= CSPI3_BASE_ADDR
+ SZ_4K
- 1,
490 .flags
= IORESOURCE_MEM
,
492 .start
= MXC_INT_CSPI3
,
493 .end
= MXC_INT_CSPI3
,
494 .flags
= IORESOURCE_IRQ
,
498 struct platform_device imx_spi_device0
= {
501 .num_resources
= ARRAY_SIZE(imx_spi_0_resources
),
502 .resource
= imx_spi_0_resources
,
505 struct platform_device imx_spi_device1
= {
508 .num_resources
= ARRAY_SIZE(imx_spi_1_resources
),
509 .resource
= imx_spi_1_resources
,
512 struct platform_device imx_spi_device2
= {
515 .num_resources
= ARRAY_SIZE(imx_spi_2_resources
),
516 .resource
= imx_spi_2_resources
,
519 #ifdef CONFIG_ARCH_MX35
520 static struct resource mxc_fec_resources
[] = {
522 .start
= MXC_FEC_BASE_ADDR
,
523 .end
= MXC_FEC_BASE_ADDR
+ 0xfff,
524 .flags
= IORESOURCE_MEM
,
526 .start
= MXC_INT_FEC
,
528 .flags
= IORESOURCE_IRQ
,
532 struct platform_device mxc_fec_device
= {
535 .num_resources
= ARRAY_SIZE(mxc_fec_resources
),
536 .resource
= mxc_fec_resources
,
540 static int mx3_devices_init(void)
543 mxc_nand_resources
[0].start
= MX31_NFC_BASE_ADDR
;
544 mxc_nand_resources
[0].end
= MX31_NFC_BASE_ADDR
+ 0xfff;
545 mxc_register_device(&mxc_rnga_device
, NULL
);
548 mxc_nand_resources
[0].start
= MX35_NFC_BASE_ADDR
;
549 mxc_nand_resources
[0].end
= MX35_NFC_BASE_ADDR
+ 0xfff;
550 otg_resources
[0].start
= MX35_OTG_BASE_ADDR
;
551 otg_resources
[0].end
= MX35_OTG_BASE_ADDR
+ 0x1ff;
552 otg_resources
[1].start
= MXC_INT_USBOTG
;
553 otg_resources
[1].end
= MXC_INT_USBOTG
;
554 mxc_usbh1_resources
[0].start
= MX35_OTG_BASE_ADDR
+ 0x400;
555 mxc_usbh1_resources
[0].end
= MX35_OTG_BASE_ADDR
+ 0x5ff;
556 mxc_usbh1_resources
[1].start
= MXC_INT_USBHS
;
557 mxc_usbh1_resources
[1].end
= MXC_INT_USBHS
;
563 subsys_initcall(mx3_devices_init
);