blob: 7a5c2ef52a48b1a78474f2e4fa274c77e99f0b38 [file] [log] [blame]
Sascha Hauere3d13ff2008-07-05 10:02:48 +02001/*
2 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
4 *
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.
13 *
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.
18 */
19
Guennadi Liakhovetskieb05bbe2009-05-04 13:13:52 +020020#include <linux/dma-mapping.h>
Sascha Hauere3d13ff2008-07-05 10:02:48 +020021#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/serial.h>
Juergen Beisert07bd1a62008-07-05 10:02:49 +020024#include <linux/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
Russell King80b02c12009-01-08 10:01:47 +000026#include <mach/irqs.h>
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -030027#include <mach/common.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/imx-uart.h>
Valentin Longchamp9c70e222009-05-07 11:51:42 +020029#include <mach/mx3_camera.h>
Sascha Hauere3d13ff2008-07-05 10:02:48 +020030
Sascha Hauer87bbb192009-01-29 16:00:23 +010031#include "devices.h"
32
Sascha Hauere3d13ff2008-07-05 10:02:48 +020033static struct resource uart0[] = {
34 {
35 .start = UART1_BASE_ADDR,
36 .end = UART1_BASE_ADDR + 0x0B5,
37 .flags = IORESOURCE_MEM,
38 }, {
39 .start = MXC_INT_UART1,
40 .end = MXC_INT_UART1,
41 .flags = IORESOURCE_IRQ,
42 },
43};
44
Sascha Hauer5cf09422008-09-09 10:19:41 +020045struct platform_device mxc_uart_device0 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020046 .name = "imx-uart",
47 .id = 0,
48 .resource = uart0,
49 .num_resources = ARRAY_SIZE(uart0),
50};
51
52static struct resource uart1[] = {
53 {
54 .start = UART2_BASE_ADDR,
55 .end = UART2_BASE_ADDR + 0x0B5,
56 .flags = IORESOURCE_MEM,
57 }, {
58 .start = MXC_INT_UART2,
59 .end = MXC_INT_UART2,
60 .flags = IORESOURCE_IRQ,
61 },
62};
63
Sascha Hauer5cf09422008-09-09 10:19:41 +020064struct platform_device mxc_uart_device1 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020065 .name = "imx-uart",
66 .id = 1,
67 .resource = uart1,
68 .num_resources = ARRAY_SIZE(uart1),
69};
70
71static struct resource uart2[] = {
72 {
73 .start = UART3_BASE_ADDR,
74 .end = UART3_BASE_ADDR + 0x0B5,
75 .flags = IORESOURCE_MEM,
76 }, {
77 .start = MXC_INT_UART3,
78 .end = MXC_INT_UART3,
79 .flags = IORESOURCE_IRQ,
80 },
81};
82
Sascha Hauer5cf09422008-09-09 10:19:41 +020083struct platform_device mxc_uart_device2 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020084 .name = "imx-uart",
85 .id = 2,
86 .resource = uart2,
87 .num_resources = ARRAY_SIZE(uart2),
88};
89
Sascha Hauer9536ff32009-02-06 15:38:51 +010090#ifdef CONFIG_ARCH_MX31
Sascha Hauere3d13ff2008-07-05 10:02:48 +020091static struct resource uart3[] = {
92 {
93 .start = UART4_BASE_ADDR,
94 .end = UART4_BASE_ADDR + 0x0B5,
95 .flags = IORESOURCE_MEM,
96 }, {
97 .start = MXC_INT_UART4,
98 .end = MXC_INT_UART4,
99 .flags = IORESOURCE_IRQ,
100 },
101};
102
Sascha Hauer5cf09422008-09-09 10:19:41 +0200103struct platform_device mxc_uart_device3 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200104 .name = "imx-uart",
105 .id = 3,
106 .resource = uart3,
107 .num_resources = ARRAY_SIZE(uart3),
108};
109
110static struct resource uart4[] = {
111 {
112 .start = UART5_BASE_ADDR,
113 .end = UART5_BASE_ADDR + 0x0B5,
114 .flags = IORESOURCE_MEM,
115 }, {
116 .start = MXC_INT_UART5,
117 .end = MXC_INT_UART5,
118 .flags = IORESOURCE_IRQ,
119 },
120};
121
Sascha Hauer5cf09422008-09-09 10:19:41 +0200122struct platform_device mxc_uart_device4 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200123 .name = "imx-uart",
124 .id = 4,
125 .resource = uart4,
126 .num_resources = ARRAY_SIZE(uart4),
127};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100128#endif /* CONFIG_ARCH_MX31 */
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200129
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200130/* GPIO port description */
131static struct mxc_gpio_port imx_gpio_ports[] = {
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200132 {
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200133 .chip.label = "gpio-0",
134 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
135 .irq = MXC_INT_GPIO1,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100136 .virtual_irq_start = MXC_GPIO_IRQ_START,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200137 }, {
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200138 .chip.label = "gpio-1",
139 .base = IO_ADDRESS(GPIO2_BASE_ADDR),
140 .irq = MXC_INT_GPIO2,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100141 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200142 }, {
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200143 .chip.label = "gpio-2",
144 .base = IO_ADDRESS(GPIO3_BASE_ADDR),
145 .irq = MXC_INT_GPIO3,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100146 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200147 }
148};
149
150int __init mxc_register_gpios(void)
151{
152 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
153}
Sascha Hauera8405922008-12-01 14:15:39 -0800154
155static struct resource mxc_w1_master_resources[] = {
156 {
157 .start = OWIRE_BASE_ADDR,
158 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
159 .flags = IORESOURCE_MEM,
160 },
161};
162
163struct platform_device mxc_w1_master_device = {
164 .name = "mxc_w1",
165 .id = 0,
166 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
167 .resource = mxc_w1_master_resources,
168};
Sascha Hauercb96cf12008-11-11 15:15:39 +0100169
170static struct resource mxc_nand_resources[] = {
171 {
Sascha Hauer9536ff32009-02-06 15:38:51 +0100172 .start = 0, /* runtime dependent */
173 .end = 0,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200174 .flags = IORESOURCE_MEM,
Sascha Hauercb96cf12008-11-11 15:15:39 +0100175 }, {
176 .start = MXC_INT_NANDFC,
177 .end = MXC_INT_NANDFC,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200178 .flags = IORESOURCE_IRQ,
Sascha Hauercb96cf12008-11-11 15:15:39 +0100179 },
180};
181
182struct platform_device mxc_nand_device = {
183 .name = "mxc_nand",
184 .id = 0,
185 .num_resources = ARRAY_SIZE(mxc_nand_resources),
186 .resource = mxc_nand_resources,
187};
Mark Brown39d1dc02009-01-15 16:14:27 +0000188
189static struct resource mxc_i2c0_resources[] = {
190 {
191 .start = I2C_BASE_ADDR,
192 .end = I2C_BASE_ADDR + SZ_4K - 1,
193 .flags = IORESOURCE_MEM,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200194 }, {
Mark Brown39d1dc02009-01-15 16:14:27 +0000195 .start = MXC_INT_I2C,
196 .end = MXC_INT_I2C,
197 .flags = IORESOURCE_IRQ,
198 },
199};
200
201struct platform_device mxc_i2c_device0 = {
202 .name = "imx-i2c",
203 .id = 0,
204 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
205 .resource = mxc_i2c0_resources,
206};
207
208static struct resource mxc_i2c1_resources[] = {
209 {
210 .start = I2C2_BASE_ADDR,
211 .end = I2C2_BASE_ADDR + SZ_4K - 1,
212 .flags = IORESOURCE_MEM,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200213 }, {
Mark Brown39d1dc02009-01-15 16:14:27 +0000214 .start = MXC_INT_I2C2,
215 .end = MXC_INT_I2C2,
216 .flags = IORESOURCE_IRQ,
217 },
218};
219
220struct platform_device mxc_i2c_device1 = {
221 .name = "imx-i2c",
222 .id = 1,
223 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
224 .resource = mxc_i2c1_resources,
225};
226
227static struct resource mxc_i2c2_resources[] = {
228 {
229 .start = I2C3_BASE_ADDR,
230 .end = I2C3_BASE_ADDR + SZ_4K - 1,
231 .flags = IORESOURCE_MEM,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200232 }, {
Mark Brown39d1dc02009-01-15 16:14:27 +0000233 .start = MXC_INT_I2C3,
234 .end = MXC_INT_I2C3,
235 .flags = IORESOURCE_IRQ,
236 },
237};
238
239struct platform_device mxc_i2c_device2 = {
240 .name = "imx-i2c",
241 .id = 2,
242 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
243 .resource = mxc_i2c2_resources,
244};
Valentin Longchampca489f82009-02-16 12:47:52 +0100245
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100246#ifdef CONFIG_ARCH_MX31
247static struct resource mxcsdhc0_resources[] = {
248 {
249 .start = MMC_SDHC1_BASE_ADDR,
250 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
251 .flags = IORESOURCE_MEM,
252 }, {
253 .start = MXC_INT_MMC_SDHC1,
254 .end = MXC_INT_MMC_SDHC1,
255 .flags = IORESOURCE_IRQ,
256 },
257};
258
259static struct resource mxcsdhc1_resources[] = {
260 {
261 .start = MMC_SDHC2_BASE_ADDR,
262 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
263 .flags = IORESOURCE_MEM,
264 }, {
265 .start = MXC_INT_MMC_SDHC2,
266 .end = MXC_INT_MMC_SDHC2,
267 .flags = IORESOURCE_IRQ,
268 },
269};
270
271struct platform_device mxcsdhc_device0 = {
272 .name = "mxc-mmc",
273 .id = 0,
274 .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
275 .resource = mxcsdhc0_resources,
276};
277
278struct platform_device mxcsdhc_device1 = {
279 .name = "mxc-mmc",
280 .id = 1,
281 .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
282 .resource = mxcsdhc1_resources,
283};
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300284
285static struct resource rnga_resources[] = {
286 {
287 .start = RNGA_BASE_ADDR,
288 .end = RNGA_BASE_ADDR + 0x28,
289 .flags = IORESOURCE_MEM,
290 },
291};
292
293struct platform_device mxc_rnga_device = {
294 .name = "mxc_rnga",
295 .id = -1,
296 .num_resources = 1,
297 .resource = rnga_resources,
298};
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100299#endif /* CONFIG_ARCH_MX31 */
300
Valentin Longchampca489f82009-02-16 12:47:52 +0100301/* i.MX31 Image Processing Unit */
302
303/* The resource order is important! */
304static struct resource mx3_ipu_rsrc[] = {
305 {
306 .start = IPU_CTRL_BASE_ADDR,
307 .end = IPU_CTRL_BASE_ADDR + 0x5F,
308 .flags = IORESOURCE_MEM,
309 }, {
310 .start = IPU_CTRL_BASE_ADDR + 0x88,
311 .end = IPU_CTRL_BASE_ADDR + 0xB3,
312 .flags = IORESOURCE_MEM,
313 }, {
314 .start = MXC_INT_IPU_SYN,
315 .end = MXC_INT_IPU_SYN,
316 .flags = IORESOURCE_IRQ,
317 }, {
318 .start = MXC_INT_IPU_ERR,
319 .end = MXC_INT_IPU_ERR,
320 .flags = IORESOURCE_IRQ,
321 },
322};
323
324struct platform_device mx3_ipu = {
325 .name = "ipu-core",
326 .id = -1,
327 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
328 .resource = mx3_ipu_rsrc,
329};
330
331static struct resource fb_resources[] = {
332 {
333 .start = IPU_CTRL_BASE_ADDR + 0xB4,
334 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
335 .flags = IORESOURCE_MEM,
336 },
337};
338
339struct platform_device mx3_fb = {
340 .name = "mx3_sdc_fb",
341 .id = -1,
342 .num_resources = ARRAY_SIZE(fb_resources),
343 .resource = fb_resources,
344 .dev = {
Valentin Longchamp9c70e222009-05-07 11:51:42 +0200345 .coherent_dma_mask = DMA_BIT_MASK(32),
Valentin Longchampca489f82009-02-16 12:47:52 +0100346 },
347};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100348
Valentin Longchamp9c70e222009-05-07 11:51:42 +0200349static struct resource camera_resources[] = {
350 {
351 .start = IPU_CTRL_BASE_ADDR + 0x60,
352 .end = IPU_CTRL_BASE_ADDR + 0x87,
353 .flags = IORESOURCE_MEM,
354 },
355};
356
357struct platform_device mx3_camera = {
358 .name = "mx3-camera",
359 .id = 0,
360 .num_resources = ARRAY_SIZE(camera_resources),
361 .resource = camera_resources,
362 .dev = {
363 .coherent_dma_mask = DMA_BIT_MASK(32),
364 },
365};
366
Guennadi Liakhovetskieb05bbe2009-05-04 13:13:52 +0200367static struct resource otg_resources[] = {
368 {
369 .start = OTG_BASE_ADDR,
370 .end = OTG_BASE_ADDR + 0x1ff,
371 .flags = IORESOURCE_MEM,
372 }, {
373 .start = MXC_INT_USB3,
374 .end = MXC_INT_USB3,
375 .flags = IORESOURCE_IRQ,
376 },
377};
378
379static u64 otg_dmamask = DMA_BIT_MASK(32);
380
381/* OTG gadget device */
382struct platform_device mxc_otg_udc_device = {
383 .name = "fsl-usb2-udc",
384 .id = -1,
385 .dev = {
386 .dma_mask = &otg_dmamask,
387 .coherent_dma_mask = DMA_BIT_MASK(32),
388 },
389 .resource = otg_resources,
390 .num_resources = ARRAY_SIZE(otg_resources),
391};
392
Sascha Hauer9536ff32009-02-06 15:38:51 +0100393#ifdef CONFIG_ARCH_MX35
394static struct resource mxc_fec_resources[] = {
395 {
396 .start = MXC_FEC_BASE_ADDR,
397 .end = MXC_FEC_BASE_ADDR + 0xfff,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200398 .flags = IORESOURCE_MEM,
Sascha Hauer9536ff32009-02-06 15:38:51 +0100399 }, {
400 .start = MXC_INT_FEC,
401 .end = MXC_INT_FEC,
Sascha Hauer3f4f54b2009-06-23 12:12:00 +0200402 .flags = IORESOURCE_IRQ,
Sascha Hauer9536ff32009-02-06 15:38:51 +0100403 },
404};
405
406struct platform_device mxc_fec_device = {
407 .name = "fec",
408 .id = 0,
409 .num_resources = ARRAY_SIZE(mxc_fec_resources),
410 .resource = mxc_fec_resources,
411};
412#endif
413
414static int mx3_devices_init(void)
415{
416 if (cpu_is_mx31()) {
417 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
418 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300419 mxc_register_device(&mxc_rnga_device, NULL);
Sascha Hauer9536ff32009-02-06 15:38:51 +0100420 }
421 if (cpu_is_mx35()) {
422 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
423 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
424 }
425
426 return 0;
427}
428
429subsys_initcall(mx3_devices_init);