blob: 08ae763d9db0ebb4f281e20dc39599a73082f81f [file] [log] [blame]
Juergen Beisertfc80a5e2008-07-05 10:02:57 +02001/*
2 * Author: MontaVista Software, Inc.
3 * <source@mvista.com>
4 *
5 * Based on the OMAP devices.c
6 *
7 * 2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
13 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 * MA 02110-1301, USA.
28 */
29#include <linux/module.h>
30#include <linux/kernel.h>
31#include <linux/init.h>
32#include <linux/platform_device.h>
33#include <linux/gpio.h>
Martin Fuzzey3eb352c2009-11-21 12:14:54 +010034#include <linux/dma-mapping.h>
Uwe Kleine-Könige9ec2a12010-06-10 17:34:59 +020035#include <linux/serial.h>
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020036
Russell King80b02c12009-01-08 10:01:47 +000037#include <mach/irqs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/hardware.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010039#include <mach/common.h>
Sascha Hauer1a02be02008-12-19 14:32:07 +010040#include <mach/mmc.h>
Uwe Kleine-Könige9ec2a12010-06-10 17:34:59 +020041#include <mach/imx-uart.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010042
43#include "devices.h"
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020044
45/*
Sascha Hauerf420db82008-12-19 14:32:14 +010046 * SPI master controller
47 *
48 * - i.MX1: 2 channel (slighly different register setting)
49 * - i.MX21: 2 channel
50 * - i.MX27: 3 channel
51 */
Uwe Kleine-König68c94b42010-02-04 22:04:32 +010052#define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq) \
53 static struct resource mxc_spi_resources ## n[] = { \
54 { \
55 .start = baseaddr, \
56 .end = baseaddr + SZ_4K - 1, \
57 .flags = IORESOURCE_MEM, \
58 }, { \
59 .start = irq, \
60 .end = irq, \
61 .flags = IORESOURCE_IRQ, \
62 }, \
63 }; \
64 \
65 struct platform_device mxc_spi_device ## n = { \
66 .name = "spi_imx", \
67 .id = n, \
68 .num_resources = ARRAY_SIZE(mxc_spi_resources ## n), \
69 .resource = mxc_spi_resources ## n, \
70 }
Sascha Hauerf420db82008-12-19 14:32:14 +010071
Uwe Kleine-König68c94b42010-02-04 22:04:32 +010072DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1);
73DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2);
Sascha Hauerf420db82008-12-19 14:32:14 +010074
75#ifdef CONFIG_MACH_MX27
Uwe Kleine-König68c94b42010-02-04 22:04:32 +010076DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3);
Sascha Hauerf420db82008-12-19 14:32:14 +010077#endif
78
79/*
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020080 * General Purpose Timer
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020081 * - i.MX21: 3 timers
82 * - i.MX27: 6 timers
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020083 */
Uwe Kleine-König2b84a3642010-02-04 14:11:02 +010084#define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq) \
85 static struct resource timer ## n ##_resources[] = { \
86 { \
87 .start = baseaddr, \
88 .end = baseaddr + SZ_4K - 1, \
89 .flags = IORESOURCE_MEM, \
90 }, { \
91 .start = irq, \
92 .end = irq, \
93 .flags = IORESOURCE_IRQ, \
94 } \
95 }; \
96 \
97 struct platform_device mxc_gpt ## n = { \
98 .name = "imx_gpt", \
99 .id = n, \
100 .num_resources = ARRAY_SIZE(timer ## n ## _resources), \
101 .resource = timer ## n ## _resources, \
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200102 }
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200103
Uwe Kleine-König2b84a3642010-02-04 14:11:02 +0100104/* We use gpt1 as system timer, so do not add a device for this one */
105DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2);
106DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3);
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200107
108#ifdef CONFIG_MACH_MX27
Uwe Kleine-König2b84a3642010-02-04 14:11:02 +0100109DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4);
110DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5);
111DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6);
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200112#endif
113
Wolfram Sang6d38c1c2010-04-29 10:03:18 +0200114/* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200115static struct resource mxc_wdt_resources[] = {
116 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100117 .start = MX2x_WDOG_BASE_ADDR,
118 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
119 .flags = IORESOURCE_MEM,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200120 },
121};
122
123struct platform_device mxc_wdt = {
Wolfram Sang6d38c1c2010-04-29 10:03:18 +0200124 .name = "imx2-wdt",
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200125 .id = 0,
126 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
127 .resource = mxc_wdt_resources,
128};
129
Sascha Hauer3d89baa2008-12-01 14:15:38 -0800130static struct resource mxc_w1_master_resources[] = {
131 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100132 .start = MX2x_OWIRE_BASE_ADDR,
133 .end = MX2x_OWIRE_BASE_ADDR + SZ_4K - 1,
Sascha Hauer3d89baa2008-12-01 14:15:38 -0800134 .flags = IORESOURCE_MEM,
135 },
136};
137
138struct platform_device mxc_w1_master_device = {
139 .name = "mxc_w1",
140 .id = 0,
141 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
142 .resource = mxc_w1_master_resources,
143};
144
Uwe Kleine-Königf0d3ab42010-02-05 16:57:59 +0100145#define DEFINE_MXC_NAND_DEVICE(pfx, baseaddr, irq) \
146 static struct resource pfx ## _nand_resources[] = { \
147 { \
148 .start = baseaddr, \
149 .end = baseaddr + SZ_4K - 1, \
150 .flags = IORESOURCE_MEM, \
151 }, { \
152 .start = irq, \
153 .end = irq, \
154 .flags = IORESOURCE_IRQ, \
155 }, \
156 }; \
157 \
158 struct platform_device pfx ## _nand_device = { \
159 .name = "mxc_nand", \
160 .id = 0, \
161 .num_resources = ARRAY_SIZE(pfx ## _nand_resources), \
162 .resource = pfx ## _nand_resources, \
163 }
Sascha Hauer02870972008-09-09 11:30:58 +0200164
Uwe Kleine-Königf0d3ab42010-02-05 16:57:59 +0100165#ifdef CONFIG_MACH_MX21
166DEFINE_MXC_NAND_DEVICE(imx21, MX21_NFC_BASE_ADDR, MX21_INT_NANDFC);
167#endif
168
169#ifdef CONFIG_MACH_MX27
170DEFINE_MXC_NAND_DEVICE(imx27, MX27_NFC_BASE_ADDR, MX27_INT_NANDFC);
171#endif
Sascha Hauer02870972008-09-09 11:30:58 +0200172
Holger Schurige4813552009-01-26 16:34:56 +0100173/*
174 * lcdc:
175 * - i.MX1: the basic controller
176 * - i.MX21: to be checked
177 * - i.MX27: like i.MX1, with slightly variations
178 */
179static struct resource mxc_fb[] = {
180 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100181 .start = MX2x_LCDC_BASE_ADDR,
182 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
Holger Schurige4813552009-01-26 16:34:56 +0100183 .flags = IORESOURCE_MEM,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200184 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100185 .start = MX2x_INT_LCDC,
186 .end = MX2x_INT_LCDC,
Holger Schurige4813552009-01-26 16:34:56 +0100187 .flags = IORESOURCE_IRQ,
188 }
189};
190
191/* mxc lcd driver */
192struct platform_device mxc_fb_device = {
193 .name = "imx-fb",
194 .id = 0,
195 .num_resources = ARRAY_SIZE(mxc_fb),
196 .resource = mxc_fb,
197 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100198 .coherent_dma_mask = DMA_BIT_MASK(32),
Holger Schurige4813552009-01-26 16:34:56 +0100199 },
200};
201
Sascha Hauer879fea12009-01-26 17:26:02 +0100202#ifdef CONFIG_MACH_MX27
203static struct resource mxc_fec_resources[] = {
204 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100205 .start = MX27_FEC_BASE_ADDR,
206 .end = MX27_FEC_BASE_ADDR + SZ_4K - 1,
207 .flags = IORESOURCE_MEM,
Sascha Hauer879fea12009-01-26 17:26:02 +0100208 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100209 .start = MX27_INT_FEC,
210 .end = MX27_INT_FEC,
211 .flags = IORESOURCE_IRQ,
Sascha Hauer879fea12009-01-26 17:26:02 +0100212 },
213};
214
215struct platform_device mxc_fec_device = {
216 .name = "fec",
217 .id = 0,
218 .num_resources = ARRAY_SIZE(mxc_fec_resources),
219 .resource = mxc_fec_resources,
220};
Holger Schurige4813552009-01-26 16:34:56 +0100221#endif
222
Uwe Kleine-König9309b2b2010-02-04 22:13:52 +0100223#define DEFINE_IMX_I2C_DEVICE(n, baseaddr, irq) \
224 static struct resource mxc_i2c_resources ## n[] = { \
225 { \
226 .start = baseaddr, \
227 .end = baseaddr + SZ_4K - 1, \
228 .flags = IORESOURCE_MEM, \
229 }, { \
230 .start = irq, \
231 .end = irq, \
232 .flags = IORESOURCE_IRQ, \
233 } \
234 }; \
235 \
236 struct platform_device mxc_i2c_device ## n = { \
237 .name = "imx-i2c", \
238 .id = n, \
239 .num_resources = ARRAY_SIZE(mxc_i2c_resources ## n), \
240 .resource = mxc_i2c_resources ## n, \
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100241 }
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100242
Uwe Kleine-König9309b2b2010-02-04 22:13:52 +0100243DEFINE_IMX_I2C_DEVICE(0, MX2x_I2C_BASE_ADDR, MX2x_INT_I2C);
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100244
245#ifdef CONFIG_MACH_MX27
Uwe Kleine-König9309b2b2010-02-04 22:13:52 +0100246DEFINE_IMX_I2C_DEVICE(1, MX27_I2C2_BASE_ADDR, MX27_INT_I2C2);
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100247#endif
248
Sascha Hauer824b16e2009-01-16 15:17:46 +0100249static struct resource mxc_pwm_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200250 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100251 .start = MX2x_PWM_BASE_ADDR,
252 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
253 .flags = IORESOURCE_MEM,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200254 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100255 .start = MX2x_INT_PWM,
256 .end = MX2x_INT_PWM,
257 .flags = IORESOURCE_IRQ,
Sascha Hauer824b16e2009-01-16 15:17:46 +0100258 }
259};
260
261struct platform_device mxc_pwm_device = {
262 .name = "mxc_pwm",
263 .id = 0,
264 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200265 .resource = mxc_pwm_resources,
Sascha Hauer824b16e2009-01-16 15:17:46 +0100266};
267
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100268#define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
269 static struct resource mxc_sdhc_resources ## n[] = { \
270 { \
271 .start = baseaddr, \
272 .end = baseaddr + SZ_4K - 1, \
273 .flags = IORESOURCE_MEM, \
274 }, { \
275 .start = irq, \
276 .end = irq, \
277 .flags = IORESOURCE_IRQ, \
278 }, { \
279 .start = dmareq, \
280 .end = dmareq, \
281 .flags = IORESOURCE_DMA, \
282 }, \
283 }; \
284 \
Russell King988addf2010-03-08 20:21:04 +0000285 static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100286 \
287 struct platform_device mxc_sdhc_device ## n = { \
288 .name = "mxc-mmc", \
289 .id = n, \
290 .dev = { \
291 .dma_mask = &mxc_sdhc ## n ## _dmamask, \
Russell King988addf2010-03-08 20:21:04 +0000292 .coherent_dma_mask = DMA_BIT_MASK(32), \
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100293 }, \
294 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
295 .resource = mxc_sdhc_resources ## n, \
296 }
Sascha Hauer1a02be02008-12-19 14:32:07 +0100297
Uwe Kleine-Königccd0e422010-02-05 10:46:56 +0100298DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
299DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
Sascha Hauer1a02be02008-12-19 14:32:07 +0100300
Sascha Hauerf6d2fa72009-08-13 10:02:30 +0200301#ifdef CONFIG_MACH_MX27
javier Martin627fb3b2009-07-15 15:26:21 +0200302static struct resource otg_resources[] = {
303 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100304 .start = MX27_USBOTG_BASE_ADDR,
305 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
306 .flags = IORESOURCE_MEM,
javier Martin627fb3b2009-07-15 15:26:21 +0200307 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100308 .start = MX27_INT_USB3,
309 .end = MX27_INT_USB3,
310 .flags = IORESOURCE_IRQ,
javier Martin627fb3b2009-07-15 15:26:21 +0200311 },
312};
313
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100314static u64 otg_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200315
316/* OTG gadget device */
317struct platform_device mxc_otg_udc_device = {
318 .name = "fsl-usb2-udc",
319 .id = -1,
320 .dev = {
321 .dma_mask = &otg_dmamask,
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100322 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200323 },
324 .resource = otg_resources,
325 .num_resources = ARRAY_SIZE(otg_resources),
326};
327
328/* OTG host */
329struct platform_device mxc_otg_host = {
330 .name = "mxc-ehci",
331 .id = 0,
332 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100333 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200334 .dma_mask = &otg_dmamask,
335 },
336 .resource = otg_resources,
337 .num_resources = ARRAY_SIZE(otg_resources),
338};
339
340/* USB host 1 */
341
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100342static u64 usbh1_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200343
344static struct resource mxc_usbh1_resources[] = {
345 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100346 .start = MX27_USBOTG_BASE_ADDR + 0x200,
347 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
javier Martin627fb3b2009-07-15 15:26:21 +0200348 .flags = IORESOURCE_MEM,
349 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100350 .start = MX27_INT_USB1,
351 .end = MX27_INT_USB1,
javier Martin627fb3b2009-07-15 15:26:21 +0200352 .flags = IORESOURCE_IRQ,
353 },
354};
355
356struct platform_device mxc_usbh1 = {
357 .name = "mxc-ehci",
358 .id = 1,
359 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100360 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200361 .dma_mask = &usbh1_dmamask,
362 },
363 .resource = mxc_usbh1_resources,
364 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
365};
366
367/* USB host 2 */
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100368static u64 usbh2_dmamask = DMA_BIT_MASK(32);
javier Martin627fb3b2009-07-15 15:26:21 +0200369
370static struct resource mxc_usbh2_resources[] = {
371 {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100372 .start = MX27_USBOTG_BASE_ADDR + 0x400,
373 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
javier Martin627fb3b2009-07-15 15:26:21 +0200374 .flags = IORESOURCE_MEM,
375 }, {
Uwe Kleine-König58152a12010-02-05 11:42:54 +0100376 .start = MX27_INT_USB2,
377 .end = MX27_INT_USB2,
javier Martin627fb3b2009-07-15 15:26:21 +0200378 .flags = IORESOURCE_IRQ,
379 },
380};
381
382struct platform_device mxc_usbh2 = {
383 .name = "mxc-ehci",
384 .id = 2,
385 .dev = {
Martin Fuzzey3eb352c2009-11-21 12:14:54 +0100386 .coherent_dma_mask = DMA_BIT_MASK(32),
javier Martin627fb3b2009-07-15 15:26:21 +0200387 .dma_mask = &usbh2_dmamask,
388 },
389 .resource = mxc_usbh2_resources,
390 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
391};
Sascha Hauerf6d2fa72009-08-13 10:02:30 +0200392#endif
javier Martin627fb3b2009-07-15 15:26:21 +0200393
Uwe Kleine-König69ddb482010-02-05 12:03:37 +0100394#define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix) \
395 { \
396 .name = _name, \
397 .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
398 .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \
399 .flags = IORESOURCE_DMA, \
400 }
Sascha Hauer23291df2009-10-22 14:50:33 +0200401
Uwe Kleine-König69ddb482010-02-05 12:03:37 +0100402#define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq) \
403 static struct resource imx_ssi_resources ## n[] = { \
404 { \
405 .start = MX2x_SSI ## ssin ## _BASE_ADDR, \
406 .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f, \
407 .flags = IORESOURCE_MEM, \
408 }, { \
409 .start = MX2x_INT_SSI1, \
410 .end = MX2x_INT_SSI1, \
411 .flags = IORESOURCE_IRQ, \
412 }, \
413 DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0), \
414 DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0), \
415 DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1), \
416 DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1), \
417 }; \
418 \
419 struct platform_device imx_ssi_device ## n = { \
420 .name = "imx-ssi", \
421 .id = n, \
422 .num_resources = ARRAY_SIZE(imx_ssi_resources ## n), \
423 .resource = imx_ssi_resources ## n, \
424 }
Sascha Hauer23291df2009-10-22 14:50:33 +0200425
Uwe Kleine-König69ddb482010-02-05 12:03:37 +0100426DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
427DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1);
Sascha Hauer23291df2009-10-22 14:50:33 +0200428
Uwe Kleine-Könige9ec2a12010-06-10 17:34:59 +0200429#define DEFINE_IMX_UART_DEVICE(n, baseaddr, irq) \
430 static struct resource imx2x_uart_resources ## n[] = { \
431 { \
432 .start = baseaddr, \
433 .end = baseaddr + 0xb5, \
434 .flags = IORESOURCE_MEM, \
435 }, { \
436 .start = irq, \
437 .end = irq, \
438 .flags = IORESOURCE_IRQ, \
439 }, \
440 }; \
441 \
442 struct platform_device mxc_uart_device ## n = { \
443 .name = "imx-uart", \
444 .id = n, \
445 .num_resources = ARRAY_SIZE(imx2x_uart_resources ## n), \
446 .resource = imx2x_uart_resources ## n, \
447 }
448
449DEFINE_IMX_UART_DEVICE(0, MX2x_UART1_BASE_ADDR, MX2x_INT_UART1);
450DEFINE_IMX_UART_DEVICE(1, MX2x_UART2_BASE_ADDR, MX2x_INT_UART2);
451DEFINE_IMX_UART_DEVICE(2, MX2x_UART3_BASE_ADDR, MX2x_INT_UART3);
452DEFINE_IMX_UART_DEVICE(3, MX2x_UART4_BASE_ADDR, MX2x_INT_UART4);
453
454#ifdef CONFIG_MACH_MX27
455DEFINE_IMX_UART_DEVICE(4, MX27_UART5_BASE_ADDR, MX27_INT_UART5);
456DEFINE_IMX_UART_DEVICE(5, MX27_UART6_BASE_ADDR, MX27_INT_UART6);
457#endif
458
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200459/* GPIO port description */
Uwe Kleine-König897359d2010-02-05 17:40:28 +0100460#define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
461 { \
462 .chip.label = "gpio-" #n, \
463 .irq = _irq, \
464 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
465 n * 0x100), \
466 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200467 }
Uwe Kleine-König897359d2010-02-05 17:40:28 +0100468
469#define DEFINE_MXC_GPIO_PORT(SOC, n) \
470 { \
471 .chip.label = "gpio-" #n, \
472 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
473 n * 0x100), \
474 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
475 }
476
477#define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
478 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
479 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
480 DEFINE_MXC_GPIO_PORT(SOC, 1), \
481 DEFINE_MXC_GPIO_PORT(SOC, 2), \
482 DEFINE_MXC_GPIO_PORT(SOC, 3), \
483 DEFINE_MXC_GPIO_PORT(SOC, 4), \
484 DEFINE_MXC_GPIO_PORT(SOC, 5), \
485 }
486
487#ifdef CONFIG_MACH_MX21
488DEFINE_MXC_GPIO_PORTS(MX21, imx21);
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200489
490int __init imx21_register_gpios(void)
491{
492 return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
493}
Uwe Kleine-König897359d2010-02-05 17:40:28 +0100494#endif
495
496#ifdef CONFIG_MACH_MX27
497DEFINE_MXC_GPIO_PORTS(MX27, imx27);
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200498
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200499int __init imx27_register_gpios(void)
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200500{
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200501 return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200502}
Uwe Kleine-König9a763bf2010-06-10 17:11:06 +0200503#endif
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100504
505#ifdef CONFIG_MACH_MX21
506static struct resource mx21_usbhc_resources[] = {
507 {
Wolfram Sange1695302010-05-15 11:25:35 +0100508 .start = MX21_USBOTG_BASE_ADDR,
509 .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100510 .flags = IORESOURCE_MEM,
511 },
512 {
Russell King988addf2010-03-08 20:21:04 +0000513 .start = MX21_INT_USBHOST,
514 .end = MX21_INT_USBHOST,
Martin Fuzzey4e0fa902009-11-21 12:14:58 +0100515 .flags = IORESOURCE_IRQ,
516 },
517};
518
519struct platform_device mx21_usbhc_device = {
520 .name = "imx21-hcd",
521 .id = 0,
522 .dev = {
523 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
524 .coherent_dma_mask = DMA_BIT_MASK(32),
525 },
526 .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
527 .resource = mx21_usbhc_resources,
528};
529#endif