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> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/imx-uart.h> |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 27 | |
Sascha Hauer | 87bbb19 | 2009-01-29 16:00:23 +0100 | [diff] [blame] | 28 | #include "devices.h" |
| 29 | |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 30 | static struct resource uart0[] = { |
| 31 | { |
| 32 | .start = UART1_BASE_ADDR, |
| 33 | .end = UART1_BASE_ADDR + 0x0B5, |
| 34 | .flags = IORESOURCE_MEM, |
| 35 | }, { |
| 36 | .start = MXC_INT_UART1, |
| 37 | .end = MXC_INT_UART1, |
| 38 | .flags = IORESOURCE_IRQ, |
| 39 | }, |
| 40 | }; |
| 41 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 42 | struct platform_device mxc_uart_device0 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 43 | .name = "imx-uart", |
| 44 | .id = 0, |
| 45 | .resource = uart0, |
| 46 | .num_resources = ARRAY_SIZE(uart0), |
| 47 | }; |
| 48 | |
| 49 | static struct resource uart1[] = { |
| 50 | { |
| 51 | .start = UART2_BASE_ADDR, |
| 52 | .end = UART2_BASE_ADDR + 0x0B5, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, { |
| 55 | .start = MXC_INT_UART2, |
| 56 | .end = MXC_INT_UART2, |
| 57 | .flags = IORESOURCE_IRQ, |
| 58 | }, |
| 59 | }; |
| 60 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 61 | struct platform_device mxc_uart_device1 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 62 | .name = "imx-uart", |
| 63 | .id = 1, |
| 64 | .resource = uart1, |
| 65 | .num_resources = ARRAY_SIZE(uart1), |
| 66 | }; |
| 67 | |
| 68 | static struct resource uart2[] = { |
| 69 | { |
| 70 | .start = UART3_BASE_ADDR, |
| 71 | .end = UART3_BASE_ADDR + 0x0B5, |
| 72 | .flags = IORESOURCE_MEM, |
| 73 | }, { |
| 74 | .start = MXC_INT_UART3, |
| 75 | .end = MXC_INT_UART3, |
| 76 | .flags = IORESOURCE_IRQ, |
| 77 | }, |
| 78 | }; |
| 79 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 80 | struct platform_device mxc_uart_device2 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 81 | .name = "imx-uart", |
| 82 | .id = 2, |
| 83 | .resource = uart2, |
| 84 | .num_resources = ARRAY_SIZE(uart2), |
| 85 | }; |
| 86 | |
| 87 | static struct resource uart3[] = { |
| 88 | { |
| 89 | .start = UART4_BASE_ADDR, |
| 90 | .end = UART4_BASE_ADDR + 0x0B5, |
| 91 | .flags = IORESOURCE_MEM, |
| 92 | }, { |
| 93 | .start = MXC_INT_UART4, |
| 94 | .end = MXC_INT_UART4, |
| 95 | .flags = IORESOURCE_IRQ, |
| 96 | }, |
| 97 | }; |
| 98 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 99 | struct platform_device mxc_uart_device3 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 100 | .name = "imx-uart", |
| 101 | .id = 3, |
| 102 | .resource = uart3, |
| 103 | .num_resources = ARRAY_SIZE(uart3), |
| 104 | }; |
| 105 | |
| 106 | static struct resource uart4[] = { |
| 107 | { |
| 108 | .start = UART5_BASE_ADDR, |
| 109 | .end = UART5_BASE_ADDR + 0x0B5, |
| 110 | .flags = IORESOURCE_MEM, |
| 111 | }, { |
| 112 | .start = MXC_INT_UART5, |
| 113 | .end = MXC_INT_UART5, |
| 114 | .flags = IORESOURCE_IRQ, |
| 115 | }, |
| 116 | }; |
| 117 | |
Sascha Hauer | 5cf0942 | 2008-09-09 10:19:41 +0200 | [diff] [blame] | 118 | struct platform_device mxc_uart_device4 = { |
Sascha Hauer | e3d13ff | 2008-07-05 10:02:48 +0200 | [diff] [blame] | 119 | .name = "imx-uart", |
| 120 | .id = 4, |
| 121 | .resource = uart4, |
| 122 | .num_resources = ARRAY_SIZE(uart4), |
| 123 | }; |
| 124 | |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 125 | /* GPIO port description */ |
| 126 | static struct mxc_gpio_port imx_gpio_ports[] = { |
| 127 | [0] = { |
| 128 | .chip.label = "gpio-0", |
| 129 | .base = IO_ADDRESS(GPIO1_BASE_ADDR), |
| 130 | .irq = MXC_INT_GPIO1, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 131 | .virtual_irq_start = MXC_GPIO_IRQ_START, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 132 | }, |
| 133 | [1] = { |
| 134 | .chip.label = "gpio-1", |
| 135 | .base = IO_ADDRESS(GPIO2_BASE_ADDR), |
| 136 | .irq = MXC_INT_GPIO2, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 137 | .virtual_irq_start = MXC_GPIO_IRQ_START + 32, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 138 | }, |
| 139 | [2] = { |
| 140 | .chip.label = "gpio-2", |
| 141 | .base = IO_ADDRESS(GPIO3_BASE_ADDR), |
| 142 | .irq = MXC_INT_GPIO3, |
Sascha Hauer | 9d631b8 | 2008-12-18 11:08:55 +0100 | [diff] [blame] | 143 | .virtual_irq_start = MXC_GPIO_IRQ_START + 64, |
Juergen Beisert | 07bd1a6 | 2008-07-05 10:02:49 +0200 | [diff] [blame] | 144 | } |
| 145 | }; |
| 146 | |
| 147 | int __init mxc_register_gpios(void) |
| 148 | { |
| 149 | return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); |
| 150 | } |
Sascha Hauer | a840592 | 2008-12-01 14:15:39 -0800 | [diff] [blame] | 151 | |
| 152 | static struct resource mxc_w1_master_resources[] = { |
| 153 | { |
| 154 | .start = OWIRE_BASE_ADDR, |
| 155 | .end = OWIRE_BASE_ADDR + SZ_4K - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | }, |
| 158 | }; |
| 159 | |
| 160 | struct platform_device mxc_w1_master_device = { |
| 161 | .name = "mxc_w1", |
| 162 | .id = 0, |
| 163 | .num_resources = ARRAY_SIZE(mxc_w1_master_resources), |
| 164 | .resource = mxc_w1_master_resources, |
| 165 | }; |
Sascha Hauer | cb96cf1 | 2008-11-11 15:15:39 +0100 | [diff] [blame] | 166 | |
| 167 | static struct resource mxc_nand_resources[] = { |
| 168 | { |
| 169 | .start = NFC_BASE_ADDR, |
| 170 | .end = NFC_BASE_ADDR + 0xfff, |
| 171 | .flags = IORESOURCE_MEM |
| 172 | }, { |
| 173 | .start = MXC_INT_NANDFC, |
| 174 | .end = MXC_INT_NANDFC, |
| 175 | .flags = IORESOURCE_IRQ |
| 176 | }, |
| 177 | }; |
| 178 | |
| 179 | struct platform_device mxc_nand_device = { |
| 180 | .name = "mxc_nand", |
| 181 | .id = 0, |
| 182 | .num_resources = ARRAY_SIZE(mxc_nand_resources), |
| 183 | .resource = mxc_nand_resources, |
| 184 | }; |
Mark Brown | 39d1dc0 | 2009-01-15 16:14:27 +0000 | [diff] [blame] | 185 | |
| 186 | static struct resource mxc_i2c0_resources[] = { |
| 187 | { |
| 188 | .start = I2C_BASE_ADDR, |
| 189 | .end = I2C_BASE_ADDR + SZ_4K - 1, |
| 190 | .flags = IORESOURCE_MEM, |
| 191 | }, |
| 192 | { |
| 193 | .start = MXC_INT_I2C, |
| 194 | .end = MXC_INT_I2C, |
| 195 | .flags = IORESOURCE_IRQ, |
| 196 | }, |
| 197 | }; |
| 198 | |
| 199 | struct platform_device mxc_i2c_device0 = { |
| 200 | .name = "imx-i2c", |
| 201 | .id = 0, |
| 202 | .num_resources = ARRAY_SIZE(mxc_i2c0_resources), |
| 203 | .resource = mxc_i2c0_resources, |
| 204 | }; |
| 205 | |
| 206 | static struct resource mxc_i2c1_resources[] = { |
| 207 | { |
| 208 | .start = I2C2_BASE_ADDR, |
| 209 | .end = I2C2_BASE_ADDR + SZ_4K - 1, |
| 210 | .flags = IORESOURCE_MEM, |
| 211 | }, |
| 212 | { |
| 213 | .start = MXC_INT_I2C2, |
| 214 | .end = MXC_INT_I2C2, |
| 215 | .flags = IORESOURCE_IRQ, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | struct platform_device mxc_i2c_device1 = { |
| 220 | .name = "imx-i2c", |
| 221 | .id = 1, |
| 222 | .num_resources = ARRAY_SIZE(mxc_i2c1_resources), |
| 223 | .resource = mxc_i2c1_resources, |
| 224 | }; |
| 225 | |
| 226 | static struct resource mxc_i2c2_resources[] = { |
| 227 | { |
| 228 | .start = I2C3_BASE_ADDR, |
| 229 | .end = I2C3_BASE_ADDR + SZ_4K - 1, |
| 230 | .flags = IORESOURCE_MEM, |
| 231 | }, |
| 232 | { |
| 233 | .start = MXC_INT_I2C3, |
| 234 | .end = MXC_INT_I2C3, |
| 235 | .flags = IORESOURCE_IRQ, |
| 236 | }, |
| 237 | }; |
| 238 | |
| 239 | struct platform_device mxc_i2c_device2 = { |
| 240 | .name = "imx-i2c", |
| 241 | .id = 2, |
| 242 | .num_resources = ARRAY_SIZE(mxc_i2c2_resources), |
| 243 | .resource = mxc_i2c2_resources, |
| 244 | }; |
Valentin Longchamp | ca489f8 | 2009-02-16 12:47:52 +0100 | [diff] [blame^] | 245 | |
| 246 | /* i.MX31 Image Processing Unit */ |
| 247 | |
| 248 | /* The resource order is important! */ |
| 249 | static struct resource mx3_ipu_rsrc[] = { |
| 250 | { |
| 251 | .start = IPU_CTRL_BASE_ADDR, |
| 252 | .end = IPU_CTRL_BASE_ADDR + 0x5F, |
| 253 | .flags = IORESOURCE_MEM, |
| 254 | }, { |
| 255 | .start = IPU_CTRL_BASE_ADDR + 0x88, |
| 256 | .end = IPU_CTRL_BASE_ADDR + 0xB3, |
| 257 | .flags = IORESOURCE_MEM, |
| 258 | }, { |
| 259 | .start = MXC_INT_IPU_SYN, |
| 260 | .end = MXC_INT_IPU_SYN, |
| 261 | .flags = IORESOURCE_IRQ, |
| 262 | }, { |
| 263 | .start = MXC_INT_IPU_ERR, |
| 264 | .end = MXC_INT_IPU_ERR, |
| 265 | .flags = IORESOURCE_IRQ, |
| 266 | }, |
| 267 | }; |
| 268 | |
| 269 | struct platform_device mx3_ipu = { |
| 270 | .name = "ipu-core", |
| 271 | .id = -1, |
| 272 | .num_resources = ARRAY_SIZE(mx3_ipu_rsrc), |
| 273 | .resource = mx3_ipu_rsrc, |
| 274 | }; |
| 275 | |
| 276 | static struct resource fb_resources[] = { |
| 277 | { |
| 278 | .start = IPU_CTRL_BASE_ADDR + 0xB4, |
| 279 | .end = IPU_CTRL_BASE_ADDR + 0x1BF, |
| 280 | .flags = IORESOURCE_MEM, |
| 281 | }, |
| 282 | }; |
| 283 | |
| 284 | struct platform_device mx3_fb = { |
| 285 | .name = "mx3_sdc_fb", |
| 286 | .id = -1, |
| 287 | .num_resources = ARRAY_SIZE(fb_resources), |
| 288 | .resource = fb_resources, |
| 289 | .dev = { |
| 290 | .coherent_dma_mask = 0xffffffff, |
| 291 | }, |
| 292 | }; |