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 /* GPIO port description */
49 static struct mxc_gpio_port imx_gpio_ports[] = {
51 .chip.label = "gpio-0",
52 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
53 .irq = MX1_GPIO_INT_PORTA,
54 .virtual_irq_start = MXC_GPIO_IRQ_START,
56 .chip.label = "gpio-1",
57 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
58 .irq = MX1_GPIO_INT_PORTB,
59 .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
61 .chip.label = "gpio-2",
62 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
63 .irq = MX1_GPIO_INT_PORTC,
64 .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
66 .chip.label = "gpio-3",
67 .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
68 .irq = MX1_GPIO_INT_PORTD,
69 .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
73 int __init imx1_register_gpios(void)
75 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
79 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
81 #ifdef CONFIG_MACH_MX27
82 static struct resource mx27_camera_resources[] = {
84 .start = MX27_CSI_BASE_ADDR,
85 .end = MX27_CSI_BASE_ADDR + 0x1f,
86 .flags = IORESOURCE_MEM,
88 .start = MX27_EMMA_PRP_BASE_ADDR,
89 .end = MX27_EMMA_PRP_BASE_ADDR + 0x1f,
90 .flags = IORESOURCE_MEM,
92 .start = MX27_INT_CSI,
94 .flags = IORESOURCE_IRQ,
96 .start = MX27_INT_EMMAPRP,
97 .end = MX27_INT_EMMAPRP,
98 .flags = IORESOURCE_IRQ,
101 struct platform_device mx27_camera_device = {
102 .name = "mx2-camera",
104 .num_resources = ARRAY_SIZE(mx27_camera_resources),
105 .resource = mx27_camera_resources,
107 .coherent_dma_mask = 0xffffffff,
112 /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */
113 static struct resource mxc_wdt_resources[] = {
115 .start = MX2x_WDOG_BASE_ADDR,
116 .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1,
117 .flags = IORESOURCE_MEM,
121 struct platform_device mxc_wdt = {
124 .num_resources = ARRAY_SIZE(mxc_wdt_resources),
125 .resource = mxc_wdt_resources,
130 * - i.MX1: the basic controller
131 * - i.MX21: to be checked
132 * - i.MX27: like i.MX1, with slightly variations
134 static struct resource mxc_fb[] = {
136 .start = MX2x_LCDC_BASE_ADDR,
137 .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
138 .flags = IORESOURCE_MEM,
140 .start = MX2x_INT_LCDC,
141 .end = MX2x_INT_LCDC,
142 .flags = IORESOURCE_IRQ,
147 struct platform_device mxc_fb_device = {
150 .num_resources = ARRAY_SIZE(mxc_fb),
153 .coherent_dma_mask = DMA_BIT_MASK(32),
157 static struct resource mxc_pwm_resources[] = {
159 .start = MX2x_PWM_BASE_ADDR,
160 .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1,
161 .flags = IORESOURCE_MEM,
163 .start = MX2x_INT_PWM,
165 .flags = IORESOURCE_IRQ,
169 struct platform_device mxc_pwm_device = {
172 .num_resources = ARRAY_SIZE(mxc_pwm_resources),
173 .resource = mxc_pwm_resources,
176 #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \
177 static struct resource mxc_sdhc_resources ## n[] = { \
180 .end = baseaddr + SZ_4K - 1, \
181 .flags = IORESOURCE_MEM, \
185 .flags = IORESOURCE_IRQ, \
189 .flags = IORESOURCE_DMA, \
193 static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \
195 struct platform_device mxc_sdhc_device ## n = { \
199 .dma_mask = &mxc_sdhc ## n ## _dmamask, \
200 .coherent_dma_mask = DMA_BIT_MASK(32), \
202 .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \
203 .resource = mxc_sdhc_resources ## n, \
206 DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1);
207 DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2);
209 #ifdef CONFIG_MACH_MX27
210 static struct resource otg_resources[] = {
212 .start = MX27_USBOTG_BASE_ADDR,
213 .end = MX27_USBOTG_BASE_ADDR + 0x1ff,
214 .flags = IORESOURCE_MEM,
216 .start = MX27_INT_USB3,
217 .end = MX27_INT_USB3,
218 .flags = IORESOURCE_IRQ,
222 static u64 otg_dmamask = DMA_BIT_MASK(32);
224 /* OTG gadget device */
225 struct platform_device mxc_otg_udc_device = {
226 .name = "fsl-usb2-udc",
229 .dma_mask = &otg_dmamask,
230 .coherent_dma_mask = DMA_BIT_MASK(32),
232 .resource = otg_resources,
233 .num_resources = ARRAY_SIZE(otg_resources),
237 struct platform_device mxc_otg_host = {
241 .coherent_dma_mask = DMA_BIT_MASK(32),
242 .dma_mask = &otg_dmamask,
244 .resource = otg_resources,
245 .num_resources = ARRAY_SIZE(otg_resources),
250 static u64 usbh1_dmamask = DMA_BIT_MASK(32);
252 static struct resource mxc_usbh1_resources[] = {
254 .start = MX27_USBOTG_BASE_ADDR + 0x200,
255 .end = MX27_USBOTG_BASE_ADDR + 0x3ff,
256 .flags = IORESOURCE_MEM,
258 .start = MX27_INT_USB1,
259 .end = MX27_INT_USB1,
260 .flags = IORESOURCE_IRQ,
264 struct platform_device mxc_usbh1 = {
268 .coherent_dma_mask = DMA_BIT_MASK(32),
269 .dma_mask = &usbh1_dmamask,
271 .resource = mxc_usbh1_resources,
272 .num_resources = ARRAY_SIZE(mxc_usbh1_resources),
276 static u64 usbh2_dmamask = DMA_BIT_MASK(32);
278 static struct resource mxc_usbh2_resources[] = {
280 .start = MX27_USBOTG_BASE_ADDR + 0x400,
281 .end = MX27_USBOTG_BASE_ADDR + 0x5ff,
282 .flags = IORESOURCE_MEM,
284 .start = MX27_INT_USB2,
285 .end = MX27_INT_USB2,
286 .flags = IORESOURCE_IRQ,
290 struct platform_device mxc_usbh2 = {
294 .coherent_dma_mask = DMA_BIT_MASK(32),
295 .dma_mask = &usbh2_dmamask,
297 .resource = mxc_usbh2_resources,
298 .num_resources = ARRAY_SIZE(mxc_usbh2_resources),
302 /* GPIO port description */
303 #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
305 .chip.label = "gpio-" #n, \
307 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
309 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
312 #define DEFINE_MXC_GPIO_PORT(SOC, n) \
314 .chip.label = "gpio-" #n, \
315 .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
317 .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
320 #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
321 static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
322 DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
323 DEFINE_MXC_GPIO_PORT(SOC, 1), \
324 DEFINE_MXC_GPIO_PORT(SOC, 2), \
325 DEFINE_MXC_GPIO_PORT(SOC, 3), \
326 DEFINE_MXC_GPIO_PORT(SOC, 4), \
327 DEFINE_MXC_GPIO_PORT(SOC, 5), \
330 #ifdef CONFIG_MACH_MX21
331 DEFINE_MXC_GPIO_PORTS(MX21, imx21);
333 int __init imx21_register_gpios(void)
335 return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
339 #ifdef CONFIG_MACH_MX27
340 DEFINE_MXC_GPIO_PORTS(MX27, imx27);
342 int __init imx27_register_gpios(void)
344 return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
348 #ifdef CONFIG_MACH_MX21
349 static struct resource mx21_usbhc_resources[] = {
351 .start = MX21_USBOTG_BASE_ADDR,
352 .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1,
353 .flags = IORESOURCE_MEM,
356 .start = MX21_INT_USBHOST,
357 .end = MX21_INT_USBHOST,
358 .flags = IORESOURCE_IRQ,
362 struct platform_device mx21_usbhc_device = {
366 .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask,
367 .coherent_dma_mask = DMA_BIT_MASK(32),
369 .num_resources = ARRAY_SIZE(mx21_usbhc_resources),
370 .resource = mx21_usbhc_resources,
374 static struct resource imx_kpp_resources[] = {
376 .start = MX2x_KPP_BASE_ADDR,
377 .end = MX2x_KPP_BASE_ADDR + 0xf,
378 .flags = IORESOURCE_MEM
380 .start = MX2x_INT_KPP,
382 .flags = IORESOURCE_IRQ,
386 struct platform_device imx_kpp_device = {
387 .name = "imx-keypad",
389 .num_resources = ARRAY_SIZE(imx_kpp_resources),
390 .resource = imx_kpp_resources,