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
14 * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
15 * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
16 * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/init.h>
35 #include <linux/platform_device.h>
36 #include <linux/gpio.h>
37 #include <linux/dma-mapping.h>
38 #include <linux/serial.h>
40 #include <mach/irqs.h>
41 #include <mach/hardware.h>
42 #include <mach/common.h>
47 #if defined(CONFIG_ARCH_MX1)
48 static struct resource imx1_camera_resources[] = {
52 .flags = IORESOURCE_MEM,
56 .flags = IORESOURCE_IRQ,
60 static u64 imx1_camera_dmamask = DMA_BIT_MASK(32);
62 struct platform_device imx1_camera_device = {
64 .id = 0, /* This is used to put cameras on this interface */
66 .dma_mask = &imx1_camera_dmamask,
67 .coherent_dma_mask = DMA_BIT_MASK(32),
69 .resource = imx1_camera_resources,
70 .num_resources = ARRAY_SIZE(imx1_camera_resources),
73 static struct resource imx_usb_resources[] = {
77 .flags = IORESOURCE_MEM,
79 .start = MX1_USBD_INT0,
81 .flags = IORESOURCE_IRQ,
83 .start = MX1_USBD_INT1,
85 .flags = IORESOURCE_IRQ,
87 .start = MX1_USBD_INT2,
89 .flags = IORESOURCE_IRQ,
91 .start = MX1_USBD_INT3,
93 .flags = IORESOURCE_IRQ,
95 .start = MX1_USBD_INT4,
97 .flags = IORESOURCE_IRQ,
99 .start = MX1_USBD_INT5,
100 .end = MX1_USBD_INT5,
101 .flags = IORESOURCE_IRQ,
103 .start = MX1_USBD_INT6,
104 .end = MX1_USBD_INT6,
105 .flags = IORESOURCE_IRQ,
109 struct platform_device imx_usb_device = {
112 .num_resources = ARRAY_SIZE(imx_usb_resources),
113 .resource = imx_usb_resources,
116 /* GPIO port description */
117 static struct mxc_gpio_port imx_gpio_ports[] = {
119 .chip.label = "gpio-0",
120 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
121 .irq = MX1_GPIO_INT_PORTA,
122 .virtual_irq_start = MXC_GPIO_IRQ_START,
124 .chip.label = "gpio-1",
125 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
126 .irq = MX1_GPIO_INT_PORTB,
127 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
129 .chip.label = "gpio-2",
130 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
131 .irq = MX1_GPIO_INT_PORTC,
132 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
134 .chip.label = "gpio-3",
135 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
136 .irq = MX1_GPIO_INT_PORTD,
137 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
141 int __init imx1_register_gpios(void)
143 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
147 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
149 #ifdef CONFIG_MACH_MX27
150 static struct resource mx27_camera_resources[] = {
152 .start = MX27_CSI_BASE_ADDR,
153 .end = MX27_CSI_BASE_ADDR + 0x1f,
154 .flags = IORESOURCE_MEM,
156 .start = MX27_EMMA_PRP_BASE_ADDR,
157 .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
158 .flags = IORESOURCE_MEM,
160 .start = MX27_INT_CSI,
162 .flags = IORESOURCE_IRQ,
164 .start = MX27_INT_EMMAPRP,
165 .end = MX27_INT_EMMAPRP,
166 .flags = IORESOURCE_IRQ,
169 struct platform_device mx27_camera_device = {
170 .name = "mx2-camera",
172 .num_resources = ARRAY_SIZE(mx27_camera_resources),
173 .resource = mx27_camera_resources,
175 .coherent_dma_mask = 0xffffffff,
180 /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
181 static struct resource mxc_wdt_resources[] = {
183 .start = MX2x_WDOG_BASE_ADDR,
184 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
185 .flags = IORESOURCE_MEM,
189 struct platform_device mxc_wdt = {
192 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
193 .resource = mxc_wdt_resources,
198 * - i.MX1: the basic controller
199 * - i.MX21: to be checked
200 * - i.MX27: like i.MX1, with slightly variations
202 static struct resource mxc_fb[] = {
204 .start = MX2x_LCDC_BASE_ADDR,
205 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
206 .flags = IORESOURCE_MEM,
208 .start = MX2x_INT_LCDC,
209 .end = MX2x_INT_LCDC,
210 .flags = IORESOURCE_IRQ,
215 struct platform_device mxc_fb_device = {
218 .num_resources = ARRAY_SIZE(mxc_fb),
221 .coherent_dma_mask = DMA_BIT_MASK(32),
225 static struct resource mxc_pwm_resources[] = {
227 .start = MX2x_PWM_BASE_ADDR,
228 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
229 .flags = IORESOURCE_MEM,
231 .start = MX2x_INT_PWM,
233 .flags = IORESOURCE_IRQ,
237 struct platform_device mxc_pwm_device = {
240 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
241 .resource = mxc_pwm_resources,
244 #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
245 static struct resource mxc_sdhc_resources ## n[] = { \
248 .end = baseaddr + SZ_4K - 1, \
249 .flags = IORESOURCE_MEM, \
253 .flags = IORESOURCE_IRQ, \
257 .flags = IORESOURCE_DMA, \
261 static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
263 struct platform_device mxc_sdhc_device ## n = { \
267 .dma_mask = &mxc_sdhc ## n ## _dmamask, \
268 .coherent_dma_mask = DMA_BIT_MASK(32), \
270 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
271 .resource = mxc_sdhc_resources ## n, \
274 DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
275 DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
277 #ifdef CONFIG_MACH_MX27
278 static struct resource otg_resources[] = {
280 .start = MX27_USBOTG_BASE_ADDR,
281 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
282 .flags = IORESOURCE_MEM,
284 .start = MX27_INT_USB3,
285 .end = MX27_INT_USB3,
286 .flags = IORESOURCE_IRQ,
290 static u64 otg_dmamask = DMA_BIT_MASK(32);
292 /* OTG gadget device */
293 struct platform_device mxc_otg_udc_device = {
294 .name = "fsl-usb2-udc",
297 .dma_mask = &otg_dmamask,
298 .coherent_dma_mask = DMA_BIT_MASK(32),
300 .resource = otg_resources,
301 .num_resources = ARRAY_SIZE(otg_resources),
305 struct platform_device mxc_otg_host = {
309 .coherent_dma_mask = DMA_BIT_MASK(32),
310 .dma_mask = &otg_dmamask,
312 .resource = otg_resources,
313 .num_resources = ARRAY_SIZE(otg_resources),
318 static u64 usbh1_dmamask = DMA_BIT_MASK(32);
320 static struct resource mxc_usbh1_resources[] = {
322 .start = MX27_USBOTG_BASE_ADDR + 0x200,
323 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
324 .flags = IORESOURCE_MEM,
326 .start = MX27_INT_USB1,
327 .end = MX27_INT_USB1,
328 .flags = IORESOURCE_IRQ,
332 struct platform_device mxc_usbh1 = {
336 .coherent_dma_mask = DMA_BIT_MASK(32),
337 .dma_mask = &usbh1_dmamask,
339 .resource = mxc_usbh1_resources,
340 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
344 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
346 static struct resource mxc_usbh2_resources[] = {
348 .start = MX27_USBOTG_BASE_ADDR + 0x400,
349 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
350 .flags = IORESOURCE_MEM,
352 .start = MX27_INT_USB2,
353 .end = MX27_INT_USB2,
354 .flags = IORESOURCE_IRQ,
358 struct platform_device mxc_usbh2 = {
362 .coherent_dma_mask = DMA_BIT_MASK(32),
363 .dma_mask = &usbh2_dmamask,
365 .resource = mxc_usbh2_resources,
366 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
370 /* GPIO port description */
371 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
373 .chip.label = "gpio-" #n, \
375 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
377 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
380 #define DEFINE_MXC_GPIO_PORT(SOC, n) \
382 .chip.label = "gpio-" #n, \
383 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
385 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
388 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
389 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
390 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
391 DEFINE_MXC_GPIO_PORT(SOC, 1), \
392 DEFINE_MXC_GPIO_PORT(SOC, 2), \
393 DEFINE_MXC_GPIO_PORT(SOC, 3), \
394 DEFINE_MXC_GPIO_PORT(SOC, 4), \
395 DEFINE_MXC_GPIO_PORT(SOC, 5), \
398 #ifdef CONFIG_MACH_MX21
399 DEFINE_MXC_GPIO_PORTS(MX21, imx21);
401 int __init imx21_register_gpios(void)
403 return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
407 #ifdef CONFIG_MACH_MX27
408 DEFINE_MXC_GPIO_PORTS(MX27, imx27);
410 int __init imx27_register_gpios(void)
412 return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
416 #ifdef CONFIG_MACH_MX21
417 static struct resource mx21_usbhc_resources[] = {
419 .start = MX21_USBOTG_BASE_ADDR,
420 .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
421 .flags = IORESOURCE_MEM,
424 .start = MX21_INT_USBHOST,
425 .end = MX21_INT_USBHOST,
426 .flags = IORESOURCE_IRQ,
430 struct platform_device mx21_usbhc_device = {
434 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
435 .coherent_dma_mask = DMA_BIT_MASK(32),
437 .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
438 .resource = mx21_usbhc_resources,
442 static struct resource imx_kpp_resources[] = {
444 .start = MX2x_KPP_BASE_ADDR,
445 .end = MX2x_KPP_BASE_ADDR + 0xf,
446 .flags = IORESOURCE_MEM
448 .start = MX2x_INT_KPP,
450 .flags = IORESOURCE_IRQ,
454 struct platform_device imx_kpp_device = {
455 .name = "imx-keypad",
457 .num_resources = ARRAY_SIZE(imx_kpp_resources),
458 .resource = imx_kpp_resources,