blob: 4ecf0977beb4b600fcac3dd4f5ded20cd70732df [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>
34
Russell King80b02c12009-01-08 10:01:47 +000035#include <mach/irqs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/hardware.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010037#include <mach/common.h>
Sascha Hauer1a02be02008-12-19 14:32:07 +010038#include <mach/mmc.h>
Holger Schurig058b7a62009-01-26 16:34:51 +010039
40#include "devices.h"
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020041
42/*
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020043 * General Purpose Timer
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020044 * - i.MX21: 3 timers
45 * - i.MX27: 6 timers
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020046 */
47
48/* We use gpt0 as system timer, so do not add a device for this one */
49
50static struct resource timer1_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020051 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020052 .start = GPT2_BASE_ADDR,
53 .end = GPT2_BASE_ADDR + 0x17,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020054 .flags = IORESOURCE_MEM,
55 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020056 .start = MXC_INT_GPT2,
57 .end = MXC_INT_GPT2,
58 .flags = IORESOURCE_IRQ,
59 }
60};
61
62struct platform_device mxc_gpt1 = {
63 .name = "imx_gpt",
64 .id = 1,
65 .num_resources = ARRAY_SIZE(timer1_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020066 .resource = timer1_resources,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020067};
68
69static struct resource timer2_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020070 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020071 .start = GPT3_BASE_ADDR,
72 .end = GPT3_BASE_ADDR + 0x17,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020073 .flags = IORESOURCE_MEM,
74 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020075 .start = MXC_INT_GPT3,
76 .end = MXC_INT_GPT3,
77 .flags = IORESOURCE_IRQ,
78 }
79};
80
81struct platform_device mxc_gpt2 = {
82 .name = "imx_gpt",
83 .id = 2,
84 .num_resources = ARRAY_SIZE(timer2_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020085 .resource = timer2_resources,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020086};
87
88#ifdef CONFIG_MACH_MX27
89static struct resource timer3_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020090 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020091 .start = GPT4_BASE_ADDR,
92 .end = GPT4_BASE_ADDR + 0x17,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +020093 .flags = IORESOURCE_MEM,
94 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +020095 .start = MXC_INT_GPT4,
96 .end = MXC_INT_GPT4,
97 .flags = IORESOURCE_IRQ,
98 }
99};
100
101struct platform_device mxc_gpt3 = {
102 .name = "imx_gpt",
103 .id = 3,
104 .num_resources = ARRAY_SIZE(timer3_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200105 .resource = timer3_resources,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200106};
107
108static struct resource timer4_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200109 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200110 .start = GPT5_BASE_ADDR,
111 .end = GPT5_BASE_ADDR + 0x17,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200112 .flags = IORESOURCE_MEM,
113 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200114 .start = MXC_INT_GPT5,
115 .end = MXC_INT_GPT5,
116 .flags = IORESOURCE_IRQ,
117 }
118};
119
120struct platform_device mxc_gpt4 = {
121 .name = "imx_gpt",
122 .id = 4,
123 .num_resources = ARRAY_SIZE(timer4_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200124 .resource = timer4_resources,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200125};
126
127static struct resource timer5_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200128 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200129 .start = GPT6_BASE_ADDR,
130 .end = GPT6_BASE_ADDR + 0x17,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200131 .flags = IORESOURCE_MEM,
132 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200133 .start = MXC_INT_GPT6,
134 .end = MXC_INT_GPT6,
135 .flags = IORESOURCE_IRQ,
136 }
137};
138
139struct platform_device mxc_gpt5 = {
140 .name = "imx_gpt",
141 .id = 5,
142 .num_resources = ARRAY_SIZE(timer5_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200143 .resource = timer5_resources,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200144};
145#endif
146
147/*
148 * Watchdog:
149 * - i.MX1
150 * - i.MX21
151 * - i.MX27
152 */
153static struct resource mxc_wdt_resources[] = {
154 {
155 .start = WDOG_BASE_ADDR,
156 .end = WDOG_BASE_ADDR + 0x30,
157 .flags = IORESOURCE_MEM,
158 },
159};
160
161struct platform_device mxc_wdt = {
162 .name = "mxc_wdt",
163 .id = 0,
164 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
165 .resource = mxc_wdt_resources,
166};
167
Sascha Hauer3d89baa2008-12-01 14:15:38 -0800168static struct resource mxc_w1_master_resources[] = {
169 {
170 .start = OWIRE_BASE_ADDR,
171 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
172 .flags = IORESOURCE_MEM,
173 },
174};
175
176struct platform_device mxc_w1_master_device = {
177 .name = "mxc_w1",
178 .id = 0,
179 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
180 .resource = mxc_w1_master_resources,
181};
182
Sascha Hauer02870972008-09-09 11:30:58 +0200183static struct resource mxc_nand_resources[] = {
184 {
185 .start = NFC_BASE_ADDR,
186 .end = NFC_BASE_ADDR + 0xfff,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200187 .flags = IORESOURCE_MEM,
Sascha Hauer02870972008-09-09 11:30:58 +0200188 }, {
189 .start = MXC_INT_NANDFC,
190 .end = MXC_INT_NANDFC,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200191 .flags = IORESOURCE_IRQ,
Sascha Hauer02870972008-09-09 11:30:58 +0200192 },
193};
194
195struct platform_device mxc_nand_device = {
196 .name = "mxc_nand",
197 .id = 0,
198 .num_resources = ARRAY_SIZE(mxc_nand_resources),
199 .resource = mxc_nand_resources,
200};
201
Holger Schurige4813552009-01-26 16:34:56 +0100202/*
203 * lcdc:
204 * - i.MX1: the basic controller
205 * - i.MX21: to be checked
206 * - i.MX27: like i.MX1, with slightly variations
207 */
208static struct resource mxc_fb[] = {
209 {
210 .start = LCDC_BASE_ADDR,
211 .end = LCDC_BASE_ADDR + 0xFFF,
212 .flags = IORESOURCE_MEM,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200213 }, {
Holger Schurige4813552009-01-26 16:34:56 +0100214 .start = MXC_INT_LCDC,
215 .end = MXC_INT_LCDC,
216 .flags = IORESOURCE_IRQ,
217 }
218};
219
220/* mxc lcd driver */
221struct platform_device mxc_fb_device = {
222 .name = "imx-fb",
223 .id = 0,
224 .num_resources = ARRAY_SIZE(mxc_fb),
225 .resource = mxc_fb,
226 .dev = {
227 .coherent_dma_mask = 0xFFFFFFFF,
228 },
229};
230
Sascha Hauer879fea12009-01-26 17:26:02 +0100231#ifdef CONFIG_MACH_MX27
232static struct resource mxc_fec_resources[] = {
233 {
234 .start = FEC_BASE_ADDR,
235 .end = FEC_BASE_ADDR + 0xfff,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200236 .flags = IORESOURCE_MEM,
Sascha Hauer879fea12009-01-26 17:26:02 +0100237 }, {
238 .start = MXC_INT_FEC,
239 .end = MXC_INT_FEC,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200240 .flags = IORESOURCE_IRQ,
Sascha Hauer879fea12009-01-26 17:26:02 +0100241 },
242};
243
244struct platform_device mxc_fec_device = {
245 .name = "fec",
246 .id = 0,
247 .num_resources = ARRAY_SIZE(mxc_fec_resources),
248 .resource = mxc_fec_resources,
249};
Holger Schurige4813552009-01-26 16:34:56 +0100250#endif
251
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100252static struct resource mxc_i2c_1_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200253 {
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100254 .start = I2C_BASE_ADDR,
255 .end = I2C_BASE_ADDR + 0x0fff,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200256 .flags = IORESOURCE_MEM,
257 }, {
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100258 .start = MXC_INT_I2C,
259 .end = MXC_INT_I2C,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200260 .flags = IORESOURCE_IRQ,
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100261 }
262};
263
264struct platform_device mxc_i2c_device0 = {
265 .name = "imx-i2c",
266 .id = 0,
267 .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200268 .resource = mxc_i2c_1_resources,
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100269};
270
271#ifdef CONFIG_MACH_MX27
272static struct resource mxc_i2c_2_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200273 {
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100274 .start = I2C2_BASE_ADDR,
275 .end = I2C2_BASE_ADDR + 0x0fff,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200276 .flags = IORESOURCE_MEM,
277 }, {
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100278 .start = MXC_INT_I2C2,
279 .end = MXC_INT_I2C2,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200280 .flags = IORESOURCE_IRQ,
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100281 }
282};
283
284struct platform_device mxc_i2c_device1 = {
285 .name = "imx-i2c",
286 .id = 1,
287 .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200288 .resource = mxc_i2c_2_resources,
Sascha Hauerc5d4dbf2009-01-28 13:26:56 +0100289};
290#endif
291
Sascha Hauer824b16e2009-01-16 15:17:46 +0100292static struct resource mxc_pwm_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200293 {
Sascha Hauer824b16e2009-01-16 15:17:46 +0100294 .start = PWM_BASE_ADDR,
295 .end = PWM_BASE_ADDR + 0x0fff,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200296 .flags = IORESOURCE_MEM,
297 }, {
Sascha Hauer824b16e2009-01-16 15:17:46 +0100298 .start = MXC_INT_PWM,
299 .end = MXC_INT_PWM,
300 .flags = IORESOURCE_IRQ,
301 }
302};
303
304struct platform_device mxc_pwm_device = {
305 .name = "mxc_pwm",
306 .id = 0,
307 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200308 .resource = mxc_pwm_resources,
Sascha Hauer824b16e2009-01-16 15:17:46 +0100309};
310
Sascha Hauer1a02be02008-12-19 14:32:07 +0100311/*
312 * Resource definition for the MXC SDHC
313 */
314static struct resource mxc_sdhc1_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200315 {
316 .start = SDHC1_BASE_ADDR,
317 .end = SDHC1_BASE_ADDR + SZ_4K - 1,
318 .flags = IORESOURCE_MEM,
319 }, {
320 .start = MXC_INT_SDHC1,
321 .end = MXC_INT_SDHC1,
322 .flags = IORESOURCE_IRQ,
323 }, {
324 .start = DMA_REQ_SDHC1,
325 .end = DMA_REQ_SDHC1,
326 .flags = IORESOURCE_DMA,
327 },
Sascha Hauer1a02be02008-12-19 14:32:07 +0100328};
329
330static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
331
332struct platform_device mxc_sdhc_device0 = {
333 .name = "mxc-mmc",
334 .id = 0,
335 .dev = {
336 .dma_mask = &mxc_sdhc1_dmamask,
337 .coherent_dma_mask = 0xffffffff,
338 },
339 .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
340 .resource = mxc_sdhc1_resources,
341};
342
343static struct resource mxc_sdhc2_resources[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200344 {
345 .start = SDHC2_BASE_ADDR,
346 .end = SDHC2_BASE_ADDR + SZ_4K - 1,
347 .flags = IORESOURCE_MEM,
348 }, {
349 .start = MXC_INT_SDHC2,
350 .end = MXC_INT_SDHC2,
351 .flags = IORESOURCE_IRQ,
352 }, {
353 .start = DMA_REQ_SDHC2,
354 .end = DMA_REQ_SDHC2,
355 .flags = IORESOURCE_DMA,
356 },
Sascha Hauer1a02be02008-12-19 14:32:07 +0100357};
358
359static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
360
361struct platform_device mxc_sdhc_device1 = {
362 .name = "mxc-mmc",
363 .id = 1,
364 .dev = {
365 .dma_mask = &mxc_sdhc2_dmamask,
366 .coherent_dma_mask = 0xffffffff,
367 },
368 .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
369 .resource = mxc_sdhc2_resources,
370};
371
javier Martin627fb3b2009-07-15 15:26:21 +0200372static struct resource otg_resources[] = {
373 {
374 .start = OTG_BASE_ADDR,
375 .end = OTG_BASE_ADDR + 0x1ff,
376 .flags = IORESOURCE_MEM,
377 }, {
378 .start = MXC_INT_USB3,
379 .end = MXC_INT_USB3,
380 .flags = IORESOURCE_IRQ,
381 },
382};
383
384static u64 otg_dmamask = 0xffffffffUL;
385
386/* OTG gadget device */
387struct platform_device mxc_otg_udc_device = {
388 .name = "fsl-usb2-udc",
389 .id = -1,
390 .dev = {
391 .dma_mask = &otg_dmamask,
392 .coherent_dma_mask = 0xffffffffUL,
393 },
394 .resource = otg_resources,
395 .num_resources = ARRAY_SIZE(otg_resources),
396};
397
398/* OTG host */
399struct platform_device mxc_otg_host = {
400 .name = "mxc-ehci",
401 .id = 0,
402 .dev = {
403 .coherent_dma_mask = 0xffffffff,
404 .dma_mask = &otg_dmamask,
405 },
406 .resource = otg_resources,
407 .num_resources = ARRAY_SIZE(otg_resources),
408};
409
410/* USB host 1 */
411
412static u64 usbh1_dmamask = 0xffffffffUL;
413
414static struct resource mxc_usbh1_resources[] = {
415 {
416 .start = OTG_BASE_ADDR + 0x200,
417 .end = OTG_BASE_ADDR + 0x3ff,
418 .flags = IORESOURCE_MEM,
419 }, {
420 .start = MXC_INT_USB1,
421 .end = MXC_INT_USB1,
422 .flags = IORESOURCE_IRQ,
423 },
424};
425
426struct platform_device mxc_usbh1 = {
427 .name = "mxc-ehci",
428 .id = 1,
429 .dev = {
430 .coherent_dma_mask = 0xffffffff,
431 .dma_mask = &usbh1_dmamask,
432 },
433 .resource = mxc_usbh1_resources,
434 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
435};
436
437/* USB host 2 */
438static u64 usbh2_dmamask = 0xffffffffUL;
439
440static struct resource mxc_usbh2_resources[] = {
441 {
442 .start = OTG_BASE_ADDR + 0x400,
443 .end = OTG_BASE_ADDR + 0x5ff,
444 .flags = IORESOURCE_MEM,
445 }, {
446 .start = MXC_INT_USB2,
447 .end = MXC_INT_USB2,
448 .flags = IORESOURCE_IRQ,
449 },
450};
451
452struct platform_device mxc_usbh2 = {
453 .name = "mxc-ehci",
454 .id = 2,
455 .dev = {
456 .coherent_dma_mask = 0xffffffff,
457 .dma_mask = &usbh2_dmamask,
458 },
459 .resource = mxc_usbh2_resources,
460 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
461};
462
463
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200464/* GPIO port description */
465static struct mxc_gpio_port imx_gpio_ports[] = {
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200466 {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200467 .chip.label = "gpio-0",
468 .irq = MXC_INT_GPIO,
Holger Schurig058b7a62009-01-26 16:34:51 +0100469 .base = IO_ADDRESS(GPIO_BASE_ADDR),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100470 .virtual_irq_start = MXC_GPIO_IRQ_START,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200471 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200472 .chip.label = "gpio-1",
Holger Schurig058b7a62009-01-26 16:34:51 +0100473 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100474 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200475 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200476 .chip.label = "gpio-2",
Holger Schurig058b7a62009-01-26 16:34:51 +0100477 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100478 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200479 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200480 .chip.label = "gpio-3",
Holger Schurig058b7a62009-01-26 16:34:51 +0100481 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100482 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200483 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200484 .chip.label = "gpio-4",
Holger Schurig058b7a62009-01-26 16:34:51 +0100485 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100486 .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
Sascha Hauerbf50bcc2009-06-23 12:04:36 +0200487 }, {
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200488 .chip.label = "gpio-5",
Holger Schurig058b7a62009-01-26 16:34:51 +0100489 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
Sascha Hauer9d631b82008-12-18 11:08:55 +0100490 .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
Juergen Beisertfc80a5e2008-07-05 10:02:57 +0200491 }
492};
493
494int __init mxc_register_gpios(void)
495{
496 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
497}