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>
32 static struct resource uart0[] = {
34 .start = UART1_BASE_ADDR,
35 .end = UART1_BASE_ADDR + 0x0B5,
36 .flags = IORESOURCE_MEM,
38 .start = MXC_INT_UART1,
40 .flags = IORESOURCE_IRQ,
44 struct platform_device mxc_uart_device0 = {
48 .num_resources = ARRAY_SIZE(uart0),
51 static struct resource uart1[] = {
53 .start = UART2_BASE_ADDR,
54 .end = UART2_BASE_ADDR + 0x0B5,
55 .flags = IORESOURCE_MEM,
57 .start = MXC_INT_UART2,
59 .flags = IORESOURCE_IRQ,
63 struct platform_device mxc_uart_device1 = {
67 .num_resources = ARRAY_SIZE(uart1),
70 static struct resource uart2[] = {
72 .start = UART3_BASE_ADDR,
73 .end = UART3_BASE_ADDR + 0x0B5,
74 .flags = IORESOURCE_MEM,
76 .start = MXC_INT_UART3,
78 .flags = IORESOURCE_IRQ,
82 struct platform_device mxc_uart_device2 = {
86 .num_resources = ARRAY_SIZE(uart2),
89 #ifdef CONFIG_ARCH_MX31
90 static struct resource uart3[] = {
92 .start = UART4_BASE_ADDR,
93 .end = UART4_BASE_ADDR + 0x0B5,
94 .flags = IORESOURCE_MEM,
96 .start = MXC_INT_UART4,
98 .flags = IORESOURCE_IRQ,
102 struct platform_device mxc_uart_device3 = {
106 .num_resources = ARRAY_SIZE(uart3),
109 static struct resource uart4[] = {
111 .start = UART5_BASE_ADDR,
112 .end = UART5_BASE_ADDR + 0x0B5,
113 .flags = IORESOURCE_MEM,
115 .start = MXC_INT_UART5,
116 .end = MXC_INT_UART5,
117 .flags = IORESOURCE_IRQ,
121 struct platform_device mxc_uart_device4 = {
125 .num_resources = ARRAY_SIZE(uart4),
127 #endif /* CONFIG_ARCH_MX31 */
129 /* GPIO port description */
130 static struct mxc_gpio_port imx_gpio_ports[] = {
132 .chip.label = "gpio-0",
133 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
134 .irq = MXC_INT_GPIO1,
135 .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,
144 .chip.label = "gpio-2",
145 .base = IO_ADDRESS(GPIO3_BASE_ADDR),
146 .irq = MXC_INT_GPIO3,
147 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
151 int __init mxc_register_gpios(void)
153 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
156 static struct resource mxc_w1_master_resources[] = {
158 .start = OWIRE_BASE_ADDR,
159 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
160 .flags = IORESOURCE_MEM,
164 struct platform_device mxc_w1_master_device = {
167 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
168 .resource = mxc_w1_master_resources,
171 static struct resource mxc_nand_resources[] = {
173 .start = 0, /* runtime dependent */
175 .flags = IORESOURCE_MEM
177 .start = MXC_INT_NANDFC,
178 .end = MXC_INT_NANDFC,
179 .flags = IORESOURCE_IRQ
183 struct platform_device mxc_nand_device = {
186 .num_resources = ARRAY_SIZE(mxc_nand_resources),
187 .resource = mxc_nand_resources,
190 static struct resource mxc_i2c0_resources[] = {
192 .start = I2C_BASE_ADDR,
193 .end = I2C_BASE_ADDR + SZ_4K - 1,
194 .flags = IORESOURCE_MEM,
197 .start = MXC_INT_I2C,
199 .flags = IORESOURCE_IRQ,
203 struct platform_device mxc_i2c_device0 = {
206 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
207 .resource = mxc_i2c0_resources,
210 static struct resource mxc_i2c1_resources[] = {
212 .start = I2C2_BASE_ADDR,
213 .end = I2C2_BASE_ADDR + SZ_4K - 1,
214 .flags = IORESOURCE_MEM,
217 .start = MXC_INT_I2C2,
219 .flags = IORESOURCE_IRQ,
223 struct platform_device mxc_i2c_device1 = {
226 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
227 .resource = mxc_i2c1_resources,
230 static struct resource mxc_i2c2_resources[] = {
232 .start = I2C3_BASE_ADDR,
233 .end = I2C3_BASE_ADDR + SZ_4K - 1,
234 .flags = IORESOURCE_MEM,
237 .start = MXC_INT_I2C3,
239 .flags = IORESOURCE_IRQ,
243 struct platform_device mxc_i2c_device2 = {
246 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
247 .resource = mxc_i2c2_resources,
250 #ifdef CONFIG_ARCH_MX31
251 static struct resource mxcsdhc0_resources[] = {
253 .start = MMC_SDHC1_BASE_ADDR,
254 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
255 .flags = IORESOURCE_MEM,
257 .start = MXC_INT_MMC_SDHC1,
258 .end = MXC_INT_MMC_SDHC1,
259 .flags = IORESOURCE_IRQ,
263 static struct resource mxcsdhc1_resources[] = {
265 .start = MMC_SDHC2_BASE_ADDR,
266 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
267 .flags = IORESOURCE_MEM,
269 .start = MXC_INT_MMC_SDHC2,
270 .end = MXC_INT_MMC_SDHC2,
271 .flags = IORESOURCE_IRQ,
275 struct platform_device mxcsdhc_device0 = {
278 .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
279 .resource = mxcsdhc0_resources,
282 struct platform_device mxcsdhc_device1 = {
285 .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
286 .resource = mxcsdhc1_resources,
289 static struct resource rnga_resources[] = {
291 .start = RNGA_BASE_ADDR,
292 .end = RNGA_BASE_ADDR + 0x28,
293 .flags = IORESOURCE_MEM,
297 struct platform_device mxc_rnga_device = {
301 .resource = rnga_resources,
303 #endif /* CONFIG_ARCH_MX31 */
305 /* i.MX31 Image Processing Unit */
307 /* The resource order is important! */
308 static struct resource mx3_ipu_rsrc[] = {
310 .start = IPU_CTRL_BASE_ADDR,
311 .end = IPU_CTRL_BASE_ADDR + 0x5F,
312 .flags = IORESOURCE_MEM,
314 .start = IPU_CTRL_BASE_ADDR + 0x88,
315 .end = IPU_CTRL_BASE_ADDR + 0xB3,
316 .flags = IORESOURCE_MEM,
318 .start = MXC_INT_IPU_SYN,
319 .end = MXC_INT_IPU_SYN,
320 .flags = IORESOURCE_IRQ,
322 .start = MXC_INT_IPU_ERR,
323 .end = MXC_INT_IPU_ERR,
324 .flags = IORESOURCE_IRQ,
328 struct platform_device mx3_ipu = {
331 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
332 .resource = mx3_ipu_rsrc,
335 static struct resource fb_resources[] = {
337 .start = IPU_CTRL_BASE_ADDR + 0xB4,
338 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
339 .flags = IORESOURCE_MEM,
343 struct platform_device mx3_fb = {
344 .name = "mx3_sdc_fb",
346 .num_resources = ARRAY_SIZE(fb_resources),
347 .resource = fb_resources,
349 .coherent_dma_mask = 0xffffffff,
353 static struct resource otg_resources[] = {
355 .start = OTG_BASE_ADDR,
356 .end = OTG_BASE_ADDR + 0x1ff,
357 .flags = IORESOURCE_MEM,
359 .start = MXC_INT_USB3,
361 .flags = IORESOURCE_IRQ,
365 static u64 otg_dmamask = DMA_BIT_MASK(32);
367 /* OTG gadget device */
368 struct platform_device mxc_otg_udc_device = {
369 .name = "fsl-usb2-udc",
372 .dma_mask = &otg_dmamask,
373 .coherent_dma_mask = DMA_BIT_MASK(32),
375 .resource = otg_resources,
376 .num_resources = ARRAY_SIZE(otg_resources),
379 #ifdef CONFIG_ARCH_MX35
380 static struct resource mxc_fec_resources[] = {
382 .start = MXC_FEC_BASE_ADDR,
383 .end = MXC_FEC_BASE_ADDR + 0xfff,
384 .flags = IORESOURCE_MEM
386 .start = MXC_INT_FEC,
388 .flags = IORESOURCE_IRQ
392 struct platform_device mxc_fec_device = {
395 .num_resources = ARRAY_SIZE(mxc_fec_resources),
396 .resource = mxc_fec_resources,
400 static int mx3_devices_init(void)
403 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
404 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
405 mxc_register_device(&mxc_rnga_device, NULL);
408 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
409 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
415 subsys_initcall(mx3_devices_init);