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