1/* 2 * Copyright 2009 Sascha Hauer, <kernel@pengutronix.de> 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * Boston, MA 02110-1301, USA. 17 */ 18 19#include <linux/platform_device.h> 20#include <linux/dma-mapping.h> 21#include <linux/gpio.h> 22#include <mach/mx25.h> 23#include <mach/irqs.h> 24 25static u64 otg_dmamask = DMA_BIT_MASK(32); 26 27static struct resource mxc_otg_resources[] = { 28 { 29 .start = MX25_OTG_BASE_ADDR, 30 .end = MX25_OTG_BASE_ADDR + 0x1ff, 31 .flags = IORESOURCE_MEM, 32 }, { 33 .start = 37, 34 .end = 37, 35 .flags = IORESOURCE_IRQ, 36 }, 37}; 38 39struct platform_device mxc_otg = { 40 .name = "mxc-ehci", 41 .id = 0, 42 .dev = { 43 .coherent_dma_mask = 0xffffffff, 44 .dma_mask = &otg_dmamask, 45 }, 46 .resource = mxc_otg_resources, 47 .num_resources = ARRAY_SIZE(mxc_otg_resources), 48}; 49 50/* OTG gadget device */ 51struct platform_device otg_udc_device = { 52 .name = "fsl-usb2-udc", 53 .id = -1, 54 .dev = { 55 .dma_mask = &otg_dmamask, 56 .coherent_dma_mask = 0xffffffff, 57 }, 58 .resource = mxc_otg_resources, 59 .num_resources = ARRAY_SIZE(mxc_otg_resources), 60}; 61 62static u64 usbh2_dmamask = DMA_BIT_MASK(32); 63 64static struct resource mxc_usbh2_resources[] = { 65 { 66 .start = MX25_OTG_BASE_ADDR + 0x400, 67 .end = MX25_OTG_BASE_ADDR + 0x5ff, 68 .flags = IORESOURCE_MEM, 69 }, { 70 .start = 35, 71 .end = 35, 72 .flags = IORESOURCE_IRQ, 73 }, 74}; 75 76struct platform_device mxc_usbh2 = { 77 .name = "mxc-ehci", 78 .id = 1, 79 .dev = { 80 .coherent_dma_mask = 0xffffffff, 81 .dma_mask = &usbh2_dmamask, 82 }, 83 .resource = mxc_usbh2_resources, 84 .num_resources = ARRAY_SIZE(mxc_usbh2_resources), 85}; 86 87static struct resource mxc_pwm_resources0[] = { 88 { 89 .start = 0x53fe0000, 90 .end = 0x53fe3fff, 91 .flags = IORESOURCE_MEM, 92 }, { 93 .start = 26, 94 .end = 26, 95 .flags = IORESOURCE_IRQ, 96 } 97}; 98 99struct platform_device mxc_pwm_device0 = { 100 .name = "mxc_pwm", 101 .id = 0, 102 .num_resources = ARRAY_SIZE(mxc_pwm_resources0), 103 .resource = mxc_pwm_resources0, 104}; 105 106static struct resource mxc_pwm_resources1[] = { 107 { 108 .start = 0x53fa0000, 109 .end = 0x53fa3fff, 110 .flags = IORESOURCE_MEM, 111 }, { 112 .start = 36, 113 .end = 36, 114 .flags = IORESOURCE_IRQ, 115 } 116}; 117 118struct platform_device mxc_pwm_device1 = { 119 .name = "mxc_pwm", 120 .id = 1, 121 .num_resources = ARRAY_SIZE(mxc_pwm_resources1), 122 .resource = mxc_pwm_resources1, 123}; 124 125static struct resource mxc_pwm_resources2[] = { 126 { 127 .start = 0x53fa8000, 128 .end = 0x53fabfff, 129 .flags = IORESOURCE_MEM, 130 }, { 131 .start = 41, 132 .end = 41, 133 .flags = IORESOURCE_IRQ, 134 } 135}; 136 137struct platform_device mxc_pwm_device2 = { 138 .name = "mxc_pwm", 139 .id = 2, 140 .num_resources = ARRAY_SIZE(mxc_pwm_resources2), 141 .resource = mxc_pwm_resources2, 142}; 143 144static struct resource mxc_keypad_resources[] = { 145 { 146 .start = 0x43fa8000, 147 .end = 0x43fabfff, 148 .flags = IORESOURCE_MEM, 149 }, { 150 .start = 24, 151 .end = 24, 152 .flags = IORESOURCE_IRQ, 153 } 154}; 155 156struct platform_device mxc_keypad_device = { 157 .name = "mxc-keypad", 158 .id = -1, 159 .num_resources = ARRAY_SIZE(mxc_keypad_resources), 160 .resource = mxc_keypad_resources, 161}; 162 163static struct resource mxc_pwm_resources3[] = { 164 { 165 .start = 0x53fc8000, 166 .end = 0x53fcbfff, 167 .flags = IORESOURCE_MEM, 168 }, { 169 .start = 42, 170 .end = 42, 171 .flags = IORESOURCE_IRQ, 172 } 173}; 174 175struct platform_device mxc_pwm_device3 = { 176 .name = "mxc_pwm", 177 .id = 3, 178 .num_resources = ARRAY_SIZE(mxc_pwm_resources3), 179 .resource = mxc_pwm_resources3, 180}; 181 182static struct mxc_gpio_port imx_gpio_ports[] = { 183 { 184 .chip.label = "gpio-0", 185 .base = (void __iomem *)MX25_GPIO1_BASE_ADDR_VIRT, 186 .irq = 52, 187 .virtual_irq_start = MXC_GPIO_IRQ_START, 188 }, { 189 .chip.label = "gpio-1", 190 .base = (void __iomem *)MX25_GPIO2_BASE_ADDR_VIRT, 191 .irq = 51, 192 .virtual_irq_start = MXC_GPIO_IRQ_START + 32, 193 }, { 194 .chip.label = "gpio-2", 195 .base = (void __iomem *)MX25_GPIO3_BASE_ADDR_VIRT, 196 .irq = 16, 197 .virtual_irq_start = MXC_GPIO_IRQ_START + 64, 198 }, { 199 .chip.label = "gpio-3", 200 .base = (void __iomem *)MX25_GPIO4_BASE_ADDR_VIRT, 201 .irq = 23, 202 .virtual_irq_start = MXC_GPIO_IRQ_START + 96, 203 } 204}; 205 206int __init imx25_register_gpios(void) 207{ 208 return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports)); 209} 210 211static struct resource mx25_fec_resources[] = { 212 { 213 .start = MX25_FEC_BASE_ADDR, 214 .end = MX25_FEC_BASE_ADDR + 0xfff, 215 .flags = IORESOURCE_MEM, 216 }, 217 { 218 .start = MX25_INT_FEC, 219 .end = MX25_INT_FEC, 220 .flags = IORESOURCE_IRQ, 221 }, 222}; 223 224struct platform_device mx25_fec_device = { 225 .name = "fec", 226 .id = 0, 227 .num_resources = ARRAY_SIZE(mx25_fec_resources), 228 .resource = mx25_fec_resources, 229}; 230 231static struct resource mx25_rtc_resources[] = { 232 { 233 .start = MX25_DRYICE_BASE_ADDR, 234 .end = MX25_DRYICE_BASE_ADDR + 0x40, 235 .flags = IORESOURCE_MEM, 236 }, 237 { 238 .start = MX25_INT_DRYICE, 239 .flags = IORESOURCE_IRQ 240 }, 241}; 242 243struct platform_device mx25_rtc_device = { 244 .name = "imxdi_rtc", 245 .id = 0, 246 .num_resources = ARRAY_SIZE(mx25_rtc_resources), 247 .resource = mx25_rtc_resources, 248}; 249 250static struct resource mx25_fb_resources[] = { 251 { 252 .start = MX25_LCDC_BASE_ADDR, 253 .end = MX25_LCDC_BASE_ADDR + 0xfff, 254 .flags = IORESOURCE_MEM, 255 }, 256 { 257 .start = MX25_INT_LCDC, 258 .end = MX25_INT_LCDC, 259 .flags = IORESOURCE_IRQ, 260 }, 261}; 262 263struct platform_device mx25_fb_device = { 264 .name = "imx-fb", 265 .id = 0, 266 .resource = mx25_fb_resources, 267 .num_resources = ARRAY_SIZE(mx25_fb_resources), 268 .dev = { 269 .coherent_dma_mask = 0xFFFFFFFF, 270 }, 271}; 272 273static struct resource mxc_wdt_resources[] = { 274 { 275 .start = MX25_WDOG_BASE_ADDR, 276 .end = MX25_WDOG_BASE_ADDR + SZ_16K - 1, 277 .flags = IORESOURCE_MEM, 278 }, 279}; 280 281struct platform_device mxc_wdt = { 282 .name = "imx2-wdt", 283 .id = 0, 284 .num_resources = ARRAY_SIZE(mxc_wdt_resources), 285 .resource = mxc_wdt_resources, 286}; 287 288static struct resource mx25_kpp_resources[] = { 289 { 290 .start = MX25_KPP_BASE_ADDR, 291 .end = MX25_KPP_BASE_ADDR + 0xf, 292 .flags = IORESOURCE_MEM, 293 }, 294 { 295 .start = MX25_INT_KPP, 296 .end = MX25_INT_KPP, 297 .flags = IORESOURCE_IRQ, 298 }, 299}; 300 301struct platform_device mx25_kpp_device = { 302 .name = "imx-keypad", 303 .id = -1, 304 .num_resources = ARRAY_SIZE(mx25_kpp_resources), 305 .resource = mx25_kpp_resources, 306}; 307 308static struct resource imx_ssi_resources0[] = { 309 { 310 .start = MX25_SSI1_BASE_ADDR, 311 .end = MX25_SSI1_BASE_ADDR + 0x3fff, 312 .flags = IORESOURCE_MEM, 313 }, { 314 .start = MX25_INT_SSI1, 315 .end = MX25_INT_SSI1, 316 .flags = IORESOURCE_IRQ, 317 }, 318}; 319 320static struct resource imx_ssi_resources1[] = { 321 { 322 .start = MX25_SSI2_BASE_ADDR, 323 .end = MX25_SSI2_BASE_ADDR + 0x3fff, 324 .flags = IORESOURCE_MEM 325 }, { 326 .start = MX25_INT_SSI2, 327 .end = MX25_INT_SSI2, 328 .flags = IORESOURCE_IRQ, 329 }, 330}; 331 332struct platform_device imx_ssi_device0 = { 333 .name = "imx-ssi", 334 .id = 0, 335 .num_resources = ARRAY_SIZE(imx_ssi_resources0), 336 .resource = imx_ssi_resources0, 337}; 338 339struct platform_device imx_ssi_device1 = { 340 .name = "imx-ssi", 341 .id = 1, 342 .num_resources = ARRAY_SIZE(imx_ssi_resources1), 343 .resource = imx_ssi_resources1, 344}; 345 346static struct resource mx25_csi_resources[] = { 347 { 348 .start = MX25_CSI_BASE_ADDR, 349 .end = MX25_CSI_BASE_ADDR + 0xfff, 350 .flags = IORESOURCE_MEM, 351 }, 352 { 353 .start = MX25_INT_CSI, 354 .flags = IORESOURCE_IRQ 355 }, 356}; 357 358struct platform_device mx25_csi_device = { 359 .name = "mx2-camera", 360 .id = 0, 361 .num_resources = ARRAY_SIZE(mx25_csi_resources), 362 .resource = mx25_csi_resources, 363 .dev = { 364 .coherent_dma_mask = 0xffffffff, 365 }, 366}; 367