Kukjin Kim | 61c542b | 2011-10-03 09:46:13 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/plat-samsung/devs.c |
| 2 | * |
| 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com |
| 5 | * |
| 6 | * Base SAMSUNG platform device definitions |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/list.h> |
| 17 | #include <linux/timer.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/serial_core.h> |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/io.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/dma-mapping.h> |
Kukjin Kim | 0523ec3 | 2011-10-03 09:46:56 +0900 | [diff] [blame^] | 25 | #include <linux/mtd/mtd.h> |
| 26 | #include <linux/mtd/onenand.h> |
Kukjin Kim | 61c542b | 2011-10-03 09:46:13 +0900 | [diff] [blame] | 27 | |
| 28 | #include <asm/irq.h> |
| 29 | #include <asm/mach/arch.h> |
| 30 | #include <asm/mach/map.h> |
| 31 | #include <asm/mach/irq.h> |
| 32 | |
| 33 | #include <mach/hardware.h> |
| 34 | #include <mach/dma.h> |
| 35 | #include <mach/irqs.h> |
| 36 | #include <mach/map.h> |
| 37 | |
| 38 | #include <plat/cpu.h> |
| 39 | #include <plat/devs.h> |
| 40 | #include <plat/fb.h> |
| 41 | #include <plat/fb-s3c2410.h> |
| 42 | #include <plat/mci.h> |
| 43 | #include <plat/ts.h> |
| 44 | #include <plat/udc.h> |
| 45 | #include <plat/regs-serial.h> |
| 46 | #include <plat/regs-spi.h> |
| 47 | |
| 48 | static u64 samsung_device_dma_mask = DMA_BIT_MASK(32); |
| 49 | |
| 50 | /* AC97 */ |
| 51 | #ifdef CONFIG_CPU_S3C2440 |
| 52 | static struct resource s3c_ac97_resource[] = { |
| 53 | [0] = { |
| 54 | .start = S3C2440_PA_AC97, |
| 55 | .end = S3C2440_PA_AC97 + S3C2440_SZ_AC97 - 1, |
| 56 | .flags = IORESOURCE_MEM, |
| 57 | }, |
| 58 | [1] = { |
| 59 | .start = IRQ_S3C244x_AC97, |
| 60 | .end = IRQ_S3C244x_AC97, |
| 61 | .flags = IORESOURCE_IRQ, |
| 62 | }, |
| 63 | [2] = { |
| 64 | .name = "PCM out", |
| 65 | .start = DMACH_PCM_OUT, |
| 66 | .end = DMACH_PCM_OUT, |
| 67 | .flags = IORESOURCE_DMA, |
| 68 | }, |
| 69 | [3] = { |
| 70 | .name = "PCM in", |
| 71 | .start = DMACH_PCM_IN, |
| 72 | .end = DMACH_PCM_IN, |
| 73 | .flags = IORESOURCE_DMA, |
| 74 | }, |
| 75 | [4] = { |
| 76 | .name = "Mic in", |
| 77 | .start = DMACH_MIC_IN, |
| 78 | .end = DMACH_MIC_IN, |
| 79 | .flags = IORESOURCE_DMA, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | struct platform_device s3c_device_ac97 = { |
| 84 | .name = "samsung-ac97", |
| 85 | .id = -1, |
| 86 | .num_resources = ARRAY_SIZE(s3c_ac97_resource), |
| 87 | .resource = s3c_ac97_resource, |
| 88 | .dev = { |
| 89 | .dma_mask = &samsung_device_dma_mask, |
| 90 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 91 | } |
| 92 | }; |
| 93 | #endif /* CONFIG_CPU_S3C2440 */ |
| 94 | |
| 95 | /* ADC */ |
| 96 | |
| 97 | #ifdef CONFIG_PLAT_S3C24XX |
| 98 | static struct resource s3c_adc_resource[] = { |
| 99 | [0] = { |
| 100 | .start = S3C24XX_PA_ADC, |
| 101 | .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1, |
| 102 | .flags = IORESOURCE_MEM, |
| 103 | }, |
| 104 | [1] = { |
| 105 | .start = IRQ_TC, |
| 106 | .end = IRQ_TC, |
| 107 | .flags = IORESOURCE_IRQ, |
| 108 | }, |
| 109 | [2] = { |
| 110 | .start = IRQ_ADC, |
| 111 | .end = IRQ_ADC, |
| 112 | .flags = IORESOURCE_IRQ, |
| 113 | } |
| 114 | }; |
| 115 | |
| 116 | struct platform_device s3c_device_adc = { |
| 117 | .name = "s3c24xx-adc", |
| 118 | .id = -1, |
| 119 | .num_resources = ARRAY_SIZE(s3c_adc_resource), |
| 120 | .resource = s3c_adc_resource, |
| 121 | }; |
| 122 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 123 | |
| 124 | /* Camif Controller */ |
| 125 | |
| 126 | #ifdef CONFIG_CPU_S3C2440 |
| 127 | static struct resource s3c_camif_resource[] = { |
| 128 | [0] = { |
| 129 | .start = S3C2440_PA_CAMIF, |
| 130 | .end = S3C2440_PA_CAMIF + S3C2440_SZ_CAMIF - 1, |
| 131 | .flags = IORESOURCE_MEM, |
| 132 | }, |
| 133 | [1] = { |
| 134 | .start = IRQ_CAM, |
| 135 | .end = IRQ_CAM, |
| 136 | .flags = IORESOURCE_IRQ, |
| 137 | } |
| 138 | }; |
| 139 | |
| 140 | struct platform_device s3c_device_camif = { |
| 141 | .name = "s3c2440-camif", |
| 142 | .id = -1, |
| 143 | .num_resources = ARRAY_SIZE(s3c_camif_resource), |
| 144 | .resource = s3c_camif_resource, |
| 145 | .dev = { |
| 146 | .dma_mask = &samsung_device_dma_mask, |
| 147 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 148 | } |
| 149 | }; |
| 150 | #endif /* CONFIG_CPU_S3C2440 */ |
| 151 | |
| 152 | /* I2S */ |
| 153 | |
| 154 | #ifdef CONFIG_PLAT_S3C24XX |
| 155 | static struct resource s3c_iis_resource[] = { |
| 156 | [0] = { |
| 157 | .start = S3C24XX_PA_IIS, |
| 158 | .end = S3C24XX_PA_IIS + S3C24XX_SZ_IIS - 1, |
| 159 | .flags = IORESOURCE_MEM, |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | struct platform_device s3c_device_iis = { |
| 164 | .name = "s3c24xx-iis", |
| 165 | .id = -1, |
| 166 | .num_resources = ARRAY_SIZE(s3c_iis_resource), |
| 167 | .resource = s3c_iis_resource, |
| 168 | .dev = { |
| 169 | .dma_mask = &samsung_device_dma_mask, |
| 170 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 171 | } |
| 172 | }; |
| 173 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 174 | |
| 175 | #ifdef CONFIG_CPU_S3C2440 |
| 176 | struct platform_device s3c2412_device_iis = { |
| 177 | .name = "s3c2412-iis", |
| 178 | .id = -1, |
| 179 | .dev = { |
| 180 | .dma_mask = &samsung_device_dma_mask, |
| 181 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 182 | } |
| 183 | }; |
| 184 | #endif /* CONFIG_CPU_S3C2440 */ |
| 185 | |
| 186 | /* LCD Controller */ |
| 187 | |
| 188 | #ifdef CONFIG_PLAT_S3C24XX |
| 189 | static struct resource s3c_lcd_resource[] = { |
| 190 | [0] = { |
| 191 | .start = S3C24XX_PA_LCD, |
| 192 | .end = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1, |
| 193 | .flags = IORESOURCE_MEM, |
| 194 | }, |
| 195 | [1] = { |
| 196 | .start = IRQ_LCD, |
| 197 | .end = IRQ_LCD, |
| 198 | .flags = IORESOURCE_IRQ, |
| 199 | } |
| 200 | }; |
| 201 | |
| 202 | struct platform_device s3c_device_lcd = { |
| 203 | .name = "s3c2410-lcd", |
| 204 | .id = -1, |
| 205 | .num_resources = ARRAY_SIZE(s3c_lcd_resource), |
| 206 | .resource = s3c_lcd_resource, |
| 207 | .dev = { |
| 208 | .dma_mask = &samsung_device_dma_mask, |
| 209 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 210 | } |
| 211 | }; |
| 212 | |
| 213 | void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd) |
| 214 | { |
| 215 | struct s3c2410fb_mach_info *npd; |
| 216 | |
| 217 | npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd); |
| 218 | if (npd) { |
| 219 | npd->displays = kmemdup(pd->displays, |
| 220 | sizeof(struct s3c2410fb_display) * npd->num_displays, |
| 221 | GFP_KERNEL); |
| 222 | if (!npd->displays) |
| 223 | printk(KERN_ERR "no memory for LCD display data\n"); |
| 224 | } else { |
| 225 | printk(KERN_ERR "no memory for LCD platform data\n"); |
| 226 | } |
| 227 | } |
| 228 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 229 | |
Kukjin Kim | 0523ec3 | 2011-10-03 09:46:56 +0900 | [diff] [blame^] | 230 | #ifdef CONFIG_S3C64XX_DEV_ONENAND1 |
| 231 | static struct resource s3c64xx_onenand1_resources[] = { |
| 232 | [0] = { |
| 233 | .start = S3C64XX_PA_ONENAND1, |
| 234 | .end = S3C64XX_PA_ONENAND1 + 0x400 - 1, |
| 235 | .flags = IORESOURCE_MEM, |
| 236 | }, |
| 237 | [1] = { |
| 238 | .start = S3C64XX_PA_ONENAND1_BUF, |
| 239 | .end = S3C64XX_PA_ONENAND1_BUF + S3C64XX_SZ_ONENAND1_BUF - 1, |
| 240 | .flags = IORESOURCE_MEM, |
| 241 | }, |
| 242 | [2] = { |
| 243 | .start = IRQ_ONENAND1, |
| 244 | .end = IRQ_ONENAND1, |
| 245 | .flags = IORESOURCE_IRQ, |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | struct platform_device s3c64xx_device_onenand1 = { |
| 250 | .name = "samsung-onenand", |
| 251 | .id = 1, |
| 252 | .num_resources = ARRAY_SIZE(s3c64xx_onenand1_resources), |
| 253 | .resource = s3c64xx_onenand1_resources, |
| 254 | }; |
| 255 | |
| 256 | void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata) |
| 257 | { |
| 258 | s3c_set_platdata(pdata, sizeof(struct onenand_platform_data), |
| 259 | &s3c64xx_device_onenand1); |
| 260 | } |
| 261 | #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */ |
| 262 | |
Kukjin Kim | 61c542b | 2011-10-03 09:46:13 +0900 | [diff] [blame] | 263 | /* RTC */ |
| 264 | |
| 265 | #ifdef CONFIG_PLAT_S3C24XX |
| 266 | static struct resource s3c_rtc_resource[] = { |
| 267 | [0] = { |
| 268 | .start = S3C24XX_PA_RTC, |
| 269 | .end = S3C24XX_PA_RTC + 0xff, |
| 270 | .flags = IORESOURCE_MEM, |
| 271 | }, |
| 272 | [1] = { |
| 273 | .start = IRQ_RTC, |
| 274 | .end = IRQ_RTC, |
| 275 | .flags = IORESOURCE_IRQ, |
| 276 | }, |
| 277 | [2] = { |
| 278 | .start = IRQ_TICK, |
| 279 | .end = IRQ_TICK, |
| 280 | .flags = IORESOURCE_IRQ |
| 281 | } |
| 282 | }; |
| 283 | |
| 284 | struct platform_device s3c_device_rtc = { |
| 285 | .name = "s3c2410-rtc", |
| 286 | .id = -1, |
| 287 | .num_resources = ARRAY_SIZE(s3c_rtc_resource), |
| 288 | .resource = s3c_rtc_resource, |
| 289 | }; |
| 290 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 291 | |
| 292 | /* SDI */ |
| 293 | |
| 294 | #ifdef CONFIG_PLAT_S3C24XX |
| 295 | static struct resource s3c_sdi_resource[] = { |
| 296 | [0] = { |
| 297 | .start = S3C24XX_PA_SDI, |
| 298 | .end = S3C24XX_PA_SDI + S3C24XX_SZ_SDI - 1, |
| 299 | .flags = IORESOURCE_MEM, |
| 300 | }, |
| 301 | [1] = { |
| 302 | .start = IRQ_SDI, |
| 303 | .end = IRQ_SDI, |
| 304 | .flags = IORESOURCE_IRQ, |
| 305 | } |
| 306 | }; |
| 307 | |
| 308 | struct platform_device s3c_device_sdi = { |
| 309 | .name = "s3c2410-sdi", |
| 310 | .id = -1, |
| 311 | .num_resources = ARRAY_SIZE(s3c_sdi_resource), |
| 312 | .resource = s3c_sdi_resource, |
| 313 | }; |
| 314 | |
| 315 | void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata) |
| 316 | { |
| 317 | s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata), |
| 318 | &s3c_device_sdi); |
| 319 | } |
| 320 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 321 | |
| 322 | /* SPI */ |
| 323 | |
| 324 | #ifdef CONFIG_PLAT_S3C24XX |
| 325 | static struct resource s3c_spi0_resource[] = { |
| 326 | [0] = { |
| 327 | .start = S3C24XX_PA_SPI, |
| 328 | .end = S3C24XX_PA_SPI + 0x1f, |
| 329 | .flags = IORESOURCE_MEM, |
| 330 | }, |
| 331 | [1] = { |
| 332 | .start = IRQ_SPI0, |
| 333 | .end = IRQ_SPI0, |
| 334 | .flags = IORESOURCE_IRQ, |
| 335 | } |
| 336 | }; |
| 337 | |
| 338 | struct platform_device s3c_device_spi0 = { |
| 339 | .name = "s3c2410-spi", |
| 340 | .id = 0, |
| 341 | .num_resources = ARRAY_SIZE(s3c_spi0_resource), |
| 342 | .resource = s3c_spi0_resource, |
| 343 | .dev = { |
| 344 | .dma_mask = &samsung_device_dma_mask, |
| 345 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 346 | } |
| 347 | }; |
| 348 | |
| 349 | static struct resource s3c_spi1_resource[] = { |
| 350 | [0] = { |
| 351 | .start = S3C24XX_PA_SPI + S3C2410_SPI1, |
| 352 | .end = S3C24XX_PA_SPI + S3C2410_SPI1 + 0x1f, |
| 353 | .flags = IORESOURCE_MEM, |
| 354 | }, |
| 355 | [1] = { |
| 356 | .start = IRQ_SPI1, |
| 357 | .end = IRQ_SPI1, |
| 358 | .flags = IORESOURCE_IRQ, |
| 359 | } |
| 360 | }; |
| 361 | |
| 362 | struct platform_device s3c_device_spi1 = { |
| 363 | .name = "s3c2410-spi", |
| 364 | .id = 1, |
| 365 | .num_resources = ARRAY_SIZE(s3c_spi1_resource), |
| 366 | .resource = s3c_spi1_resource, |
| 367 | .dev = { |
| 368 | .dma_mask = &samsung_device_dma_mask, |
| 369 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 370 | } |
| 371 | }; |
| 372 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 373 | |
| 374 | /* Touchscreen */ |
| 375 | |
| 376 | #ifdef CONFIG_PLAT_S3C24XX |
| 377 | static struct resource s3c_ts_resource[] = { |
| 378 | [0] = { |
| 379 | .start = S3C24XX_PA_ADC, |
| 380 | .end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1, |
| 381 | .flags = IORESOURCE_MEM, |
| 382 | }, |
| 383 | [1] = { |
| 384 | .start = IRQ_TC, |
| 385 | .end = IRQ_TC, |
| 386 | .flags = IORESOURCE_IRQ, |
| 387 | }, |
| 388 | |
| 389 | }; |
| 390 | |
| 391 | struct platform_device s3c_device_ts = { |
| 392 | .name = "s3c2410-ts", |
| 393 | .id = -1, |
| 394 | .dev.parent = &s3c_device_adc.dev, |
| 395 | .num_resources = ARRAY_SIZE(s3c_ts_resource), |
| 396 | .resource = s3c_ts_resource, |
| 397 | }; |
| 398 | |
| 399 | void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info) |
| 400 | { |
| 401 | s3c_set_platdata(hard_s3c2410ts_info, |
| 402 | sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts); |
| 403 | } |
| 404 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 405 | |
| 406 | /* USB Device (Gadget) */ |
| 407 | |
| 408 | #ifdef CONFIG_PLAT_S3C24XX |
| 409 | static struct resource s3c_usbgadget_resource[] = { |
| 410 | [0] = { |
| 411 | .start = S3C24XX_PA_USBDEV, |
| 412 | .end = S3C24XX_PA_USBDEV + S3C24XX_SZ_USBDEV - 1, |
| 413 | .flags = IORESOURCE_MEM, |
| 414 | }, |
| 415 | [1] = { |
| 416 | .start = IRQ_USBD, |
| 417 | .end = IRQ_USBD, |
| 418 | .flags = IORESOURCE_IRQ, |
| 419 | } |
| 420 | }; |
| 421 | |
| 422 | struct platform_device s3c_device_usbgadget = { |
| 423 | .name = "s3c2410-usbgadget", |
| 424 | .id = -1, |
| 425 | .num_resources = ARRAY_SIZE(s3c_usbgadget_resource), |
| 426 | .resource = s3c_usbgadget_resource, |
| 427 | }; |
| 428 | |
| 429 | void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd) |
| 430 | { |
| 431 | s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget); |
| 432 | } |
| 433 | #endif /* CONFIG_PLAT_S3C24XX */ |
| 434 | |
| 435 | /* USB High Spped 2.0 Device (Gadget) */ |
| 436 | |
| 437 | #ifdef CONFIG_PLAT_S3C24XX |
| 438 | static struct resource s3c_hsudc_resource[] = { |
| 439 | [0] = { |
| 440 | .start = S3C2416_PA_HSUDC, |
| 441 | .end = S3C2416_PA_HSUDC + S3C2416_SZ_HSUDC - 1, |
| 442 | .flags = IORESOURCE_MEM, |
| 443 | }, |
| 444 | [1] = { |
| 445 | .start = IRQ_USBD, |
| 446 | .end = IRQ_USBD, |
| 447 | .flags = IORESOURCE_IRQ, |
| 448 | } |
| 449 | }; |
| 450 | |
| 451 | struct platform_device s3c_device_usb_hsudc = { |
| 452 | .name = "s3c-hsudc", |
| 453 | .id = -1, |
| 454 | .num_resources = ARRAY_SIZE(s3c_hsudc_resource), |
| 455 | .resource = s3c_hsudc_resource, |
| 456 | .dev = { |
| 457 | .dma_mask = &samsung_device_dma_mask, |
| 458 | .coherent_dma_mask = DMA_BIT_MASK(32), |
| 459 | }, |
| 460 | }; |
| 461 | |
| 462 | void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd) |
| 463 | { |
| 464 | s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc); |
| 465 | } |
| 466 | #endif /* CONFIG_PLAT_S3C24XX */ |