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
81 #define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq) \
82 static struct resource timer ## n ##_resources[] = { \
85 .end = baseaddr + SZ_4K - 1, \
86 .flags = IORESOURCE_MEM, \
90 .flags = IORESOURCE_IRQ, \
94 struct platform_device mxc_gpt ## n = { \
97 .num_resources = ARRAY_SIZE(timer ## n ## _resources), \
98 .resource = timer ## n ## _resources, \
101 /* We use gpt1 as system timer, so do not add a device for this one */
102 DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2);
103 DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3);
105 #ifdef CONFIG_MACH_MX27
106 DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4);
107 DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5);
108 DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6);
117 static struct resource mxc_wdt_resources[] = {
119 .start = WDOG_BASE_ADDR,
120 .end = WDOG_BASE_ADDR + 0x30,
121 .flags = IORESOURCE_MEM,
125 struct platform_device mxc_wdt = {
128 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
129 .resource = mxc_wdt_resources,
132 static struct resource mxc_w1_master_resources[] = {
134 .start = OWIRE_BASE_ADDR,
135 .end = OWIRE_BASE_ADDR + SZ_4K - 1,
136 .flags = IORESOURCE_MEM,
140 struct platform_device mxc_w1_master_device = {
143 .num_resources = ARRAY_SIZE(mxc_w1_master_resources),
144 .resource = mxc_w1_master_resources,
147 static struct resource mxc_nand_resources[] = {
149 .start = NFC_BASE_ADDR,
150 .end = NFC_BASE_ADDR + 0xfff,
151 .flags = IORESOURCE_MEM,
153 .start = MXC_INT_NANDFC,
154 .end = MXC_INT_NANDFC,
155 .flags = IORESOURCE_IRQ,
159 struct platform_device mxc_nand_device = {
162 .num_resources = ARRAY_SIZE(mxc_nand_resources),
163 .resource = mxc_nand_resources,
168 * - i.MX1: the basic controller
169 * - i.MX21: to be checked
170 * - i.MX27: like i.MX1, with slightly variations
172 static struct resource mxc_fb[] = {
174 .start = LCDC_BASE_ADDR,
175 .end = LCDC_BASE_ADDR + 0xFFF,
176 .flags = IORESOURCE_MEM,
178 .start = MXC_INT_LCDC,
180 .flags = IORESOURCE_IRQ,
185 struct platform_device mxc_fb_device = {
188 .num_resources = ARRAY_SIZE(mxc_fb),
191 .coherent_dma_mask = 0xFFFFFFFF,
195 #ifdef CONFIG_MACH_MX27
196 static struct resource mxc_fec_resources[] = {
198 .start = FEC_BASE_ADDR,
199 .end = FEC_BASE_ADDR + 0xfff,
200 .flags = IORESOURCE_MEM,
202 .start = MXC_INT_FEC,
204 .flags = IORESOURCE_IRQ,
208 struct platform_device mxc_fec_device = {
211 .num_resources = ARRAY_SIZE(mxc_fec_resources),
212 .resource = mxc_fec_resources,
216 static struct resource mxc_i2c_1_resources[] = {
218 .start = I2C_BASE_ADDR,
219 .end = I2C_BASE_ADDR + 0x0fff,
220 .flags = IORESOURCE_MEM,
222 .start = MXC_INT_I2C,
224 .flags = IORESOURCE_IRQ,
228 struct platform_device mxc_i2c_device0 = {
231 .num_resources = ARRAY_SIZE(mxc_i2c_1_resources),
232 .resource = mxc_i2c_1_resources,
235 #ifdef CONFIG_MACH_MX27
236 static struct resource mxc_i2c_2_resources[] = {
238 .start = I2C2_BASE_ADDR,
239 .end = I2C2_BASE_ADDR + 0x0fff,
240 .flags = IORESOURCE_MEM,
242 .start = MXC_INT_I2C2,
244 .flags = IORESOURCE_IRQ,
248 struct platform_device mxc_i2c_device1 = {
251 .num_resources = ARRAY_SIZE(mxc_i2c_2_resources),
252 .resource = mxc_i2c_2_resources,
256 static struct resource mxc_pwm_resources[] = {
258 .start = PWM_BASE_ADDR,
259 .end = PWM_BASE_ADDR + 0x0fff,
260 .flags = IORESOURCE_MEM,
262 .start = MXC_INT_PWM,
264 .flags = IORESOURCE_IRQ,
268 struct platform_device mxc_pwm_device = {
271 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
272 .resource = mxc_pwm_resources,
276 * Resource definition for the MXC SDHC
278 static struct resource mxc_sdhc1_resources[] = {
280 .start = SDHC1_BASE_ADDR,
281 .end = SDHC1_BASE_ADDR + SZ_4K - 1,
282 .flags = IORESOURCE_MEM,
284 .start = MXC_INT_SDHC1,
285 .end = MXC_INT_SDHC1,
286 .flags = IORESOURCE_IRQ,
288 .start = DMA_REQ_SDHC1,
289 .end = DMA_REQ_SDHC1,
290 .flags = IORESOURCE_DMA,
294 static u64 mxc_sdhc1_dmamask = 0xffffffffUL;
296 struct platform_device mxc_sdhc_device0 = {
300 .dma_mask = &mxc_sdhc1_dmamask,
301 .coherent_dma_mask = 0xffffffff,
303 .num_resources = ARRAY_SIZE(mxc_sdhc1_resources),
304 .resource = mxc_sdhc1_resources,
307 static struct resource mxc_sdhc2_resources[] = {
309 .start = SDHC2_BASE_ADDR,
310 .end = SDHC2_BASE_ADDR + SZ_4K - 1,
311 .flags = IORESOURCE_MEM,
313 .start = MXC_INT_SDHC2,
314 .end = MXC_INT_SDHC2,
315 .flags = IORESOURCE_IRQ,
317 .start = DMA_REQ_SDHC2,
318 .end = DMA_REQ_SDHC2,
319 .flags = IORESOURCE_DMA,
323 static u64 mxc_sdhc2_dmamask = 0xffffffffUL;
325 struct platform_device mxc_sdhc_device1 = {
329 .dma_mask = &mxc_sdhc2_dmamask,
330 .coherent_dma_mask = 0xffffffff,
332 .num_resources = ARRAY_SIZE(mxc_sdhc2_resources),
333 .resource = mxc_sdhc2_resources,
336 #ifdef CONFIG_MACH_MX27
337 static struct resource otg_resources[] = {
339 .start = OTG_BASE_ADDR,
340 .end = OTG_BASE_ADDR + 0x1ff,
341 .flags = IORESOURCE_MEM,
343 .start = MXC_INT_USB3,
345 .flags = IORESOURCE_IRQ,
349 static u64 otg_dmamask = 0xffffffffUL;
351 /* OTG gadget device */
352 struct platform_device mxc_otg_udc_device = {
353 .name = "fsl-usb2-udc",
356 .dma_mask = &otg_dmamask,
357 .coherent_dma_mask = 0xffffffffUL,
359 .resource = otg_resources,
360 .num_resources = ARRAY_SIZE(otg_resources),
364 struct platform_device mxc_otg_host = {
368 .coherent_dma_mask = 0xffffffff,
369 .dma_mask = &otg_dmamask,
371 .resource = otg_resources,
372 .num_resources = ARRAY_SIZE(otg_resources),
377 static u64 usbh1_dmamask = 0xffffffffUL;
379 static struct resource mxc_usbh1_resources[] = {
381 .start = OTG_BASE_ADDR + 0x200,
382 .end = OTG_BASE_ADDR + 0x3ff,
383 .flags = IORESOURCE_MEM,
385 .start = MXC_INT_USB1,
387 .flags = IORESOURCE_IRQ,
391 struct platform_device mxc_usbh1 = {
395 .coherent_dma_mask = 0xffffffff,
396 .dma_mask = &usbh1_dmamask,
398 .resource = mxc_usbh1_resources,
399 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
403 static u64 usbh2_dmamask = 0xffffffffUL;
405 static struct resource mxc_usbh2_resources[] = {
407 .start = OTG_BASE_ADDR + 0x400,
408 .end = OTG_BASE_ADDR + 0x5ff,
409 .flags = IORESOURCE_MEM,
411 .start = MXC_INT_USB2,
413 .flags = IORESOURCE_IRQ,
417 struct platform_device mxc_usbh2 = {
421 .coherent_dma_mask = 0xffffffff,
422 .dma_mask = &usbh2_dmamask,
424 .resource = mxc_usbh2_resources,
425 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
429 static struct resource imx_ssi_resources0[] = {
431 .start = SSI1_BASE_ADDR,
432 .end = SSI1_BASE_ADDR + 0x6F,
433 .flags = IORESOURCE_MEM,
435 .start = MXC_INT_SSI1,
437 .flags = IORESOURCE_IRQ,
440 .start = DMA_REQ_SSI1_TX0,
441 .end = DMA_REQ_SSI1_TX0,
442 .flags = IORESOURCE_DMA,
445 .start = DMA_REQ_SSI1_RX0,
446 .end = DMA_REQ_SSI1_RX0,
447 .flags = IORESOURCE_DMA,
450 .start = DMA_REQ_SSI1_TX1,
451 .end = DMA_REQ_SSI1_TX1,
452 .flags = IORESOURCE_DMA,
455 .start = DMA_REQ_SSI1_RX1,
456 .end = DMA_REQ_SSI1_RX1,
457 .flags = IORESOURCE_DMA,
461 static struct resource imx_ssi_resources1[] = {
463 .start = SSI2_BASE_ADDR,
464 .end = SSI2_BASE_ADDR + 0x6F,
465 .flags = IORESOURCE_MEM,
467 .start = MXC_INT_SSI2,
469 .flags = IORESOURCE_IRQ,
472 .start = DMA_REQ_SSI2_TX0,
473 .end = DMA_REQ_SSI2_TX0,
474 .flags = IORESOURCE_DMA,
477 .start = DMA_REQ_SSI2_RX0,
478 .end = DMA_REQ_SSI2_RX0,
479 .flags = IORESOURCE_DMA,
482 .start = DMA_REQ_SSI2_TX1,
483 .end = DMA_REQ_SSI2_TX1,
484 .flags = IORESOURCE_DMA,
487 .start = DMA_REQ_SSI2_RX1,
488 .end = DMA_REQ_SSI2_RX1,
489 .flags = IORESOURCE_DMA,
493 struct platform_device imx_ssi_device0 = {
496 .num_resources = ARRAY_SIZE(imx_ssi_resources0),
497 .resource = imx_ssi_resources0,
500 struct platform_device imx_ssi_device1 = {
503 .num_resources = ARRAY_SIZE(imx_ssi_resources1),
504 .resource = imx_ssi_resources1,
507 /* GPIO port description */
508 static struct mxc_gpio_port imx_gpio_ports[] = {
510 .chip.label = "gpio-0",
512 .base = IO_ADDRESS(GPIO_BASE_ADDR),
513 .virtual_irq_start = MXC_GPIO_IRQ_START,
515 .chip.label = "gpio-1",
516 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x100),
517 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
519 .chip.label = "gpio-2",
520 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x200),
521 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
523 .chip.label = "gpio-3",
524 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x300),
525 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
527 .chip.label = "gpio-4",
528 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x400),
529 .virtual_irq_start = MXC_GPIO_IRQ_START + 128,
531 .chip.label = "gpio-5",
532 .base = IO_ADDRESS(GPIO_BASE_ADDR + 0x500),
533 .virtual_irq_start = MXC_GPIO_IRQ_START + 160,
537 int __init mxc_register_gpios(void)
539 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));