Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved. |
| 3 | * Copyright 2008 Sascha Hauer, kernel@pengutronix.de |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/serial.h> |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 23 | #include <linux/gpio.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/hardware.h> |
Russell King | 80b02c1 | 2009-01-08 10:01:47 +0000 | [diff] [blame] | 25 | #include <mach/irqs.h> |
Alan Carvalho de Assis | 45001e9 | 2009-04-02 12:38:41 -0300 | [diff] [blame] | 26 | #include <mach/common.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/imx-uart.h> |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 28 | |
Sascha Hauer | 87bbb19 | 2009-01-29 16:00:23 +0100 | [diff] [blame] | 29 | #include "devices.h" |
| 30 | |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 31 | static struct resource uart0[] = { |
| 32 | { |
| 33 | .start = UART1_BASE_ADDR, |
| 34 | .end = UART1_BASE_ADDR + 0x0B5, |
| 35 | .flags = IORESOURCE_MEM, |
| 36 | }, { |
| 37 | .start = MXC_INT_UART1, |
| 38 | .end = MXC_INT_UART1, |
| 39 | .flags = IORESOURCE_IRQ, |
| 40 | }, |
| 41 | }; |
| 42 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 43 | struct platform_device mxc_uart_device0 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 44 | .name = "imx-uart", |
| 45 | .id = 0, |
| 46 | .resource = uart0, |
| 47 | .num_resources = ARRAY_SIZE(uart0), |
| 48 | }; |
| 49 | |
| 50 | static struct resource uart1[] = { |
| 51 | { |
| 52 | .start = UART2_BASE_ADDR, |
| 53 | .end = UART2_BASE_ADDR + 0x0B5, |
| 54 | .flags = IORESOURCE_MEM, |
| 55 | }, { |
| 56 | .start = MXC_INT_UART2, |
| 57 | .end = MXC_INT_UART2, |
| 58 | .flags = IORESOURCE_IRQ, |
| 59 | }, |
| 60 | }; |
| 61 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 62 | struct platform_device mxc_uart_device1 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 63 | .name = "imx-uart", |
| 64 | .id = 1, |
| 65 | .resource = uart1, |
| 66 | .num_resources = ARRAY_SIZE(uart1), |
| 67 | }; |
| 68 | |
| 69 | static struct resource uart2[] = { |
| 70 | { |
| 71 | .start = UART3_BASE_ADDR, |
| 72 | .end = UART3_BASE_ADDR + 0x0B5, |
| 73 | .flags = IORESOURCE_MEM, |
| 74 | }, { |
| 75 | .start = MXC_INT_UART3, |
| 76 | .end = MXC_INT_UART3, |
| 77 | .flags = IORESOURCE_IRQ, |
| 78 | }, |
| 79 | }; |
| 80 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 81 | struct platform_device mxc_uart_device2 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 82 | .name = "imx-uart", |
| 83 | .id = 2, |
| 84 | .resource = uart2, |
| 85 | .num_resources = ARRAY_SIZE(uart2), |
| 86 | }; |
| 87 | |
Sascha Hauer | 9536ff3 | 2009-02-06 15:38:51 +0100 | [diff] [blame] | 88 | #ifdef CONFIG_ARCH_MX31 |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 89 | static struct resource uart3[] = { |
| 90 | { |
| 91 | .start = UART4_BASE_ADDR, |
| 92 | .end = UART4_BASE_ADDR + 0x0B5, |
| 93 | .flags = IORESOURCE_MEM, |
| 94 | }, { |
| 95 | .start = MXC_INT_UART4, |
| 96 | .end = MXC_INT_UART4, |
| 97 | .flags = IORESOURCE_IRQ, |
| 98 | }, |
| 99 | }; |
| 100 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 101 | struct platform_device mxc_uart_device3 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 102 | .name = "imx-uart", |
| 103 | .id = 3, |
| 104 | .resource = uart3, |
| 105 | .num_resources = ARRAY_SIZE(uart3), |
| 106 | }; |
| 107 | |
| 108 | static struct resource uart4[] = { |
| 109 | { |
| 110 | .start = UART5_BASE_ADDR, |
| 111 | .end = UART5_BASE_ADDR + 0x0B5, |
| 112 | .flags = IORESOURCE_MEM, |
| 113 | }, { |
| 114 | .start = MXC_INT_UART5, |
| 115 | .end = MXC_INT_UART5, |
| 116 | .flags = IORESOURCE_IRQ, |
| 117 | }, |
| 118 | }; |
| 119 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 120 | struct platform_device mxc_uart_device4 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 121 | .name = "imx-uart", |
| 122 | .id = 4, |
| 123 | .resource = uart4, |
| 124 | .num_resources = ARRAY_SIZE(uart4), |
| 125 | }; |
Sascha Hauer | 9536ff3 | 2009-02-06 15:38:51 +0100 | [diff] [blame] | 126 | #endif /* CONFIG_ARCH_MX31 */ |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 127 | |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 128 | /* GPIO port description */ |
| 129 | static struct mxc_gpio_port imx_gpio_ports[] = { |
| 130 | [0] = { |
| 131 | .chip.label = "gpio-0", |
| 132 | .base = IO_ADDRESS(GPIO1_BASE_ADDR), |
| 133 | .irq = MXC_INT_GPIO1, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 134 | .virtual_irq_start = MXC_GPIO_IRQ_START, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 135 | }, |
| 136 | [1] = { |
| 137 | .chip.label = "gpio-1", |
| 138 | .base = IO_ADDRESS(GPIO2_BASE_ADDR), |
| 139 | .irq = MXC_INT_GPIO2, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 140 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 141 | }, |
| 142 | [2] = { |
| 143 | .chip.label = "gpio-2", |
| 144 | .base = IO_ADDRESS(GPIO3_BASE_ADDR), |
| 145 | .irq = MXC_INT_GPIO3, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 146 | .virtual_irq_start = MXC_GPIO_IRQ_START + 64, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 147 | } |
| 148 | }; |
| 149 | |
| 150 | int __init mxc_register_gpios(void) |
| 151 | { |
| 152 | return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); |
| 153 | } |
Sascha Hauer | a840592 | 2008-12-01 14:15:39 -0800 | [diff] [blame] | 154 | |
| 155 | static struct resource mxc_w1_master_resources[] = { |
| 156 | { |
| 157 | .start = OWIRE_BASE_ADDR, |
| 158 | .end = OWIRE_BASE_ADDR + SZ_4K - 1, |
| 159 | .flags = IORESOURCE_MEM, |
| 160 | }, |
| 161 | }; |
| 162 | |
| 163 | struct platform_device mxc_w1_master_device = { |
| 164 | .name = "mxc_w1", |
| 165 | .id = 0, |
| 166 | .num_resources = ARRAY_SIZE(mxc_w1_master_resources), |
| 167 | .resource = mxc_w1_master_resources, |
| 168 | }; |
Sascha Hauer | cb96cf1 | 2008-11-11 15:15:39 +0100 | [diff] [blame] | 169 | |
| 170 | static struct resource mxc_nand_resources[] = { |
| 171 | { |
Sascha Hauer | 9536ff3 | 2009-02-06 15:38:51 +0100 | [diff] [blame] | 172 | .start = 0, /* runtime dependent */ |
| 173 | .end = 0, |
Sascha Hauer | cb96cf1 | 2008-11-11 15:15:39 +0100 | [diff] [blame] | 174 | .flags = IORESOURCE_MEM |
| 175 | }, { |
| 176 | .start = MXC_INT_NANDFC, |
| 177 | .end = MXC_INT_NANDFC, |
| 178 | .flags = IORESOURCE_IRQ |
| 179 | }, |
| 180 | }; |
| 181 | |
| 182 | struct platform_device mxc_nand_device = { |
| 183 | .name = "mxc_nand", |
| 184 | .id = 0, |
| 185 | .num_resources = ARRAY_SIZE(mxc_nand_resources), |
| 186 | .resource = mxc_nand_resources, |
| 187 | }; |
Mark Brown | 39d1dc0 | 2009-01-15 16:14:27 +0000 | [diff] [blame] | 188 | |
| 189 | static struct resource mxc_i2c0_resources[] = { |
| 190 | { |
| 191 | .start = I2C_BASE_ADDR, |
| 192 | .end = I2C_BASE_ADDR + SZ_4K - 1, |
| 193 | .flags = IORESOURCE_MEM, |
| 194 | }, |
| 195 | { |
| 196 | .start = MXC_INT_I2C, |
| 197 | .end = MXC_INT_I2C, |
| 198 | .flags = IORESOURCE_IRQ, |
| 199 | }, |
| 200 | }; |
| 201 | |
| 202 | struct platform_device mxc_i2c_device0 = { |
| 203 | .name = "imx-i2c", |
| 204 | .id = 0, |
| 205 | .num_resources = ARRAY_SIZE(mxc_i2c0_resources), |
| 206 | .resource = mxc_i2c0_resources, |
| 207 | }; |
| 208 | |
| 209 | static struct resource mxc_i2c1_resources[] = { |
| 210 | { |
| 211 | .start = I2C2_BASE_ADDR, |
| 212 | .end = I2C2_BASE_ADDR + SZ_4K - 1, |
| 213 | .flags = IORESOURCE_MEM, |
| 214 | }, |
| 215 | { |
| 216 | .start = MXC_INT_I2C2, |
| 217 | .end = MXC_INT_I2C2, |
| 218 | .flags = IORESOURCE_IRQ, |
| 219 | }, |
| 220 | }; |
| 221 | |
| 222 | struct platform_device mxc_i2c_device1 = { |
| 223 | .name = "imx-i2c", |
| 224 | .id = 1, |
| 225 | .num_resources = ARRAY_SIZE(mxc_i2c1_resources), |
| 226 | .resource = mxc_i2c1_resources, |
| 227 | }; |
| 228 | |
| 229 | static struct resource mxc_i2c2_resources[] = { |
| 230 | { |
| 231 | .start = I2C3_BASE_ADDR, |
| 232 | .end = I2C3_BASE_ADDR + SZ_4K - 1, |
| 233 | .flags = IORESOURCE_MEM, |
| 234 | }, |
| 235 | { |
| 236 | .start = MXC_INT_I2C3, |
| 237 | .end = MXC_INT_I2C3, |
| 238 | .flags = IORESOURCE_IRQ, |
| 239 | }, |
| 240 | }; |
| 241 | |
| 242 | struct platform_device mxc_i2c_device2 = { |
| 243 | .name = "imx-i2c", |
| 244 | .id = 2, |
| 245 | .num_resources = ARRAY_SIZE(mxc_i2c2_resources), |
| 246 | .resource = mxc_i2c2_resources, |
| 247 | }; |
Valentin Longchamp | ca489f8 | 2009-02-16 12:47:52 +0100 | [diff] [blame] | 248 | |
Sascha Hauer | 2adc1d6 | 2008-12-19 14:32:06 +0100 | [diff] [blame] | 249 | #ifdef CONFIG_ARCH_MX31 |
| 250 | static struct resource mxcsdhc0_resources[] = { |
| 251 | { |
| 252 | .start = MMC_SDHC1_BASE_ADDR, |
| 253 | .end = MMC_SDHC1_BASE_ADDR + SZ_16K - 1, |
| 254 | .flags = IORESOURCE_MEM, |
| 255 | }, { |
| 256 | .start = MXC_INT_MMC_SDHC1, |
| 257 | .end = MXC_INT_MMC_SDHC1, |
| 258 | .flags = IORESOURCE_IRQ, |
| 259 | }, |
| 260 | }; |
| 261 | |
| 262 | static struct resource mxcsdhc1_resources[] = { |
| 263 | { |
| 264 | .start = MMC_SDHC2_BASE_ADDR, |
| 265 | .end = MMC_SDHC2_BASE_ADDR + SZ_16K - 1, |
| 266 | .flags = IORESOURCE_MEM, |
| 267 | }, { |
| 268 | .start = MXC_INT_MMC_SDHC2, |
| 269 | .end = MXC_INT_MMC_SDHC2, |
| 270 | .flags = IORESOURCE_IRQ, |
| 271 | }, |
| 272 | }; |
| 273 | |
| 274 | struct platform_device mxcsdhc_device0 = { |
| 275 | .name = "mxc-mmc", |
| 276 | .id = 0, |
| 277 | .num_resources = ARRAY_SIZE(mxcsdhc0_resources), |
| 278 | .resource = mxcsdhc0_resources, |
| 279 | }; |
| 280 | |
| 281 | struct platform_device mxcsdhc_device1 = { |
| 282 | .name = "mxc-mmc", |
| 283 | .id = 1, |
| 284 | .num_resources = ARRAY_SIZE(mxcsdhc1_resources), |
| 285 | .resource = mxcsdhc1_resources, |
| 286 | }; |
Alan Carvalho de Assis | 45001e9 | 2009-04-02 12:38:41 -0300 | [diff] [blame] | 287 | |
| 288 | static struct resource rnga_resources[] = { |
| 289 | { |
| 290 | .start = RNGA_BASE_ADDR, |
| 291 | .end = RNGA_BASE_ADDR + 0x28, |
| 292 | .flags = IORESOURCE_MEM, |
| 293 | }, |
| 294 | }; |
| 295 | |
| 296 | struct platform_device mxc_rnga_device = { |
| 297 | .name = "mxc_rnga", |
| 298 | .id = -1, |
| 299 | .num_resources = 1, |
| 300 | .resource = rnga_resources, |
| 301 | }; |
Sascha Hauer | 2adc1d6 | 2008-12-19 14:32:06 +0100 | [diff] [blame] | 302 | #endif /* CONFIG_ARCH_MX31 */ |
| 303 | |
Valentin Longchamp | ca489f8 | 2009-02-16 12:47:52 +0100 | [diff] [blame] | 304 | /* i.MX31 Image Processing Unit */ |
| 305 | |
| 306 | /* The resource order is important! */ |
| 307 | static struct resource mx3_ipu_rsrc[] = { |
| 308 | { |
| 309 | .start = IPU_CTRL_BASE_ADDR, |
| 310 | .end = IPU_CTRL_BASE_ADDR + 0x5F, |
| 311 | .flags = IORESOURCE_MEM, |
| 312 | }, { |
| 313 | .start = IPU_CTRL_BASE_ADDR + 0x88, |
| 314 | .end = IPU_CTRL_BASE_ADDR + 0xB3, |
| 315 | .flags = IORESOURCE_MEM, |
| 316 | }, { |
| 317 | .start = MXC_INT_IPU_SYN, |
| 318 | .end = MXC_INT_IPU_SYN, |
| 319 | .flags = IORESOURCE_IRQ, |
| 320 | }, { |
| 321 | .start = MXC_INT_IPU_ERR, |
| 322 | .end = MXC_INT_IPU_ERR, |
| 323 | .flags = IORESOURCE_IRQ, |
| 324 | }, |
| 325 | }; |
| 326 | |
| 327 | struct platform_device mx3_ipu = { |
| 328 | .name = "ipu-core", |
| 329 | .id = -1, |
| 330 | .num_resources = ARRAY_SIZE(mx3_ipu_rsrc), |
| 331 | .resource = mx3_ipu_rsrc, |
| 332 | }; |
| 333 | |
| 334 | static struct resource fb_resources[] = { |
| 335 | { |
| 336 | .start = IPU_CTRL_BASE_ADDR + 0xB4, |
| 337 | .end = IPU_CTRL_BASE_ADDR + 0x1BF, |
| 338 | .flags = IORESOURCE_MEM, |
| 339 | }, |
| 340 | }; |
| 341 | |
| 342 | struct platform_device mx3_fb = { |
| 343 | .name = "mx3_sdc_fb", |
| 344 | .id = -1, |
| 345 | .num_resources = ARRAY_SIZE(fb_resources), |
| 346 | .resource = fb_resources, |
| 347 | .dev = { |
| 348 | .coherent_dma_mask = 0xffffffff, |
| 349 | }, |
| 350 | }; |
Sascha Hauer | 9536ff3 | 2009-02-06 15:38:51 +0100 | [diff] [blame] | 351 | |
| 352 | #ifdef CONFIG_ARCH_MX35 |
| 353 | static struct resource mxc_fec_resources[] = { |
| 354 | { |
| 355 | .start = MXC_FEC_BASE_ADDR, |
| 356 | .end = MXC_FEC_BASE_ADDR + 0xfff, |
| 357 | .flags = IORESOURCE_MEM |
| 358 | }, { |
| 359 | .start = MXC_INT_FEC, |
| 360 | .end = MXC_INT_FEC, |
| 361 | .flags = IORESOURCE_IRQ |
| 362 | }, |
| 363 | }; |
| 364 | |
| 365 | struct platform_device mxc_fec_device = { |
| 366 | .name = "fec", |
| 367 | .id = 0, |
| 368 | .num_resources = ARRAY_SIZE(mxc_fec_resources), |
| 369 | .resource = mxc_fec_resources, |
| 370 | }; |
| 371 | #endif |
| 372 | |
| 373 | static int mx3_devices_init(void) |
| 374 | { |
| 375 | if (cpu_is_mx31()) { |
| 376 | mxc_nand_resources[0].start = MX31_NFC_BASE_ADDR; |
| 377 | mxc_nand_resources[0].end = MX31_NFC_BASE_ADDR + 0xfff; |
Alan Carvalho de Assis | 45001e9 | 2009-04-02 12:38:41 -0300 | [diff] [blame] | 378 | mxc_register_device(&mxc_rnga_device, NULL); |
Sascha Hauer | 9536ff3 | 2009-02-06 15:38:51 +0100 | [diff] [blame] | 379 | } |
| 380 | if (cpu_is_mx35()) { |
| 381 | mxc_nand_resources[0].start = MX35_NFC_BASE_ADDR; |
| 382 | mxc_nand_resources[0].end = MX35_NFC_BASE_ADDR + 0xfff; |
| 383 | } |
| 384 | |
| 385 | return 0; |
| 386 | } |
| 387 | |
| 388 | subsys_initcall(mx3_devices_init); |