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/spi-s3c64xx.h>
70 static u64 samsung_device_dma_mask
= DMA_BIT_MASK(32);
73 #ifdef CONFIG_CPU_S3C2440
74 static struct resource s3c_ac97_resource
[] = {
75 [0] = DEFINE_RES_MEM(S3C2440_PA_AC97
, S3C2440_SZ_AC97
),
76 [1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97
),
77 [2] = DEFINE_RES_DMA_NAMED(DMACH_PCM_OUT
, "PCM out"),
78 [3] = DEFINE_RES_DMA_NAMED(DMACH_PCM_IN
, "PCM in"),
79 [4] = DEFINE_RES_DMA_NAMED(DMACH_MIC_IN
, "Mic in"),
82 struct platform_device s3c_device_ac97
= {
83 .name
= "samsung-ac97",
85 .num_resources
= ARRAY_SIZE(s3c_ac97_resource
),
86 .resource
= s3c_ac97_resource
,
88 .dma_mask
= &samsung_device_dma_mask
,
89 .coherent_dma_mask
= DMA_BIT_MASK(32),
92 #endif /* CONFIG_CPU_S3C2440 */
96 #ifdef CONFIG_PLAT_S3C24XX
97 static struct resource s3c_adc_resource
[] = {
98 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC
, S3C24XX_SZ_ADC
),
99 [1] = DEFINE_RES_IRQ(IRQ_TC
),
100 [2] = DEFINE_RES_IRQ(IRQ_ADC
),
103 struct platform_device s3c_device_adc
= {
104 .name
= "s3c24xx-adc",
106 .num_resources
= ARRAY_SIZE(s3c_adc_resource
),
107 .resource
= s3c_adc_resource
,
109 #endif /* CONFIG_PLAT_S3C24XX */
111 #if defined(CONFIG_SAMSUNG_DEV_ADC)
112 static struct resource s3c_adc_resource
[] = {
113 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC
, SZ_256
),
114 [1] = DEFINE_RES_IRQ(IRQ_TC
),
115 [2] = DEFINE_RES_IRQ(IRQ_ADC
),
118 struct platform_device s3c_device_adc
= {
119 .name
= "samsung-adc",
121 .num_resources
= ARRAY_SIZE(s3c_adc_resource
),
122 .resource
= s3c_adc_resource
,
124 #endif /* CONFIG_SAMSUNG_DEV_ADC */
126 /* Camif Controller */
128 #ifdef CONFIG_CPU_S3C2440
129 static struct resource s3c_camif_resource
[] = {
130 [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF
, S3C2440_SZ_CAMIF
),
131 [1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C
),
132 [2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P
),
135 struct platform_device s3c_device_camif
= {
136 .name
= "s3c2440-camif",
138 .num_resources
= ARRAY_SIZE(s3c_camif_resource
),
139 .resource
= s3c_camif_resource
,
141 .dma_mask
= &samsung_device_dma_mask
,
142 .coherent_dma_mask
= DMA_BIT_MASK(32),
145 #endif /* CONFIG_CPU_S3C2440 */
149 #ifdef CONFIG_S3C_DEV_FB
150 static struct resource s3c_fb_resource
[] = {
151 [0] = DEFINE_RES_MEM(S3C_PA_FB
, SZ_16K
),
152 [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC
),
153 [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO
),
154 [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM
),
157 struct platform_device s3c_device_fb
= {
160 .num_resources
= ARRAY_SIZE(s3c_fb_resource
),
161 .resource
= s3c_fb_resource
,
163 .dma_mask
= &samsung_device_dma_mask
,
164 .coherent_dma_mask
= DMA_BIT_MASK(32),
168 void __init
s3c_fb_set_platdata(struct s3c_fb_platdata
*pd
)
170 s3c_set_platdata(pd
, sizeof(struct s3c_fb_platdata
),
173 #endif /* CONFIG_S3C_DEV_FB */
177 #ifdef CONFIG_S3C_DEV_HWMON
178 struct platform_device s3c_device_hwmon
= {
181 .dev
.parent
= &s3c_device_adc
.dev
,
184 void __init
s3c_hwmon_set_platdata(struct s3c_hwmon_pdata
*pd
)
186 s3c_set_platdata(pd
, sizeof(struct s3c_hwmon_pdata
),
189 #endif /* CONFIG_S3C_DEV_HWMON */
193 #ifdef CONFIG_S3C_DEV_HSMMC
194 static struct resource s3c_hsmmc_resource
[] = {
195 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0
, SZ_4K
),
196 [1] = DEFINE_RES_IRQ(IRQ_HSMMC0
),
199 struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata
= {
201 .host_caps
= (MMC_CAP_4_BIT_DATA
|
202 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
205 struct platform_device s3c_device_hsmmc0
= {
208 .num_resources
= ARRAY_SIZE(s3c_hsmmc_resource
),
209 .resource
= s3c_hsmmc_resource
,
211 .dma_mask
= &samsung_device_dma_mask
,
212 .coherent_dma_mask
= DMA_BIT_MASK(32),
213 .platform_data
= &s3c_hsmmc0_def_platdata
,
217 void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata
*pd
)
219 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc0_def_platdata
);
221 #endif /* CONFIG_S3C_DEV_HSMMC */
223 #ifdef CONFIG_S3C_DEV_HSMMC1
224 static struct resource s3c_hsmmc1_resource
[] = {
225 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1
, SZ_4K
),
226 [1] = DEFINE_RES_IRQ(IRQ_HSMMC1
),
229 struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata
= {
231 .host_caps
= (MMC_CAP_4_BIT_DATA
|
232 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
235 struct platform_device s3c_device_hsmmc1
= {
238 .num_resources
= ARRAY_SIZE(s3c_hsmmc1_resource
),
239 .resource
= s3c_hsmmc1_resource
,
241 .dma_mask
= &samsung_device_dma_mask
,
242 .coherent_dma_mask
= DMA_BIT_MASK(32),
243 .platform_data
= &s3c_hsmmc1_def_platdata
,
247 void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata
*pd
)
249 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc1_def_platdata
);
251 #endif /* CONFIG_S3C_DEV_HSMMC1 */
255 #ifdef CONFIG_S3C_DEV_HSMMC2
256 static struct resource s3c_hsmmc2_resource
[] = {
257 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2
, SZ_4K
),
258 [1] = DEFINE_RES_IRQ(IRQ_HSMMC2
),
261 struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata
= {
263 .host_caps
= (MMC_CAP_4_BIT_DATA
|
264 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
267 struct platform_device s3c_device_hsmmc2
= {
270 .num_resources
= ARRAY_SIZE(s3c_hsmmc2_resource
),
271 .resource
= s3c_hsmmc2_resource
,
273 .dma_mask
= &samsung_device_dma_mask
,
274 .coherent_dma_mask
= DMA_BIT_MASK(32),
275 .platform_data
= &s3c_hsmmc2_def_platdata
,
279 void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata
*pd
)
281 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc2_def_platdata
);
283 #endif /* CONFIG_S3C_DEV_HSMMC2 */
285 #ifdef CONFIG_S3C_DEV_HSMMC3
286 static struct resource s3c_hsmmc3_resource
[] = {
287 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3
, SZ_4K
),
288 [1] = DEFINE_RES_IRQ(IRQ_HSMMC3
),
291 struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata
= {
293 .host_caps
= (MMC_CAP_4_BIT_DATA
|
294 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
297 struct platform_device s3c_device_hsmmc3
= {
300 .num_resources
= ARRAY_SIZE(s3c_hsmmc3_resource
),
301 .resource
= s3c_hsmmc3_resource
,
303 .dma_mask
= &samsung_device_dma_mask
,
304 .coherent_dma_mask
= DMA_BIT_MASK(32),
305 .platform_data
= &s3c_hsmmc3_def_platdata
,
309 void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata
*pd
)
311 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc3_def_platdata
);
313 #endif /* CONFIG_S3C_DEV_HSMMC3 */
317 static struct resource s3c_i2c0_resource
[] = {
318 [0] = DEFINE_RES_MEM(S3C_PA_IIC
, SZ_4K
),
319 [1] = DEFINE_RES_IRQ(IRQ_IIC
),
322 struct platform_device s3c_device_i2c0
= {
323 .name
= "s3c2410-i2c",
325 .num_resources
= ARRAY_SIZE(s3c_i2c0_resource
),
326 .resource
= s3c_i2c0_resource
,
329 struct s3c2410_platform_i2c default_i2c_data __initdata
= {
332 .frequency
= 100*1000,
336 void __init
s3c_i2c0_set_platdata(struct s3c2410_platform_i2c
*pd
)
338 struct s3c2410_platform_i2c
*npd
;
341 pd
= &default_i2c_data
;
345 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
349 npd
->cfg_gpio
= s3c_i2c0_cfg_gpio
;
352 #ifdef CONFIG_S3C_DEV_I2C1
353 static struct resource s3c_i2c1_resource
[] = {
354 [0] = DEFINE_RES_MEM(S3C_PA_IIC1
, SZ_4K
),
355 [1] = DEFINE_RES_IRQ(IRQ_IIC1
),
358 struct platform_device s3c_device_i2c1
= {
359 .name
= "s3c2410-i2c",
361 .num_resources
= ARRAY_SIZE(s3c_i2c1_resource
),
362 .resource
= s3c_i2c1_resource
,
365 void __init
s3c_i2c1_set_platdata(struct s3c2410_platform_i2c
*pd
)
367 struct s3c2410_platform_i2c
*npd
;
370 pd
= &default_i2c_data
;
374 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
378 npd
->cfg_gpio
= s3c_i2c1_cfg_gpio
;
380 #endif /* CONFIG_S3C_DEV_I2C1 */
382 #ifdef CONFIG_S3C_DEV_I2C2
383 static struct resource s3c_i2c2_resource
[] = {
384 [0] = DEFINE_RES_MEM(S3C_PA_IIC2
, SZ_4K
),
385 [1] = DEFINE_RES_IRQ(IRQ_IIC2
),
388 struct platform_device s3c_device_i2c2
= {
389 .name
= "s3c2410-i2c",
391 .num_resources
= ARRAY_SIZE(s3c_i2c2_resource
),
392 .resource
= s3c_i2c2_resource
,
395 void __init
s3c_i2c2_set_platdata(struct s3c2410_platform_i2c
*pd
)
397 struct s3c2410_platform_i2c
*npd
;
400 pd
= &default_i2c_data
;
404 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
408 npd
->cfg_gpio
= s3c_i2c2_cfg_gpio
;
410 #endif /* CONFIG_S3C_DEV_I2C2 */
412 #ifdef CONFIG_S3C_DEV_I2C3
413 static struct resource s3c_i2c3_resource
[] = {
414 [0] = DEFINE_RES_MEM(S3C_PA_IIC3
, SZ_4K
),
415 [1] = DEFINE_RES_IRQ(IRQ_IIC3
),
418 struct platform_device s3c_device_i2c3
= {
419 .name
= "s3c2440-i2c",
421 .num_resources
= ARRAY_SIZE(s3c_i2c3_resource
),
422 .resource
= s3c_i2c3_resource
,
425 void __init
s3c_i2c3_set_platdata(struct s3c2410_platform_i2c
*pd
)
427 struct s3c2410_platform_i2c
*npd
;
430 pd
= &default_i2c_data
;
434 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
438 npd
->cfg_gpio
= s3c_i2c3_cfg_gpio
;
440 #endif /*CONFIG_S3C_DEV_I2C3 */
442 #ifdef CONFIG_S3C_DEV_I2C4
443 static struct resource s3c_i2c4_resource
[] = {
444 [0] = DEFINE_RES_MEM(S3C_PA_IIC4
, SZ_4K
),
445 [1] = DEFINE_RES_IRQ(IRQ_IIC4
),
448 struct platform_device s3c_device_i2c4
= {
449 .name
= "s3c2440-i2c",
451 .num_resources
= ARRAY_SIZE(s3c_i2c4_resource
),
452 .resource
= s3c_i2c4_resource
,
455 void __init
s3c_i2c4_set_platdata(struct s3c2410_platform_i2c
*pd
)
457 struct s3c2410_platform_i2c
*npd
;
460 pd
= &default_i2c_data
;
464 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
468 npd
->cfg_gpio
= s3c_i2c4_cfg_gpio
;
470 #endif /*CONFIG_S3C_DEV_I2C4 */
472 #ifdef CONFIG_S3C_DEV_I2C5
473 static struct resource s3c_i2c5_resource
[] = {
474 [0] = DEFINE_RES_MEM(S3C_PA_IIC5
, SZ_4K
),
475 [1] = DEFINE_RES_IRQ(IRQ_IIC5
),
478 struct platform_device s3c_device_i2c5
= {
479 .name
= "s3c2440-i2c",
481 .num_resources
= ARRAY_SIZE(s3c_i2c5_resource
),
482 .resource
= s3c_i2c5_resource
,
485 void __init
s3c_i2c5_set_platdata(struct s3c2410_platform_i2c
*pd
)
487 struct s3c2410_platform_i2c
*npd
;
490 pd
= &default_i2c_data
;
494 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
498 npd
->cfg_gpio
= s3c_i2c5_cfg_gpio
;
500 #endif /*CONFIG_S3C_DEV_I2C5 */
502 #ifdef CONFIG_S3C_DEV_I2C6
503 static struct resource s3c_i2c6_resource
[] = {
504 [0] = DEFINE_RES_MEM(S3C_PA_IIC6
, SZ_4K
),
505 [1] = DEFINE_RES_IRQ(IRQ_IIC6
),
508 struct platform_device s3c_device_i2c6
= {
509 .name
= "s3c2440-i2c",
511 .num_resources
= ARRAY_SIZE(s3c_i2c6_resource
),
512 .resource
= s3c_i2c6_resource
,
515 void __init
s3c_i2c6_set_platdata(struct s3c2410_platform_i2c
*pd
)
517 struct s3c2410_platform_i2c
*npd
;
520 pd
= &default_i2c_data
;
524 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
528 npd
->cfg_gpio
= s3c_i2c6_cfg_gpio
;
530 #endif /* CONFIG_S3C_DEV_I2C6 */
532 #ifdef CONFIG_S3C_DEV_I2C7
533 static struct resource s3c_i2c7_resource
[] = {
534 [0] = DEFINE_RES_MEM(S3C_PA_IIC7
, SZ_4K
),
535 [1] = DEFINE_RES_IRQ(IRQ_IIC7
),
538 struct platform_device s3c_device_i2c7
= {
539 .name
= "s3c2440-i2c",
541 .num_resources
= ARRAY_SIZE(s3c_i2c7_resource
),
542 .resource
= s3c_i2c7_resource
,
545 void __init
s3c_i2c7_set_platdata(struct s3c2410_platform_i2c
*pd
)
547 struct s3c2410_platform_i2c
*npd
;
550 pd
= &default_i2c_data
;
554 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
558 npd
->cfg_gpio
= s3c_i2c7_cfg_gpio
;
560 #endif /* CONFIG_S3C_DEV_I2C7 */
564 #ifdef CONFIG_PLAT_S3C24XX
565 static struct resource s3c_iis_resource
[] = {
566 [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS
, S3C24XX_SZ_IIS
),
569 struct platform_device s3c_device_iis
= {
570 .name
= "s3c24xx-iis",
572 .num_resources
= ARRAY_SIZE(s3c_iis_resource
),
573 .resource
= s3c_iis_resource
,
575 .dma_mask
= &samsung_device_dma_mask
,
576 .coherent_dma_mask
= DMA_BIT_MASK(32),
579 #endif /* CONFIG_PLAT_S3C24XX */
583 #ifdef CONFIG_SAMSUNG_DEV_IDE
584 static struct resource s3c_cfcon_resource
[] = {
585 [0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON
, SZ_16K
),
586 [1] = DEFINE_RES_IRQ(IRQ_CFCON
),
589 struct platform_device s3c_device_cfcon
= {
591 .num_resources
= ARRAY_SIZE(s3c_cfcon_resource
),
592 .resource
= s3c_cfcon_resource
,
595 void __init
s3c_ide_set_platdata(struct s3c_ide_platdata
*pdata
)
597 s3c_set_platdata(pdata
, sizeof(struct s3c_ide_platdata
),
600 #endif /* CONFIG_SAMSUNG_DEV_IDE */
604 #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
605 static struct resource samsung_keypad_resources
[] = {
606 [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD
, SZ_32
),
607 [1] = DEFINE_RES_IRQ(IRQ_KEYPAD
),
610 struct platform_device samsung_device_keypad
= {
611 .name
= "samsung-keypad",
613 .num_resources
= ARRAY_SIZE(samsung_keypad_resources
),
614 .resource
= samsung_keypad_resources
,
617 void __init
samsung_keypad_set_platdata(struct samsung_keypad_platdata
*pd
)
619 struct samsung_keypad_platdata
*npd
;
621 npd
= s3c_set_platdata(pd
, sizeof(struct samsung_keypad_platdata
),
622 &samsung_device_keypad
);
625 npd
->cfg_gpio
= samsung_keypad_cfg_gpio
;
627 #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
631 #ifdef CONFIG_PLAT_S3C24XX
632 static struct resource s3c_lcd_resource
[] = {
633 [0] = DEFINE_RES_MEM(S3C24XX_PA_LCD
, S3C24XX_SZ_LCD
),
634 [1] = DEFINE_RES_IRQ(IRQ_LCD
),
637 struct platform_device s3c_device_lcd
= {
638 .name
= "s3c2410-lcd",
640 .num_resources
= ARRAY_SIZE(s3c_lcd_resource
),
641 .resource
= s3c_lcd_resource
,
643 .dma_mask
= &samsung_device_dma_mask
,
644 .coherent_dma_mask
= DMA_BIT_MASK(32),
648 void __init
s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info
*pd
)
650 struct s3c2410fb_mach_info
*npd
;
652 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &s3c_device_lcd
);
654 npd
->displays
= kmemdup(pd
->displays
,
655 sizeof(struct s3c2410fb_display
) * npd
->num_displays
,
658 printk(KERN_ERR
"no memory for LCD display data\n");
660 printk(KERN_ERR
"no memory for LCD platform data\n");
663 #endif /* CONFIG_PLAT_S3C24XX */
667 #ifdef CONFIG_S3C_DEV_NAND
668 static struct resource s3c_nand_resource
[] = {
669 [0] = DEFINE_RES_MEM(S3C_PA_NAND
, SZ_1M
),
672 struct platform_device s3c_device_nand
= {
673 .name
= "s3c2410-nand",
675 .num_resources
= ARRAY_SIZE(s3c_nand_resource
),
676 .resource
= s3c_nand_resource
,
680 * s3c_nand_copy_set() - copy nand set data
681 * @set: The new structure, directly copied from the old.
683 * Copy all the fields from the NAND set field from what is probably __initdata
684 * to new kernel memory. The code returns 0 if the copy happened correctly or
685 * an error code for the calling function to display.
687 * Note, we currently do not try and look to see if we've already copied the
688 * data in a previous set.
690 static int __init
s3c_nand_copy_set(struct s3c2410_nand_set
*set
)
695 size
= sizeof(struct mtd_partition
) * set
->nr_partitions
;
697 ptr
= kmemdup(set
->partitions
, size
, GFP_KERNEL
);
698 set
->partitions
= ptr
;
704 if (set
->nr_map
&& set
->nr_chips
) {
705 size
= sizeof(int) * set
->nr_chips
;
706 ptr
= kmemdup(set
->nr_map
, size
, GFP_KERNEL
);
713 if (set
->ecc_layout
) {
714 ptr
= kmemdup(set
->ecc_layout
,
715 sizeof(struct nand_ecclayout
), GFP_KERNEL
);
716 set
->ecc_layout
= ptr
;
725 void __init
s3c_nand_set_platdata(struct s3c2410_platform_nand
*nand
)
727 struct s3c2410_platform_nand
*npd
;
731 /* note, if we get a failure in allocation, we simply drop out of the
732 * function. If there is so little memory available at initialisation
733 * time then there is little chance the system is going to run.
736 npd
= s3c_set_platdata(nand
, sizeof(struct s3c2410_platform_nand
),
741 /* now see if we need to copy any of the nand set data */
743 size
= sizeof(struct s3c2410_nand_set
) * npd
->nr_sets
;
745 struct s3c2410_nand_set
*from
= npd
->sets
;
746 struct s3c2410_nand_set
*to
;
749 to
= kmemdup(from
, size
, GFP_KERNEL
);
750 npd
->sets
= to
; /* set, even if we failed */
753 printk(KERN_ERR
"%s: no memory for sets\n", __func__
);
757 for (i
= 0; i
< npd
->nr_sets
; i
++) {
758 ret
= s3c_nand_copy_set(to
);
760 printk(KERN_ERR
"%s: failed to copy set %d\n",
768 #endif /* CONFIG_S3C_DEV_NAND */
772 #ifdef CONFIG_S3C_DEV_ONENAND
773 static struct resource s3c_onenand_resources
[] = {
774 [0] = DEFINE_RES_MEM(S3C_PA_ONENAND
, SZ_1K
),
775 [1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF
, S3C_SZ_ONENAND_BUF
),
776 [2] = DEFINE_RES_IRQ(IRQ_ONENAND
),
779 struct platform_device s3c_device_onenand
= {
780 .name
= "samsung-onenand",
782 .num_resources
= ARRAY_SIZE(s3c_onenand_resources
),
783 .resource
= s3c_onenand_resources
,
785 #endif /* CONFIG_S3C_DEV_ONENAND */
787 #ifdef CONFIG_S3C64XX_DEV_ONENAND1
788 static struct resource s3c64xx_onenand1_resources
[] = {
789 [0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1
, SZ_1K
),
790 [1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF
, S3C64XX_SZ_ONENAND1_BUF
),
791 [2] = DEFINE_RES_IRQ(IRQ_ONENAND1
),
794 struct platform_device s3c64xx_device_onenand1
= {
795 .name
= "samsung-onenand",
797 .num_resources
= ARRAY_SIZE(s3c64xx_onenand1_resources
),
798 .resource
= s3c64xx_onenand1_resources
,
801 void __init
s3c64xx_onenand1_set_platdata(struct onenand_platform_data
*pdata
)
803 s3c_set_platdata(pdata
, sizeof(struct onenand_platform_data
),
804 &s3c64xx_device_onenand1
);
806 #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
810 #ifdef CONFIG_SAMSUNG_DEV_PWM
811 static struct resource samsung_pwm_resource
[] = {
812 DEFINE_RES_MEM(SAMSUNG_PA_TIMER
, SZ_4K
),
815 struct platform_device samsung_device_pwm
= {
816 .name
= "samsung-pwm",
818 .num_resources
= ARRAY_SIZE(samsung_pwm_resource
),
819 .resource
= samsung_pwm_resource
,
822 void __init
samsung_pwm_set_platdata(struct samsung_pwm_variant
*pd
)
824 samsung_device_pwm
.dev
.platform_data
= pd
;
826 #endif /* CONFIG_SAMSUNG_DEV_PWM */
830 #ifdef CONFIG_PLAT_S3C24XX
831 static struct resource s3c_rtc_resource
[] = {
832 [0] = DEFINE_RES_MEM(S3C24XX_PA_RTC
, SZ_256
),
833 [1] = DEFINE_RES_IRQ(IRQ_RTC
),
834 [2] = DEFINE_RES_IRQ(IRQ_TICK
),
837 struct platform_device s3c_device_rtc
= {
838 .name
= "s3c2410-rtc",
840 .num_resources
= ARRAY_SIZE(s3c_rtc_resource
),
841 .resource
= s3c_rtc_resource
,
843 #endif /* CONFIG_PLAT_S3C24XX */
845 #ifdef CONFIG_S3C_DEV_RTC
846 static struct resource s3c_rtc_resource
[] = {
847 [0] = DEFINE_RES_MEM(S3C_PA_RTC
, SZ_256
),
848 [1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM
),
849 [2] = DEFINE_RES_IRQ(IRQ_RTC_TIC
),
852 struct platform_device s3c_device_rtc
= {
853 .name
= "s3c64xx-rtc",
855 .num_resources
= ARRAY_SIZE(s3c_rtc_resource
),
856 .resource
= s3c_rtc_resource
,
858 #endif /* CONFIG_S3C_DEV_RTC */
862 #ifdef CONFIG_PLAT_S3C24XX
863 static struct resource s3c_sdi_resource
[] = {
864 [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI
, S3C24XX_SZ_SDI
),
865 [1] = DEFINE_RES_IRQ(IRQ_SDI
),
868 struct platform_device s3c_device_sdi
= {
869 .name
= "s3c2410-sdi",
871 .num_resources
= ARRAY_SIZE(s3c_sdi_resource
),
872 .resource
= s3c_sdi_resource
,
875 void __init
s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata
*pdata
)
877 s3c_set_platdata(pdata
, sizeof(struct s3c24xx_mci_pdata
),
880 #endif /* CONFIG_PLAT_S3C24XX */
884 #ifdef CONFIG_PLAT_S3C24XX
885 static struct resource s3c_spi0_resource
[] = {
886 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI
, SZ_32
),
887 [1] = DEFINE_RES_IRQ(IRQ_SPI0
),
890 struct platform_device s3c_device_spi0
= {
891 .name
= "s3c2410-spi",
893 .num_resources
= ARRAY_SIZE(s3c_spi0_resource
),
894 .resource
= s3c_spi0_resource
,
896 .dma_mask
= &samsung_device_dma_mask
,
897 .coherent_dma_mask
= DMA_BIT_MASK(32),
901 static struct resource s3c_spi1_resource
[] = {
902 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1
, SZ_32
),
903 [1] = DEFINE_RES_IRQ(IRQ_SPI1
),
906 struct platform_device s3c_device_spi1
= {
907 .name
= "s3c2410-spi",
909 .num_resources
= ARRAY_SIZE(s3c_spi1_resource
),
910 .resource
= s3c_spi1_resource
,
912 .dma_mask
= &samsung_device_dma_mask
,
913 .coherent_dma_mask
= DMA_BIT_MASK(32),
916 #endif /* CONFIG_PLAT_S3C24XX */
920 #ifdef CONFIG_PLAT_S3C24XX
921 static struct resource s3c_ts_resource
[] = {
922 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC
, S3C24XX_SZ_ADC
),
923 [1] = DEFINE_RES_IRQ(IRQ_TC
),
926 struct platform_device s3c_device_ts
= {
927 .name
= "s3c2410-ts",
929 .dev
.parent
= &s3c_device_adc
.dev
,
930 .num_resources
= ARRAY_SIZE(s3c_ts_resource
),
931 .resource
= s3c_ts_resource
,
934 void __init
s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info
*hard_s3c2410ts_info
)
936 s3c_set_platdata(hard_s3c2410ts_info
,
937 sizeof(struct s3c2410_ts_mach_info
), &s3c_device_ts
);
939 #endif /* CONFIG_PLAT_S3C24XX */
941 #ifdef CONFIG_SAMSUNG_DEV_TS
942 static struct resource s3c_ts_resource
[] = {
943 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC
, SZ_256
),
944 [1] = DEFINE_RES_IRQ(IRQ_TC
),
947 static struct s3c2410_ts_mach_info default_ts_data __initdata
= {
950 .oversampling_shift
= 2,
953 struct platform_device s3c_device_ts
= {
954 .name
= "s3c64xx-ts",
956 .num_resources
= ARRAY_SIZE(s3c_ts_resource
),
957 .resource
= s3c_ts_resource
,
960 void __init
s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info
*pd
)
963 pd
= &default_ts_data
;
965 s3c_set_platdata(pd
, sizeof(struct s3c2410_ts_mach_info
),
968 #endif /* CONFIG_SAMSUNG_DEV_TS */
972 #ifdef CONFIG_S3C_DEV_USB_HOST
973 static struct resource s3c_usb_resource
[] = {
974 [0] = DEFINE_RES_MEM(S3C_PA_USBHOST
, SZ_256
),
975 [1] = DEFINE_RES_IRQ(IRQ_USBH
),
978 struct platform_device s3c_device_ohci
= {
979 .name
= "s3c2410-ohci",
981 .num_resources
= ARRAY_SIZE(s3c_usb_resource
),
982 .resource
= s3c_usb_resource
,
984 .dma_mask
= &samsung_device_dma_mask
,
985 .coherent_dma_mask
= DMA_BIT_MASK(32),
990 * s3c_ohci_set_platdata - initialise OHCI device platform data
991 * @info: The platform data.
993 * This call copies the @info passed in and sets the device .platform_data
994 * field to that copy. The @info is copied so that the original can be marked
998 void __init
s3c_ohci_set_platdata(struct s3c2410_hcd_info
*info
)
1000 s3c_set_platdata(info
, sizeof(struct s3c2410_hcd_info
),
1003 #endif /* CONFIG_S3C_DEV_USB_HOST */
1005 /* USB Device (Gadget) */
1007 #ifdef CONFIG_PLAT_S3C24XX
1008 static struct resource s3c_usbgadget_resource
[] = {
1009 [0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV
, S3C24XX_SZ_USBDEV
),
1010 [1] = DEFINE_RES_IRQ(IRQ_USBD
),
1013 struct platform_device s3c_device_usbgadget
= {
1014 .name
= "s3c2410-usbgadget",
1016 .num_resources
= ARRAY_SIZE(s3c_usbgadget_resource
),
1017 .resource
= s3c_usbgadget_resource
,
1020 void __init
s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info
*pd
)
1022 s3c_set_platdata(pd
, sizeof(*pd
), &s3c_device_usbgadget
);
1024 #endif /* CONFIG_PLAT_S3C24XX */
1028 #ifdef CONFIG_S3C_DEV_USB_HSOTG
1029 static struct resource s3c_usb_hsotg_resources
[] = {
1030 [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG
, SZ_128K
),
1031 [1] = DEFINE_RES_IRQ(IRQ_OTG
),
1034 struct platform_device s3c_device_usb_hsotg
= {
1035 .name
= "s3c-hsotg",
1037 .num_resources
= ARRAY_SIZE(s3c_usb_hsotg_resources
),
1038 .resource
= s3c_usb_hsotg_resources
,
1040 .dma_mask
= &samsung_device_dma_mask
,
1041 .coherent_dma_mask
= DMA_BIT_MASK(32),
1045 void __init
dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat
*pd
)
1047 struct dwc2_hsotg_plat
*npd
;
1049 npd
= s3c_set_platdata(pd
, sizeof(struct dwc2_hsotg_plat
),
1050 &s3c_device_usb_hsotg
);
1053 npd
->phy_init
= s5p_usb_phy_init
;
1055 npd
->phy_exit
= s5p_usb_phy_exit
;
1057 #endif /* CONFIG_S3C_DEV_USB_HSOTG */
1059 /* USB High Spped 2.0 Device (Gadget) */
1061 #ifdef CONFIG_PLAT_S3C24XX
1062 static struct resource s3c_hsudc_resource
[] = {
1063 [0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC
, S3C2416_SZ_HSUDC
),
1064 [1] = DEFINE_RES_IRQ(IRQ_USBD
),
1067 struct platform_device s3c_device_usb_hsudc
= {
1068 .name
= "s3c-hsudc",
1070 .num_resources
= ARRAY_SIZE(s3c_hsudc_resource
),
1071 .resource
= s3c_hsudc_resource
,
1073 .dma_mask
= &samsung_device_dma_mask
,
1074 .coherent_dma_mask
= DMA_BIT_MASK(32),
1078 void __init
s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata
*pd
)
1080 s3c_set_platdata(pd
, sizeof(*pd
), &s3c_device_usb_hsudc
);
1082 #endif /* CONFIG_PLAT_S3C24XX */
1086 #ifdef CONFIG_S3C_DEV_WDT
1087 static struct resource s3c_wdt_resource
[] = {
1088 [0] = DEFINE_RES_MEM(S3C_PA_WDT
, SZ_1K
),
1089 [1] = DEFINE_RES_IRQ(IRQ_WDT
),
1092 struct platform_device s3c_device_wdt
= {
1093 .name
= "s3c2410-wdt",
1095 .num_resources
= ARRAY_SIZE(s3c_wdt_resource
),
1096 .resource
= s3c_wdt_resource
,
1098 #endif /* CONFIG_S3C_DEV_WDT */
1100 #ifdef CONFIG_S3C64XX_DEV_SPI0
1101 static struct resource s3c64xx_spi0_resource
[] = {
1102 [0] = DEFINE_RES_MEM(S3C_PA_SPI0
, SZ_256
),
1103 [1] = DEFINE_RES_DMA(DMACH_SPI0_TX
),
1104 [2] = DEFINE_RES_DMA(DMACH_SPI0_RX
),
1105 [3] = DEFINE_RES_IRQ(IRQ_SPI0
),
1108 struct platform_device s3c64xx_device_spi0
= {
1109 .name
= "s3c6410-spi",
1111 .num_resources
= ARRAY_SIZE(s3c64xx_spi0_resource
),
1112 .resource
= s3c64xx_spi0_resource
,
1114 .dma_mask
= &samsung_device_dma_mask
,
1115 .coherent_dma_mask
= DMA_BIT_MASK(32),
1119 void __init
s3c64xx_spi0_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1122 struct s3c64xx_spi_info pd
;
1124 /* Reject invalid configuration */
1125 if (!num_cs
|| src_clk_nr
< 0) {
1126 pr_err("%s: Invalid SPI configuration\n", __func__
);
1131 pd
.src_clk_nr
= src_clk_nr
;
1132 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi0_cfg_gpio
;
1133 #if defined(CONFIG_PL330_DMA)
1134 pd
.filter
= pl330_filter
;
1135 #elif defined(CONFIG_S3C64XX_PL080)
1136 pd
.filter
= pl08x_filter_id
;
1137 #elif defined(CONFIG_S3C24XX_DMAC)
1138 pd
.filter
= s3c24xx_dma_filter
;
1141 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi0
);
1143 #endif /* CONFIG_S3C64XX_DEV_SPI0 */
1145 #ifdef CONFIG_S3C64XX_DEV_SPI1
1146 static struct resource s3c64xx_spi1_resource
[] = {
1147 [0] = DEFINE_RES_MEM(S3C_PA_SPI1
, SZ_256
),
1148 [1] = DEFINE_RES_DMA(DMACH_SPI1_TX
),
1149 [2] = DEFINE_RES_DMA(DMACH_SPI1_RX
),
1150 [3] = DEFINE_RES_IRQ(IRQ_SPI1
),
1153 struct platform_device s3c64xx_device_spi1
= {
1154 .name
= "s3c6410-spi",
1156 .num_resources
= ARRAY_SIZE(s3c64xx_spi1_resource
),
1157 .resource
= s3c64xx_spi1_resource
,
1159 .dma_mask
= &samsung_device_dma_mask
,
1160 .coherent_dma_mask
= DMA_BIT_MASK(32),
1164 void __init
s3c64xx_spi1_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1167 struct s3c64xx_spi_info pd
;
1169 /* Reject invalid configuration */
1170 if (!num_cs
|| src_clk_nr
< 0) {
1171 pr_err("%s: Invalid SPI configuration\n", __func__
);
1176 pd
.src_clk_nr
= src_clk_nr
;
1177 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi1_cfg_gpio
;
1178 #if defined(CONFIG_PL330_DMA)
1179 pd
.filter
= pl330_filter
;
1180 #elif defined(CONFIG_S3C64XX_PL080)
1181 pd
.filter
= pl08x_filter_id
;
1184 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi1
);
1186 #endif /* CONFIG_S3C64XX_DEV_SPI1 */
1188 #ifdef CONFIG_S3C64XX_DEV_SPI2
1189 static struct resource s3c64xx_spi2_resource
[] = {
1190 [0] = DEFINE_RES_MEM(S3C_PA_SPI2
, SZ_256
),
1191 [1] = DEFINE_RES_DMA(DMACH_SPI2_TX
),
1192 [2] = DEFINE_RES_DMA(DMACH_SPI2_RX
),
1193 [3] = DEFINE_RES_IRQ(IRQ_SPI2
),
1196 struct platform_device s3c64xx_device_spi2
= {
1197 .name
= "s3c6410-spi",
1199 .num_resources
= ARRAY_SIZE(s3c64xx_spi2_resource
),
1200 .resource
= s3c64xx_spi2_resource
,
1202 .dma_mask
= &samsung_device_dma_mask
,
1203 .coherent_dma_mask
= DMA_BIT_MASK(32),
1207 void __init
s3c64xx_spi2_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1210 struct s3c64xx_spi_info pd
;
1212 /* Reject invalid configuration */
1213 if (!num_cs
|| src_clk_nr
< 0) {
1214 pr_err("%s: Invalid SPI configuration\n", __func__
);
1219 pd
.src_clk_nr
= src_clk_nr
;
1220 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi2_cfg_gpio
;
1221 #if defined(CONFIG_PL330_DMA)
1222 pd
.filter
= pl330_filter
;
1223 #elif defined(CONFIG_S3C64XX_PL080)
1224 pd
.filter
= pl08x_filter_id
;
1227 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi2
);
1229 #endif /* CONFIG_S3C64XX_DEV_SPI2 */