blob: 227a538bb941d54ce87bb7e01e43095648f2805b [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
20#include <linux/module.h>
21#include <linux/platform_device.h>
22#include <linux/serial.h>
Juergen Beisert07bd1a62008-07-05 10:02:49 +020023#include <linux/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/hardware.h>
Russell King80b02c12009-01-08 10:01:47 +000025#include <mach/irqs.h>
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -030026#include <mach/common.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/imx-uart.h>
Sascha Hauere3d13ff2008-07-05 10:02:48 +020028
Sascha Hauer87bbb192009-01-29 16:00:23 +010029#include "devices.h"
30
Sascha Hauere3d13ff2008-07-05 10:02:48 +020031static struct resource uart0[] = {
32 {
33 .start = UART1_BASE_ADDR,
34 .end = UART1_BASE_ADDR + 0x0B5,
35 .flags = IORESOURCE_MEM,
36 }, {
37 .start = MXC_INT_UART1,
38 .end = MXC_INT_UART1,
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
Sascha Hauer5cf09422008-09-09 10:19:41 +020043struct platform_device mxc_uart_device0 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020044 .name = "imx-uart",
45 .id = 0,
46 .resource = uart0,
47 .num_resources = ARRAY_SIZE(uart0),
48};
49
50static struct resource uart1[] = {
51 {
52 .start = UART2_BASE_ADDR,
53 .end = UART2_BASE_ADDR + 0x0B5,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .start = MXC_INT_UART2,
57 .end = MXC_INT_UART2,
58 .flags = IORESOURCE_IRQ,
59 },
60};
61
Sascha Hauer5cf09422008-09-09 10:19:41 +020062struct platform_device mxc_uart_device1 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020063 .name = "imx-uart",
64 .id = 1,
65 .resource = uart1,
66 .num_resources = ARRAY_SIZE(uart1),
67};
68
69static struct resource uart2[] = {
70 {
71 .start = UART3_BASE_ADDR,
72 .end = UART3_BASE_ADDR + 0x0B5,
73 .flags = IORESOURCE_MEM,
74 }, {
75 .start = MXC_INT_UART3,
76 .end = MXC_INT_UART3,
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
Sascha Hauer5cf09422008-09-09 10:19:41 +020081struct platform_device mxc_uart_device2 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +020082 .name = "imx-uart",
83 .id = 2,
84 .resource = uart2,
85 .num_resources = ARRAY_SIZE(uart2),
86};
87
Sascha Hauer9536ff32009-02-06 15:38:51 +010088#ifdef CONFIG_ARCH_MX31
Sascha Hauere3d13ff2008-07-05 10:02:48 +020089static struct resource uart3[] = {
90 {
91 .start = UART4_BASE_ADDR,
92 .end = UART4_BASE_ADDR + 0x0B5,
93 .flags = IORESOURCE_MEM,
94 }, {
95 .start = MXC_INT_UART4,
96 .end = MXC_INT_UART4,
97 .flags = IORESOURCE_IRQ,
98 },
99};
100
Sascha Hauer5cf09422008-09-09 10:19:41 +0200101struct platform_device mxc_uart_device3 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200102 .name = "imx-uart",
103 .id = 3,
104 .resource = uart3,
105 .num_resources = ARRAY_SIZE(uart3),
106};
107
108static struct resource uart4[] = {
109 {
110 .start = UART5_BASE_ADDR,
111 .end = UART5_BASE_ADDR + 0x0B5,
112 .flags = IORESOURCE_MEM,
113 }, {
114 .start = MXC_INT_UART5,
115 .end = MXC_INT_UART5,
116 .flags = IORESOURCE_IRQ,
117 },
118};
119
Sascha Hauer5cf09422008-09-09 10:19:41 +0200120struct platform_device mxc_uart_device4 = {
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200121 .name = "imx-uart",
122 .id = 4,
123 .resource = uart4,
124 .num_resources = ARRAY_SIZE(uart4),
125};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100126#endif /* CONFIG_ARCH_MX31 */
Sascha Hauere3d13ff2008-07-05 10:02:48 +0200127
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200128/* GPIO port description */
129static struct mxc_gpio_port imx_gpio_ports[] = {
130 [0] = {
131 .chip.label = "gpio-0",
132 .base = IO_ADDRESS(GPIO1_BASE_ADDR),
133 .irq = MXC_INT_GPIO1,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100134 .virtual_irq_start = MXC_GPIO_IRQ_START,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200135 },
136 [1] = {
137 .chip.label = "gpio-1",
138 .base = IO_ADDRESS(GPIO2_BASE_ADDR),
139 .irq = MXC_INT_GPIO2,
Sascha Hauer9d631b82008-12-18 11:08:55 +0100140 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
Juergen Beisert07bd1a62008-07-05 10:02:49 +0200141 },
142 [2] = {
143 .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 Hauercb96cf12008-11-11 15:15:39 +0100174 .flags = IORESOURCE_MEM
175 }, {
176 .start = MXC_INT_NANDFC,
177 .end = MXC_INT_NANDFC,
178 .flags = IORESOURCE_IRQ
179 },
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,
194 },
195 {
196 .start = MXC_INT_I2C,
197 .end = MXC_INT_I2C,
198 .flags = IORESOURCE_IRQ,
199 },
200};
201
202struct platform_device mxc_i2c_device0 = {
203 .name = "imx-i2c",
204 .id = 0,
205 .num_resources = ARRAY_SIZE(mxc_i2c0_resources),
206 .resource = mxc_i2c0_resources,
207};
208
209static struct resource mxc_i2c1_resources[] = {
210 {
211 .start = I2C2_BASE_ADDR,
212 .end = I2C2_BASE_ADDR + SZ_4K - 1,
213 .flags = IORESOURCE_MEM,
214 },
215 {
216 .start = MXC_INT_I2C2,
217 .end = MXC_INT_I2C2,
218 .flags = IORESOURCE_IRQ,
219 },
220};
221
222struct platform_device mxc_i2c_device1 = {
223 .name = "imx-i2c",
224 .id = 1,
225 .num_resources = ARRAY_SIZE(mxc_i2c1_resources),
226 .resource = mxc_i2c1_resources,
227};
228
229static struct resource mxc_i2c2_resources[] = {
230 {
231 .start = I2C3_BASE_ADDR,
232 .end = I2C3_BASE_ADDR + SZ_4K - 1,
233 .flags = IORESOURCE_MEM,
234 },
235 {
236 .start = MXC_INT_I2C3,
237 .end = MXC_INT_I2C3,
238 .flags = IORESOURCE_IRQ,
239 },
240};
241
242struct platform_device mxc_i2c_device2 = {
243 .name = "imx-i2c",
244 .id = 2,
245 .num_resources = ARRAY_SIZE(mxc_i2c2_resources),
246 .resource = mxc_i2c2_resources,
247};
Valentin Longchampca489f82009-02-16 12:47:52 +0100248
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100249#ifdef CONFIG_ARCH_MX31
250static struct resource mxcsdhc0_resources[] = {
251 {
252 .start = MMC_SDHC1_BASE_ADDR,
253 .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1,
254 .flags = IORESOURCE_MEM,
255 }, {
256 .start = MXC_INT_MMC_SDHC1,
257 .end = MXC_INT_MMC_SDHC1,
258 .flags = IORESOURCE_IRQ,
259 },
260};
261
262static struct resource mxcsdhc1_resources[] = {
263 {
264 .start = MMC_SDHC2_BASE_ADDR,
265 .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1,
266 .flags = IORESOURCE_MEM,
267 }, {
268 .start = MXC_INT_MMC_SDHC2,
269 .end = MXC_INT_MMC_SDHC2,
270 .flags = IORESOURCE_IRQ,
271 },
272};
273
274struct platform_device mxcsdhc_device0 = {
275 .name = "mxc-mmc",
276 .id = 0,
277 .num_resources = ARRAY_SIZE(mxcsdhc0_resources),
278 .resource = mxcsdhc0_resources,
279};
280
281struct platform_device mxcsdhc_device1 = {
282 .name = "mxc-mmc",
283 .id = 1,
284 .num_resources = ARRAY_SIZE(mxcsdhc1_resources),
285 .resource = mxcsdhc1_resources,
286};
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300287
288static struct resource rnga_resources[] = {
289 {
290 .start = RNGA_BASE_ADDR,
291 .end = RNGA_BASE_ADDR + 0x28,
292 .flags = IORESOURCE_MEM,
293 },
294};
295
296struct platform_device mxc_rnga_device = {
297 .name = "mxc_rnga",
298 .id = -1,
299 .num_resources = 1,
300 .resource = rnga_resources,
301};
Sascha Hauer2adc1d62008-12-19 14:32:06 +0100302#endif /* CONFIG_ARCH_MX31 */
303
Valentin Longchampca489f82009-02-16 12:47:52 +0100304/* i.MX31 Image Processing Unit */
305
306/* The resource order is important! */
307static struct resource mx3_ipu_rsrc[] = {
308 {
309 .start = IPU_CTRL_BASE_ADDR,
310 .end = IPU_CTRL_BASE_ADDR + 0x5F,
311 .flags = IORESOURCE_MEM,
312 }, {
313 .start = IPU_CTRL_BASE_ADDR + 0x88,
314 .end = IPU_CTRL_BASE_ADDR + 0xB3,
315 .flags = IORESOURCE_MEM,
316 }, {
317 .start = MXC_INT_IPU_SYN,
318 .end = MXC_INT_IPU_SYN,
319 .flags = IORESOURCE_IRQ,
320 }, {
321 .start = MXC_INT_IPU_ERR,
322 .end = MXC_INT_IPU_ERR,
323 .flags = IORESOURCE_IRQ,
324 },
325};
326
327struct platform_device mx3_ipu = {
328 .name = "ipu-core",
329 .id = -1,
330 .num_resources = ARRAY_SIZE(mx3_ipu_rsrc),
331 .resource = mx3_ipu_rsrc,
332};
333
334static struct resource fb_resources[] = {
335 {
336 .start = IPU_CTRL_BASE_ADDR + 0xB4,
337 .end = IPU_CTRL_BASE_ADDR + 0x1BF,
338 .flags = IORESOURCE_MEM,
339 },
340};
341
342struct platform_device mx3_fb = {
343 .name = "mx3_sdc_fb",
344 .id = -1,
345 .num_resources = ARRAY_SIZE(fb_resources),
346 .resource = fb_resources,
347 .dev = {
348 .coherent_dma_mask = 0xffffffff,
349 },
350};
Sascha Hauer9536ff32009-02-06 15:38:51 +0100351
352#ifdef CONFIG_ARCH_MX35
353static struct resource mxc_fec_resources[] = {
354 {
355 .start = MXC_FEC_BASE_ADDR,
356 .end = MXC_FEC_BASE_ADDR + 0xfff,
357 .flags = IORESOURCE_MEM
358 }, {
359 .start = MXC_INT_FEC,
360 .end = MXC_INT_FEC,
361 .flags = IORESOURCE_IRQ
362 },
363};
364
365struct platform_device mxc_fec_device = {
366 .name = "fec",
367 .id = 0,
368 .num_resources = ARRAY_SIZE(mxc_fec_resources),
369 .resource = mxc_fec_resources,
370};
371#endif
372
373static int mx3_devices_init(void)
374{
375 if (cpu_is_mx31()) {
376 mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR;
377 mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff;
Alan Carvalho de Assis45001e92009-04-02 12:38:41 -0300378 mxc_register_device(&mxc_rnga_device, NULL);
Sascha Hauer9536ff32009-02-06 15:38:51 +0100379 }
380 if (cpu_is_mx35()) {
381 mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR;
382 mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff;
383 }
384
385 return 0;
386}
387
388subsys_initcall(mx3_devices_init);