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 <linux/platform_data/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 #define samsung_device_dma_mask (*((u64[]) { 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 #ifdef CONFIG_S3C24XX_DMAC
82 .dma_filter
= s3c24xx_dma_filter
,
84 .dma_playback
= (void *)DMACH_PCM_OUT
,
85 .dma_capture
= (void *)DMACH_PCM_IN
,
86 .dma_capture_mic
= (void *)DMACH_MIC_IN
,
89 struct platform_device s3c_device_ac97
= {
90 .name
= "samsung-ac97",
92 .num_resources
= ARRAY_SIZE(s3c_ac97_resource
),
93 .resource
= s3c_ac97_resource
,
95 .dma_mask
= &samsung_device_dma_mask
,
96 .coherent_dma_mask
= DMA_BIT_MASK(32),
97 .platform_data
= &s3c_ac97_pdata
,
100 #endif /* CONFIG_CPU_S3C2440 */
104 #ifdef CONFIG_PLAT_S3C24XX
105 static struct resource s3c_adc_resource
[] = {
106 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC
, S3C24XX_SZ_ADC
),
107 [1] = DEFINE_RES_IRQ(IRQ_TC
),
108 [2] = DEFINE_RES_IRQ(IRQ_ADC
),
111 struct platform_device s3c_device_adc
= {
112 .name
= "s3c24xx-adc",
114 .num_resources
= ARRAY_SIZE(s3c_adc_resource
),
115 .resource
= s3c_adc_resource
,
117 #endif /* CONFIG_PLAT_S3C24XX */
119 #if defined(CONFIG_SAMSUNG_DEV_ADC)
120 static struct resource s3c_adc_resource
[] = {
121 [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC
, SZ_256
),
122 [1] = DEFINE_RES_IRQ(IRQ_ADC
),
123 [2] = DEFINE_RES_IRQ(IRQ_TC
),
126 struct platform_device s3c_device_adc
= {
127 .name
= "exynos-adc",
129 .num_resources
= ARRAY_SIZE(s3c_adc_resource
),
130 .resource
= s3c_adc_resource
,
132 #endif /* CONFIG_SAMSUNG_DEV_ADC */
134 /* Camif Controller */
136 #ifdef CONFIG_CPU_S3C2440
137 static struct resource s3c_camif_resource
[] = {
138 [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF
, S3C2440_SZ_CAMIF
),
139 [1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C
),
140 [2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P
),
143 struct platform_device s3c_device_camif
= {
144 .name
= "s3c2440-camif",
146 .num_resources
= ARRAY_SIZE(s3c_camif_resource
),
147 .resource
= s3c_camif_resource
,
149 .dma_mask
= &samsung_device_dma_mask
,
150 .coherent_dma_mask
= DMA_BIT_MASK(32),
153 #endif /* CONFIG_CPU_S3C2440 */
157 #ifdef CONFIG_S3C_DEV_FB
158 static struct resource s3c_fb_resource
[] = {
159 [0] = DEFINE_RES_MEM(S3C_PA_FB
, SZ_16K
),
160 [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC
),
161 [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO
),
162 [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM
),
165 struct platform_device s3c_device_fb
= {
168 .num_resources
= ARRAY_SIZE(s3c_fb_resource
),
169 .resource
= s3c_fb_resource
,
171 .dma_mask
= &samsung_device_dma_mask
,
172 .coherent_dma_mask
= DMA_BIT_MASK(32),
176 void __init
s3c_fb_set_platdata(struct s3c_fb_platdata
*pd
)
178 s3c_set_platdata(pd
, sizeof(struct s3c_fb_platdata
),
181 #endif /* CONFIG_S3C_DEV_FB */
185 #ifdef CONFIG_S3C_DEV_HWMON
186 struct platform_device s3c_device_hwmon
= {
189 .dev
.parent
= &s3c_device_adc
.dev
,
192 void __init
s3c_hwmon_set_platdata(struct s3c_hwmon_pdata
*pd
)
194 s3c_set_platdata(pd
, sizeof(struct s3c_hwmon_pdata
),
197 #endif /* CONFIG_S3C_DEV_HWMON */
201 #ifdef CONFIG_S3C_DEV_HSMMC
202 static struct resource s3c_hsmmc_resource
[] = {
203 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0
, SZ_4K
),
204 [1] = DEFINE_RES_IRQ(IRQ_HSMMC0
),
207 struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata
= {
209 .host_caps
= (MMC_CAP_4_BIT_DATA
|
210 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
213 struct platform_device s3c_device_hsmmc0
= {
216 .num_resources
= ARRAY_SIZE(s3c_hsmmc_resource
),
217 .resource
= s3c_hsmmc_resource
,
219 .dma_mask
= &samsung_device_dma_mask
,
220 .coherent_dma_mask
= DMA_BIT_MASK(32),
221 .platform_data
= &s3c_hsmmc0_def_platdata
,
225 void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata
*pd
)
227 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc0_def_platdata
);
229 #endif /* CONFIG_S3C_DEV_HSMMC */
231 #ifdef CONFIG_S3C_DEV_HSMMC1
232 static struct resource s3c_hsmmc1_resource
[] = {
233 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1
, SZ_4K
),
234 [1] = DEFINE_RES_IRQ(IRQ_HSMMC1
),
237 struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata
= {
239 .host_caps
= (MMC_CAP_4_BIT_DATA
|
240 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
243 struct platform_device s3c_device_hsmmc1
= {
246 .num_resources
= ARRAY_SIZE(s3c_hsmmc1_resource
),
247 .resource
= s3c_hsmmc1_resource
,
249 .dma_mask
= &samsung_device_dma_mask
,
250 .coherent_dma_mask
= DMA_BIT_MASK(32),
251 .platform_data
= &s3c_hsmmc1_def_platdata
,
255 void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata
*pd
)
257 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc1_def_platdata
);
259 #endif /* CONFIG_S3C_DEV_HSMMC1 */
263 #ifdef CONFIG_S3C_DEV_HSMMC2
264 static struct resource s3c_hsmmc2_resource
[] = {
265 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2
, SZ_4K
),
266 [1] = DEFINE_RES_IRQ(IRQ_HSMMC2
),
269 struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata
= {
271 .host_caps
= (MMC_CAP_4_BIT_DATA
|
272 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
275 struct platform_device s3c_device_hsmmc2
= {
278 .num_resources
= ARRAY_SIZE(s3c_hsmmc2_resource
),
279 .resource
= s3c_hsmmc2_resource
,
281 .dma_mask
= &samsung_device_dma_mask
,
282 .coherent_dma_mask
= DMA_BIT_MASK(32),
283 .platform_data
= &s3c_hsmmc2_def_platdata
,
287 void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata
*pd
)
289 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc2_def_platdata
);
291 #endif /* CONFIG_S3C_DEV_HSMMC2 */
293 #ifdef CONFIG_S3C_DEV_HSMMC3
294 static struct resource s3c_hsmmc3_resource
[] = {
295 [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3
, SZ_4K
),
296 [1] = DEFINE_RES_IRQ(IRQ_HSMMC3
),
299 struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata
= {
301 .host_caps
= (MMC_CAP_4_BIT_DATA
|
302 MMC_CAP_MMC_HIGHSPEED
| MMC_CAP_SD_HIGHSPEED
),
305 struct platform_device s3c_device_hsmmc3
= {
308 .num_resources
= ARRAY_SIZE(s3c_hsmmc3_resource
),
309 .resource
= s3c_hsmmc3_resource
,
311 .dma_mask
= &samsung_device_dma_mask
,
312 .coherent_dma_mask
= DMA_BIT_MASK(32),
313 .platform_data
= &s3c_hsmmc3_def_platdata
,
317 void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata
*pd
)
319 s3c_sdhci_set_platdata(pd
, &s3c_hsmmc3_def_platdata
);
321 #endif /* CONFIG_S3C_DEV_HSMMC3 */
325 static struct resource s3c_i2c0_resource
[] = {
326 [0] = DEFINE_RES_MEM(S3C_PA_IIC
, SZ_4K
),
327 [1] = DEFINE_RES_IRQ(IRQ_IIC
),
330 struct platform_device s3c_device_i2c0
= {
331 .name
= "s3c2410-i2c",
333 .num_resources
= ARRAY_SIZE(s3c_i2c0_resource
),
334 .resource
= s3c_i2c0_resource
,
337 struct s3c2410_platform_i2c default_i2c_data __initdata
= {
340 .frequency
= 100*1000,
344 void __init
s3c_i2c0_set_platdata(struct s3c2410_platform_i2c
*pd
)
346 struct s3c2410_platform_i2c
*npd
;
349 pd
= &default_i2c_data
;
353 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
357 npd
->cfg_gpio
= s3c_i2c0_cfg_gpio
;
360 #ifdef CONFIG_S3C_DEV_I2C1
361 static struct resource s3c_i2c1_resource
[] = {
362 [0] = DEFINE_RES_MEM(S3C_PA_IIC1
, SZ_4K
),
363 [1] = DEFINE_RES_IRQ(IRQ_IIC1
),
366 struct platform_device s3c_device_i2c1
= {
367 .name
= "s3c2410-i2c",
369 .num_resources
= ARRAY_SIZE(s3c_i2c1_resource
),
370 .resource
= s3c_i2c1_resource
,
373 void __init
s3c_i2c1_set_platdata(struct s3c2410_platform_i2c
*pd
)
375 struct s3c2410_platform_i2c
*npd
;
378 pd
= &default_i2c_data
;
382 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
386 npd
->cfg_gpio
= s3c_i2c1_cfg_gpio
;
388 #endif /* CONFIG_S3C_DEV_I2C1 */
390 #ifdef CONFIG_S3C_DEV_I2C2
391 static struct resource s3c_i2c2_resource
[] = {
392 [0] = DEFINE_RES_MEM(S3C_PA_IIC2
, SZ_4K
),
393 [1] = DEFINE_RES_IRQ(IRQ_IIC2
),
396 struct platform_device s3c_device_i2c2
= {
397 .name
= "s3c2410-i2c",
399 .num_resources
= ARRAY_SIZE(s3c_i2c2_resource
),
400 .resource
= s3c_i2c2_resource
,
403 void __init
s3c_i2c2_set_platdata(struct s3c2410_platform_i2c
*pd
)
405 struct s3c2410_platform_i2c
*npd
;
408 pd
= &default_i2c_data
;
412 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
416 npd
->cfg_gpio
= s3c_i2c2_cfg_gpio
;
418 #endif /* CONFIG_S3C_DEV_I2C2 */
420 #ifdef CONFIG_S3C_DEV_I2C3
421 static struct resource s3c_i2c3_resource
[] = {
422 [0] = DEFINE_RES_MEM(S3C_PA_IIC3
, SZ_4K
),
423 [1] = DEFINE_RES_IRQ(IRQ_IIC3
),
426 struct platform_device s3c_device_i2c3
= {
427 .name
= "s3c2440-i2c",
429 .num_resources
= ARRAY_SIZE(s3c_i2c3_resource
),
430 .resource
= s3c_i2c3_resource
,
433 void __init
s3c_i2c3_set_platdata(struct s3c2410_platform_i2c
*pd
)
435 struct s3c2410_platform_i2c
*npd
;
438 pd
= &default_i2c_data
;
442 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
446 npd
->cfg_gpio
= s3c_i2c3_cfg_gpio
;
448 #endif /*CONFIG_S3C_DEV_I2C3 */
450 #ifdef CONFIG_S3C_DEV_I2C4
451 static struct resource s3c_i2c4_resource
[] = {
452 [0] = DEFINE_RES_MEM(S3C_PA_IIC4
, SZ_4K
),
453 [1] = DEFINE_RES_IRQ(IRQ_IIC4
),
456 struct platform_device s3c_device_i2c4
= {
457 .name
= "s3c2440-i2c",
459 .num_resources
= ARRAY_SIZE(s3c_i2c4_resource
),
460 .resource
= s3c_i2c4_resource
,
463 void __init
s3c_i2c4_set_platdata(struct s3c2410_platform_i2c
*pd
)
465 struct s3c2410_platform_i2c
*npd
;
468 pd
= &default_i2c_data
;
472 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
476 npd
->cfg_gpio
= s3c_i2c4_cfg_gpio
;
478 #endif /*CONFIG_S3C_DEV_I2C4 */
480 #ifdef CONFIG_S3C_DEV_I2C5
481 static struct resource s3c_i2c5_resource
[] = {
482 [0] = DEFINE_RES_MEM(S3C_PA_IIC5
, SZ_4K
),
483 [1] = DEFINE_RES_IRQ(IRQ_IIC5
),
486 struct platform_device s3c_device_i2c5
= {
487 .name
= "s3c2440-i2c",
489 .num_resources
= ARRAY_SIZE(s3c_i2c5_resource
),
490 .resource
= s3c_i2c5_resource
,
493 void __init
s3c_i2c5_set_platdata(struct s3c2410_platform_i2c
*pd
)
495 struct s3c2410_platform_i2c
*npd
;
498 pd
= &default_i2c_data
;
502 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
506 npd
->cfg_gpio
= s3c_i2c5_cfg_gpio
;
508 #endif /*CONFIG_S3C_DEV_I2C5 */
510 #ifdef CONFIG_S3C_DEV_I2C6
511 static struct resource s3c_i2c6_resource
[] = {
512 [0] = DEFINE_RES_MEM(S3C_PA_IIC6
, SZ_4K
),
513 [1] = DEFINE_RES_IRQ(IRQ_IIC6
),
516 struct platform_device s3c_device_i2c6
= {
517 .name
= "s3c2440-i2c",
519 .num_resources
= ARRAY_SIZE(s3c_i2c6_resource
),
520 .resource
= s3c_i2c6_resource
,
523 void __init
s3c_i2c6_set_platdata(struct s3c2410_platform_i2c
*pd
)
525 struct s3c2410_platform_i2c
*npd
;
528 pd
= &default_i2c_data
;
532 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
536 npd
->cfg_gpio
= s3c_i2c6_cfg_gpio
;
538 #endif /* CONFIG_S3C_DEV_I2C6 */
540 #ifdef CONFIG_S3C_DEV_I2C7
541 static struct resource s3c_i2c7_resource
[] = {
542 [0] = DEFINE_RES_MEM(S3C_PA_IIC7
, SZ_4K
),
543 [1] = DEFINE_RES_IRQ(IRQ_IIC7
),
546 struct platform_device s3c_device_i2c7
= {
547 .name
= "s3c2440-i2c",
549 .num_resources
= ARRAY_SIZE(s3c_i2c7_resource
),
550 .resource
= s3c_i2c7_resource
,
553 void __init
s3c_i2c7_set_platdata(struct s3c2410_platform_i2c
*pd
)
555 struct s3c2410_platform_i2c
*npd
;
558 pd
= &default_i2c_data
;
562 npd
= s3c_set_platdata(pd
, sizeof(struct s3c2410_platform_i2c
),
566 npd
->cfg_gpio
= s3c_i2c7_cfg_gpio
;
568 #endif /* CONFIG_S3C_DEV_I2C7 */
572 #ifdef CONFIG_PLAT_S3C24XX
573 static struct resource s3c_iis_resource
[] = {
574 [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS
, S3C24XX_SZ_IIS
),
577 static struct s3c_audio_pdata s3c_iis_platdata
= {
578 #ifdef CONFIG_S3C24XX_DMAC
579 .dma_filter
= s3c24xx_dma_filter
,
581 .dma_playback
= (void *)DMACH_I2S_OUT
,
582 .dma_capture
= (void *)DMACH_I2S_IN
,
585 struct platform_device s3c_device_iis
= {
586 .name
= "s3c24xx-iis",
588 .num_resources
= ARRAY_SIZE(s3c_iis_resource
),
589 .resource
= s3c_iis_resource
,
591 .dma_mask
= &samsung_device_dma_mask
,
592 .coherent_dma_mask
= DMA_BIT_MASK(32),
593 .platform_data
= &s3c_iis_platdata
,
596 #endif /* CONFIG_PLAT_S3C24XX */
600 #ifdef CONFIG_SAMSUNG_DEV_IDE
601 static struct resource s3c_cfcon_resource
[] = {
602 [0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON
, SZ_16K
),
603 [1] = DEFINE_RES_IRQ(IRQ_CFCON
),
606 struct platform_device s3c_device_cfcon
= {
608 .num_resources
= ARRAY_SIZE(s3c_cfcon_resource
),
609 .resource
= s3c_cfcon_resource
,
612 void __init
s3c_ide_set_platdata(struct s3c_ide_platdata
*pdata
)
614 s3c_set_platdata(pdata
, sizeof(struct s3c_ide_platdata
),
617 #endif /* CONFIG_SAMSUNG_DEV_IDE */
621 #ifdef CONFIG_SAMSUNG_DEV_KEYPAD
622 static struct resource samsung_keypad_resources
[] = {
623 [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD
, SZ_32
),
624 [1] = DEFINE_RES_IRQ(IRQ_KEYPAD
),
627 struct platform_device samsung_device_keypad
= {
628 .name
= "samsung-keypad",
630 .num_resources
= ARRAY_SIZE(samsung_keypad_resources
),
631 .resource
= samsung_keypad_resources
,
634 void __init
samsung_keypad_set_platdata(struct samsung_keypad_platdata
*pd
)
636 struct samsung_keypad_platdata
*npd
;
638 npd
= s3c_set_platdata(pd
, sizeof(struct samsung_keypad_platdata
),
639 &samsung_device_keypad
);
642 npd
->cfg_gpio
= samsung_keypad_cfg_gpio
;
644 #endif /* CONFIG_SAMSUNG_DEV_KEYPAD */
648 #ifdef CONFIG_PLAT_S3C24XX
649 static struct resource s3c_lcd_resource
[] = {
650 [0] = DEFINE_RES_MEM(S3C24XX_PA_LCD
, S3C24XX_SZ_LCD
),
651 [1] = DEFINE_RES_IRQ(IRQ_LCD
),
654 struct platform_device s3c_device_lcd
= {
655 .name
= "s3c2410-lcd",
657 .num_resources
= ARRAY_SIZE(s3c_lcd_resource
),
658 .resource
= s3c_lcd_resource
,
660 .dma_mask
= &samsung_device_dma_mask
,
661 .coherent_dma_mask
= DMA_BIT_MASK(32),
665 void __init
s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info
*pd
)
667 struct s3c2410fb_mach_info
*npd
;
669 npd
= s3c_set_platdata(pd
, sizeof(*npd
), &s3c_device_lcd
);
671 npd
->displays
= kmemdup(pd
->displays
,
672 sizeof(struct s3c2410fb_display
) * npd
->num_displays
,
675 printk(KERN_ERR
"no memory for LCD display data\n");
677 printk(KERN_ERR
"no memory for LCD platform data\n");
680 #endif /* CONFIG_PLAT_S3C24XX */
684 #ifdef CONFIG_S3C_DEV_NAND
685 static struct resource s3c_nand_resource
[] = {
686 [0] = DEFINE_RES_MEM(S3C_PA_NAND
, SZ_1M
),
689 struct platform_device s3c_device_nand
= {
690 .name
= "s3c2410-nand",
692 .num_resources
= ARRAY_SIZE(s3c_nand_resource
),
693 .resource
= s3c_nand_resource
,
697 * s3c_nand_copy_set() - copy nand set data
698 * @set: The new structure, directly copied from the old.
700 * Copy all the fields from the NAND set field from what is probably __initdata
701 * to new kernel memory. The code returns 0 if the copy happened correctly or
702 * an error code for the calling function to display.
704 * Note, we currently do not try and look to see if we've already copied the
705 * data in a previous set.
707 static int __init
s3c_nand_copy_set(struct s3c2410_nand_set
*set
)
712 size
= sizeof(struct mtd_partition
) * set
->nr_partitions
;
714 ptr
= kmemdup(set
->partitions
, size
, GFP_KERNEL
);
715 set
->partitions
= ptr
;
721 if (set
->nr_map
&& set
->nr_chips
) {
722 size
= sizeof(int) * set
->nr_chips
;
723 ptr
= kmemdup(set
->nr_map
, size
, GFP_KERNEL
);
733 void __init
s3c_nand_set_platdata(struct s3c2410_platform_nand
*nand
)
735 struct s3c2410_platform_nand
*npd
;
739 /* note, if we get a failure in allocation, we simply drop out of the
740 * function. If there is so little memory available at initialisation
741 * time then there is little chance the system is going to run.
744 npd
= s3c_set_platdata(nand
, sizeof(struct s3c2410_platform_nand
),
749 /* now see if we need to copy any of the nand set data */
751 size
= sizeof(struct s3c2410_nand_set
) * npd
->nr_sets
;
753 struct s3c2410_nand_set
*from
= npd
->sets
;
754 struct s3c2410_nand_set
*to
;
757 to
= kmemdup(from
, size
, GFP_KERNEL
);
758 npd
->sets
= to
; /* set, even if we failed */
761 printk(KERN_ERR
"%s: no memory for sets\n", __func__
);
765 for (i
= 0; i
< npd
->nr_sets
; i
++) {
766 ret
= s3c_nand_copy_set(to
);
768 printk(KERN_ERR
"%s: failed to copy set %d\n",
776 #endif /* CONFIG_S3C_DEV_NAND */
780 #ifdef CONFIG_S3C_DEV_ONENAND
781 static struct resource s3c_onenand_resources
[] = {
782 [0] = DEFINE_RES_MEM(S3C_PA_ONENAND
, SZ_1K
),
783 [1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF
, S3C_SZ_ONENAND_BUF
),
784 [2] = DEFINE_RES_IRQ(IRQ_ONENAND
),
787 struct platform_device s3c_device_onenand
= {
788 .name
= "samsung-onenand",
790 .num_resources
= ARRAY_SIZE(s3c_onenand_resources
),
791 .resource
= s3c_onenand_resources
,
793 #endif /* CONFIG_S3C_DEV_ONENAND */
795 #ifdef CONFIG_S3C64XX_DEV_ONENAND1
796 static struct resource s3c64xx_onenand1_resources
[] = {
797 [0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1
, SZ_1K
),
798 [1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF
, S3C64XX_SZ_ONENAND1_BUF
),
799 [2] = DEFINE_RES_IRQ(IRQ_ONENAND1
),
802 struct platform_device s3c64xx_device_onenand1
= {
803 .name
= "samsung-onenand",
805 .num_resources
= ARRAY_SIZE(s3c64xx_onenand1_resources
),
806 .resource
= s3c64xx_onenand1_resources
,
809 void __init
s3c64xx_onenand1_set_platdata(struct onenand_platform_data
*pdata
)
811 s3c_set_platdata(pdata
, sizeof(struct onenand_platform_data
),
812 &s3c64xx_device_onenand1
);
814 #endif /* CONFIG_S3C64XX_DEV_ONENAND1 */
818 #ifdef CONFIG_SAMSUNG_DEV_PWM
819 static struct resource samsung_pwm_resource
[] = {
820 DEFINE_RES_MEM(SAMSUNG_PA_TIMER
, SZ_4K
),
823 struct platform_device samsung_device_pwm
= {
824 .name
= "samsung-pwm",
826 .num_resources
= ARRAY_SIZE(samsung_pwm_resource
),
827 .resource
= samsung_pwm_resource
,
830 void __init
samsung_pwm_set_platdata(struct samsung_pwm_variant
*pd
)
832 samsung_device_pwm
.dev
.platform_data
= pd
;
834 #endif /* CONFIG_SAMSUNG_DEV_PWM */
838 #ifdef CONFIG_PLAT_S3C24XX
839 static struct resource s3c_rtc_resource
[] = {
840 [0] = DEFINE_RES_MEM(S3C24XX_PA_RTC
, SZ_256
),
841 [1] = DEFINE_RES_IRQ(IRQ_RTC
),
842 [2] = DEFINE_RES_IRQ(IRQ_TICK
),
845 struct platform_device s3c_device_rtc
= {
846 .name
= "s3c2410-rtc",
848 .num_resources
= ARRAY_SIZE(s3c_rtc_resource
),
849 .resource
= s3c_rtc_resource
,
851 #endif /* CONFIG_PLAT_S3C24XX */
853 #ifdef CONFIG_S3C_DEV_RTC
854 static struct resource s3c_rtc_resource
[] = {
855 [0] = DEFINE_RES_MEM(S3C_PA_RTC
, SZ_256
),
856 [1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM
),
857 [2] = DEFINE_RES_IRQ(IRQ_RTC_TIC
),
860 struct platform_device s3c_device_rtc
= {
861 .name
= "s3c64xx-rtc",
863 .num_resources
= ARRAY_SIZE(s3c_rtc_resource
),
864 .resource
= s3c_rtc_resource
,
866 #endif /* CONFIG_S3C_DEV_RTC */
870 #ifdef CONFIG_PLAT_S3C24XX
871 static struct resource s3c_sdi_resource
[] = {
872 [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI
, S3C24XX_SZ_SDI
),
873 [1] = DEFINE_RES_IRQ(IRQ_SDI
),
876 struct platform_device s3c_device_sdi
= {
877 .name
= "s3c2410-sdi",
879 .num_resources
= ARRAY_SIZE(s3c_sdi_resource
),
880 .resource
= s3c_sdi_resource
,
883 void __init
s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata
*pdata
)
885 s3c_set_platdata(pdata
, sizeof(struct s3c24xx_mci_pdata
),
888 #endif /* CONFIG_PLAT_S3C24XX */
892 #ifdef CONFIG_PLAT_S3C24XX
893 static struct resource s3c_spi0_resource
[] = {
894 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI
, SZ_32
),
895 [1] = DEFINE_RES_IRQ(IRQ_SPI0
),
898 struct platform_device s3c_device_spi0
= {
899 .name
= "s3c2410-spi",
901 .num_resources
= ARRAY_SIZE(s3c_spi0_resource
),
902 .resource
= s3c_spi0_resource
,
904 .dma_mask
= &samsung_device_dma_mask
,
905 .coherent_dma_mask
= DMA_BIT_MASK(32),
909 static struct resource s3c_spi1_resource
[] = {
910 [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1
, SZ_32
),
911 [1] = DEFINE_RES_IRQ(IRQ_SPI1
),
914 struct platform_device s3c_device_spi1
= {
915 .name
= "s3c2410-spi",
917 .num_resources
= ARRAY_SIZE(s3c_spi1_resource
),
918 .resource
= s3c_spi1_resource
,
920 .dma_mask
= &samsung_device_dma_mask
,
921 .coherent_dma_mask
= DMA_BIT_MASK(32),
924 #endif /* CONFIG_PLAT_S3C24XX */
928 #ifdef CONFIG_PLAT_S3C24XX
929 static struct resource s3c_ts_resource
[] = {
930 [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC
, S3C24XX_SZ_ADC
),
931 [1] = DEFINE_RES_IRQ(IRQ_TC
),
934 struct platform_device s3c_device_ts
= {
935 .name
= "s3c2410-ts",
937 .dev
.parent
= &s3c_device_adc
.dev
,
938 .num_resources
= ARRAY_SIZE(s3c_ts_resource
),
939 .resource
= s3c_ts_resource
,
942 void __init
s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info
*hard_s3c2410ts_info
)
944 s3c_set_platdata(hard_s3c2410ts_info
,
945 sizeof(struct s3c2410_ts_mach_info
), &s3c_device_ts
);
947 #endif /* CONFIG_PLAT_S3C24XX */
949 #ifdef CONFIG_SAMSUNG_DEV_TS
950 static struct s3c2410_ts_mach_info default_ts_data __initdata
= {
953 .oversampling_shift
= 2,
956 void __init
s3c64xx_ts_set_platdata(struct s3c2410_ts_mach_info
*pd
)
959 pd
= &default_ts_data
;
961 s3c_set_platdata(pd
, sizeof(struct s3c2410_ts_mach_info
),
964 #endif /* CONFIG_SAMSUNG_DEV_TS */
968 #ifdef CONFIG_S3C_DEV_USB_HOST
969 static struct resource s3c_usb_resource
[] = {
970 [0] = DEFINE_RES_MEM(S3C_PA_USBHOST
, SZ_256
),
971 [1] = DEFINE_RES_IRQ(IRQ_USBH
),
974 struct platform_device s3c_device_ohci
= {
975 .name
= "s3c2410-ohci",
977 .num_resources
= ARRAY_SIZE(s3c_usb_resource
),
978 .resource
= s3c_usb_resource
,
980 .dma_mask
= &samsung_device_dma_mask
,
981 .coherent_dma_mask
= DMA_BIT_MASK(32),
986 * s3c_ohci_set_platdata - initialise OHCI device platform data
987 * @info: The platform data.
989 * This call copies the @info passed in and sets the device .platform_data
990 * field to that copy. The @info is copied so that the original can be marked
994 void __init
s3c_ohci_set_platdata(struct s3c2410_hcd_info
*info
)
996 s3c_set_platdata(info
, sizeof(struct s3c2410_hcd_info
),
999 #endif /* CONFIG_S3C_DEV_USB_HOST */
1001 /* USB Device (Gadget) */
1003 #ifdef CONFIG_PLAT_S3C24XX
1004 static struct resource s3c_usbgadget_resource
[] = {
1005 [0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV
, S3C24XX_SZ_USBDEV
),
1006 [1] = DEFINE_RES_IRQ(IRQ_USBD
),
1009 struct platform_device s3c_device_usbgadget
= {
1010 .name
= "s3c2410-usbgadget",
1012 .num_resources
= ARRAY_SIZE(s3c_usbgadget_resource
),
1013 .resource
= s3c_usbgadget_resource
,
1016 void __init
s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info
*pd
)
1018 s3c_set_platdata(pd
, sizeof(*pd
), &s3c_device_usbgadget
);
1020 #endif /* CONFIG_PLAT_S3C24XX */
1024 #ifdef CONFIG_S3C_DEV_USB_HSOTG
1025 static struct resource s3c_usb_hsotg_resources
[] = {
1026 [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG
, SZ_128K
),
1027 [1] = DEFINE_RES_IRQ(IRQ_OTG
),
1030 struct platform_device s3c_device_usb_hsotg
= {
1031 .name
= "s3c-hsotg",
1033 .num_resources
= ARRAY_SIZE(s3c_usb_hsotg_resources
),
1034 .resource
= s3c_usb_hsotg_resources
,
1036 .dma_mask
= &samsung_device_dma_mask
,
1037 .coherent_dma_mask
= DMA_BIT_MASK(32),
1041 void __init
dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat
*pd
)
1043 struct dwc2_hsotg_plat
*npd
;
1045 npd
= s3c_set_platdata(pd
, sizeof(struct dwc2_hsotg_plat
),
1046 &s3c_device_usb_hsotg
);
1049 npd
->phy_init
= s5p_usb_phy_init
;
1051 npd
->phy_exit
= s5p_usb_phy_exit
;
1053 #endif /* CONFIG_S3C_DEV_USB_HSOTG */
1055 /* USB High Spped 2.0 Device (Gadget) */
1057 #ifdef CONFIG_PLAT_S3C24XX
1058 static struct resource s3c_hsudc_resource
[] = {
1059 [0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC
, S3C2416_SZ_HSUDC
),
1060 [1] = DEFINE_RES_IRQ(IRQ_USBD
),
1063 struct platform_device s3c_device_usb_hsudc
= {
1064 .name
= "s3c-hsudc",
1066 .num_resources
= ARRAY_SIZE(s3c_hsudc_resource
),
1067 .resource
= s3c_hsudc_resource
,
1069 .dma_mask
= &samsung_device_dma_mask
,
1070 .coherent_dma_mask
= DMA_BIT_MASK(32),
1074 void __init
s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata
*pd
)
1076 s3c_set_platdata(pd
, sizeof(*pd
), &s3c_device_usb_hsudc
);
1078 #endif /* CONFIG_PLAT_S3C24XX */
1082 #ifdef CONFIG_S3C_DEV_WDT
1083 static struct resource s3c_wdt_resource
[] = {
1084 [0] = DEFINE_RES_MEM(S3C_PA_WDT
, SZ_1K
),
1085 [1] = DEFINE_RES_IRQ(IRQ_WDT
),
1088 struct platform_device s3c_device_wdt
= {
1089 .name
= "s3c2410-wdt",
1091 .num_resources
= ARRAY_SIZE(s3c_wdt_resource
),
1092 .resource
= s3c_wdt_resource
,
1094 #endif /* CONFIG_S3C_DEV_WDT */
1096 #ifdef CONFIG_S3C64XX_DEV_SPI0
1097 static struct resource s3c64xx_spi0_resource
[] = {
1098 [0] = DEFINE_RES_MEM(S3C_PA_SPI0
, SZ_256
),
1099 [1] = DEFINE_RES_IRQ(IRQ_SPI0
),
1102 struct platform_device s3c64xx_device_spi0
= {
1103 .name
= "s3c6410-spi",
1105 .num_resources
= ARRAY_SIZE(s3c64xx_spi0_resource
),
1106 .resource
= s3c64xx_spi0_resource
,
1108 .dma_mask
= &samsung_device_dma_mask
,
1109 .coherent_dma_mask
= DMA_BIT_MASK(32),
1113 void __init
s3c64xx_spi0_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1116 struct s3c64xx_spi_info pd
;
1118 /* Reject invalid configuration */
1119 if (!num_cs
|| src_clk_nr
< 0) {
1120 pr_err("%s: Invalid SPI configuration\n", __func__
);
1125 pd
.src_clk_nr
= src_clk_nr
;
1126 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi0_cfg_gpio
;
1127 pd
.dma_tx
= (void *)DMACH_SPI0_TX
;
1128 pd
.dma_rx
= (void *)DMACH_SPI0_RX
;
1129 #if defined(CONFIG_PL330_DMA)
1130 pd
.filter
= pl330_filter
;
1131 #elif defined(CONFIG_S3C64XX_PL080)
1132 pd
.filter
= pl08x_filter_id
;
1133 #elif defined(CONFIG_S3C24XX_DMAC)
1134 pd
.filter
= s3c24xx_dma_filter
;
1137 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi0
);
1139 #endif /* CONFIG_S3C64XX_DEV_SPI0 */
1141 #ifdef CONFIG_S3C64XX_DEV_SPI1
1142 static struct resource s3c64xx_spi1_resource
[] = {
1143 [0] = DEFINE_RES_MEM(S3C_PA_SPI1
, SZ_256
),
1144 [1] = DEFINE_RES_IRQ(IRQ_SPI1
),
1147 struct platform_device s3c64xx_device_spi1
= {
1148 .name
= "s3c6410-spi",
1150 .num_resources
= ARRAY_SIZE(s3c64xx_spi1_resource
),
1151 .resource
= s3c64xx_spi1_resource
,
1153 .dma_mask
= &samsung_device_dma_mask
,
1154 .coherent_dma_mask
= DMA_BIT_MASK(32),
1158 void __init
s3c64xx_spi1_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1161 struct s3c64xx_spi_info pd
;
1163 /* Reject invalid configuration */
1164 if (!num_cs
|| src_clk_nr
< 0) {
1165 pr_err("%s: Invalid SPI configuration\n", __func__
);
1170 pd
.src_clk_nr
= src_clk_nr
;
1171 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi1_cfg_gpio
;
1172 pd
.dma_tx
= (void *)DMACH_SPI1_TX
;
1173 pd
.dma_rx
= (void *)DMACH_SPI1_RX
;
1174 #if defined(CONFIG_PL330_DMA)
1175 pd
.filter
= pl330_filter
;
1176 #elif defined(CONFIG_S3C64XX_PL080)
1177 pd
.filter
= pl08x_filter_id
;
1181 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi1
);
1183 #endif /* CONFIG_S3C64XX_DEV_SPI1 */
1185 #ifdef CONFIG_S3C64XX_DEV_SPI2
1186 static struct resource s3c64xx_spi2_resource
[] = {
1187 [0] = DEFINE_RES_MEM(S3C_PA_SPI2
, SZ_256
),
1188 [1] = DEFINE_RES_IRQ(IRQ_SPI2
),
1191 struct platform_device s3c64xx_device_spi2
= {
1192 .name
= "s3c6410-spi",
1194 .num_resources
= ARRAY_SIZE(s3c64xx_spi2_resource
),
1195 .resource
= s3c64xx_spi2_resource
,
1197 .dma_mask
= &samsung_device_dma_mask
,
1198 .coherent_dma_mask
= DMA_BIT_MASK(32),
1202 void __init
s3c64xx_spi2_set_platdata(int (*cfg_gpio
)(void), int src_clk_nr
,
1205 struct s3c64xx_spi_info pd
;
1207 /* Reject invalid configuration */
1208 if (!num_cs
|| src_clk_nr
< 0) {
1209 pr_err("%s: Invalid SPI configuration\n", __func__
);
1214 pd
.src_clk_nr
= src_clk_nr
;
1215 pd
.cfg_gpio
= (cfg_gpio
) ? cfg_gpio
: s3c64xx_spi2_cfg_gpio
;
1216 pd
.dma_tx
= (void *)DMACH_SPI2_TX
;
1217 pd
.dma_rx
= (void *)DMACH_SPI2_RX
;
1218 #if defined(CONFIG_PL330_DMA)
1219 pd
.filter
= pl330_filter
;
1220 #elif defined(CONFIG_S3C64XX_PL080)
1221 pd
.filter
= pl08x_filter_id
;
1224 s3c_set_platdata(&pd
, sizeof(pd
), &s3c64xx_device_spi2
);
1226 #endif /* CONFIG_S3C64XX_DEV_SPI2 */