1 /* linux/arch/arm/plat-samsung/devs.c
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * Base SAMSUNG platform device definitions
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.
13 #include <linux/amba/pl330.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
18 #include <linux/timer.h>
19 #include <linux/init.h>
20 #include <linux/serial_core.h>
21 #include <linux/serial_s3c.h>
22 #include <linux/platform_device.h>
24 #include <linux/slab.h>
25 #include <linux/string.h>
26 #include <linux/dma-mapping.h>
28 #include <linux/gfp.h>
29 #include <linux/mtd/mtd.h>
30 #include <linux/mtd/onenand.h>
31 #include <linux/mtd/partitions.h>
32 #include <linux/mmc/host.h>
33 #include <linux/ioport.h>
34 #include <linux/sizes.h>
35 #include <linux/platform_data/s3c-hsudc.h>
36 #include <linux/platform_data/s3c-hsotg.h>
37 #include <linux/platform_data/dma-s3c24xx.h>
39 #include <media/s5p_hdmi.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
47 #include <mach/irqs.h>
51 #include <plat/devs.h>
53 #include <linux/platform_data/ata-samsung_cf.h>
55 #include <plat/fb-s3c2410.h>
56 #include <linux/platform_data/hwmon-s3c.h>
57 #include <linux/platform_data/i2c-s3c2410.h>
58 #include <plat/keypad.h>
59 #include <linux/platform_data/mmc-s3cmci.h>
60 #include <linux/platform_data/mtd-nand-s3c2410.h>
61 #include <plat/pwm-core.h>
62 #include <plat/sdhci.h>
63 #include <linux/platform_data/touchscreen-s3c2410.h>
64 #include <linux/platform_data/usb-s3c2410_udc.h>
65 #include <linux/platform_data/usb-ohci-s3c2410.h>
66 #include <plat/usb-phy.h>
67 #include <plat/regs-spi.h>
68 #include <linux/platform_data/asoc-s3c.h>
69 #include <linux/platform_data/spi-s3c64xx.h>
71 static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);
74 #ifdef CONFIG_CPU_S3C2440
75 static struct resource s3c_ac97_resource[] = {
76 [0] = DEFINE_RES_MEM(S3C2440_PA_AC97, S3C2440_SZ_AC97),
77 [1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97),
80 static struct s3c_audio_pdata s3c_ac97_pdata = {
81 .dma_playback = (void *)DMACH_PCM_OUT,
82 .dma_capture = (void *)DMACH_PCM_IN,
83 .dma_capture_mic = (void *)DMACH_MIC_IN,
86 struct platform_device s3c_device_ac97 = {
87 .name = "samsung-ac97",
89 .num_resources = ARRAY_SIZE(s3c_ac97_resource),
90 .resource = s3c_ac97_resource,
92 .dma_mask = &samsung_device_dma_mask,
93 .coherent_dma_mask = DMA_BIT_MASK(32),
94 .platform_data = &s3c_ac97_pdata,
97 #endif /* CONFIG_CPU_S3C2440 */
101 #ifdef CONFIG_PLAT_S3C24XX
102 static struct resource s3c_adc_resource[] = {
103 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
104 [1] = DEFINE_RES_IRQ(IRQ_TC),
105 [2] = DEFINE_RES_IRQ(IRQ_ADC),
108 struct platform_device s3c_device_adc = {
109 .name = "s3c24xx-adc",
111 .num_resources = ARRAY_SIZE(s3c_adc_resource),
112 .resource = s3c_adc_resource,
114 #endif /* CONFIG_PLAT_S3C24XX */
116 #if defined(CONFIG_SAMSUNG_DEV_ADC)
117 static struct resource s3c_adc_resource[] = {
118 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
119 [1] = DEFINE_RES_IRQ(IRQ_TC),
120 [2] = DEFINE_RES_IRQ(IRQ_ADC),
123 struct platform_device s3c_device_adc = {
124 .name = "samsung-adc",
126 .num_resources = ARRAY_SIZE(s3c_adc_resource),
127 .resource = s3c_adc_resource,
129 #endif /* CONFIG_SAMSUNG_DEV_ADC */
131 /* Camif Controller */
133 #ifdef CONFIG_CPU_S3C2440
134 static struct resource s3c_camif_resource[] = {
135 [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF),
136 [1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C),
137 [2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P),
140 struct platform_device s3c_device_camif = {
141 .name = "s3c2440-camif",
143 .num_resources = ARRAY_SIZE(s3c_camif_resource),
144 .resource = s3c_camif_resource,
146 .dma_mask = &samsung_device_dma_mask,
147 .coherent_dma_mask = DMA_BIT_MASK(32),
150 #endif /* CONFIG_CPU_S3C2440 */
154 #ifdef CONFIG_S3C_DEV_FB
155 static struct resource s3c_fb_resource[] = {
156 [0] = DEFINE_RES_MEM(S3C_PA_FB, SZ_16K),
157 [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC),
158 [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO),
159 [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM),
162 struct platform_device s3c_device_fb = {
165 .num_resources = ARRAY_SIZE(s3c_fb_resource),
166 .resource = s3c_fb_resource,
168 .dma_mask = &samsung_device_dma_mask,
169 .coherent_dma_mask = DMA_BIT_MASK(32),
173 void __init s3c_fb_set_platdata(struct s3c_fb_platdata *pd)
175 s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata),
178 #endif /* CONFIG_S3C_DEV_FB */
182 #ifdef CONFIG_S3C_DEV_HWMON
183 struct platform_device s3c_device_hwmon = {
186 .dev.parent = &s3c_device_adc.dev,
189 void __init s3c_hwmon_set_platdata(struct s3c_hwmon_pdata *pd)
191 s3c_set_platdata(pd, sizeof(struct s3c_hwmon_pdata),
194 #endif /* CONFIG_S3C_DEV_HWMON */
198 #ifdef CONFIG_S3C_DEV_HSMMC
199 static struct resource s3c_hsmmc_resource[] = {
200 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0, SZ_4K),
201 [1] = DEFINE_RES_IRQ(IRQ_HSMMC0),
204 struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = {
206 .host_caps = (MMC_CAP_4_BIT_DATA |
207 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
210 struct platform_device s3c_device_hsmmc0 = {
213 .num_resources = ARRAY_SIZE(s3c_hsmmc_resource),
214 .resource = s3c_hsmmc_resource,
216 .dma_mask = &samsung_device_dma_mask,
217 .coherent_dma_mask = DMA_BIT_MASK(32),
218 .platform_data = &s3c_hsmmc0_def_platdata,
222 void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd)
224 s3c_sdhci_set_platdata(pd, &s3c_hsmmc0_def_platdata);
226 #endif /* CONFIG_S3C_DEV_HSMMC */
228 #ifdef CONFIG_S3C_DEV_HSMMC1
229 static struct resource s3c_hsmmc1_resource[] = {
230 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1, SZ_4K),
231 [1] = DEFINE_RES_IRQ(IRQ_HSMMC1),
234 struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata = {
236 .host_caps = (MMC_CAP_4_BIT_DATA |
237 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
240 struct platform_device s3c_device_hsmmc1 = {
243 .num_resources = ARRAY_SIZE(s3c_hsmmc1_resource),
244 .resource = s3c_hsmmc1_resource,
246 .dma_mask = &samsung_device_dma_mask,
247 .coherent_dma_mask = DMA_BIT_MASK(32),
248 .platform_data = &s3c_hsmmc1_def_platdata,
252 void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd)
254 s3c_sdhci_set_platdata(pd, &s3c_hsmmc1_def_platdata);
256 #endif /* CONFIG_S3C_DEV_HSMMC1 */
260 #ifdef CONFIG_S3C_DEV_HSMMC2
261 static struct resource s3c_hsmmc2_resource[] = {
262 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2, SZ_4K),
263 [1] = DEFINE_RES_IRQ(IRQ_HSMMC2),
266 struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = {
268 .host_caps = (MMC_CAP_4_BIT_DATA |
269 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
272 struct platform_device s3c_device_hsmmc2 = {
275 .num_resources = ARRAY_SIZE(s3c_hsmmc2_resource),
276 .resource = s3c_hsmmc2_resource,
278 .dma_mask = &samsung_device_dma_mask,
279 .coherent_dma_mask = DMA_BIT_MASK(32),
280 .platform_data = &s3c_hsmmc2_def_platdata,
284 void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd)
286 s3c_sdhci_set_platdata(pd, &s3c_hsmmc2_def_platdata);
288 #endif /* CONFIG_S3C_DEV_HSMMC2 */
290 #ifdef CONFIG_S3C_DEV_HSMMC3
291 static struct resource s3c_hsmmc3_resource[] = {
292 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3, SZ_4K),
293 [1] = DEFINE_RES_IRQ(IRQ_HSMMC3),
296 struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata = {
298 .host_caps = (MMC_CAP_4_BIT_DATA |
299 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
302 struct platform_device s3c_device_hsmmc3 = {
305 .num_resources = ARRAY_SIZE(s3c_hsmmc3_resource),
306 .resource = s3c_hsmmc3_resource,
308 .dma_mask = &samsung_device_dma_mask,
309 .coherent_dma_mask = DMA_BIT_MASK(32),
310 .platform_data = &s3c_hsmmc3_def_platdata,
314 void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd)
316 s3c_sdhci_set_platdata(pd, &s3c_hsmmc3_def_platdata);
318 #endif /* CONFIG_S3C_DEV_HSMMC3 */
322 static struct resource s3c_i2c0_resource[] = {
323 [0] = DEFINE_RES_MEM(S3C_PA_IIC, SZ_4K),
324 [1] = DEFINE_RES_IRQ(IRQ_IIC),
327 struct platform_device s3c_device_i2c0 = {
328 .name = "s3c2410-i2c",
330 .num_resources = ARRAY_SIZE(s3c_i2c0_resource),
331 .resource = s3c_i2c0_resource,
334 struct s3c2410_platform_i2c default_i2c_data __initdata = {
337 .frequency = 100*1000,
341 void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
343 struct s3c2410_platform_i2c *npd;
346 pd = &default_i2c_data;
350 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
354 npd->cfg_gpio = s3c_i2c0_cfg_gpio;
357 #ifdef CONFIG_S3C_DEV_I2C1
358 static struct resource s3c_i2c1_resource[] = {
359 [0] = DEFINE_RES_MEM(S3C_PA_IIC1, SZ_4K),
360 [1] = DEFINE_RES_IRQ(IRQ_IIC1),
363 struct platform_device s3c_device_i2c1 = {
364 .name = "s3c2410-i2c",
366 .num_resources = ARRAY_SIZE(s3c_i2c1_resource),
367 .resource = s3c_i2c1_resource,
370 void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
372 struct s3c2410_platform_i2c *npd;
375 pd = &default_i2c_data;
379 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
383 npd->cfg_gpio = s3c_i2c1_cfg_gpio;
385 #endif /* CONFIG_S3C_DEV_I2C1 */
387 #ifdef CONFIG_S3C_DEV_I2C2
388 static struct resource s3c_i2c2_resource[] = {
389 [0] = DEFINE_RES_MEM(S3C_PA_IIC2, SZ_4K),
390 [1] = DEFINE_RES_IRQ(IRQ_IIC2),
393 struct platform_device s3c_device_i2c2 = {
394 .name = "s3c2410-i2c",
396 .num_resources = ARRAY_SIZE(s3c_i2c2_resource),
397 .resource = s3c_i2c2_resource,
400 void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd)
402 struct s3c2410_platform_i2c *npd;
405 pd = &default_i2c_data;
409 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
413 npd->cfg_gpio = s3c_i2c2_cfg_gpio;
415 #endif /* CONFIG_S3C_DEV_I2C2 */
417 #ifdef CONFIG_S3C_DEV_I2C3
418 static struct resource s3c_i2c3_resource[] = {
419 [0] = DEFINE_RES_MEM(S3C_PA_IIC3, SZ_4K),
420 [1] = DEFINE_RES_IRQ(IRQ_IIC3),
423 struct platform_device s3c_device_i2c3 = {
424 .name = "s3c2440-i2c",
426 .num_resources = ARRAY_SIZE(s3c_i2c3_resource),
427 .resource = s3c_i2c3_resource,
430 void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
432 struct s3c2410_platform_i2c *npd;
435 pd = &default_i2c_data;
439 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
443 npd->cfg_gpio = s3c_i2c3_cfg_gpio;
445 #endif /*CONFIG_S3C_DEV_I2C3 */
447 #ifdef CONFIG_S3C_DEV_I2C4
448 static struct resource s3c_i2c4_resource[] = {
449 [0] = DEFINE_RES_MEM(S3C_PA_IIC4, SZ_4K),
450 [1] = DEFINE_RES_IRQ(IRQ_IIC4),
453 struct platform_device s3c_device_i2c4 = {
454 .name = "s3c2440-i2c",
456 .num_resources = ARRAY_SIZE(s3c_i2c4_resource),
457 .resource = s3c_i2c4_resource,
460 void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
462 struct s3c2410_platform_i2c *npd;
465 pd = &default_i2c_data;
469 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
473 npd->cfg_gpio = s3c_i2c4_cfg_gpio;
475 #endif /*CONFIG_S3C_DEV_I2C4 */
477 #ifdef CONFIG_S3C_DEV_I2C5
478 static struct resource s3c_i2c5_resource[] = {
479 [0] = DEFINE_RES_MEM(S3C_PA_IIC5, SZ_4K),
480 [1] = DEFINE_RES_IRQ(IRQ_IIC5),
483 struct platform_device s3c_device_i2c5 = {
484 .name = "s3c2440-i2c",
486 .num_resources = ARRAY_SIZE(s3c_i2c5_resource),
487 .resource = s3c_i2c5_resource,
490 void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd)
492 struct s3c2410_platform_i2c *npd;
495 pd = &default_i2c_data;
499 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
503 npd->cfg_gpio = s3c_i2c5_cfg_gpio;
505 #endif /*CONFIG_S3C_DEV_I2C5 */
507 #ifdef CONFIG_S3C_DEV_I2C6
508 static struct resource s3c_i2c6_resource[] = {
509 [0] = DEFINE_RES_MEM(S3C_PA_IIC6, SZ_4K),
510 [1] = DEFINE_RES_IRQ(IRQ_IIC6),
513 struct platform_device s3c_device_i2c6 = {
514 .name = "s3c2440-i2c",
516 .num_resources = ARRAY_SIZE(s3c_i2c6_resource),
517 .resource = s3c_i2c6_resource,
520 void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd)
522 struct s3c2410_platform_i2c *npd;
525 pd = &default_i2c_data;
529 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
533 npd->cfg_gpio = s3c_i2c6_cfg_gpio;
535 #endif /* CONFIG_S3C_DEV_I2C6 */
537 #ifdef CONFIG_S3C_DEV_I2C7
538 static struct resource s3c_i2c7_resource[] = {
539 [0] = DEFINE_RES_MEM(S3C_PA_IIC7, SZ_4K),
540 [1] = DEFINE_RES_IRQ(IRQ_IIC7),
543 struct platform_device s3c_device_i2c7 = {
544 .name = "s3c2440-i2c",
546 .num_resources = ARRAY_SIZE(s3c_i2c7_resource),
547 .resource = s3c_i2c7_resource,
550 void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd)
552 struct s3c2410_platform_i2c *npd;
555 pd = &default_i2c_data;
559 npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
563 npd->cfg_gpio = s3c_i2c7_cfg_gpio;
565 #endif /* CONFIG_S3C_DEV_I2C7 */
569 #ifdef CONFIG_PLAT_S3C24XX
570 static struct resource s3c_iis_resource[] = {
571 [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS),
574 struct platform_device s3c_device_iis = {
575 .name = "s3c24xx-iis",
577 .num_resources = ARRAY_SIZE(s3c_iis_resource),
578 .resource = s3c_iis_resource,
580 .dma_mask = &samsung_device_dma_mask,
581 .coherent_dma_mask = DMA_BIT_MASK(32),
584 #endif /* CONFIG_PLAT_S3C24XX */
588 #ifdef CONFIG_SAMSUNG_DEV_IDE
589 static struct resource s3c_cfcon_resource[] = {
590 [0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON, SZ_16K),
591 [1] = DEFINE_RES_IRQ(IRQ_CFCON),
594 struct platform_device s3c_device_cfcon = {
596 .num_resources = ARRAY_SIZE(s3c_cfcon_resource),
597 .resource = s3c_cfcon_resource,
600 void __init s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
602 s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata),
605 #endif /* CONFIG_SAMSUNG_DEV_IDE */
609 #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
610 static struct resource samsung_keypad_resources[] = {
611 [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32),
612 [1] = DEFINE_RES_IRQ(IRQ_KEYPAD),
615 struct platform_device samsung_device_keypad = {
616 .name = "samsung-keypad",
618 .num_resources = ARRAY_SIZE(samsung_keypad_resources),
619 .resource = samsung_keypad_resources,
622 void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd)
624 struct samsung_keypad_platdata *npd;
626 npd = s3c_set_platdata(pd, sizeof(struct samsung_keypad_platdata),
627 &samsung_device_keypad);
630 npd->cfg_gpio = samsung_keypad_cfg_gpio;
632 #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
636 #ifdef CONFIG_PLAT_S3C24XX
637 static struct resource s3c_lcd_resource[] = {
638 [0] = DEFINE_RES_MEM(S3C24XX_PA_LCD, S3C24XX_SZ_LCD),
639 [1] = DEFINE_RES_IRQ(IRQ_LCD),
642 struct platform_device s3c_device_lcd = {
643 .name = "s3c2410-lcd",
645 .num_resources = ARRAY_SIZE(s3c_lcd_resource),
646 .resource = s3c_lcd_resource,
648 .dma_mask = &samsung_device_dma_mask,
649 .coherent_dma_mask = DMA_BIT_MASK(32),
653 void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd)
655 struct s3c2410fb_mach_info *npd;
657 npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd);
659 npd->displays = kmemdup(pd->displays,
660 sizeof(struct s3c2410fb_display) * npd->num_displays,
663 printk(KERN_ERR "no memory for LCD display data\n");
665 printk(KERN_ERR "no memory for LCD platform data\n");
668 #endif /* CONFIG_PLAT_S3C24XX */
672 #ifdef CONFIG_S3C_DEV_NAND
673 static struct resource s3c_nand_resource[] = {
674 [0] = DEFINE_RES_MEM(S3C_PA_NAND, SZ_1M),
677 struct platform_device s3c_device_nand = {
678 .name = "s3c2410-nand",
680 .num_resources = ARRAY_SIZE(s3c_nand_resource),
681 .resource = s3c_nand_resource,
685 * s3c_nand_copy_set() - copy nand set data
686 * @set: The new structure, directly copied from the old.
688 * Copy all the fields from the NAND set field from what is probably __initdata
689 * to new kernel memory. The code returns 0 if the copy happened correctly or
690 * an error code for the calling function to display.
692 * Note, we currently do not try and look to see if we've already copied the
693 * data in a previous set.
695 static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
700 size = sizeof(struct mtd_partition) * set->nr_partitions;
702 ptr = kmemdup(set->partitions, size, GFP_KERNEL);
703 set->partitions = ptr;
709 if (set->nr_map && set->nr_chips) {
710 size = sizeof(int) * set->nr_chips;
711 ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
718 if (set->ecc_layout) {
719 ptr = kmemdup(set->ecc_layout,
720 sizeof(struct nand_ecclayout), GFP_KERNEL);
721 set->ecc_layout = ptr;
730 void __init s3c_nand_set_platdata(struct s3c2410_platform_nand *nand)
732 struct s3c2410_platform_nand *npd;
736 /* note, if we get a failure in allocation, we simply drop out of the
737 * function. If there is so little memory available at initialisation
738 * time then there is little chance the system is going to run.
741 npd = s3c_set_platdata(nand, sizeof(struct s3c2410_platform_nand),
746 /* now see if we need to copy any of the nand set data */
748 size = sizeof(struct s3c2410_nand_set) * npd->nr_sets;
750 struct s3c2410_nand_set *from = npd->sets;
751 struct s3c2410_nand_set *to;
754 to = kmemdup(from, size, GFP_KERNEL);
755 npd->sets = to; /* set, even if we failed */
758 printk(KERN_ERR "%s: no memory for sets\n", __func__);
762 for (i = 0; i < npd->nr_sets; i++) {
763 ret = s3c_nand_copy_set(to);
765 printk(KERN_ERR "%s: failed to copy set %d\n",
773 #endif /* CONFIG_S3C_DEV_NAND */
777 #ifdef CONFIG_S3C_DEV_ONENAND
778 static struct resource s3c_onenand_resources[] = {
779 [0] = DEFINE_RES_MEM(S3C_PA_ONENAND, SZ_1K),
780 [1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF, S3C_SZ_ONENAND_BUF),
781 [2] = DEFINE_RES_IRQ(IRQ_ONENAND),
784 struct platform_device s3c_device_onenand = {
785 .name = "samsung-onenand",
787 .num_resources = ARRAY_SIZE(s3c_onenand_resources),
788 .resource = s3c_onenand_resources,
790 #endif /* CONFIG_S3C_DEV_ONENAND */
792 #ifdef CONFIG_S3C64XX_DEV_ONENAND1
793 static struct resource s3c64xx_onenand1_resources[] = {
794 [0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1, SZ_1K),
795 [1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF, S3C64XX_SZ_ONENAND1_BUF),
796 [2] = DEFINE_RES_IRQ(IRQ_ONENAND1),
799 struct platform_device s3c64xx_device_onenand1 = {
800 .name = "samsung-onenand",
802 .num_resources = ARRAY_SIZE(s3c64xx_onenand1_resources),
803 .resource = s3c64xx_onenand1_resources,
806 void __init s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
808 s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
809 &s3c64xx_device_onenand1);
811 #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
815 #ifdef CONFIG_SAMSUNG_DEV_PWM
816 static struct resource samsung_pwm_resource[] = {
817 DEFINE_RES_MEM(SAMSUNG_PA_TIMER, SZ_4K),
820 struct platform_device samsung_device_pwm = {
821 .name = "samsung-pwm",
823 .num_resources = ARRAY_SIZE(samsung_pwm_resource),
824 .resource = samsung_pwm_resource,
827 void __init samsung_pwm_set_platdata(struct samsung_pwm_variant *pd)
829 samsung_device_pwm.dev.platform_data = pd;
831 #endif /* CONFIG_SAMSUNG_DEV_PWM */
835 #ifdef CONFIG_PLAT_S3C24XX
836 static struct resource s3c_rtc_resource[] = {
837 [0] = DEFINE_RES_MEM(S3C24XX_PA_RTC, SZ_256),
838 [1] = DEFINE_RES_IRQ(IRQ_RTC),
839 [2] = DEFINE_RES_IRQ(IRQ_TICK),
842 struct platform_device s3c_device_rtc = {
843 .name = "s3c2410-rtc",
845 .num_resources = ARRAY_SIZE(s3c_rtc_resource),
846 .resource = s3c_rtc_resource,
848 #endif /* CONFIG_PLAT_S3C24XX */
850 #ifdef CONFIG_S3C_DEV_RTC
851 static struct resource s3c_rtc_resource[] = {
852 [0] = DEFINE_RES_MEM(S3C_PA_RTC, SZ_256),
853 [1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM),
854 [2] = DEFINE_RES_IRQ(IRQ_RTC_TIC),
857 struct platform_device s3c_device_rtc = {
858 .name = "s3c64xx-rtc",
860 .num_resources = ARRAY_SIZE(s3c_rtc_resource),
861 .resource = s3c_rtc_resource,
863 #endif /* CONFIG_S3C_DEV_RTC */
867 #ifdef CONFIG_PLAT_S3C24XX
868 static struct resource s3c_sdi_resource[] = {
869 [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI),
870 [1] = DEFINE_RES_IRQ(IRQ_SDI),
873 struct platform_device s3c_device_sdi = {
874 .name = "s3c2410-sdi",
876 .num_resources = ARRAY_SIZE(s3c_sdi_resource),
877 .resource = s3c_sdi_resource,
880 void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
882 s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata),
885 #endif /* CONFIG_PLAT_S3C24XX */
889 #ifdef CONFIG_PLAT_S3C24XX
890 static struct resource s3c_spi0_resource[] = {
891 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI, SZ_32),
892 [1] = DEFINE_RES_IRQ(IRQ_SPI0),
895 struct platform_device s3c_device_spi0 = {
896 .name = "s3c2410-spi",
898 .num_resources = ARRAY_SIZE(s3c_spi0_resource),
899 .resource = s3c_spi0_resource,
901 .dma_mask = &samsung_device_dma_mask,
902 .coherent_dma_mask = DMA_BIT_MASK(32),
906 static struct resource s3c_spi1_resource[] = {
907 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1, SZ_32),
908 [1] = DEFINE_RES_IRQ(IRQ_SPI1),
911 struct platform_device s3c_device_spi1 = {
912 .name = "s3c2410-spi",
914 .num_resources = ARRAY_SIZE(s3c_spi1_resource),
915 .resource = s3c_spi1_resource,
917 .dma_mask = &samsung_device_dma_mask,
918 .coherent_dma_mask = DMA_BIT_MASK(32),
921 #endif /* CONFIG_PLAT_S3C24XX */
925 #ifdef CONFIG_PLAT_S3C24XX
926 static struct resource s3c_ts_resource[] = {
927 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC),
928 [1] = DEFINE_RES_IRQ(IRQ_TC),
931 struct platform_device s3c_device_ts = {
932 .name = "s3c2410-ts",
934 .dev.parent = &s3c_device_adc.dev,
935 .num_resources = ARRAY_SIZE(s3c_ts_resource),
936 .resource = s3c_ts_resource,
939 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
941 s3c_set_platdata(hard_s3c2410ts_info,
942 sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts);
944 #endif /* CONFIG_PLAT_S3C24XX */
946 #ifdef CONFIG_SAMSUNG_DEV_TS
947 static struct resource s3c_ts_resource[] = {
948 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256),
949 [1] = DEFINE_RES_IRQ(IRQ_TC),
952 static struct s3c2410_ts_mach_info default_ts_data __initdata = {
955 .oversampling_shift = 2,
958 struct platform_device s3c_device_ts = {
959 .name = "s3c64xx-ts",
961 .num_resources = ARRAY_SIZE(s3c_ts_resource),
962 .resource = s3c_ts_resource,
965 void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd)
968 pd = &default_ts_data;
970 s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info),
973 #endif /* CONFIG_SAMSUNG_DEV_TS */
977 #ifdef CONFIG_S3C_DEV_USB_HOST
978 static struct resource s3c_usb_resource[] = {
979 [0] = DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256),
980 [1] = DEFINE_RES_IRQ(IRQ_USBH),
983 struct platform_device s3c_device_ohci = {
984 .name = "s3c2410-ohci",
986 .num_resources = ARRAY_SIZE(s3c_usb_resource),
987 .resource = s3c_usb_resource,
989 .dma_mask = &samsung_device_dma_mask,
990 .coherent_dma_mask = DMA_BIT_MASK(32),
995 * s3c_ohci_set_platdata - initialise OHCI device platform data
996 * @info: The platform data.
998 * This call copies the @info passed in and sets the device .platform_data
999 * field to that copy. The @info is copied so that the original can be marked
1003 void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *info)
1005 s3c_set_platdata(info, sizeof(struct s3c2410_hcd_info),
1008 #endif /* CONFIG_S3C_DEV_USB_HOST */
1010 /* USB Device (Gadget) */
1012 #ifdef CONFIG_PLAT_S3C24XX
1013 static struct resource s3c_usbgadget_resource[] = {
1014 [0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV, S3C24XX_SZ_USBDEV),
1015 [1] = DEFINE_RES_IRQ(IRQ_USBD),
1018 struct platform_device s3c_device_usbgadget = {
1019 .name = "s3c2410-usbgadget",
1021 .num_resources = ARRAY_SIZE(s3c_usbgadget_resource),
1022 .resource = s3c_usbgadget_resource,
1025 void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd)
1027 s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget);
1029 #endif /* CONFIG_PLAT_S3C24XX */
1033 #ifdef CONFIG_S3C_DEV_USB_HSOTG
1034 static struct resource s3c_usb_hsotg_resources[] = {
1035 [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG, SZ_128K),
1036 [1] = DEFINE_RES_IRQ(IRQ_OTG),
1039 struct platform_device s3c_device_usb_hsotg = {
1040 .name = "s3c-hsotg",
1042 .num_resources = ARRAY_SIZE(s3c_usb_hsotg_resources),
1043 .resource = s3c_usb_hsotg_resources,
1045 .dma_mask = &samsung_device_dma_mask,
1046 .coherent_dma_mask = DMA_BIT_MASK(32),
1050 void __init dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat *pd)
1052 struct dwc2_hsotg_plat *npd;
1054 npd = s3c_set_platdata(pd, sizeof(struct dwc2_hsotg_plat),
1055 &s3c_device_usb_hsotg);
1058 npd->phy_init = s5p_usb_phy_init;
1060 npd->phy_exit = s5p_usb_phy_exit;
1062 #endif /* CONFIG_S3C_DEV_USB_HSOTG */
1064 /* USB High Spped 2.0 Device (Gadget) */
1066 #ifdef CONFIG_PLAT_S3C24XX
1067 static struct resource s3c_hsudc_resource[] = {
1068 [0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC, S3C2416_SZ_HSUDC),
1069 [1] = DEFINE_RES_IRQ(IRQ_USBD),
1072 struct platform_device s3c_device_usb_hsudc = {
1073 .name = "s3c-hsudc",
1075 .num_resources = ARRAY_SIZE(s3c_hsudc_resource),
1076 .resource = s3c_hsudc_resource,
1078 .dma_mask = &samsung_device_dma_mask,
1079 .coherent_dma_mask = DMA_BIT_MASK(32),
1083 void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd)
1085 s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc);
1087 #endif /* CONFIG_PLAT_S3C24XX */
1091 #ifdef CONFIG_S3C_DEV_WDT
1092 static struct resource s3c_wdt_resource[] = {
1093 [0] = DEFINE_RES_MEM(S3C_PA_WDT, SZ_1K),
1094 [1] = DEFINE_RES_IRQ(IRQ_WDT),
1097 struct platform_device s3c_device_wdt = {
1098 .name = "s3c2410-wdt",
1100 .num_resources = ARRAY_SIZE(s3c_wdt_resource),
1101 .resource = s3c_wdt_resource,
1103 #endif /* CONFIG_S3C_DEV_WDT */
1105 #ifdef CONFIG_S3C64XX_DEV_SPI0
1106 static struct resource s3c64xx_spi0_resource[] = {
1107 [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256),
1108 [1] = DEFINE_RES_DMA(DMACH_SPI0_TX),
1109 [2] = DEFINE_RES_DMA(DMACH_SPI0_RX),
1110 [3] = DEFINE_RES_IRQ(IRQ_SPI0),
1113 struct platform_device s3c64xx_device_spi0 = {
1114 .name = "s3c6410-spi",
1116 .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource),
1117 .resource = s3c64xx_spi0_resource,
1119 .dma_mask = &samsung_device_dma_mask,
1120 .coherent_dma_mask = DMA_BIT_MASK(32),
1124 void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1127 struct s3c64xx_spi_info pd;
1129 /* Reject invalid configuration */
1130 if (!num_cs || src_clk_nr < 0) {
1131 pr_err("%s: Invalid SPI configuration\n", __func__);
1136 pd.src_clk_nr = src_clk_nr;
1137 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
1138 #if defined(CONFIG_PL330_DMA)
1139 pd.filter = pl330_filter;
1140 #elif defined(CONFIG_S3C64XX_PL080)
1141 pd.filter = pl08x_filter_id;
1142 #elif defined(CONFIG_S3C24XX_DMAC)
1143 pd.filter = s3c24xx_dma_filter;
1146 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0);
1148 #endif /* CONFIG_S3C64XX_DEV_SPI0 */
1150 #ifdef CONFIG_S3C64XX_DEV_SPI1
1151 static struct resource s3c64xx_spi1_resource[] = {
1152 [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256),
1153 [1] = DEFINE_RES_DMA(DMACH_SPI1_TX),
1154 [2] = DEFINE_RES_DMA(DMACH_SPI1_RX),
1155 [3] = DEFINE_RES_IRQ(IRQ_SPI1),
1158 struct platform_device s3c64xx_device_spi1 = {
1159 .name = "s3c6410-spi",
1161 .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource),
1162 .resource = s3c64xx_spi1_resource,
1164 .dma_mask = &samsung_device_dma_mask,
1165 .coherent_dma_mask = DMA_BIT_MASK(32),
1169 void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1172 struct s3c64xx_spi_info pd;
1174 /* Reject invalid configuration */
1175 if (!num_cs || src_clk_nr < 0) {
1176 pr_err("%s: Invalid SPI configuration\n", __func__);
1181 pd.src_clk_nr = src_clk_nr;
1182 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
1183 #if defined(CONFIG_PL330_DMA)
1184 pd.filter = pl330_filter;
1185 #elif defined(CONFIG_S3C64XX_PL080)
1186 pd.filter = pl08x_filter_id;
1189 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1);
1191 #endif /* CONFIG_S3C64XX_DEV_SPI1 */
1193 #ifdef CONFIG_S3C64XX_DEV_SPI2
1194 static struct resource s3c64xx_spi2_resource[] = {
1195 [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256),
1196 [1] = DEFINE_RES_DMA(DMACH_SPI2_TX),
1197 [2] = DEFINE_RES_DMA(DMACH_SPI2_RX),
1198 [3] = DEFINE_RES_IRQ(IRQ_SPI2),
1201 struct platform_device s3c64xx_device_spi2 = {
1202 .name = "s3c6410-spi",
1204 .num_resources = ARRAY_SIZE(s3c64xx_spi2_resource),
1205 .resource = s3c64xx_spi2_resource,
1207 .dma_mask = &samsung_device_dma_mask,
1208 .coherent_dma_mask = DMA_BIT_MASK(32),
1212 void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr,
1215 struct s3c64xx_spi_info pd;
1217 /* Reject invalid configuration */
1218 if (!num_cs || src_clk_nr < 0) {
1219 pr_err("%s: Invalid SPI configuration\n", __func__);
1224 pd.src_clk_nr = src_clk_nr;
1225 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
1226 #if defined(CONFIG_PL330_DMA)
1227 pd.filter = pl330_filter;
1228 #elif defined(CONFIG_S3C64XX_PL080)
1229 pd.filter = pl08x_filter_id;
1232 s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2);
1234 #endif /* CONFIG_S3C64XX_DEV_SPI2 */