blob: f55c9863ea42238644add41e21bf5d56ec454fad [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>
Sascha Hauere3d13ff2008-07-05 10:02:48 +020029
Sascha Hauer87bbb192009-01-29 16:00:23 +010030#include "devices.h"
31
Sascha Hauere3d13ff2008-07-05 10:02:48 +020032static struct resource uart0[] = {
33 {
34 .start = UART1_BASE_ADDR,
35 .end = UART1_BASE_ADDR + 0x0B5,
36 .flags = IORESOURCE_MEM,
37 }, {
38 .start = MXC_INT_UART1,
39 .end = MXC_INT_UART1,
40 .flags = IORESOURCE_IRQ,
41 },
42};
43
Sascha Hauer5cf09422008-09-09 10:19:41 +020044struct platform_device mxc_uart_device0 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020045 .name = "imx-uart",
46 .id = 0,
47 .resource = uart0,
48 .num_resources = ARRAY_SIZE(uart0),
49};
50
51static struct resource uart1[] = {
52 {
53 .start = UART2_BASE_ADDR,
54 .end = UART2_BASE_ADDR + 0x0B5,
55 .flags = IORESOURCE_MEM,
56 }, {
57 .start = MXC_INT_UART2,
58 .end = MXC_INT_UART2,
59 .flags = IORESOURCE_IRQ,
60 },
61};
62
Sascha Hauer5cf09422008-09-09 10:19:41 +020063struct platform_device mxc_uart_device1 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020064 .name = "imx-uart",
65 .id = 1,
66 .resource = uart1,
67 .num_resources = ARRAY_SIZE(uart1),
68};
69
70static struct resource uart2[] = {
71 {
72 .start = UART3_BASE_ADDR,
73 .end = UART3_BASE_ADDR + 0x0B5,
74 .flags = IORESOURCE_MEM,
75 }, {
76 .start = MXC_INT_UART3,
77 .end = MXC_INT_UART3,
78 .flags = IORESOURCE_IRQ,
79 },
80};
81
Sascha Hauer5cf09422008-09-09 10:19:41 +020082struct platform_device mxc_uart_device2 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020083 .name = "imx-uart",
84 .id = 2,
85 .resource = uart2,
86 .num_resources = ARRAY_SIZE(uart2),
87};
88
Sascha Hauer9536ff32009-02-06 15:38:51 +010089#ifdef CONFIG_ARCH_MX31
Sascha Hauere3d13ff2008-07-05 10:02:48 +020090static struct resource uart3[] = {
91 {
92 .start = UART4_BASE_ADDR,
93 .end = UART4_BASE_ADDR + 0x0B5,
94 .flags = IORESOURCE_MEM,
95 }, {
96 .start = MXC_INT_UART4,
97 .end = MXC_INT_UART4,
98 .flags = IORESOURCE_IRQ,
99 },
100};
101
Sascha Hauer5cf09422008-09-09 10:19:41 +0200102struct platform_device mxc_uart_device3 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200103 .name = "imx-uart",
104 .id = 3,
105 .resource = uart3,
106 .num_resources = ARRAY_SIZE(uart3),
107};
108
109static struct resource uart4[] = {
110 {
111 .start = UART5_BASE_ADDR,
112 .end = UART5_BASE_ADDR + 0x0B5,
113 .flags = IORESOURCE_MEM,
114 }, {
115 .start = MXC_INT_UART5,
116 .end = MXC_INT_UART5,
117 .flags = IORESOURCE_IRQ,
118 },
119};
120
Sascha Hauer5cf09422008-09-09 10:19:41 +0200121struct platform_device mxc_uart_device4 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200122 .name = "imx-uart",
123 .id = 4,
124 .resource = uart4,
125 .num_resources = ARRAY_SIZE(uart4),
126};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100127#endif /* CONFIG_ARCH_MX31 */
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200128
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200129/* GPIO port description */
130static struct mxc_gpio_port imx_gpio_ports[] = {
131 [0] = {
132 .chip.label = "gpio-0",
133 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
134 .irq = MXC_INT_GPIO1,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100135 .virtual_irq_start = MXC_GPIO_IRQ_START,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200136 },
137 [1] = {
138 .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,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200142 },
143 [2] = {
144 .chip.label = "gpio-2",
145 .base = IO_ADDRESS(GPIO3_BASE_ADDR),
146 .irq = MXC_INT_GPIO3,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100147 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200148 }
149};
150
151int __init mxc_register_gpios(void)
152{
153 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
154}
Sascha Hauera8405922008-12-01 14:15:39 -0800155
156static struct resource mxc_w1_master_resources[] = {
157 {
158 .start = OWIRE_BASE_ADDR,
159 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
160 .flags = IORESOURCE_MEM,
161 },
162};
163
164struct platform_device mxc_w1_master_device = {
165 .name = "mxc_w1",
166 .id = 0,
167 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
168 .resource = mxc_w1_master_resources,
169};
Sascha Hauercb96cf12008-11-11 15:15:39 +0100170
171static struct resource mxc_nand_resources[] = {
172 {
Sascha Hauer9536ff32009-02-06 15:38:51 +0100173 .start = 0, /* runtime dependent */
174 .end = 0,
Sascha Hauercb96cf12008-11-11 15:15:39 +0100175 .flags = IORESOURCE_MEM
176 }, {
177 .start = MXC_INT_NANDFC,
178 .end = MXC_INT_NANDFC,
179 .flags = IORESOURCE_IRQ
180 },
181};
182
183struct platform_device mxc_nand_device = {
184 .name = "mxc_nand",
185 .id = 0,
186 .num_resources = ARRAY_SIZE(mxc_nand_resources),
187 .resource = mxc_nand_resources,
188};
Mark Brown39d1dc02009-01-15 16:14:27 +0000189
190static struct resource mxc_i2c0_resources[] = {
191 {
192 .start = I2C_BASE_ADDR,
193 .end = I2C_BASE_ADDR + SZ_4K - 1,
194 .flags = IORESOURCE_MEM,
195 },
196 {
197 .start = MXC_INT_I2C,
198 .end = MXC_INT_I2C,
199 .flags = IORESOURCE_IRQ,
200 },
201};
202
203struct platform_device mxc_i2c_device0 = {
204 .name = "imx-i2c",
205 .id = 0,
206 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
207 .resource = mxc_i2c0_resources,
208};
209
210static struct resource mxc_i2c1_resources[] = {
211 {
212 .start = I2C2_BASE_ADDR,
213 .end = I2C2_BASE_ADDR + SZ_4K - 1,
214 .flags = IORESOURCE_MEM,
215 },
216 {
217 .start = MXC_INT_I2C2,
218 .end = MXC_INT_I2C2,
219 .flags = IORESOURCE_IRQ,
220 },
221};
222
223struct platform_device mxc_i2c_device1 = {
224 .name = "imx-i2c",
225 .id = 1,
226 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
227 .resource = mxc_i2c1_resources,
228};
229
230static struct resource mxc_i2c2_resources[] = {
231 {
232 .start = I2C3_BASE_ADDR,
233 .end = I2C3_BASE_ADDR + SZ_4K - 1,
234 .flags = IORESOURCE_MEM,
235 },
236 {
237 .start = MXC_INT_I2C3,
238 .end = MXC_INT_I2C3,
239 .flags = IORESOURCE_IRQ,
240 },
241};
242
243struct platform_device mxc_i2c_device2 = {
244 .name = "imx-i2c",
245 .id = 2,
246 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
247 .resource = mxc_i2c2_resources,
248};
Valentin Longchampca489f82009-02-16 12:47:52 +0100249
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100250#ifdef CONFIG_ARCH_MX31
251static struct resource mxcsdhc0_resources[] = {
252 {
253 .start = MMC_SDHC1_BASE_ADDR,
254 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
255 .flags = IORESOURCE_MEM,
256 }, {
257 .start = MXC_INT_MMC_SDHC1,
258 .end = MXC_INT_MMC_SDHC1,
259 .flags = IORESOURCE_IRQ,
260 },
261};
262
263static struct resource mxcsdhc1_resources[] = {
264 {
265 .start = MMC_SDHC2_BASE_ADDR,
266 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
267 .flags = IORESOURCE_MEM,
268 }, {
269 .start = MXC_INT_MMC_SDHC2,
270 .end = MXC_INT_MMC_SDHC2,
271 .flags = IORESOURCE_IRQ,
272 },
273};
274
275struct platform_device mxcsdhc_device0 = {
276 .name = "mxc-mmc",
277 .id = 0,
278 .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
279 .resource = mxcsdhc0_resources,
280};
281
282struct platform_device mxcsdhc_device1 = {
283 .name = "mxc-mmc",
284 .id = 1,
285 .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
286 .resource = mxcsdhc1_resources,
287};
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300288
289static struct resource rnga_resources[] = {
290 {
291 .start = RNGA_BASE_ADDR,
292 .end = RNGA_BASE_ADDR + 0x28,
293 .flags = IORESOURCE_MEM,
294 },
295};
296
297struct platform_device mxc_rnga_device = {
298 .name = "mxc_rnga",
299 .id = -1,
300 .num_resources = 1,
301 .resource = rnga_resources,
302};
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100303#endif /* CONFIG_ARCH_MX31 */
304
Valentin Longchampca489f82009-02-16 12:47:52 +0100305/* i.MX31 Image Processing Unit */
306
307/* The resource order is important! */
308static struct resource mx3_ipu_rsrc[] = {
309 {
310 .start = IPU_CTRL_BASE_ADDR,
311 .end = IPU_CTRL_BASE_ADDR + 0x5F,
312 .flags = IORESOURCE_MEM,
313 }, {
314 .start = IPU_CTRL_BASE_ADDR + 0x88,
315 .end = IPU_CTRL_BASE_ADDR + 0xB3,
316 .flags = IORESOURCE_MEM,
317 }, {
318 .start = MXC_INT_IPU_SYN,
319 .end = MXC_INT_IPU_SYN,
320 .flags = IORESOURCE_IRQ,
321 }, {
322 .start = MXC_INT_IPU_ERR,
323 .end = MXC_INT_IPU_ERR,
324 .flags = IORESOURCE_IRQ,
325 },
326};
327
328struct platform_device mx3_ipu = {
329 .name = "ipu-core",
330 .id = -1,
331 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
332 .resource = mx3_ipu_rsrc,
333};
334
335static struct resource fb_resources[] = {
336 {
337 .start = IPU_CTRL_BASE_ADDR + 0xB4,
338 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
339 .flags = IORESOURCE_MEM,
340 },
341};
342
343struct platform_device mx3_fb = {
344 .name = "mx3_sdc_fb",
345 .id = -1,
346 .num_resources = ARRAY_SIZE(fb_resources),
347 .resource = fb_resources,
348 .dev = {
349 .coherent_dma_mask = 0xffffffff,
350 },
351};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100352
Guennadi Liakhovetskieb05bbe2009-05-04 13:13:52 +0200353static struct resource otg_resources[] = {
354 {
355 .start = OTG_BASE_ADDR,
356 .end = OTG_BASE_ADDR + 0x1ff,
357 .flags = IORESOURCE_MEM,
358 }, {
359 .start = MXC_INT_USB3,
360 .end = MXC_INT_USB3,
361 .flags = IORESOURCE_IRQ,
362 },
363};
364
365static u64 otg_dmamask = DMA_BIT_MASK(32);
366
367/* OTG gadget device */
368struct platform_device mxc_otg_udc_device = {
369 .name = "fsl-usb2-udc",
370 .id = -1,
371 .dev = {
372 .dma_mask = &otg_dmamask,
373 .coherent_dma_mask = DMA_BIT_MASK(32),
374 },
375 .resource = otg_resources,
376 .num_resources = ARRAY_SIZE(otg_resources),
377};
378
Sascha Hauer9536ff32009-02-06 15:38:51 +0100379#ifdef CONFIG_ARCH_MX35
380static struct resource mxc_fec_resources[] = {
381 {
382 .start = MXC_FEC_BASE_ADDR,
383 .end = MXC_FEC_BASE_ADDR + 0xfff,
384 .flags = IORESOURCE_MEM
385 }, {
386 .start = MXC_INT_FEC,
387 .end = MXC_INT_FEC,
388 .flags = IORESOURCE_IRQ
389 },
390};
391
392struct platform_device mxc_fec_device = {
393 .name = "fec",
394 .id = 0,
395 .num_resources = ARRAY_SIZE(mxc_fec_resources),
396 .resource = mxc_fec_resources,
397};
398#endif
399
400static int mx3_devices_init(void)
401{
402 if (cpu_is_mx31()) {
403 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
404 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300405 mxc_register_device(&mxc_rnga_device, NULL);
Sascha Hauer9536ff32009-02-06 15:38:51 +0100406 }
407 if (cpu_is_mx35()) {
408 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
409 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
410 }
411
412 return 0;
413}
414
415subsys_initcall(mx3_devices_init);