2 * Author: MontaVista Software, Inc.
5 * Based on the OMAP devices.c
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
12 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
13 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
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.
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,
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>
35 #include <mach/irqs.h>
36 #include <mach/hardware.h>
37 #include <mach/common.h>
43 * SPI master controller
45 * - i.MX1: 2 channel (slighly different register setting)
49 #define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq) \
50 static struct resource mxc_spi_resources ## n[] = { \
53 .end = baseaddr + SZ_4K - 1, \
54 .flags = IORESOURCE_MEM, \
58 .flags = IORESOURCE_IRQ, \
62 struct platform_device mxc_spi_device ## n = { \
65 .num_resources = ARRAY_SIZE(mxc_spi_resources ## n), \
66 .resource = mxc_spi_resources ## n, \
69 DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1);
70 DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2);
72 #ifdef CONFIG_MACH_MX27
73 DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3);
77 * General Purpose Timer
82 /* We use gpt0 as system timer, so do not add a device for this one */
84 static struct resource timer1_resources[] = {
86 .start = GPT2_BASE_ADDR,
87 .end = GPT2_BASE_ADDR + 0x17,
88 .flags = IORESOURCE_MEM,
90 .start = MXC_INT_GPT2,
92 .flags = IORESOURCE_IRQ,
96 struct platform_device mxc_gpt1 = {
99 .num_resources = ARRAY_SIZE(timer1_resources),
100 .resource = timer1_resources,
103 static struct resource timer2_resources[] = {
105 .start = GPT3_BASE_ADDR,
106 .end = GPT3_BASE_ADDR + 0x17,
107 .flags = IORESOURCE_MEM,
109 .start = MXC_INT_GPT3,
111 .flags = IORESOURCE_IRQ,
115 struct platform_device mxc_gpt2 = {
118 .num_resources = ARRAY_SIZE(timer2_resources),
119 .resource = timer2_resources,
122 #ifdef CONFIG_MACH_MX27
123 static struct resource timer3_resources[] = {
125 .start = GPT4_BASE_ADDR,
126 .end = GPT4_BASE_ADDR + 0x17,
127 .flags = IORESOURCE_MEM,
129 .start = MXC_INT_GPT4,
131 .flags = IORESOURCE_IRQ,
135 struct platform_device mxc_gpt3 = {
138 .num_resources = ARRAY_SIZE(timer3_resources),
139 .resource = timer3_resources,
142 static struct resource timer4_resources[] = {
144 .start = GPT5_BASE_ADDR,
145 .end = GPT5_BASE_ADDR + 0x17,
146 .flags = IORESOURCE_MEM,
148 .start = MXC_INT_GPT5,
150 .flags = IORESOURCE_IRQ,
154 struct platform_device mxc_gpt4 = {
157 .num_resources = ARRAY_SIZE(timer4_resources),
158 .resource = timer4_resources,
161 static struct resource timer5_resources[] = {
163 .start = GPT6_BASE_ADDR,
164 .end = GPT6_BASE_ADDR + 0x17,
165 .flags = IORESOURCE_MEM,
167 .start = MXC_INT_GPT6,
169 .flags = IORESOURCE_IRQ,
173 struct platform_device mxc_gpt5 = {
176 .num_resources = ARRAY_SIZE(timer5_resources),
177 .resource = timer5_resources,
187 static struct resource mxc_wdt_resources[] = {
189 .start = WDOG_BASE_ADDR,
190 .end = WDOG_BASE_ADDR + 0x30,
191 .flags = IORESOURCE_MEM,
195 struct platform_device mxc_wdt = {
198 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
199 .resource = mxc_wdt_resources,
202 static struct resource mxc_w1_master_resources[] = {
204 .start = OWIRE_BASE_ADDR,
205 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
206 .flags = IORESOURCE_MEM,
210 struct platform_device mxc_w1_master_device = {
213 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
214 .resource = mxc_w1_master_resources,
217 static struct resource mxc_nand_resources[] = {
219 .start = NFC_BASE_ADDR,
220 .end = NFC_BASE_ADDR + 0xfff,
221 .flags = IORESOURCE_MEM,
223 .start = MXC_INT_NANDFC,
224 .end = MXC_INT_NANDFC,
225 .flags = IORESOURCE_IRQ,
229 struct platform_device mxc_nand_device = {
232 .num_resources = ARRAY_SIZE(mxc_nand_resources),
233 .resource = mxc_nand_resources,
238 * - i.MX1: the basic controller
239 * - i.MX21: to be checked
240 * - i.MX27: like i.MX1, with slightly variations
242 static struct resource mxc_fb[] = {
244 .start = LCDC_BASE_ADDR,
245 .end = LCDC_BASE_ADDR + 0xFFF,
246 .flags = IORESOURCE_MEM,
248 .start = MXC_INT_LCDC,
250 .flags = IORESOURCE_IRQ,
255 struct platform_device mxc_fb_device = {
258 .num_resources = ARRAY_SIZE(mxc_fb),
261 .coherent_dma_mask = 0xFFFFFFFF,
265 #ifdef CONFIG_MACH_MX27
266 static struct resource mxc_fec_resources[] = {
268 .start = FEC_BASE_ADDR,
269 .end = FEC_BASE_ADDR + 0xfff,
270 .flags = IORESOURCE_MEM,
272 .start = MXC_INT_FEC,
274 .flags = IORESOURCE_IRQ,
278 struct platform_device mxc_fec_device = {
281 .num_resources = ARRAY_SIZE(mxc_fec_resources),
282 .resource = mxc_fec_resources,
286 static struct resource mxc_i2c_1_resources[] = {
288 .start = I2C_BASE_ADDR,
289 .end = I2C_BASE_ADDR + 0x0fff,
290 .flags = IORESOURCE_MEM,
292 .start = MXC_INT_I2C,
294 .flags = IORESOURCE_IRQ,
298 struct platform_device mxc_i2c_device0 = {
301 .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
302 .resource = mxc_i2c_1_resources,
305 #ifdef CONFIG_MACH_MX27
306 static struct resource mxc_i2c_2_resources[] = {
308 .start = I2C2_BASE_ADDR,
309 .end = I2C2_BASE_ADDR + 0x0fff,
310 .flags = IORESOURCE_MEM,
312 .start = MXC_INT_I2C2,
314 .flags = IORESOURCE_IRQ,
318 struct platform_device mxc_i2c_device1 = {
321 .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
322 .resource = mxc_i2c_2_resources,
326 static struct resource mxc_pwm_resources[] = {
328 .start = PWM_BASE_ADDR,
329 .end = PWM_BASE_ADDR + 0x0fff,
330 .flags = IORESOURCE_MEM,
332 .start = MXC_INT_PWM,
334 .flags = IORESOURCE_IRQ,
338 struct platform_device mxc_pwm_device = {
341 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
342 .resource = mxc_pwm_resources,
346 * Resource definition for the MXC SDHC
348 static struct resource mxc_sdhc1_resources[] = {
350 .start = SDHC1_BASE_ADDR,
351 .end = SDHC1_BASE_ADDR + SZ_4K - 1,
352 .flags = IORESOURCE_MEM,
354 .start = MXC_INT_SDHC1,
355 .end = MXC_INT_SDHC1,
356 .flags = IORESOURCE_IRQ,
358 .start = DMA_REQ_SDHC1,
359 .end = DMA_REQ_SDHC1,
360 .flags = IORESOURCE_DMA,
364 static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
366 struct platform_device mxc_sdhc_device0 = {
370 .dma_mask = &mxc_sdhc1_dmamask,
371 .coherent_dma_mask = 0xffffffff,
373 .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
374 .resource = mxc_sdhc1_resources,
377 static struct resource mxc_sdhc2_resources[] = {
379 .start = SDHC2_BASE_ADDR,
380 .end = SDHC2_BASE_ADDR + SZ_4K - 1,
381 .flags = IORESOURCE_MEM,
383 .start = MXC_INT_SDHC2,
384 .end = MXC_INT_SDHC2,
385 .flags = IORESOURCE_IRQ,
387 .start = DMA_REQ_SDHC2,
388 .end = DMA_REQ_SDHC2,
389 .flags = IORESOURCE_DMA,
393 static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
395 struct platform_device mxc_sdhc_device1 = {
399 .dma_mask = &mxc_sdhc2_dmamask,
400 .coherent_dma_mask = 0xffffffff,
402 .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
403 .resource = mxc_sdhc2_resources,
406 #ifdef CONFIG_MACH_MX27
407 static struct resource otg_resources[] = {
409 .start = OTG_BASE_ADDR,
410 .end = OTG_BASE_ADDR + 0x1ff,
411 .flags = IORESOURCE_MEM,
413 .start = MXC_INT_USB3,
415 .flags = IORESOURCE_IRQ,
419 static u64 otg_dmamask = 0xffffffffUL;
421 /* OTG gadget device */
422 struct platform_device mxc_otg_udc_device = {
423 .name = "fsl-usb2-udc",
426 .dma_mask = &otg_dmamask,
427 .coherent_dma_mask = 0xffffffffUL,
429 .resource = otg_resources,
430 .num_resources = ARRAY_SIZE(otg_resources),
434 struct platform_device mxc_otg_host = {
438 .coherent_dma_mask = 0xffffffff,
439 .dma_mask = &otg_dmamask,
441 .resource = otg_resources,
442 .num_resources = ARRAY_SIZE(otg_resources),
447 static u64 usbh1_dmamask = 0xffffffffUL;
449 static struct resource mxc_usbh1_resources[] = {
451 .start = OTG_BASE_ADDR + 0x200,
452 .end = OTG_BASE_ADDR + 0x3ff,
453 .flags = IORESOURCE_MEM,
455 .start = MXC_INT_USB1,
457 .flags = IORESOURCE_IRQ,
461 struct platform_device mxc_usbh1 = {
465 .coherent_dma_mask = 0xffffffff,
466 .dma_mask = &usbh1_dmamask,
468 .resource = mxc_usbh1_resources,
469 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
473 static u64 usbh2_dmamask = 0xffffffffUL;
475 static struct resource mxc_usbh2_resources[] = {
477 .start = OTG_BASE_ADDR + 0x400,
478 .end = OTG_BASE_ADDR + 0x5ff,
479 .flags = IORESOURCE_MEM,
481 .start = MXC_INT_USB2,
483 .flags = IORESOURCE_IRQ,
487 struct platform_device mxc_usbh2 = {
491 .coherent_dma_mask = 0xffffffff,
492 .dma_mask = &usbh2_dmamask,
494 .resource = mxc_usbh2_resources,
495 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
499 static struct resource imx_ssi_resources0[] = {
501 .start = SSI1_BASE_ADDR,
502 .end = SSI1_BASE_ADDR + 0x6F,
503 .flags = IORESOURCE_MEM,
505 .start = MXC_INT_SSI1,
507 .flags = IORESOURCE_IRQ,
510 .start = DMA_REQ_SSI1_TX0,
511 .end = DMA_REQ_SSI1_TX0,
512 .flags = IORESOURCE_DMA,
515 .start = DMA_REQ_SSI1_RX0,
516 .end = DMA_REQ_SSI1_RX0,
517 .flags = IORESOURCE_DMA,
520 .start = DMA_REQ_SSI1_TX1,
521 .end = DMA_REQ_SSI1_TX1,
522 .flags = IORESOURCE_DMA,
525 .start = DMA_REQ_SSI1_RX1,
526 .end = DMA_REQ_SSI1_RX1,
527 .flags = IORESOURCE_DMA,
531 static struct resource imx_ssi_resources1[] = {
533 .start = SSI2_BASE_ADDR,
534 .end = SSI2_BASE_ADDR + 0x6F,
535 .flags = IORESOURCE_MEM,
537 .start = MXC_INT_SSI2,
539 .flags = IORESOURCE_IRQ,
542 .start = DMA_REQ_SSI2_TX0,
543 .end = DMA_REQ_SSI2_TX0,
544 .flags = IORESOURCE_DMA,
547 .start = DMA_REQ_SSI2_RX0,
548 .end = DMA_REQ_SSI2_RX0,
549 .flags = IORESOURCE_DMA,
552 .start = DMA_REQ_SSI2_TX1,
553 .end = DMA_REQ_SSI2_TX1,
554 .flags = IORESOURCE_DMA,
557 .start = DMA_REQ_SSI2_RX1,
558 .end = DMA_REQ_SSI2_RX1,
559 .flags = IORESOURCE_DMA,
563 struct platform_device imx_ssi_device0 = {
566 .num_resources = ARRAY_SIZE(imx_ssi_resources0),
567 .resource = imx_ssi_resources0,
570 struct platform_device imx_ssi_device1 = {
573 .num_resources = ARRAY_SIZE(imx_ssi_resources1),
574 .resource = imx_ssi_resources1,
577 /* GPIO port description */
578 static struct mxc_gpio_port imx_gpio_ports[] = {
580 .chip.label = "gpio-0",
582 .base = IO_ADDRESS(GPIO_BASE_ADDR),
583 .virtual_irq_start = MXC_GPIO_IRQ_START,
585 .chip.label = "gpio-1",
586 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
587 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
589 .chip.label = "gpio-2",
590 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
591 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
593 .chip.label = "gpio-3",
594 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
595 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
597 .chip.label = "gpio-4",
598 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
599 .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
601 .chip.label = "gpio-5",
602 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
603 .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
607 int __init mxc_register_gpios(void)
609 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));