Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 1 | /* |
| 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> |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 34 | #include <linux/dma-mapping.h> |
Uwe Kleine-König | e9ec2a1 | 2010-06-10 17:34:59 +0200 | [diff] [blame] | 35 | #include <linux/serial.h> |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 36 | |
Russell King | 80b02c1 | 2009-01-08 10:01:47 +0000 | [diff] [blame] | 37 | #include <mach/irqs.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 38 | #include <mach/hardware.h> |
Holger Schurig | 058b7a6 | 2009-01-26 16:34:51 +0100 | [diff] [blame] | 39 | #include <mach/common.h> |
Sascha Hauer | 1a02be0 | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 40 | #include <mach/mmc.h> |
Uwe Kleine-König | e9ec2a1 | 2010-06-10 17:34:59 +0200 | [diff] [blame] | 41 | #include <mach/imx-uart.h> |
Holger Schurig | 058b7a6 | 2009-01-26 16:34:51 +0100 | [diff] [blame] | 42 | |
| 43 | #include "devices.h" |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 44 | |
| 45 | /* |
Sascha Hauer | f420db8 | 2008-12-19 14:32:14 +0100 | [diff] [blame] | 46 | * SPI master controller |
| 47 | * |
| 48 | * - i.MX1: 2 channel (slighly different register setting) |
| 49 | * - i.MX21: 2 channel |
| 50 | * - i.MX27: 3 channel |
| 51 | */ |
Uwe Kleine-König | 68c94b4 | 2010-02-04 22:04:32 +0100 | [diff] [blame] | 52 | #define DEFINE_IMX_SPI_DEVICE(n, baseaddr, irq) \ |
| 53 | static struct resource mxc_spi_resources ## n[] = { \ |
| 54 | { \ |
| 55 | .start = baseaddr, \ |
| 56 | .end = baseaddr + SZ_4K - 1, \ |
| 57 | .flags = IORESOURCE_MEM, \ |
| 58 | }, { \ |
| 59 | .start = irq, \ |
| 60 | .end = irq, \ |
| 61 | .flags = IORESOURCE_IRQ, \ |
| 62 | }, \ |
| 63 | }; \ |
| 64 | \ |
| 65 | struct platform_device mxc_spi_device ## n = { \ |
| 66 | .name = "spi_imx", \ |
| 67 | .id = n, \ |
| 68 | .num_resources = ARRAY_SIZE(mxc_spi_resources ## n), \ |
| 69 | .resource = mxc_spi_resources ## n, \ |
| 70 | } |
Sascha Hauer | f420db8 | 2008-12-19 14:32:14 +0100 | [diff] [blame] | 71 | |
Uwe Kleine-König | 68c94b4 | 2010-02-04 22:04:32 +0100 | [diff] [blame] | 72 | DEFINE_IMX_SPI_DEVICE(0, MX2x_CSPI1_BASE_ADDR, MX2x_INT_CSPI1); |
| 73 | DEFINE_IMX_SPI_DEVICE(1, MX2x_CSPI2_BASE_ADDR, MX2x_INT_CSPI2); |
Sascha Hauer | f420db8 | 2008-12-19 14:32:14 +0100 | [diff] [blame] | 74 | |
| 75 | #ifdef CONFIG_MACH_MX27 |
Uwe Kleine-König | 68c94b4 | 2010-02-04 22:04:32 +0100 | [diff] [blame] | 76 | DEFINE_IMX_SPI_DEVICE(2, MX27_CSPI3_BASE_ADDR, MX27_INT_CSPI3); |
Sascha Hauer | f420db8 | 2008-12-19 14:32:14 +0100 | [diff] [blame] | 77 | #endif |
| 78 | |
| 79 | /* |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 80 | * General Purpose Timer |
Sascha Hauer | bf50bcc | 2009-06-23 12:04:36 +0200 | [diff] [blame] | 81 | * - i.MX21: 3 timers |
| 82 | * - i.MX27: 6 timers |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 83 | */ |
Uwe Kleine-König | 2b84a364 | 2010-02-04 14:11:02 +0100 | [diff] [blame] | 84 | #define DEFINE_IMX_GPT_DEVICE(n, baseaddr, irq) \ |
| 85 | static struct resource timer ## n ##_resources[] = { \ |
| 86 | { \ |
| 87 | .start = baseaddr, \ |
| 88 | .end = baseaddr + SZ_4K - 1, \ |
| 89 | .flags = IORESOURCE_MEM, \ |
| 90 | }, { \ |
| 91 | .start = irq, \ |
| 92 | .end = irq, \ |
| 93 | .flags = IORESOURCE_IRQ, \ |
| 94 | } \ |
| 95 | }; \ |
| 96 | \ |
| 97 | struct platform_device mxc_gpt ## n = { \ |
| 98 | .name = "imx_gpt", \ |
| 99 | .id = n, \ |
| 100 | .num_resources = ARRAY_SIZE(timer ## n ## _resources), \ |
| 101 | .resource = timer ## n ## _resources, \ |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 102 | } |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 103 | |
Uwe Kleine-König | 2b84a364 | 2010-02-04 14:11:02 +0100 | [diff] [blame] | 104 | /* We use gpt1 as system timer, so do not add a device for this one */ |
| 105 | DEFINE_IMX_GPT_DEVICE(1, MX2x_GPT2_BASE_ADDR, MX2x_INT_GPT2); |
| 106 | DEFINE_IMX_GPT_DEVICE(2, MX2x_GPT3_BASE_ADDR, MX2x_INT_GPT3); |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 107 | |
| 108 | #ifdef CONFIG_MACH_MX27 |
Uwe Kleine-König | 2b84a364 | 2010-02-04 14:11:02 +0100 | [diff] [blame] | 109 | DEFINE_IMX_GPT_DEVICE(3, MX27_GPT4_BASE_ADDR, MX27_INT_GPT4); |
| 110 | DEFINE_IMX_GPT_DEVICE(4, MX27_GPT5_BASE_ADDR, MX27_INT_GPT5); |
| 111 | DEFINE_IMX_GPT_DEVICE(5, MX27_GPT6_BASE_ADDR, MX27_INT_GPT6); |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 112 | #endif |
| 113 | |
Wolfram Sang | 6d38c1c | 2010-04-29 10:03:18 +0200 | [diff] [blame] | 114 | /* Watchdog: i.MX1 has seperate driver, i.MX21 and i.MX27 are equal */ |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 115 | static struct resource mxc_wdt_resources[] = { |
| 116 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 117 | .start = MX2x_WDOG_BASE_ADDR, |
| 118 | .end = MX2x_WDOG_BASE_ADDR + SZ_4K - 1, |
| 119 | .flags = IORESOURCE_MEM, |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 120 | }, |
| 121 | }; |
| 122 | |
| 123 | struct platform_device mxc_wdt = { |
Wolfram Sang | 6d38c1c | 2010-04-29 10:03:18 +0200 | [diff] [blame] | 124 | .name = "imx2-wdt", |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 125 | .id = 0, |
| 126 | .num_resources = ARRAY_SIZE(mxc_wdt_resources), |
| 127 | .resource = mxc_wdt_resources, |
| 128 | }; |
| 129 | |
Sascha Hauer | 3d89baa | 2008-12-01 14:15:38 -0800 | [diff] [blame] | 130 | static struct resource mxc_w1_master_resources[] = { |
| 131 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 132 | .start = MX2x_OWIRE_BASE_ADDR, |
| 133 | .end = MX2x_OWIRE_BASE_ADDR + SZ_4K - 1, |
Sascha Hauer | 3d89baa | 2008-12-01 14:15:38 -0800 | [diff] [blame] | 134 | .flags = IORESOURCE_MEM, |
| 135 | }, |
| 136 | }; |
| 137 | |
| 138 | struct platform_device mxc_w1_master_device = { |
| 139 | .name = "mxc_w1", |
| 140 | .id = 0, |
| 141 | .num_resources = ARRAY_SIZE(mxc_w1_master_resources), |
| 142 | .resource = mxc_w1_master_resources, |
| 143 | }; |
| 144 | |
Uwe Kleine-König | f0d3ab4 | 2010-02-05 16:57:59 +0100 | [diff] [blame] | 145 | #define DEFINE_MXC_NAND_DEVICE(pfx, baseaddr, irq) \ |
| 146 | static struct resource pfx ## _nand_resources[] = { \ |
| 147 | { \ |
| 148 | .start = baseaddr, \ |
| 149 | .end = baseaddr + SZ_4K - 1, \ |
| 150 | .flags = IORESOURCE_MEM, \ |
| 151 | }, { \ |
| 152 | .start = irq, \ |
| 153 | .end = irq, \ |
| 154 | .flags = IORESOURCE_IRQ, \ |
| 155 | }, \ |
| 156 | }; \ |
| 157 | \ |
| 158 | struct platform_device pfx ## _nand_device = { \ |
| 159 | .name = "mxc_nand", \ |
| 160 | .id = 0, \ |
| 161 | .num_resources = ARRAY_SIZE(pfx ## _nand_resources), \ |
| 162 | .resource = pfx ## _nand_resources, \ |
| 163 | } |
Sascha Hauer | 0287097 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 164 | |
Uwe Kleine-König | f0d3ab4 | 2010-02-05 16:57:59 +0100 | [diff] [blame] | 165 | #ifdef CONFIG_MACH_MX21 |
| 166 | DEFINE_MXC_NAND_DEVICE(imx21, MX21_NFC_BASE_ADDR, MX21_INT_NANDFC); |
| 167 | #endif |
| 168 | |
| 169 | #ifdef CONFIG_MACH_MX27 |
| 170 | DEFINE_MXC_NAND_DEVICE(imx27, MX27_NFC_BASE_ADDR, MX27_INT_NANDFC); |
| 171 | #endif |
Sascha Hauer | 0287097 | 2008-09-09 11:30:58 +0200 | [diff] [blame] | 172 | |
Holger Schurig | e481355 | 2009-01-26 16:34:56 +0100 | [diff] [blame] | 173 | /* |
| 174 | * lcdc: |
| 175 | * - i.MX1: the basic controller |
| 176 | * - i.MX21: to be checked |
| 177 | * - i.MX27: like i.MX1, with slightly variations |
| 178 | */ |
| 179 | static struct resource mxc_fb[] = { |
| 180 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 181 | .start = MX2x_LCDC_BASE_ADDR, |
| 182 | .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1, |
Holger Schurig | e481355 | 2009-01-26 16:34:56 +0100 | [diff] [blame] | 183 | .flags = IORESOURCE_MEM, |
Sascha Hauer | bf50bcc | 2009-06-23 12:04:36 +0200 | [diff] [blame] | 184 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 185 | .start = MX2x_INT_LCDC, |
| 186 | .end = MX2x_INT_LCDC, |
Holger Schurig | e481355 | 2009-01-26 16:34:56 +0100 | [diff] [blame] | 187 | .flags = IORESOURCE_IRQ, |
| 188 | } |
| 189 | }; |
| 190 | |
| 191 | /* mxc lcd driver */ |
| 192 | struct platform_device mxc_fb_device = { |
| 193 | .name = "imx-fb", |
| 194 | .id = 0, |
| 195 | .num_resources = ARRAY_SIZE(mxc_fb), |
| 196 | .resource = mxc_fb, |
| 197 | .dev = { |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 198 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Holger Schurig | e481355 | 2009-01-26 16:34:56 +0100 | [diff] [blame] | 199 | }, |
| 200 | }; |
| 201 | |
Sascha Hauer | 879fea1 | 2009-01-26 17:26:02 +0100 | [diff] [blame] | 202 | #ifdef CONFIG_MACH_MX27 |
| 203 | static struct resource mxc_fec_resources[] = { |
| 204 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 205 | .start = MX27_FEC_BASE_ADDR, |
| 206 | .end = MX27_FEC_BASE_ADDR + SZ_4K - 1, |
| 207 | .flags = IORESOURCE_MEM, |
Sascha Hauer | 879fea1 | 2009-01-26 17:26:02 +0100 | [diff] [blame] | 208 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 209 | .start = MX27_INT_FEC, |
| 210 | .end = MX27_INT_FEC, |
| 211 | .flags = IORESOURCE_IRQ, |
Sascha Hauer | 879fea1 | 2009-01-26 17:26:02 +0100 | [diff] [blame] | 212 | }, |
| 213 | }; |
| 214 | |
| 215 | struct platform_device mxc_fec_device = { |
| 216 | .name = "fec", |
| 217 | .id = 0, |
| 218 | .num_resources = ARRAY_SIZE(mxc_fec_resources), |
| 219 | .resource = mxc_fec_resources, |
| 220 | }; |
Holger Schurig | e481355 | 2009-01-26 16:34:56 +0100 | [diff] [blame] | 221 | #endif |
| 222 | |
Uwe Kleine-König | 9309b2b | 2010-02-04 22:13:52 +0100 | [diff] [blame] | 223 | #define DEFINE_IMX_I2C_DEVICE(n, baseaddr, irq) \ |
| 224 | static struct resource mxc_i2c_resources ## n[] = { \ |
| 225 | { \ |
| 226 | .start = baseaddr, \ |
| 227 | .end = baseaddr + SZ_4K - 1, \ |
| 228 | .flags = IORESOURCE_MEM, \ |
| 229 | }, { \ |
| 230 | .start = irq, \ |
| 231 | .end = irq, \ |
| 232 | .flags = IORESOURCE_IRQ, \ |
| 233 | } \ |
| 234 | }; \ |
| 235 | \ |
| 236 | struct platform_device mxc_i2c_device ## n = { \ |
| 237 | .name = "imx-i2c", \ |
| 238 | .id = n, \ |
| 239 | .num_resources = ARRAY_SIZE(mxc_i2c_resources ## n), \ |
| 240 | .resource = mxc_i2c_resources ## n, \ |
Sascha Hauer | c5d4dbf | 2009-01-28 13:26:56 +0100 | [diff] [blame] | 241 | } |
Sascha Hauer | c5d4dbf | 2009-01-28 13:26:56 +0100 | [diff] [blame] | 242 | |
Uwe Kleine-König | 9309b2b | 2010-02-04 22:13:52 +0100 | [diff] [blame] | 243 | DEFINE_IMX_I2C_DEVICE(0, MX2x_I2C_BASE_ADDR, MX2x_INT_I2C); |
Sascha Hauer | c5d4dbf | 2009-01-28 13:26:56 +0100 | [diff] [blame] | 244 | |
| 245 | #ifdef CONFIG_MACH_MX27 |
Uwe Kleine-König | 9309b2b | 2010-02-04 22:13:52 +0100 | [diff] [blame] | 246 | DEFINE_IMX_I2C_DEVICE(1, MX27_I2C2_BASE_ADDR, MX27_INT_I2C2); |
Sascha Hauer | c5d4dbf | 2009-01-28 13:26:56 +0100 | [diff] [blame] | 247 | #endif |
| 248 | |
Sascha Hauer | 824b16e | 2009-01-16 15:17:46 +0100 | [diff] [blame] | 249 | static struct resource mxc_pwm_resources[] = { |
Sascha Hauer | bf50bcc | 2009-06-23 12:04:36 +0200 | [diff] [blame] | 250 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 251 | .start = MX2x_PWM_BASE_ADDR, |
| 252 | .end = MX2x_PWM_BASE_ADDR + SZ_4K - 1, |
| 253 | .flags = IORESOURCE_MEM, |
Sascha Hauer | bf50bcc | 2009-06-23 12:04:36 +0200 | [diff] [blame] | 254 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 255 | .start = MX2x_INT_PWM, |
| 256 | .end = MX2x_INT_PWM, |
| 257 | .flags = IORESOURCE_IRQ, |
Sascha Hauer | 824b16e | 2009-01-16 15:17:46 +0100 | [diff] [blame] | 258 | } |
| 259 | }; |
| 260 | |
| 261 | struct platform_device mxc_pwm_device = { |
| 262 | .name = "mxc_pwm", |
| 263 | .id = 0, |
| 264 | .num_resources = ARRAY_SIZE(mxc_pwm_resources), |
Sascha Hauer | bf50bcc | 2009-06-23 12:04:36 +0200 | [diff] [blame] | 265 | .resource = mxc_pwm_resources, |
Sascha Hauer | 824b16e | 2009-01-16 15:17:46 +0100 | [diff] [blame] | 266 | }; |
| 267 | |
Uwe Kleine-König | ccd0e42 | 2010-02-05 10:46:56 +0100 | [diff] [blame] | 268 | #define DEFINE_MXC_MMC_DEVICE(n, baseaddr, irq, dmareq) \ |
| 269 | static struct resource mxc_sdhc_resources ## n[] = { \ |
| 270 | { \ |
| 271 | .start = baseaddr, \ |
| 272 | .end = baseaddr + SZ_4K - 1, \ |
| 273 | .flags = IORESOURCE_MEM, \ |
| 274 | }, { \ |
| 275 | .start = irq, \ |
| 276 | .end = irq, \ |
| 277 | .flags = IORESOURCE_IRQ, \ |
| 278 | }, { \ |
| 279 | .start = dmareq, \ |
| 280 | .end = dmareq, \ |
| 281 | .flags = IORESOURCE_DMA, \ |
| 282 | }, \ |
| 283 | }; \ |
| 284 | \ |
Russell King | 988addf | 2010-03-08 20:21:04 +0000 | [diff] [blame] | 285 | static u64 mxc_sdhc ## n ## _dmamask = DMA_BIT_MASK(32); \ |
Uwe Kleine-König | ccd0e42 | 2010-02-05 10:46:56 +0100 | [diff] [blame] | 286 | \ |
| 287 | struct platform_device mxc_sdhc_device ## n = { \ |
| 288 | .name = "mxc-mmc", \ |
| 289 | .id = n, \ |
| 290 | .dev = { \ |
| 291 | .dma_mask = &mxc_sdhc ## n ## _dmamask, \ |
Russell King | 988addf | 2010-03-08 20:21:04 +0000 | [diff] [blame] | 292 | .coherent_dma_mask = DMA_BIT_MASK(32), \ |
Uwe Kleine-König | ccd0e42 | 2010-02-05 10:46:56 +0100 | [diff] [blame] | 293 | }, \ |
| 294 | .num_resources = ARRAY_SIZE(mxc_sdhc_resources ## n), \ |
| 295 | .resource = mxc_sdhc_resources ## n, \ |
| 296 | } |
Sascha Hauer | 1a02be0 | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 297 | |
Uwe Kleine-König | ccd0e42 | 2010-02-05 10:46:56 +0100 | [diff] [blame] | 298 | DEFINE_MXC_MMC_DEVICE(0, MX2x_SDHC1_BASE_ADDR, MX2x_INT_SDHC1, MX2x_DMA_REQ_SDHC1); |
| 299 | DEFINE_MXC_MMC_DEVICE(1, MX2x_SDHC2_BASE_ADDR, MX2x_INT_SDHC2, MX2x_DMA_REQ_SDHC2); |
Sascha Hauer | 1a02be0 | 2008-12-19 14:32:07 +0100 | [diff] [blame] | 300 | |
Sascha Hauer | f6d2fa7 | 2009-08-13 10:02:30 +0200 | [diff] [blame] | 301 | #ifdef CONFIG_MACH_MX27 |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 302 | static struct resource otg_resources[] = { |
| 303 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 304 | .start = MX27_USBOTG_BASE_ADDR, |
| 305 | .end = MX27_USBOTG_BASE_ADDR + 0x1ff, |
| 306 | .flags = IORESOURCE_MEM, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 307 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 308 | .start = MX27_INT_USB3, |
| 309 | .end = MX27_INT_USB3, |
| 310 | .flags = IORESOURCE_IRQ, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 311 | }, |
| 312 | }; |
| 313 | |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 314 | static u64 otg_dmamask = DMA_BIT_MASK(32); |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 315 | |
| 316 | /* OTG gadget device */ |
| 317 | struct platform_device mxc_otg_udc_device = { |
| 318 | .name = "fsl-usb2-udc", |
| 319 | .id = -1, |
| 320 | .dev = { |
| 321 | .dma_mask = &otg_dmamask, |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 322 | .coherent_dma_mask = DMA_BIT_MASK(32), |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 323 | }, |
| 324 | .resource = otg_resources, |
| 325 | .num_resources = ARRAY_SIZE(otg_resources), |
| 326 | }; |
| 327 | |
| 328 | /* OTG host */ |
| 329 | struct platform_device mxc_otg_host = { |
| 330 | .name = "mxc-ehci", |
| 331 | .id = 0, |
| 332 | .dev = { |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 333 | .coherent_dma_mask = DMA_BIT_MASK(32), |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 334 | .dma_mask = &otg_dmamask, |
| 335 | }, |
| 336 | .resource = otg_resources, |
| 337 | .num_resources = ARRAY_SIZE(otg_resources), |
| 338 | }; |
| 339 | |
| 340 | /* USB host 1 */ |
| 341 | |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 342 | static u64 usbh1_dmamask = DMA_BIT_MASK(32); |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 343 | |
| 344 | static struct resource mxc_usbh1_resources[] = { |
| 345 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 346 | .start = MX27_USBOTG_BASE_ADDR + 0x200, |
| 347 | .end = MX27_USBOTG_BASE_ADDR + 0x3ff, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 348 | .flags = IORESOURCE_MEM, |
| 349 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 350 | .start = MX27_INT_USB1, |
| 351 | .end = MX27_INT_USB1, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 352 | .flags = IORESOURCE_IRQ, |
| 353 | }, |
| 354 | }; |
| 355 | |
| 356 | struct platform_device mxc_usbh1 = { |
| 357 | .name = "mxc-ehci", |
| 358 | .id = 1, |
| 359 | .dev = { |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 360 | .coherent_dma_mask = DMA_BIT_MASK(32), |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 361 | .dma_mask = &usbh1_dmamask, |
| 362 | }, |
| 363 | .resource = mxc_usbh1_resources, |
| 364 | .num_resources = ARRAY_SIZE(mxc_usbh1_resources), |
| 365 | }; |
| 366 | |
| 367 | /* USB host 2 */ |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 368 | static u64 usbh2_dmamask = DMA_BIT_MASK(32); |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 369 | |
| 370 | static struct resource mxc_usbh2_resources[] = { |
| 371 | { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 372 | .start = MX27_USBOTG_BASE_ADDR + 0x400, |
| 373 | .end = MX27_USBOTG_BASE_ADDR + 0x5ff, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 374 | .flags = IORESOURCE_MEM, |
| 375 | }, { |
Uwe Kleine-König | 58152a1 | 2010-02-05 11:42:54 +0100 | [diff] [blame] | 376 | .start = MX27_INT_USB2, |
| 377 | .end = MX27_INT_USB2, |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 378 | .flags = IORESOURCE_IRQ, |
| 379 | }, |
| 380 | }; |
| 381 | |
| 382 | struct platform_device mxc_usbh2 = { |
| 383 | .name = "mxc-ehci", |
| 384 | .id = 2, |
| 385 | .dev = { |
Martin Fuzzey | 3eb352c | 2009-11-21 12:14:54 +0100 | [diff] [blame] | 386 | .coherent_dma_mask = DMA_BIT_MASK(32), |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 387 | .dma_mask = &usbh2_dmamask, |
| 388 | }, |
| 389 | .resource = mxc_usbh2_resources, |
| 390 | .num_resources = ARRAY_SIZE(mxc_usbh2_resources), |
| 391 | }; |
Sascha Hauer | f6d2fa7 | 2009-08-13 10:02:30 +0200 | [diff] [blame] | 392 | #endif |
javier Martin | 627fb3b | 2009-07-15 15:26:21 +0200 | [diff] [blame] | 393 | |
Uwe Kleine-König | 69ddb48 | 2010-02-05 12:03:37 +0100 | [diff] [blame] | 394 | #define DEFINE_IMX_SSI_DMARES(_name, ssin, suffix) \ |
| 395 | { \ |
| 396 | .name = _name, \ |
| 397 | .start = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \ |
| 398 | .end = MX2x_DMA_REQ_SSI ## ssin ## _ ## suffix, \ |
| 399 | .flags = IORESOURCE_DMA, \ |
| 400 | } |
Sascha Hauer | 23291df | 2009-10-22 14:50:33 +0200 | [diff] [blame] | 401 | |
Uwe Kleine-König | 69ddb48 | 2010-02-05 12:03:37 +0100 | [diff] [blame] | 402 | #define DEFINE_IMX_SSI_DEVICE(n, ssin, baseaddr, irq) \ |
| 403 | static struct resource imx_ssi_resources ## n[] = { \ |
| 404 | { \ |
| 405 | .start = MX2x_SSI ## ssin ## _BASE_ADDR, \ |
| 406 | .end = MX2x_SSI ## ssin ## _BASE_ADDR + 0x6f, \ |
| 407 | .flags = IORESOURCE_MEM, \ |
| 408 | }, { \ |
| 409 | .start = MX2x_INT_SSI1, \ |
| 410 | .end = MX2x_INT_SSI1, \ |
| 411 | .flags = IORESOURCE_IRQ, \ |
| 412 | }, \ |
| 413 | DEFINE_IMX_SSI_DMARES("tx0", ssin, TX0), \ |
| 414 | DEFINE_IMX_SSI_DMARES("rx0", ssin, RX0), \ |
| 415 | DEFINE_IMX_SSI_DMARES("tx1", ssin, TX1), \ |
| 416 | DEFINE_IMX_SSI_DMARES("rx1", ssin, RX1), \ |
| 417 | }; \ |
| 418 | \ |
| 419 | struct platform_device imx_ssi_device ## n = { \ |
| 420 | .name = "imx-ssi", \ |
| 421 | .id = n, \ |
| 422 | .num_resources = ARRAY_SIZE(imx_ssi_resources ## n), \ |
| 423 | .resource = imx_ssi_resources ## n, \ |
| 424 | } |
Sascha Hauer | 23291df | 2009-10-22 14:50:33 +0200 | [diff] [blame] | 425 | |
Uwe Kleine-König | 69ddb48 | 2010-02-05 12:03:37 +0100 | [diff] [blame] | 426 | DEFINE_IMX_SSI_DEVICE(0, 1, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1); |
| 427 | DEFINE_IMX_SSI_DEVICE(1, 2, MX2x_SSI1_BASE_ADDR, MX2x_INT_SSI1); |
Sascha Hauer | 23291df | 2009-10-22 14:50:33 +0200 | [diff] [blame] | 428 | |
Uwe Kleine-König | e9ec2a1 | 2010-06-10 17:34:59 +0200 | [diff] [blame] | 429 | #define DEFINE_IMX_UART_DEVICE(n, baseaddr, irq) \ |
| 430 | static struct resource imx2x_uart_resources ## n[] = { \ |
| 431 | { \ |
| 432 | .start = baseaddr, \ |
| 433 | .end = baseaddr + 0xb5, \ |
| 434 | .flags = IORESOURCE_MEM, \ |
| 435 | }, { \ |
| 436 | .start = irq, \ |
| 437 | .end = irq, \ |
| 438 | .flags = IORESOURCE_IRQ, \ |
| 439 | }, \ |
| 440 | }; \ |
| 441 | \ |
| 442 | struct platform_device mxc_uart_device ## n = { \ |
| 443 | .name = "imx-uart", \ |
| 444 | .id = n, \ |
| 445 | .num_resources = ARRAY_SIZE(imx2x_uart_resources ## n), \ |
| 446 | .resource = imx2x_uart_resources ## n, \ |
| 447 | } |
| 448 | |
| 449 | DEFINE_IMX_UART_DEVICE(0, MX2x_UART1_BASE_ADDR, MX2x_INT_UART1); |
| 450 | DEFINE_IMX_UART_DEVICE(1, MX2x_UART2_BASE_ADDR, MX2x_INT_UART2); |
| 451 | DEFINE_IMX_UART_DEVICE(2, MX2x_UART3_BASE_ADDR, MX2x_INT_UART3); |
| 452 | DEFINE_IMX_UART_DEVICE(3, MX2x_UART4_BASE_ADDR, MX2x_INT_UART4); |
| 453 | |
| 454 | #ifdef CONFIG_MACH_MX27 |
| 455 | DEFINE_IMX_UART_DEVICE(4, MX27_UART5_BASE_ADDR, MX27_INT_UART5); |
| 456 | DEFINE_IMX_UART_DEVICE(5, MX27_UART6_BASE_ADDR, MX27_INT_UART6); |
| 457 | #endif |
| 458 | |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 459 | /* GPIO port description */ |
Uwe Kleine-König | 897359d | 2010-02-05 17:40:28 +0100 | [diff] [blame] | 460 | #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \ |
| 461 | { \ |
| 462 | .chip.label = "gpio-" #n, \ |
| 463 | .irq = _irq, \ |
| 464 | .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \ |
| 465 | n * 0x100), \ |
| 466 | .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \ |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 467 | } |
Uwe Kleine-König | 897359d | 2010-02-05 17:40:28 +0100 | [diff] [blame] | 468 | |
| 469 | #define DEFINE_MXC_GPIO_PORT(SOC, n) \ |
| 470 | { \ |
| 471 | .chip.label = "gpio-" #n, \ |
| 472 | .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \ |
| 473 | n * 0x100), \ |
| 474 | .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \ |
| 475 | } |
| 476 | |
| 477 | #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \ |
| 478 | static struct mxc_gpio_port pfx ## _gpio_ports[] = { \ |
| 479 | DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \ |
| 480 | DEFINE_MXC_GPIO_PORT(SOC, 1), \ |
| 481 | DEFINE_MXC_GPIO_PORT(SOC, 2), \ |
| 482 | DEFINE_MXC_GPIO_PORT(SOC, 3), \ |
| 483 | DEFINE_MXC_GPIO_PORT(SOC, 4), \ |
| 484 | DEFINE_MXC_GPIO_PORT(SOC, 5), \ |
| 485 | } |
| 486 | |
| 487 | #ifdef CONFIG_MACH_MX21 |
| 488 | DEFINE_MXC_GPIO_PORTS(MX21, imx21); |
Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 489 | |
| 490 | int __init imx21_register_gpios(void) |
| 491 | { |
| 492 | return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports)); |
| 493 | } |
Uwe Kleine-König | 897359d | 2010-02-05 17:40:28 +0100 | [diff] [blame] | 494 | #endif |
| 495 | |
| 496 | #ifdef CONFIG_MACH_MX27 |
| 497 | DEFINE_MXC_GPIO_PORTS(MX27, imx27); |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 498 | |
Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 499 | int __init imx27_register_gpios(void) |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 500 | { |
Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 501 | return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports)); |
Juergen Beisert | fc80a5e | 2008-07-05 10:02:57 +0200 | [diff] [blame] | 502 | } |
Uwe Kleine-König | 9a763bf | 2010-06-10 17:11:06 +0200 | [diff] [blame] | 503 | #endif |
Martin Fuzzey | 4e0fa90 | 2009-11-21 12:14:58 +0100 | [diff] [blame] | 504 | |
| 505 | #ifdef CONFIG_MACH_MX21 |
| 506 | static struct resource mx21_usbhc_resources[] = { |
| 507 | { |
Wolfram Sang | e169530 | 2010-05-15 11:25:35 +0100 | [diff] [blame] | 508 | .start = MX21_USBOTG_BASE_ADDR, |
| 509 | .end = MX21_USBOTG_BASE_ADDR + SZ_8K - 1, |
Martin Fuzzey | 4e0fa90 | 2009-11-21 12:14:58 +0100 | [diff] [blame] | 510 | .flags = IORESOURCE_MEM, |
| 511 | }, |
| 512 | { |
Russell King | 988addf | 2010-03-08 20:21:04 +0000 | [diff] [blame] | 513 | .start = MX21_INT_USBHOST, |
| 514 | .end = MX21_INT_USBHOST, |
Martin Fuzzey | 4e0fa90 | 2009-11-21 12:14:58 +0100 | [diff] [blame] | 515 | .flags = IORESOURCE_IRQ, |
| 516 | }, |
| 517 | }; |
| 518 | |
| 519 | struct platform_device mx21_usbhc_device = { |
| 520 | .name = "imx21-hcd", |
| 521 | .id = 0, |
| 522 | .dev = { |
| 523 | .dma_mask = &mx21_usbhc_device.dev.coherent_dma_mask, |
| 524 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 525 | }, |
| 526 | .num_resources = ARRAY_SIZE(mx21_usbhc_resources), |
| 527 | .resource = mx21_usbhc_resources, |
| 528 | }; |
| 529 | #endif |